diff options
Diffstat (limited to 'include/api_zot.php')
-rw-r--r-- | include/api_zot.php | 80 |
1 files changed, 60 insertions, 20 deletions
diff --git a/include/api_zot.php b/include/api_zot.php index 8f621d998..7a217854f 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); @@ -87,12 +89,9 @@ return false; } $sections = (($_REQUEST['sections']) ? explode(',',$_REQUEST['sections']) : ''); - if($_REQUEST['posts']) { - $sections = get_default_export_sections(); - $sections[] = 'items'; - } + $codebase = ((isset($_REQUEST['zap_compat']) && $_REQUEST['zap_compat']) ? true : false); - 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) { @@ -103,7 +102,7 @@ $page = intval($_REQUEST['page']); $records = intval($_REQUEST['records']); if(! $records) { - $records = 50; + $records = 10; } if(! $_REQUEST['since']) $start = NULL_DATE; @@ -111,8 +110,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['zap_compat']) && $_REQUEST['zap_compat']) ? 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)); } @@ -137,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) { @@ -200,7 +200,7 @@ } function api_attach_list($type) { - if(api_user() === false) + if(api_user() === false) return false; logger('api_user: ' . api_user()); @@ -233,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); } @@ -276,7 +276,7 @@ $ptr['content'] = base64_encode($x); } } - + $ret = array('attach' => $ptr); json_return_and_die($ret); } @@ -289,10 +289,11 @@ return false; if(! $_REQUEST['file_id']) return false; + $codebase = ((isset($_REQUEST['zap_compat']) && $_REQUEST['zap_compat']) ? true : false); $channel = channelx_by_n(api_user()); - $ret = attach_export_data($channel,$_REQUEST['file_id']); + $ret = attach_export_data($channel,$_REQUEST['file_id'],false,$codebase); if($ret) { json_return_and_die($ret); @@ -300,6 +301,45 @@ killme(); } + function api_file_export_page($type) { + if(api_user() === false) + return false; + + $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); + + $ret['success'] = false; + $ret['total'] = 0; + $ret['results'] = []; + + $count = attach_count_files($channel['channel_id'], get_observer_hash()); + if($count['success']) { + $ret['total'] = $count['results']; + } + + if (!$ret['total']) { + json_return_and_die($ret); + } + + $files = attach_list_files($channel['channel_id'], get_observer_hash(), '', '', '', 'created asc' ,$page, 1); + + if (!$files['success']) { + json_return_and_die($ret); + } + + foreach($files['results'] as $file) { + $ret['results'][] = attach_export_data($channel, $file['hash'], false, $codebase); + } + + if($ret['results']) { + $ret['success'] = true; + json_return_and_die($ret); + } + + killme(); + } + function api_file_detail($type) { if(api_user() === false) @@ -312,11 +352,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); } @@ -398,7 +438,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']) ); @@ -423,7 +463,7 @@ return false; logger('api_xchan'); - if($_SERVER['REQUEST_METHOD'] === 'POST') { + if($_SERVER['REQUEST_METHOD'] === 'POST') { $r = xchan_store($_REQUEST); } $r = xchan_fetch($_REQUEST); @@ -494,7 +534,7 @@ } } } - + json_return_and_die($x); } @@ -525,7 +565,7 @@ } $mod = new Zotlabs\Module\Item(); - $x = $mod->post(); + $x = $mod->post(); json_return_and_die($x); } @@ -561,8 +601,8 @@ foreach($i as $ii) { $tmp[] = encode_item($ii,true); } - $ret['item'] = $tmp; - + $ret['item'] = $tmp; + json_return_and_die($ret); } |