From 5a2a8717e3da4e84802cc72eebb600db2f774f0a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 5 Apr 2016 23:11:24 -0700 Subject: provide function to collect file/photo sync data per help/filesync --- include/attach.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mod/getfile.php | 1 + 2 files changed, 56 insertions(+) diff --git a/include/attach.php b/include/attach.php index 4ecc273e9..1b6bad55b 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1814,3 +1814,58 @@ function filepath_macro($s) { } +function attach_export_data($channel,$resource_id) { + + $ret = array(); + + $paths = array(); + + $hash_ptr = $resource_id; + + do { + $r = q("select * from attach where hash = '%s' and uid = %d limit 1", + dbesc($hash_ptr), + intval($channel['channel_id']) + ); + if(! $r) + break; + + if($hash_ptr === $resource_id) + $attach_ptr = $r[0]; + + $hash_ptr = $r[0]['parent']; + $paths[] = $r[0]; + } while($hash_ptr); + + $paths = array_reverse($paths); + + $ret['attach'] = $paths; + + if($attach_ptr['is_photo']) { + $r = q("select * from photo where resource_id = '%s' and uid = %d order by scale asc", + dbesc($resource_id), + intval($channel['channel_id']) + ); + $ret['photo'] = $r; + + $r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ", + dbesc($resource_id), + intval($channel['channel_id']) + ); + if($r) { + $ret['item'] = array(); + $items = q("select item.*, item.id as item_id from item where item.parent = %d ", + intval($r[0]['id']) + ); + if($items) { + xchan_query($items); + $items = fetch_post_tags($items,true); + foreach($items as $rr) + $ret['item'][] = encode_item($rr,true); + } + } + } + + return $ret; + +} \ No newline at end of file diff --git a/mod/getfile.php b/mod/getfile.php index 16392f8dd..6eca7ee34 100644 --- a/mod/getfile.php +++ b/mod/getfile.php @@ -21,6 +21,7 @@ require_once('include/Contact.php'); +require_once('include/attach.php'); function getfile_post(&$a) { -- cgit v1.2.3