aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-06 14:57:51 -0800
committerfriendica <info@friendica.com>2014-01-06 14:57:51 -0800
commit8223f04b97a822f8acac78a452919dbf77b91146 (patch)
tree66a2a18dd94c6a8c7d3117e133b3d8f76cc775a1 /include
parentdb0867aeec968402becd39b548f13c1e27c0368d (diff)
downloadvolse-hubzilla-8223f04b97a822f8acac78a452919dbf77b91146.tar.gz
volse-hubzilla-8223f04b97a822f8acac78a452919dbf77b91146.tar.bz2
volse-hubzilla-8223f04b97a822f8acac78a452919dbf77b91146.zip
add potentially recursive set permissions function for file storage
Diffstat (limited to 'include')
-rw-r--r--include/attach.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/attach.php b/include/attach.php
index cd211f2a2..e602af984 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -631,4 +631,44 @@ function attach_mkdir($channel,$observer_hash,$arr = null) {
return $ret;
-} \ No newline at end of file
+}
+
+
+
+function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$deny_cid,$deny_gid,$recurse = false) {
+
+ $r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ if(! $r)
+ return;
+
+ if($r[0]['flags'] & ATTACH_FLAG_DIR) {
+ if($recurse) {
+ $r = q("select hash, flags from attach where folder = '%s' and uid = %d",
+ dbesc($resource),
+ intval($channel_id)
+ );
+ if($r) {
+ foreach($r as $rr) {
+ attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$deny_cid,$deny_gid,$recurse);
+ }
+ }
+ }
+ }
+
+ $x = q("update attach set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s' where hash = '%s' and uid = %d limit 1",
+ dbesc($allow_cid),
+ dbesc($allow_gid),
+ dbesc($deny_cid),
+ dbesc($deny_gid),
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ return;
+}
+
+