aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-09-29 19:43:22 +0000
committerMario <mario@mariovavti.com>2021-09-29 19:43:22 +0000
commit2688abf25a0bfc2a9e3b7537afc08a8d44f49e0c (patch)
tree1985554c433635a3b6e54d5bdf23da43394d4223
parent5eb79bd51efbd69d297bbd6f46ee9d1583ec694e (diff)
downloadvolse-hubzilla-2688abf25a0bfc2a9e3b7537afc08a8d44f49e0c.tar.gz
volse-hubzilla-2688abf25a0bfc2a9e3b7537afc08a8d44f49e0c.tar.bz2
volse-hubzilla-2688abf25a0bfc2a9e3b7537afc08a8d44f49e0c.zip
revise content import/export part 1
-rw-r--r--include/api_zot.php57
-rw-r--r--include/channel.php22
2 files changed, 56 insertions, 23 deletions
diff --git a/include/api_zot.php b/include/api_zot.php
index 9beaaa19c..93b99c0c8 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -22,6 +22,8 @@
api_register_func('api/z/1.0/filedata', 'api_file_data', true);
api_register_func('api/red/file/export', 'api_file_export', true);
api_register_func('api/z/1.0/file/export', 'api_file_export', true);
+ api_register_func('api/red/file/export_page', 'api_file_export_page', true);
+ api_register_func('api/z/1.0/file/export_page', 'api_file_export_page', true);
api_register_func('api/red/file', 'api_file_detail', true);
api_register_func('api/z/1.0/file', 'api_file_detail', true);
api_register_func('api/red/albums','api_albums', true);
@@ -88,10 +90,6 @@
}
$sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : '');
$codebase = ((isset($_REQUEST['zap_compat']) && $_REQUEST['zap_compat']) ? true : false);
- if($_REQUEST['posts']) {
- $sections = get_default_export_sections();
- $sections[] = 'items';
- }
json_return_and_die(identity_basic_export(api_user(),$sections,$codebase));
}
@@ -104,7 +102,7 @@
$page = intval($_REQUEST['page']);
$records = intval($_REQUEST['records']);
if(! $records) {
- $records = 50;
+ $records = 10;
}
if(! $_REQUEST['since'])
$start = NULL_DATE;
@@ -139,7 +137,7 @@
$_REQUEST['datequery'] = $_REQUEST['dend'];
$arr = $_REQUEST;
- $ret = [];
+ $ret = [];
$i = items_fetch($arr,App::get_channel(),get_observer_hash());
if($i) {
foreach($i as $iv) {
@@ -202,7 +200,7 @@
}
function api_attach_list($type) {
- if(api_user() === false)
+ if(api_user() === false)
return false;
logger('api_user: ' . api_user());
@@ -235,7 +233,7 @@
dbesc($_REQUEST['file_id'])
);
if($r) {
- unset($r[0]['content']);
+ unset($r[0]['content']);
$ret = array('attach' => $r[0]);
json_return_and_die($ret);
}
@@ -278,7 +276,7 @@
$ptr['content'] = base64_encode($x);
}
}
-
+
$ret = array('attach' => $ptr);
json_return_and_die($ret);
}
@@ -303,6 +301,31 @@
killme();
}
+ function api_file_export_page($type) {
+ if(api_user() === false)
+ return false;
+
+ $ret = [];
+ $codebase = ((isset($_REQUEST['zap_compat']) && $_REQUEST['zap_compat']) ? true : false);
+ $channel = channelx_by_n(api_user());
+ $page = ((array_key_exists('page',$_REQUEST)) ? intval($_REQUEST['page']) : 0);
+
+ $files = attach_list_files($channel['channel_id'], get_observer_hash(), '', '', '', 'created asc' ,$page, 1);
+
+ if (!$files['success']) {
+ return false;
+ }
+
+ foreach($files['results'] as $file) {
+ $ret[] = attach_export_data($channel, $file['hash'], false, $codebase);
+ }
+
+ if($ret) {
+ json_return_and_die($ret);
+ }
+ killme();
+ }
+
function api_file_detail($type) {
if(api_user() === false)
@@ -315,11 +338,11 @@
if($r) {
if($r[0]['is_dir'])
$r[0]['content'] = '';
- elseif(intval($r[0]['os_storage']))
+ elseif(intval($r[0]['os_storage']))
$r[0]['content'] = base64_encode(file_get_contents(dbunescbin($r[0]['content'])));
else
$r[0]['content'] = base64_encode(dbunescbin($r[0]['content']));
-
+
$ret = array('attach' => $r[0]);
json_return_and_die($ret);
}
@@ -401,7 +424,7 @@
}
if($r) {
- $x = q("select * from pgrp_member left join abook on abook_xchan = xchan and abook_channel = pgrp_member.uid left join xchan on pgrp_member.xchan = xchan.xchan_hash
+ $x = q("select * from pgrp_member left join abook on abook_xchan = xchan and abook_channel = pgrp_member.uid left join xchan on pgrp_member.xchan = xchan.xchan_hash
where gid = %d",
intval($r[0]['id'])
);
@@ -426,7 +449,7 @@
return false;
logger('api_xchan');
- if($_SERVER['REQUEST_METHOD'] === 'POST') {
+ if($_SERVER['REQUEST_METHOD'] === 'POST') {
$r = xchan_store($_REQUEST);
}
$r = xchan_fetch($_REQUEST);
@@ -497,7 +520,7 @@
}
}
}
-
+
json_return_and_die($x);
}
@@ -528,7 +551,7 @@
}
$mod = new Zotlabs\Module\Item();
- $x = $mod->post();
+ $x = $mod->post();
json_return_and_die($x);
}
@@ -564,8 +587,8 @@
foreach($i as $ii) {
$tmp[] = encode_item($ii,true);
}
- $ret['item'] = $tmp;
-
+ $ret['item'] = $tmp;
+
json_return_and_die($ret);
}
diff --git a/include/channel.php b/include/channel.php
index ed46904e7..53b781eb6 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -802,7 +802,6 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals
/*
* basic channel export
*/
-
if(! $sections) {
$sections = get_default_export_sections();
}
@@ -1117,7 +1116,7 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals
and created > %s - INTERVAL %s and resource_type = '' order by created",
intval($channel_id),
db_utcnow(),
- db_quoteinterval('3 MONTH')
+ db_quoteinterval('1 MONTH')
);
if($r) {
$ret['item'] = array();
@@ -1239,11 +1238,11 @@ function channel_export_items_date($channel_id, $start, $finish, $zap_compat = f
*
* @param int $channel_id The channel ID
* @param int $page
- * @param int $limit (default 50)
+ * @param int $limit (default 10)
* @return array
*/
-function channel_export_items_page($channel_id, $start, $finish, $page = 0, $limit = 50, $zap_compat = false) {
+function channel_export_items_page($channel_id, $start, $finish, $page = 0, $limit = 10, $zap_compat = false) {
if(intval($page) < 1) {
$page = 0;
@@ -1253,8 +1252,8 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim
$limit = 1;
}
- if(intval($limit) > 5000) {
- $limit = 5000;
+ if(intval($limit) > 1000) {
+ $limit = 1000;
}
if(! $start)
@@ -1279,6 +1278,17 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim
$ret['compatibility']['codebase'] = 'zap';
}
+ $r = q("select count(id) as total from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type != 'photo' and created >= '%s' and created <= '%s'",
+ intval(ITEM_TYPE_POST),
+ intval($channel_id),
+ dbesc($start),
+ dbesc($finish)
+ );
+
+ if ($r) {
+ $ret['items_total']= $r[0]['total'];
+ $ret['items_page']= $limit;
+ }
$r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type != 'photo' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
intval(ITEM_TYPE_POST),