aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/widgets.php14
-rw-r--r--include/wiki.php12
2 files changed, 20 insertions, 6 deletions
diff --git a/include/widgets.php b/include/widgets.php
index acbd9bcd3..cff58d225 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -860,13 +860,19 @@ function widget_chatroom_members() {
function widget_wiki_list($arr) {
require_once("include/wiki.php");
- $r = wiki_list(App::$profile['channel_hash']);
+ if(argc()>1) {
+ $nick = argv(1);
+ } else {
+ $channel = \App::get_channel();
+ $nick = $channel['channel_address'];
+ }
+ $wikis = wiki_list($nick, get_observer_hash());
- if($r) {
+ if($wikis) {
return replace_macros(get_markup_template('wikilist.tpl'), array(
'$header' => t('Wiki List'),
- '$read' => $r['read'],
- '$write' => $r['write']
+ '$channel' => $nick,
+ '$wikis' => $wikis['wikis']
));
}
}
diff --git a/include/wiki.php b/include/wiki.php
index 32caa98e8..7cd838f95 100644
--- a/include/wiki.php
+++ b/include/wiki.php
@@ -15,9 +15,17 @@ function wiki_delete() {
}
-function wiki_list($observer_hash) {
+function wiki_list($nick, $observer_hash) {
+ if (local_channel() || remote_channel()) {
+ $sql_extra = item_permissions_sql(get_channel_by_nick($nick)['channel_id'], $observer_hash);
+ } else {
+ $sql_extra = " AND item_private = 0 ";
+ }
+ $wikis = q("SELECT * FROM item WHERE resource_type = '%s' AND mid = parent_mid AND item_deleted = 0 $sql_extra",
+ dbesc(WIKI_ITEM_RESOURCE_TYPE)
+ );
// TODO: query db for wikis the observer can access. Return with two lists, for read and write access
- return array('write' => array('wiki1'), 'read' => array('wiki1', 'wiki2'));
+ return array('wikis' => $wikis);
}
function wiki_pages() {