aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-09-08 19:12:46 -0700
committerfriendica <info@friendica.com>2013-09-08 19:12:46 -0700
commitf8c709830fe9268ccf9abe4801eb7a6ca39eff2d (patch)
tree5cdd173506522f891f98b3985445d33ea056cbc4
parent135c1887328f7c2e03d03c0c41d6ab4773996519 (diff)
parentdcc74185d08c0be3320b6a547ec19c2b3db05544 (diff)
downloadvolse-hubzilla-f8c709830fe9268ccf9abe4801eb7a6ca39eff2d.tar.gz
volse-hubzilla-f8c709830fe9268ccf9abe4801eb7a6ca39eff2d.tar.bz2
volse-hubzilla-f8c709830fe9268ccf9abe4801eb7a6ca39eff2d.zip
Merge https://github.com/friendica/red into zpull
-rw-r--r--mod/filestorage.php70
-rw-r--r--view/tpl/filestorage.tpl22
2 files changed, 92 insertions, 0 deletions
diff --git a/mod/filestorage.php b/mod/filestorage.php
new file mode 100644
index 000000000..41055f98e
--- /dev/null
+++ b/mod/filestorage.php
@@ -0,0 +1,70 @@
+<?php
+
+function filestorage_content(&$a) {
+
+ if(argc() > 1)
+ $which = argv(1);
+ else {
+ notice( t('Requested profile is not available.') . EOL );
+ $a->error = 404;
+ return;
+ }
+
+ $r = q("select channel_id from channel where channel_address = '%s'",
+ dbesc($which)
+ );
+ if($r) {
+ $owner = intval($r[0]['channel_id']);
+ }
+
+ $is_owner = (((local_user()) && ($owner == local_user())) ? true : false);
+ if (! $is_owner) {
+ info( t('Permission Denied.') . EOL );
+ return;
+ }
+ if ((argc() > 3 && argv(3) === 'delete') ? true : false);{
+ $file = argv(2);
+ $r = q("delete from attach where id = '%s' and uid = '%s' limit 1",
+ dbesc($file),
+ intval($owner)
+ );
+
+
+ }
+
+
+$r = q("select * from attach where uid = %d order by filename asc",
+ intval($owner)
+);
+
+ $files = null;
+
+ if($r) {
+ $files = array();
+ foreach($r as $rr) {
+ $files[$rr['id']][] = array('id' => $rr['id'],'download' => $rr['hash'], 'title' => $rr['filename'], 'size' => $rr['filesize']);
+ }
+ }
+
+
+ $limit = service_class_fetch ($owner,'attach_upload_limit');
+ $r = q("select sum(filesize) as total from attach where uid = %d ",
+ intval($owner)
+ );
+ $used = $r[0]['total'];
+
+ $url = z_root() . "/filestorage/" . $which;
+ return $o . replace_macros(get_markup_template("filestorage.tpl"), array(
+ '$baseurl' => $url,
+ '$download' => t('Download'),
+ '$files' => $files,
+ '$channel' => $which,
+ '$delete' => t('Delete'),
+ '$used' => $used,
+ '$usedlabel' => t('Used: '),
+ '$limit' => $limit,
+ '$limitlabel' => t('Limit: '),
+ ));
+
+
+}
diff --git a/view/tpl/filestorage.tpl b/view/tpl/filestorage.tpl
new file mode 100644
index 000000000..995b52cc8
--- /dev/null
+++ b/view/tpl/filestorage.tpl
@@ -0,0 +1,22 @@
+{{if $files}}
+
+ <div class="generic-content-wrapper">
+ {{if $limit}}{{$limitlabel}}{{$limit}}{{/if}} {{if $used}} {{$usedlabel}}{{$used}}{{/if}}
+
+
+ {{foreach $files as $key => $items}}
+ {{foreach $items as $item}}
+ <div class="files-list-item">
+ <a href="attach/{{$item.download}}">{{$download}}</a> |
+ <a href="{{$baseurl}}/{{$item.id}}/delete">{{$delete}}
+ <a href="page/{{$channel}}/{{$item.title}}">{{$title}}</a> {{$item.title}} |
+ {{$item.size}} bytes
+
+</div>
+ {{/foreach}}
+ {{/foreach}}
+ </div>
+
+ <div class="clear"></div>
+
+{{/if}}