From 68bdd26426269ff641ef97bdecb3d2cff38fb6b5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 13 Dec 2016 10:09:26 +0100 Subject: simplify wikilist widget --- include/widgets.php | 93 ++++++-------------------------------------- view/tpl/wikilist_widget.tpl | 39 +------------------ 2 files changed, 12 insertions(+), 120 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index 4cb8f8372..f24bb488b 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -898,87 +898,17 @@ function widget_chatroom_members() { } function widget_wiki_list($arr) { - - require_once("include/wiki.php"); - $channel = null; - if (argc() < 2 && local_channel()) { - // This should not occur because /wiki should redirect to /wiki/channel ... - $channel = \App::get_channel(); - } else { - $channel = channelx_by_nick(argv(1)); // Channel being viewed by observer - } - if (!$channel) { - return ''; - } - // init() should have forced the URL to redirect to /wiki/channel so assume argc() > 1 - $nick = argv(1); - $owner = channelx_by_nick($nick); // The channel who owns the wikis being viewed - // Determine if the observer is the channel owner so the ACL dialog can be populated - if (local_channel() === intval($owner['channel_id'])) { - - // Obtain the default permission settings of the channel - $owner_acl = array( - 'allow_cid' => $owner['channel_allow_cid'], - 'allow_gid' => $owner['channel_allow_gid'], - 'deny_cid' => $owner['channel_deny_cid'], - 'deny_gid' => $owner['channel_deny_gid'] - ); - // Initialize the ACL to the channel default permissions - $x = array( - 'lockstate' => (( $owner['channel_allow_cid'] || - $owner['channel_allow_gid'] || - $owner['channel_deny_cid'] || - $owner['channel_deny_gid']) ? 'lock' : 'unlock' - ), - 'acl' => populate_acl($owner_acl), - 'allow_cid' => acl2json($owner_acl['allow_cid']), - 'allow_gid' => acl2json($owner_acl['allow_gid']), - 'deny_cid' => acl2json($owner_acl['deny_cid']), - 'deny_gid' => acl2json($owner_acl['deny_gid']), - 'bang' => '' - ); - } else { - // Not the channel owner - $owner_acl = $x = array(); - } - if(argc()>1) { - $activeWikiURLname = argv(2); - } else { - $activeWikiURLname = ''; - } - logger($activeWikiURLname, LOGGER_DEBUG); - $wikis = wiki_list($channel, get_observer_hash()); - foreach($wikis['wikis'] as &$w) { - if($w['urlName'] === $activeWikiURLname) { - $w['active'] = true; - } else { - $w['active'] = false; - } - } - if ($wikis) { - return replace_macros(get_markup_template('wikilist_widget.tpl'), array( - '$header' => t('Wiki List'), - '$channel' => $channel['channel_address'], - '$wikis' => $wikis['wikis'], - // If the observer is the local channel owner, show the wiki controls - '$owner' => ((local_channel() && local_channel() === intval(\App::$profile['uid'])) ? true : false), - '$edit' => t('Edit'), - '$download' => t('Download'), - '$view' => t('View'), - '$addnew' => t('Create new wiki'), - '$create' => t('Create'), - '$wikiName' => array('wikiName', t('Wiki name')), - '$lockstate' => $x['lockstate'], - '$acl' => $x['acl'], - '$allow_cid' => $x['allow_cid'], - '$allow_gid' => $x['allow_gid'], - '$deny_cid' => $x['deny_cid'], - '$deny_gid' => $x['deny_gid'], - '$bang' => $x['bang'], - '$notify' => array('postVisible', t('Send notification'), '', '', array(t('No'), t('Yes'))) - )); - } - return ''; + require_once("include/wiki.php"); + $channel = channelx_by_n(App::$profile_uid); + $wikis = wiki_list($channel, get_observer_hash()); + if($wikis) { + return replace_macros(get_markup_template('wikilist_widget.tpl'), array( + '$header' => t('Wiki List'), + '$channel' => $channel['channel_address'], + '$wikis' => $wikis['wikis'] + )); + } + return ''; } function widget_wiki_pages($arr) { @@ -1573,7 +1503,6 @@ function widget_tasklist($arr) { function widget_helpindex($arr) { $o .= '
'; - //$o .= '

' . t('Documentation') . '

'; $level_0 = get_help_content('sitetoc'); if(! $level_0) diff --git a/view/tpl/wikilist_widget.tpl b/view/tpl/wikilist_widget.tpl index 51eccad90..1f92b5807 100644 --- a/view/tpl/wikilist_widget.tpl +++ b/view/tpl/wikilist_widget.tpl @@ -1,45 +1,8 @@

{{$header}}

- {{if $owner}} - - {{/if}}
-{{$acl}} -- cgit v1.2.3