From ca15fbb08e1907d699c80a00bc74384c5ab0cd8f Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Tue, 26 Sep 2023 21:50:20 +1000 Subject: [PATCH] sort out site admin app --- Code/Lib/Apps.php | 83 +++++++++++++++++++++++++++++++++++++++++-- Code/Lib/Navbar.php | 2 -- Code/Update/_1270.php | 21 +++++++++++ boot.php | 2 +- 4 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 Code/Update/_1270.php diff --git a/Code/Lib/Apps.php b/Code/Lib/Apps.php index e11bf7dc5..8e03b5892 100644 --- a/Code/Lib/Apps.php +++ b/Code/Lib/Apps.php @@ -73,7 +73,6 @@ class Apps $default_apps = [ 'Access Lists', - 'Admin', 'Channel Home', 'Connections', 'Directory', @@ -84,6 +83,7 @@ class Apps 'Profile Photo', 'Search', 'Settings', + 'Site Admin', 'Stream', 'Suggest Channels', 'View Profile' @@ -941,8 +941,10 @@ class Apps } $conf = (($menu === 'nav_featured_app') ? 'app_order' : 'app_pin_order'); - - $x = (($uid) ? get_pconfig($uid, 'system', $conf) : get_config('system', $conf)); + $x = (($uid) ? PConfig::Get($uid, 'system', $conf) : get_config('system', $conf)); +// if (!$x) { +// $x = self::app_system_order($uid, $conf); +// } if (($x) && (!is_array($x))) { $y = explode(',', $x); $x = $y; @@ -967,6 +969,66 @@ class Apps return $ret; } + public static function app_system_order($uid, $conf) + { + $returnValue = []; + $apps = []; + $applist = self::app_list($uid); + if ($applist) { + foreach ($applist as $app) { + if ($app['term']) { + for ($x = 0; $x < count($app['term']); $x++) { + if (in_array($app['term'][$x]['term'], ['nav_pinned_app', 'nav_featured_app'])) { + unset($app['term'][$x]); + } + } + } + $encoded = self::app_encode($app); + $apps[] = $encoded; + } + } + if ($conf === 'app_pin_order' && file_exists('app/app_order')) { + $list = file('app/app_order', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); + if ($list) { + $ids = []; + foreach ($list as $entry) { + $found = self::find_app_by_name(trim($entry), $apps); + if (empty($found['term'])) { + $found['term'] = 'nav_featured_app'; + } + elseif (! str_contains($found['term'], 'nav_featured_app')) { + $found['term'] .= ',nav_featured_app'; + } + self::app_update($found); + $returnValue[] = $found; + $ids[]= $found['guid']; + } + PConfig::Set($uid,'system', $conf, implode(',', $ids)); + } + } + if ($conf === 'app_order' && file_exists('app/nav_order')) { + $list = file('app/nav_order', FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); + if ($list) { + $ids = []; + foreach ($list as $entry) { + $found = self::find_app_by_name(trim($entry), $apps); + if (empty($found['term'])) { + $found['term'] = 'nav_pinned_app'; + } + elseif (! str_contains($found['term'], 'nav_pinned_app')) { + $found['term'] .= ',nav_pinned_app'; + } + self::app_update($found); + $returnValue[] = $found; + $ids[]= $found['guid']; + } + PConfig::Set($uid,'system', $conf, implode(',', $ids)); + } + } + + return $returnValue; + } + public static function find_app_in_array($guid, $arr) { if (!$arr) { @@ -980,6 +1042,21 @@ class Apps return false; } + public static function find_app_by_name($name, $arr) + { + if (!$arr) { + return false; + } + + foreach ($arr as $x) { + if ($x['guid'] === hash('whirlpool', $name)) { + return $x; + } + } + return false; + + } + public static function moveup($uid, $guid, $menu) { $syslist = []; diff --git a/Code/Lib/Navbar.php b/Code/Lib/Navbar.php index 2e9deea5f..d4ca33ad2 100644 --- a/Code/Lib/Navbar.php +++ b/Code/Lib/Navbar.php @@ -213,8 +213,6 @@ class Navbar { $pinned_list = Apps::app_order(local_channel(), $pinned_list, 'nav_pinned_app'); - - $syslist = []; $list = Apps::app_list(local_channel(), false, [ 'nav_featured_app' ]); if ($list) { diff --git a/Code/Update/_1270.php b/Code/Update/_1270.php new file mode 100644 index 000000000..61dba2eaa --- /dev/null +++ b/Code/Update/_1270.php @@ -0,0 +1,21 @@ +