sort out site admin app

This commit is contained in:
Mike Macgirvin 2023-09-26 21:50:20 +10:00
parent 5a26aeda03
commit ca15fbb08e
4 changed files with 102 additions and 6 deletions

View file

@ -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 = [];

View file

@ -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) {

21
Code/Update/_1270.php Normal file
View file

@ -0,0 +1,21 @@
<?php
namespace Code\Update;
class _1268
{
public function run()
{
// remove deprecated apps from system list
$access = 'b8e7b73ffc8b5533de4a37ed8dd133abc2f5f6cac4af0e55d83c8da104e1fa58df3ae2f01ce87e429a1dd71581a39d3c18959eddbf2ae535f174b8bdcec768df';
q("delete from app where app_id = '$access' ");
return UPDATE_SUCCESS;
}
public function verify()
{
return true;
}
}

View file

@ -26,7 +26,7 @@ use Code\Lib\Url;
*/
const REPOSITORY_ID = 'streams';
const DB_UPDATE_VERSION = 1269;
const DB_UPDATE_VERSION = 1270;
const PROJECT_BASE = __DIR__;
const ACTIVITYPUB_ENABLED = true;
const NOMAD_PROTOCOL_VERSION = '12.0';