aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-11-09 09:10:19 +0000
committerMario <mario@mariovavti.com>2021-11-09 09:10:19 +0000
commitfe7ecede700fe04631d23f36473e697ce2b364dc (patch)
treee713fc39dba500a25cb2acf8561e286fb8b41ff0 /include/import.php
parent42de18d96d201d74e5df3ed1b8f6132cb00357b6 (diff)
parent089708ab9f90309a0c27ae633cf8f2604fce1170 (diff)
downloadvolse-hubzilla-fe7ecede700fe04631d23f36473e697ce2b364dc.tar.gz
volse-hubzilla-fe7ecede700fe04631d23f36473e697ce2b364dc.tar.bz2
volse-hubzilla-fe7ecede700fe04631d23f36473e697ce2b364dc.zip
Merge branch '6.4RC'6.4
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php78
1 files changed, 53 insertions, 25 deletions
diff --git a/include/import.php b/include/import.php
index ae7b2787a..8707a9430 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;
@@ -238,7 +239,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)) {
@@ -524,7 +526,6 @@ function sync_apps($channel, $apps) {
}
-
/**
* @brief Import system apps.
* System apps from the original server may not exist on this system
@@ -538,50 +539,49 @@ 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, true);
- foreach($apps as $app) {
+ foreach ($apps as $app) {
- if(array_key_exists('app_system',$app) && (! intval($app['app_system'])))
+ if (array_key_exists('app_system',$app) && (! intval($app['app_system']))) {
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'])) {
+ foreach ($sysapps as $sysapp) {
+ 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']),
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.
*
@@ -590,17 +590,45 @@ function import_sysapps($channel, $apps) {
*/
function sync_sysapps($channel, $apps) {
- if($channel && $apps) {
+ $sysapps = Apps::get_system_apps(false, true);
+ if ($channel && $apps) {
+
+ $columns = db_columns('app');
+
+ foreach ($apps as $app) {
- // we do not currently sync system apps
+ $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['name'])) {
+ 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
+ $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.
*
@@ -1265,6 +1293,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);
@@ -1690,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'];