diff options
author | redmatrix <git@macgirvin.com> | 2016-04-05 23:11:24 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-04-05 23:11:24 -0700 |
commit | 5a2a8717e3da4e84802cc72eebb600db2f774f0a (patch) | |
tree | 29e7e54df06fb27430d9e471e83f00ba28513985 /include/attach.php | |
parent | 0d50d295388c634a00f0c084e5c5ce78b098a78c (diff) | |
download | volse-hubzilla-5a2a8717e3da4e84802cc72eebb600db2f774f0a.tar.gz volse-hubzilla-5a2a8717e3da4e84802cc72eebb600db2f774f0a.tar.bz2 volse-hubzilla-5a2a8717e3da4e84802cc72eebb600db2f774f0a.zip |
provide function to collect file/photo sync data per help/filesync
Diffstat (limited to 'include/attach.php')
-rw-r--r-- | include/attach.php | 55 |
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 |