sync cloud storage permission changes (issue #538 continued)

This commit is contained in:
redmatrix 2016-10-01 16:01:22 -07:00 committed by Mario Vavti
parent 27d5b9cfd0
commit 1af56b1025
2 changed files with 15 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class Filestorage extends \Zotlabs\Web\Controller {
//get the object before permissions change so we can catch eventual former allowed members //get the object before permissions change so we can catch eventual former allowed members
$object = get_file_activity_object($channel_id, $resource, $cloudPath); $object = get_file_activity_object($channel_id, $resource, $cloudPath);
attach_change_permissions($channel_id, $resource, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], $recurse); attach_change_permissions($channel_id, $resource, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], $recurse, true);
file_activity($channel_id, $object, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], 'post', $notify); file_activity($channel_id, $object, $x['allow_cid'], $x['allow_gid'], $x['deny_cid'], $x['deny_gid'], 'post', $notify);

View File

@ -1198,7 +1198,11 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
* @param string $deny_gid * @param string $deny_gid
* @param boolean $recurse (optional) default false * @param boolean $recurse (optional) default false
*/ */
function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false) { function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse = false, $sync = false) {
$channel = channelx_by_n($channel_id);
if(! $channel)
return;
$r = q("select hash, flags, is_dir, is_photo from attach where hash = '%s' and uid = %d limit 1", $r = q("select hash, flags, is_dir, is_photo from attach where hash = '%s' and uid = %d limit 1",
dbesc($resource), dbesc($resource),
@ -1216,7 +1220,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
); );
if($r) { if($r) {
foreach($r as $rr) { foreach($r as $rr) {
attach_change_permissions($channel_id, $rr['hash'], $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse); attach_change_permissions($channel_id, $rr['hash'], $allow_cid, $allow_gid, $deny_cid, $deny_gid, $recurse, $sync);
} }
} }
} }
@ -1240,6 +1244,13 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
intval($channel_id) intval($channel_id)
); );
} }
if($sync) {
$data = attach_export_data($channel,$resource_id);
if($data)
build_sync_packet($channel['channel_id'],array('file' => array($data)));
}
} }
/** /**