aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-05-29 20:39:19 -0400
committerAndrew Manning <tamanning@zoho.com>2016-05-29 20:39:19 -0400
commit00d32f6b947d10b836cf1a4d59dbff3413517fd5 (patch)
tree9f5c31a3a91e65ddcd6fb6049c14c6717f12019c
parentfad27fc1e791dbe77321d4b45eb6293f8ff97310 (diff)
downloadvolse-hubzilla-00d32f6b947d10b836cf1a4d59dbff3413517fd5.tar.gz
volse-hubzilla-00d32f6b947d10b836cf1a4d59dbff3413517fd5.tar.bz2
volse-hubzilla-00d32f6b947d10b836cf1a4d59dbff3413517fd5.zip
Only show wiki delete control if channel owner
-rw-r--r--Zotlabs/Module/Wiki.php1
-rw-r--r--include/widgets.php16
-rw-r--r--include/wiki.php4
-rw-r--r--view/tpl/wikilist.tpl2
4 files changed, 16 insertions, 7 deletions
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index b369221c8..3c1f14a9b 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -78,6 +78,7 @@ class Wiki extends \Zotlabs\Web\Controller {
if(argc()<3) {
// GET /wiki/channel
+ $channel = get_channel_by_nick(argv(1));
$wikiheader = t('Wiki Sandbox');
$content = '"# Wiki Sandbox\n\nContent you **edit** and **preview** here *will not be saved*."';
$hide_editor = false;
diff --git a/include/widgets.php b/include/widgets.php
index 539d227aa..b19c36bc6 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -857,19 +857,25 @@ function widget_chatroom_members() {
function widget_wiki_list($arr) {
require_once("include/wiki.php");
- if(argc()>1) {
+ if (argc() > 1) {
$nick = argv(1);
+ $channel = get_channel_by_nick($nick);
} else {
$channel = \App::get_channel();
$nick = $channel['channel_address'];
}
- $wikis = wiki_list($nick, get_observer_hash());
-
- if($wikis) {
+ $wikis = wiki_list($channel, get_observer_hash());
+ if (local_channel() === intval($channel['channel_id'])) {
+ $showControls = true;
+ } else {
+ $showControls = false;
+ }
+ if ($wikis) {
return replace_macros(get_markup_template('wikilist.tpl'), array(
'$header' => t('Wiki List'),
'$channel' => $nick,
- '$wikis' => $wikis['wikis']
+ '$wikis' => $wikis['wikis'],
+ '$showControls' => $showControls
));
}
}
diff --git a/include/wiki.php b/include/wiki.php
index e07cda660..54644dd18 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -7,9 +7,9 @@
use \Zotlabs\Storage\GitRepo as GitRepo;
define ( 'WIKI_ITEM_RESOURCE_TYPE', 'wiki' );
-function wiki_list($nick, $observer_hash) {
+function wiki_list($channel, $observer_hash) {
if (local_channel() || remote_channel()) {
- $sql_extra = item_permissions_sql(get_channel_by_nick($nick)['channel_id'], $observer_hash);
+ $sql_extra = item_permissions_sql($channel['channel_id'], $observer_hash);
} else {
$sql_extra = " AND item_private = 0 ";
}
diff --git a/view/tpl/wikilist.tpl b/view/tpl/wikilist.tpl
index d1652dcf4..91ac1a7b3 100644
--- a/view/tpl/wikilist.tpl
+++ b/view/tpl/wikilist.tpl
@@ -8,8 +8,10 @@
</a>
<ul class="dropdown-menu pull-right">
<li><a href="/wiki/{{$channel}}/{{$wiki.title}}/Home.md" title="View {{$wiki.title}}">View</a></li>
+ {{if $showControls}}
<li class="divider"></li>
<li><a href="#" onclick="wiki_delete_wiki('{{$wiki.title}}','{{$wiki.resource_id}}'); return false;" title="Delete {{$wiki.title}}">Delete wiki</a></li>
+ {{/if}}
</ul>
</li>
{{/foreach}}