dokuwiki: how can I hide media manager link from n

2019-05-03 22:46发布

In dokuwiki how can I hide "media manager" link or any other link on the top, from non logged in users?

标签: dokuwiki
7条回答
Explosion°爆炸
2楼-- · 2019-05-03 23:29

My solution will may be hide too much information, but here we go:

  1. Login as admin
  2. Go the management section
  3. Scroll to ACL (Access Control List) Management
  4. Set User/Group „@all“ Permissions to „None“
查看更多
3楼-- · 2019-05-03 23:38

I wanted only the sitemap to be visible to visitors and registered users (I use the site as a blog), so only wanted recent changes and media links to be visible to me (administrator).

This is the code I changed in "Greebo", in inc/Menu/SiteMenu.php

    protected $types = array(
        //'Recent', // comment out stuff not required
        //'Media',
        'Index'     // leave sitemap for spiders
    );

    // add this function
    // remove the "&& $INFO['isadmin']" to allow all logged in users to see options
    public function __construct(){
        global $INPUT;
        global $INFO;
        if($INPUT->server->str('REMOTE_USER') && $INFO['isadmin']){
            $this->types = array( 'Recent', 'Media', 'Index' );
        }
    }

查看更多
We Are One
4楼-- · 2019-05-03 23:42

Create a plugin. Let's assume the plugin name is nositetoolsanon, so you need to create a file under lib/plugins/nositetoolsanon/action.php.

<?php
if(!defined('DOKU_INC')) die();

class action_plugin_nositetoolsanon extends DokuWiki_Action_Plugin {
    public function getInfo(){
        return array('date'=>'2017-08-25', 'name'=>'No sitetools for anonymous users', 'author'=>'Phy25');
    }

    public function register(Doku_Event_Handler $controller) {
        $controller->register_hook('TEMPLATE_SITETOOLS_DISPLAY', 'BEFORE', $this, 'action_link');
    }

    public function action_link(&$event, $param){
        global $INFO;
        if(empty($INFO["userinfo"])){
            // more robust check by ACL: global $ID; if (auth_quickaclcheck($ID) < AUTH_READ)
            $event->preventDefault();
        }
    }
}

This method applies to any template and won't be overwritten by updates.

HINT: If you want to hind namespaces for users who are unable to read, try to set $conf['sneaky_index'] = 1 in the config file, though it may cause issues if deeper namespaces have higher permissions than the ones above.

查看更多
该账号已被封号
5楼-- · 2019-05-03 23:43

one way is changing the template like this: in /lib/tpl/dokuwiki/tpl_header.php:

            <?php
                if ($INFO['isadmin']) {
                    tpl_action('recent', 1, 'li'); //recent changes
                    tpl_action('media', 1, 'li'); //media manager
                    tpl_action('index', 1, 'li'); //sitemap
                }
            ?>
查看更多
贪生不怕死
6楼-- · 2019-05-03 23:44

If no user is logged, $INFO["userinfo"] is empty

in /lib/tpl/dokuwiki/tpl_header.php replace

tpl_toolsevent('sitetools', array(
                    tpl_action('recent', true, 'li', true),
                    tpl_action('media', true, 'li', true),
                    tpl_action('index', true, 'li', true)
                ));

with

             if(!empty($INFO["userinfo"]))  {
                tpl_toolsevent('sitetools', array(
                    tpl_action('recent', true, 'li', true),
                    tpl_action('media', true, 'li', true),
                    tpl_action('index', true, 'li', true)
                ));
             }
查看更多
可以哭但决不认输i
7楼-- · 2019-05-03 23:48

Not exactly what you're looking for (and maybe a bit late anyway), but here's a way to disable the Media Manager link for all (including logged-in) users:

  • go to admin panel, Configuration Settings;
  • search for Disable DokuWiki actions (option name: disableactions);
  • in Other actions, add keyword media (see reference here).

Note that this will hide the link for everyone, but users with writing access can still launch the media manager by clicking on corresponding button when editing pages.

查看更多
登录 后发表回答