aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobody <nobody@zotlabs.com>2021-02-16 23:33:39 -0800
committernobody <nobody@zotlabs.com>2021-02-16 23:38:17 -0800
commit7e3046b85cec84ffdd8f482ec2e519b165fe3d54 (patch)
tree7518adae4af446e05bbb1b3db3a0c7cd11bcbfc9
parent281b2261aff9919e208562466e7969ccae26d9a0 (diff)
downloadvolse-hubzilla-7e3046b85cec84ffdd8f482ec2e519b165fe3d54.tar.gz
volse-hubzilla-7e3046b85cec84ffdd8f482ec2e519b165fe3d54.tar.bz2
volse-hubzilla-7e3046b85cec84ffdd8f482ec2e519b165fe3d54.zip
more work on zap channel export.
-rw-r--r--Zotlabs/Module/Uexport.php7
-rw-r--r--boot.php1
-rw-r--r--include/api_zot.php6
-rw-r--r--include/channel.php65
-rw-r--r--include/items.php2
5 files changed, 41 insertions, 40 deletions
diff --git a/Zotlabs/Module/Uexport.php b/Zotlabs/Module/Uexport.php
index 3d1587b87..55c316317 100644
--- a/Zotlabs/Module/Uexport.php
+++ b/Zotlabs/Module/Uexport.php
@@ -17,6 +17,7 @@ class Uexport extends Controller {
if(argc() > 1) {
$sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : '');
+ $zap_compat = (($_REQUEST['zap_compat']) ? intval($_REQUEST['zap_compat']) : false);
$channel = App::get_channel();
@@ -32,12 +33,12 @@ class Uexport extends Controller {
header('content-disposition: attachment; filename="' . $channel['channel_address'] . (($year) ? '-' . $year : '') . (($month) ? '-' . $month : '') . (($_REQUEST['sections']) ? '-' . $_REQUEST['sections'] : '') . '.json"' );
if($year) {
- echo json_encode(identity_export_year(local_channel(),$year,$month));
+ echo json_encode(identity_export_year(local_channel(),$year,$month, $zap_compat));
killme();
}
if(argc() > 1 && argv(1) === 'basic') {
- echo json_encode(identity_basic_export(local_channel(),$sections));
+ echo json_encode(identity_basic_export(local_channel(),$sections, $zap_compat));
killme();
}
@@ -46,7 +47,7 @@ class Uexport extends Controller {
if(argc() > 1 && argv(1) === 'complete') {
$sections = get_default_export_sections();
$sections[] = 'items';
- echo json_encode(identity_basic_export(local_channel(),$sections));
+ echo json_encode(identity_basic_export(local_channel(),$sections, $zap_compat));
killme();
}
}
diff --git a/boot.php b/boot.php
index 1d8872257..1e84a36a6 100644
--- a/boot.php
+++ b/boot.php
@@ -603,6 +603,7 @@ define ( 'DBTYPE_POSTGRES', 1 );
function sys_boot() {
+
// our central App object
App::init();
diff --git a/include/api_zot.php b/include/api_zot.php
index 8f621d998..0ec9202dc 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -87,12 +87,13 @@
return false;
}
$sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : '');
+ $codebase = ((isset($_REQUEST['codebase']) && $_REQUEST['codebase'] === 'zap') ? true : false);
if($_REQUEST['posts']) {
$sections = get_default_export_sections();
$sections[] = 'items';
}
- json_return_and_die(identity_basic_export(api_user(),$sections));
+ json_return_and_die(identity_basic_export(api_user(),$sections,$codebase));
}
function api_item_export_page($type) {
@@ -111,8 +112,9 @@
$start = datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['since']);
}
$finish = datetime_convert(date_default_timezone_get(),'UTC', (($_REQUEST['until']) ? $_REQUEST['until'] : 'now'));
+ $codebase = ((isset($_REQUEST['codebase']) && $_REQUEST['codebase'] === 'zap') ? true : false);
- json_return_and_die(channel_export_items_page(api_user(),$start,$finish,$page,$records));
+ json_return_and_die(channel_export_items_page(api_user(),$start,$finish,$page,$records,$codebase));
}
diff --git a/include/channel.php b/include/channel.php
index 08b5ee889..ba4f6c6d9 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -937,50 +937,47 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals
$newconfig = [];
$abconfig = load_abconfig($channel_id,$ret['abook'][$x]['abook_xchan']);
- // Partly revert of commit 85cf25a2a8bfbbfe10de485d4affd54626fbbfa4
if($abconfig) {
- $ret['abook'][$x]['abconfig'] = $abconfig;
- }
+ if ($zap_compat) {
+ foreach ($abconfig as $abc) {
+
+ if ($abc['cat'] === 'my_perms') {
+ if (intval($abc['v'])) {
+ $my_perms[] = $abc['k'];
+ }
+ continue;
+ }
+ if ($abc['cat'] === 'their_perms') {
+ if (intval($abc['v'])) {
+ $their_perms[] = $abc['k'];
+ }
+ continue;
+ }
+ if (preg_match('|^a:[0-9]+:{.*}$|s', $abc['v'])) {
+ $abc['v'] = serialise(unserialize($abc['v']));
+ }
+ $newconfig[] = $abc;
+ }
- /* This was added in commit 85cf25a2a8bfbbfe10de485d4affd54626fbbfa4
- * Seems unfinished work on zap compatibility for cloning.
- * It breaks cloning of abconfig for hubzilla - reverted to the above code.
+ $ret['abook'][$x]['abconfig'] = $newconfig;
- if($abconfig) {
- foreach ($abconfig as $abc) {
+ $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_xchan'], 'cat' => 'system', 'k' => 'my_perms', 'v' => implode(',',$my_perms) ];
+ $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_xchan'], 'cat' => 'system', 'k' => 'their_perms', 'v' => implode(',',$their_perms) ];
- if ($abc['cat'] === 'my_perms' && intval($abc['v'])) {
- $my_perms[] = $abc['k'];
- continue;
- }
- if ($abc['cat'] === 'their_perms' && intval($abc['v'])) {
- $their_perms[] = $abc['k'];
- continue;
- }
- if ($zap_compat && preg_match('|^a:[0-9]+:{.*}$|s', $abc['v'])) {
- $abc['v'] = serialise(unserialize($abc['v']));
- }
- $newconfig[] = $abc;
}
-
- $ret['abook'][$x]['abconfig'] = $newconfig;
-
- if ($zap_compat) {
- $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_chan'], 'cat' => 'system', 'k' => 'my_perms', 'v' => implode(',',$my_perms) ];
- $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_chan'], 'cat' => 'system', 'k' => 'their_perms', 'v' => implode(',',$their_perms) ];
+ else {
+ $ret['abook'][$x]['abconfig'] = $abconfig;
}
}
- */
+
translate_abook_perms_outbound($ret['abook'][$x]);
}
-
-
// pick up the zot xchan and hublocs also
- if($ret['channel']['channel_portable_id']) {
+ if($ret['channel']['channel_portable_id'] && ! $zot_compat) {
$xchans[] = $ret['channel']['channel_portable_id'];
}
@@ -1223,7 +1220,7 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals
* * \e array \b relocate - (optional)
* * \e array \b item - array with items encoded_item()
*/
-function identity_export_year($channel_id, $year, $month = 0) {
+function identity_export_year($channel_id, $year, $month = 0, $zap_compat = false) {
if(! $year)
return array();
@@ -1241,7 +1238,7 @@ function identity_export_year($channel_id, $year, $month = 0) {
else
$maxdate = datetime_convert('UTC', 'UTC', $year+1 . '-01-01 00:00:00');
- return channel_export_items_date($channel_id,$mindate,$maxdate);
+ return channel_export_items_date($channel_id,$mindate,$maxdate, $zap_compat);
}
@@ -1256,7 +1253,7 @@ function identity_export_year($channel_id, $year, $month = 0) {
* @return array
*/
-function channel_export_items_date($channel_id, $start, $finish) {
+function channel_export_items_date($channel_id, $start, $finish, $zap_compat = false) {
if(! $start)
return array();
@@ -1304,7 +1301,7 @@ function channel_export_items_date($channel_id, $start, $finish) {
* @return array
*/
-function channel_export_items_page($channel_id, $start, $finish, $page = 0, $limit = 50) {
+function channel_export_items_page($channel_id, $start, $finish, $page = 0, $limit = 50, $zap_compat = false) {
if(intval($page) < 1) {
$page = 0;
diff --git a/include/items.php b/include/items.php
index 12b543697..bc3ce55ec 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1089,7 +1089,7 @@ function empty_acl($item) {
return (($item['allow_cid'] === EMPTY_STR && $item['allow_gid'] === EMPTY_STR && $item['deny_cid'] === EMPTY_STR && $item['deny_gid'] === EMPTY_STR) ? true : false);
}
-function encode_item($item,$mirror = false) {
+function encode_item($item,$mirror = false,$zap_compat = false) {
$x = [];
$x['type'] = 'activity';
$x['encoding'] = 'zot';