From 4ba47698d7d0ef6c799bd0a28045c1d1e49c76f3 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 29 Sep 2021 21:47:12 +0200 Subject: revise content import/export part 2 --- include/import.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index ae7b2787a..f635f3705 100644 --- a/include/import.php +++ b/include/import.php @@ -1265,6 +1265,7 @@ function sync_files($channel, $files) { $store_path = $newfname; + $fp = fopen($newfname,'w'); if(! $fp) { logger('failed to open storage file.',LOGGER_NORMAL,LOG_ERR); -- cgit v1.2.3 From 4afd1ac705b7e0b8db7bbfacc5f46e0e42c9d4f1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Oct 2021 09:05:32 +0200 Subject: add optional $removed argument to channelx_by functions to allow inclusion of removed channels which is required (mod channel, daemon notifier -> refresh_all) if a channel got removed also remove caching to App so we always get a fresh copy. In import_hublocs() add site_id to the array passed to Libzot::gethubs() because it is expected there. --- include/import.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index f635f3705..6e25f4154 100644 --- a/include/import.php +++ b/include/import.php @@ -238,7 +238,8 @@ function import_hublocs($channel, $hublocs, $seize, $moving = false) { 'id' => $hubloc['hubloc_guid'], 'id_sig' => $hubloc['hubloc_guid_sig'], 'location' => $hubloc['hubloc_url'], - 'location_sig' => $hubloc['hubloc_url_sig'] + 'location_sig' => $hubloc['hubloc_url_sig'], + 'site_id' => $hubloc['hubloc_site_id'] ]; if (($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize)) { -- cgit v1.2.3 From 6da7fe7d27b30f691c07e5fb767afc904c3063c0 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 Oct 2021 09:24:13 +0000 Subject: provide system app sync --- include/import.php | 74 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 21 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 6e25f4154..3bd2af4ce 100644 --- a/include/import.php +++ b/include/import.php @@ -1,5 +1,6 @@ Date: Mon, 4 Oct 2021 13:31:26 +0200 Subject: app sync fixes - part 2 --- include/import.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include/import.php') 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); } } } -- cgit v1.2.3 From 743098921220364341e5e3b194fbe0b442a4c28c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Oct 2021 13:41:54 +0200 Subject: more app sync fixes --- include/import.php | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index c986eeaef..ab44a6012 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); + $sysapps = Apps::get_system_apps(false, true); foreach ($apps as $app) { @@ -549,32 +549,34 @@ 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 ($app['app_id'] === hash('whirlpool',$sysapp['app_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']), + intval($channel['channel_id']) + ); + } + else { // 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) { - break; + continue; } $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); } } } @@ -606,7 +608,6 @@ 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", @@ -619,6 +620,15 @@ 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'); @@ -632,8 +642,6 @@ function sync_sysapps($channel, $apps) { } - - /** * @brief Import chatrooms. * -- cgit v1.2.3 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(-) (limited to 'include/import.php') 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 From c2c5730d00927a2e246a8c7e55450ea81d25a1a0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Oct 2021 14:08:39 +0200 Subject: more app sync fixes --- include/import.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index c986eeaef..88d29a46d 100644 --- a/include/import.php +++ b/include/import.php @@ -556,11 +556,11 @@ function import_sysapps($channel, $apps) { $term = ((array_key_exists('term',$app) && is_array($app['term'])) ? $app['term'] : null); foreach ($sysapps as $sysapp) { - if ($app['app_id'] === hash('whirlpool',$sysapp['app_name'])) { + if ($app['app_id'] === hash('whirlpool', $sysapp['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']), @@ -572,9 +572,9 @@ function import_sysapps($channel, $apps) { $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); } } } -- cgit v1.2.3 From 04c6d77d2cced4f2228be77107bbb85ee2f77562 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Oct 2021 14:14:30 +0200 Subject: set the sync flag to true --- include/import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 88d29a46d..b11d01511 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); + $sysapps = Apps::get_system_apps(false, true); foreach ($apps as $app) { -- cgit v1.2.3 From 3a38946f8a9e08fec5406fedac2577a890c8773d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Oct 2021 20:19:16 +0200 Subject: more app sync --- include/import.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index b11d01511..6186fd6ed 100644 --- a/include/import.php +++ b/include/import.php @@ -609,10 +609,29 @@ function sync_sysapps($channel, $apps) { 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']), - intval($channel['channel_id']) - ); + if(Apps::can_delete($channel['channel_id'], ['guid' => $app['app_id']])) { + $local_app = q("select id from app where app_id = '%s' and app_channel = %d limit 1", + dbesc($app['app_id']), + intval($channel['channel_id']) + ); + if ($local_app) { + q("delete from term where otype = %d and oid = %d", + intval(TERM_OBJ_APP), + intval($local_app[0]['id']) + ); + + q("delete from app where app_id = '%s' and app_channel = %d", + dbesc($app['app_id']), + intval($channel['channel_id']) + ); + } + } + else { + q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", + dbesc($app['app_id']), + intval($channel['channel_id']) + ); + } } else { // install this app on this server -- cgit v1.2.3 From c33660a015ff4a2ed387caa4064fc8c4d8655419 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 6 Oct 2021 09:36:14 +0200 Subject: move sync logic for apps to mod appman. this way we can re-use the functions without creating sync loops. --- include/import.php | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index 6186fd6ed..c6d89b5f3 100644 --- a/include/import.php +++ b/include/import.php @@ -591,7 +591,6 @@ function import_sysapps($channel, $apps) { function sync_sysapps($channel, $apps) { $sysapps = Apps::get_system_apps(false, true); - if ($channel && $apps) { $columns = db_columns('app'); @@ -608,30 +607,8 @@ 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']) { - if(Apps::can_delete($channel['channel_id'], ['guid' => $app['app_id']])) { - $local_app = q("select id from app where app_id = '%s' and app_channel = %d limit 1", - dbesc($app['app_id']), - intval($channel['channel_id']) - ); - if ($local_app) { - q("delete from term where otype = %d and oid = %d", - intval(TERM_OBJ_APP), - intval($local_app[0]['id']) - ); - - q("delete from app where app_id = '%s' and app_channel = %d", - dbesc($app['app_id']), - intval($channel['channel_id']) - ); - } - } - else { - q("update app set app_deleted = 1 where app_id = '%s' and app_channel = %d", - dbesc($app['app_id']), - intval($channel['channel_id']) - ); - } + if (array_key_exists('app_deleted',$app) && $app['app_deleted'] == 1 && $app['app_id']) { + Apps::app_destroy($channel['channel_id'], ['guid' => $app['app_id']]); } else { // install this app on this server -- cgit v1.2.3 From f19acd9f50ec9b8c78f77af64d523d2295b46052 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Oct 2021 07:56:42 +0000 Subject: remove redundant variable and provide missing phpdoc --- include/import.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index c6d89b5f3..b0a1a77e5 100644 --- a/include/import.php +++ b/include/import.php @@ -597,7 +597,6 @@ function sync_sysapps($channel, $apps) { foreach ($apps as $app) { - $exists = false; $term = ((array_key_exists('term',$app)) ? $app['term'] : null); if (array_key_exists('app_system',$app) && (! intval($app['app_system']))) { -- cgit v1.2.3 From 8bae40449f2a5bfcc6ef86f82be1e15bdb9b9acd Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Oct 2021 08:07:19 +0000 Subject: remove library/urlify and use vendor/jbroadway/urlify instead --- include/import.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/import.php') diff --git a/include/import.php b/include/import.php index b0a1a77e5..8707a9430 100644 --- a/include/import.php +++ b/include/import.php @@ -1719,8 +1719,7 @@ function import_webpage_element($element, $channel, $type) { $namespace = 'WEBPAGE'; $name = $element['pagelink']; if($name) { - require_once('library/urlify/URLify.php'); - $name = strtolower(\URLify::transliterate($name)); + $name = strtolower(URLify::transliterate($name)); } $arr['title'] = $element['title']; $arr['term'] = $element['term']; -- cgit v1.2.3