provide function to collect file/photo sync data per help/filesync
This commit is contained in:
parent
0d50d29538
commit
5a2a8717e3
@ -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;
|
||||
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
require_once('include/Contact.php');
|
||||
require_once('include/attach.php');
|
||||
|
||||
function getfile_post(&$a) {
|
||||
|
||||
|
Reference in New Issue
Block a user