From 21a6dffd5f24b0468e17e9e22fb795dff1020472 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Oct 2021 13:54:45 +0200 Subject: Revert "more app sync fixes" This reverts commit 743098921220364341e5e3b194fbe0b442a4c28c. --- include/import.php | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/include/import.php b/include/import.php index ab44a6012..c986eeaef 100644 --- a/include/import.php +++ b/include/import.php @@ -541,7 +541,7 @@ function import_sysapps($channel, $apps) { if ($channel && $apps) { - $sysapps = Apps::get_system_apps(false, true); + $sysapps = Apps::get_system_apps(false); foreach ($apps as $app) { @@ -549,34 +549,32 @@ function import_sysapps($channel, $apps) { continue; } + if (array_key_exists('app_deleted',$app) && (intval($app['app_deleted']))) { + continue; + } + $term = ((array_key_exists('term',$app) && is_array($app['term'])) ? $app['term'] : null); foreach ($sysapps as $sysapp) { - 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']), - intval($channel['channel_id']) - ); - } - else { + if ($app['app_id'] === hash('whirlpool',$sysapp['app_name'])) { // 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']); $installed = q("select id from app where app_id = '%s' and app_channel = %d limit 1", dbesc($newapp['guid']), intval($channel['channel_id']) ); if ($installed) { - continue; + break; } $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); } } } @@ -608,6 +606,7 @@ function sync_sysapps($channel, $apps) { } foreach ($sysapps as $sysapp) { + 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", @@ -620,15 +619,6 @@ function sync_sysapps($channel, $apps) { $newapp = $sysapp; $newapp['uid'] = $channel['channel_id']; $newapp['guid'] = hash('whirlpool', $newapp['name']); - - $installed = q("select id from app where app_id = '%s' and app_channel = %d limit 1", - dbesc($newapp['guid']), - intval($channel['channel_id']) - ); - if ($installed) { - continue; - } - $newapp['system'] = 1; if ($term) { $newapp['categories'] = array_elm_to_str($term, 'term'); @@ -642,6 +632,8 @@ function sync_sysapps($channel, $apps) { } + + /** * @brief Import chatrooms. * -- cgit v1.2.3