aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-06 16:49:07 -0800
committerfriendica <info@friendica.com>2014-01-06 16:49:07 -0800
commit8dc22c564aee0a6edf590a9a47021ea1ceb4aecf (patch)
tree5796daf0efa053d505e5298724ca2b44e892cb3f
parent8223f04b97a822f8acac78a452919dbf77b91146 (diff)
downloadvolse-hubzilla-8dc22c564aee0a6edf590a9a47021ea1ceb4aecf.tar.gz
volse-hubzilla-8dc22c564aee0a6edf590a9a47021ea1ceb4aecf.tar.bz2
volse-hubzilla-8dc22c564aee0a6edf590a9a47021ea1ceb4aecf.zip
provide ability to change attachment/file permissions
-rw-r--r--mod/filestorage.php74
-rw-r--r--view/tpl/attach_edit.tpl32
-rw-r--r--view/tpl/filestorage.tpl1
3 files changed, 106 insertions, 1 deletions
diff --git a/mod/filestorage.php b/mod/filestorage.php
index 3d63e6da3..152b449c2 100644
--- a/mod/filestorage.php
+++ b/mod/filestorage.php
@@ -1,5 +1,37 @@
<?php
+require_once('include/attach.php');
+
+function filestorage_post(&$a) {
+
+ $channel_id = ((x($_POST,'uid')) ? intval($_POST['uid']) : 0);
+
+ if((! $channel_id) || (! local_user()) || ($channel_id != local_user())) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ $recurse = ((x($_POST,'recurse')) ? intval($_POST['recurse']) : 0);
+ $resource = ((x($_POST,'filehash')) ? notags($_POST['filehash']) : '');
+
+ if(! $resource) {
+ notice(t('Item not found.') . EOL);
+ return;
+ }
+
+ $str_group_allow = perms2str($_REQUEST['group_allow']);
+ $str_contact_allow = perms2str($_REQUEST['contact_allow']);
+ $str_group_deny = perms2str($_REQUEST['group_deny']);
+ $str_contact_deny = perms2str($_REQUEST['contact_deny']);
+
+ attach_change_permissions($channel_id,$resource,$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny,$recurse = false);
+
+}
+
+
+
+
+
function filestorage_content(&$a) {
if(argc() > 1)
@@ -40,7 +72,7 @@ function filestorage_content(&$a) {
if(argc() > 3 && argv(3) === 'delete') {
if(! $perms['write_storage']) {
- notice( t('Permission denied. VS.') . EOL);
+ notice( t('Permission denied.') . EOL);
return;
}
@@ -53,6 +85,45 @@ function filestorage_content(&$a) {
}
+ if(argc() > 3 && argv(3) === 'edit') {
+ require_once('include/acl_selectors.php');
+ if(! $perms['write_storage']) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+ $file = intval(argv(2));
+
+ $r = q("select id, folder, filename, flags, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1",
+ intval($file),
+ intval($owner)
+ );
+
+ $f = $r[0];
+
+ $channel = $a->get_channel();
+
+
+ $aclselect_e = populate_acl($f);
+ $is_a_dir = (($f['flags'] & ATTACH_FLAG_DIR) ? true : false);
+
+
+ $o = replace_macros(get_markup_template('attach_edit.tpl'), array(
+ '$header' => t('Edit file permissions'),
+ '$file' => $f,
+ '$uid' => $channel['channel_id'],
+ '$channelnick' => $channel['channel_address'],
+ '$permissions' => t('Permissions'),
+ '$aclselect' => $aclselect_e,
+ '$recurse' => t('Include all files and sub folders'),
+ '$backlink' => t('Return to file list'),
+ '$isadir' => $is_a_dir,
+ '$submit' => t('Submit')
+
+ ));
+
+ return $o;
+ }
+
$r = q("select * from attach where uid = %d order by edited desc",
intval($owner)
);
@@ -83,6 +154,7 @@ function filestorage_content(&$a) {
'$download' => t('Download'),
'$files' => $files,
'$channel' => $which,
+ '$edit' => t('Edit Permissions'),
'$delete' => t('Delete'),
'$used' => $used,
'$usedlabel' => t('Used: '),
diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl
new file mode 100644
index 000000000..1483336ff
--- /dev/null
+++ b/view/tpl/attach_edit.tpl
@@ -0,0 +1,32 @@
+
+<h1>{{$header}}</h1>
+
+<h2>{{$file.filename}}</h2>
+
+
+<div id="attach-edit-backlink"><a href="filestorage/{{$channelnick}}">{{$backlink}}</a></div>
+
+
+<form action="filestorage/{{$channelnick}}/{{$file.id}}/edit" method="post" >
+
+<input type="hidden" name="channelnick" value="{{$channelnick}}" />
+<input type="hidden" name="filehash" value="{{$file.hash}}" />
+<input type="hidden" name="uid" value="{{$uid}}" />
+<input type="hidden" name="fileid" value="{{$file.id}}" />
+
+{{if $isadir}}
+<div id="attach-edit-recurse" >
+ <label id="attach-edit-recurse-text" for="attach-recurse-input" >{{$recurse}}</label>
+ <input id="attach-recurse-input" type="checkbox" name="recurse" value="1" />
+</div>
+{{/if}}
+
+<div id="attach-edit-perms" >
+{{$aclselect}}
+</div>
+
+<div class="clear"></div>
+<input type="submit" name="submit" value="{{$submit}}" />
+</form>
+
+
diff --git a/view/tpl/filestorage.tpl b/view/tpl/filestorage.tpl
index 995b52cc8..a3eab83d5 100644
--- a/view/tpl/filestorage.tpl
+++ b/view/tpl/filestorage.tpl
@@ -8,6 +8,7 @@
{{foreach $items as $item}}
<div class="files-list-item">
<a href="attach/{{$item.download}}">{{$download}}</a> |
+ <a href="{{$baseurl}}/{{$item.id}}/edit">{{$edit}} |
<a href="{{$baseurl}}/{{$item.id}}/delete">{{$delete}}
<a href="page/{{$channel}}/{{$item.title}}">{{$title}}</a> {{$item.title}} |
{{$item.size}} bytes