aboutsummaryrefslogtreecommitdiffstats
path: root/include/attach.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/attach.php')
-rw-r--r--include/attach.php55
1 files changed, 55 insertions, 0 deletions
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