aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Apps.php9
-rw-r--r--Zotlabs/Lib/Libsync.php4
-rw-r--r--include/import.php74
3 files changed, 64 insertions, 23 deletions
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 3c09adaa5..89be58311 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -635,13 +635,18 @@ class Apps {
intval($uid)
);
if($r) {
- if(($app['uid']) && (! $r[0]['app_system'])) {
+ if($app['uid']) {
if($app['categories'] && (! $app['term'])) {
$r[0]['term'] = q("select * from term where otype = %d and oid = %d",
intval(TERM_OBJ_APP),
intval($r[0]['id'])
);
- Libsync::build_sync_packet($uid,array('app' => $r[0]));
+ }
+ if (intval($r[0]['app_system'])) {
+ Libsync::build_sync_packet($uid, ['sysapp' => $r[0]]);
+ }
+ else {
+ Libsync::build_sync_packet($uid, ['app' => $r[0]]);
}
}
}
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index 2b47fcf1a..e08f14447 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -246,6 +246,10 @@ class Libsync {
if (array_key_exists('app', $arr) && $arr['app'])
sync_apps($channel, $arr['app']);
+ if (array_key_exists('sysapp',$arr) && $arr['sysapp']) {
+ sync_sysapps($channel,$arr['sysapp']);
+ }
+
if (array_key_exists('addressbook', $arr) && $arr['addressbook'])
sync_addressbook($channel, $arr['addressbook']);
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 @@
<?php
+use Zotlabs\Lib\Apps;
use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Libzot;
@@ -525,7 +526,6 @@ function sync_apps($channel, $apps) {
}
-
/**
* @brief Import system apps.
* System apps from the original server may not exist on this system
@@ -539,19 +539,24 @@ function sync_apps($channel, $apps) {
*/
function import_sysapps($channel, $apps) {
- if($channel && $apps) {
+ if ($channel && $apps) {
- $sysapps = \Zotlabs\Lib\Apps::get_system_apps(false);
+ $sysapps = Apps::get_system_apps(false);
- foreach($apps as $app) {
+ foreach ($apps as $app) {
+
+ if (array_key_exists('app_system',$app) && (! intval($app['app_system']))) {
+ continue;
+ }
- if(array_key_exists('app_system',$app) && (! intval($app['app_system'])))
+ 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'])) {
+ foreach ($sysapps as $sysapp) {
+ if ($app['app_id'] === hash('whirlpool',$sysapp['app_name'])) {
// install this app on this server
$newapp = $sysapp;
$newapp['uid'] = $channel['channel_id'];
@@ -561,28 +566,22 @@ function import_sysapps($channel, $apps) {
dbesc($newapp['guid']),
intval($channel['channel_id'])
);
- if($installed) {
+ if ($installed) {
break;
}
$newapp['system'] = 1;
- if($term) {
- $s = EMPTY_STR;
- foreach($term as $t) {
- if($s) {
- $s .= ',';
- }
- $s .= $t['term'];
- }
- $newapp['categories'] = $s;
+ if ($term) {
+ $newapp['categories'] = array_elm_to_str($term,'term');
}
- \Zotlabs\Lib\Apps::app_install($channel['channel_id'],$newapp);
+ Apps::app_install($channel['channel_id'],$newapp);
}
}
}
}
}
+
/**
* @brief Sync system apps.
*
@@ -591,17 +590,50 @@ function import_sysapps($channel, $apps) {
*/
function sync_sysapps($channel, $apps) {
- if($channel && $apps) {
+ $sysapps = Apps::get_system_apps(false);
+
+ if ($channel && $apps) {
+
+ $columns = db_columns('app');
+
+ foreach ($apps as $app) {
- // we do not currently sync system apps
+ $exists = false;
+ $term = ((array_key_exists('term',$app)) ? $app['term'] : null);
+
+ if (array_key_exists('app_system',$app) && (! intval($app['app_system']))) {
+ continue;
+ }
+ 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['system'] = 1;
+ if ($term) {
+ $newapp['categories'] = array_elm_to_str($term,'term');
+ }
+ Apps::app_install($channel['channel_id'],$newapp);
+ }
+ }
+ }
+ }
}
}
-
/**
* @brief Import chatrooms.
*