diff options
-rw-r--r-- | Zotlabs/Lib/Apps.php | 23 | ||||
-rw-r--r-- | include/import.php | 12 |
2 files changed, 19 insertions, 16 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 89be58311..defdbdb06 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -22,9 +22,10 @@ class Apps { * @brief * * @param boolean $translate (optional) default true + * @param boolean $sync (optional) default false used if called from sync_sysapps() * @return array */ - static public function get_system_apps($translate = true) { + static public function get_system_apps($translate = true, $sync = false) { $ret = []; if(is_dir('apps')) @@ -34,7 +35,7 @@ class Apps { if($files) { foreach($files as $f) { - $x = self::parse_app_description($f,$translate); + $x = self::parse_app_description($f, $translate, $sync); if($x) { $ret[] = $x; } @@ -46,7 +47,7 @@ class Apps { $path = explode('/',$f); $plugin = trim($path[1]); if(plugin_is_installed($plugin)) { - $x = self::parse_app_description($f,$translate); + $x = self::parse_app_description($f, $translate, $sync); if($x) { $x['plugin'] = $plugin; $ret[] = $x; @@ -212,7 +213,7 @@ class Apps { * @param boolean $translate (optional) default true * @return boolean|array */ - static public function parse_app_description($f, $translate = true) { + static public function parse_app_description($f, $translate = true, $sync = false) { $ret = []; $matches = []; @@ -258,7 +259,7 @@ class Apps { if(array_key_exists('categories',$ret)) $ret['categories'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['categories']); - if(array_key_exists('requires',$ret)) { + if(array_key_exists('requires',$ret) && !$sync) { $requires = explode(',',$ret['requires']); foreach($requires as $require) { $require = trim(strtolower($require)); @@ -310,14 +311,16 @@ class Apps { } } } - if(isset($ret)) { - if($translate) - self::translate_system_apps($ret); - return $ret; + if(empty($ret)) { + return false; } - return false; + if($translate) { + self::translate_system_apps($ret); + } + + return $ret; } diff --git a/include/import.php b/include/import.php index 3bd2af4ce..c986eeaef 100644 --- a/include/import.php +++ b/include/import.php @@ -590,7 +590,7 @@ function import_sysapps($channel, $apps) { */ function sync_sysapps($channel, $apps) { - $sysapps = Apps::get_system_apps(false); + $sysapps = Apps::get_system_apps(false, true); if ($channel && $apps) { @@ -606,7 +606,8 @@ function sync_sysapps($channel, $apps) { } foreach ($sysapps as $sysapp) { - if ($app['app_id'] === hash('whirlpool',$sysapp['app_name'])) { + + if ($app['app_id'] === hash('whirlpool', $sysapp['name'])) { if (array_key_exists('app_deleted',$app) && $app['app_deleted'] && $app['app_id']) { q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", dbesc($app['app_id']), @@ -617,13 +618,12 @@ function sync_sysapps($channel, $apps) { // install this app on this server $newapp = $sysapp; $newapp['uid'] = $channel['channel_id']; - $newapp['guid'] = hash('whirlpool',$newapp['name']); - + $newapp['guid'] = hash('whirlpool', $newapp['name']); $newapp['system'] = 1; if ($term) { - $newapp['categories'] = array_elm_to_str($term,'term'); + $newapp['categories'] = array_elm_to_str($term, 'term'); } - Apps::app_install($channel['channel_id'],$newapp); + Apps::app_install($channel['channel_id'], $newapp); } } } |