sivann
sivann

Reputation: 2131

dokuwiki: how can I hide media manager link from non logged in users

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

Upvotes: 6

Views: 7226

Answers (8)

Lizz2299
Lizz2299

Reputation: 21

My solution with "grebo"

  • find inc/Action/Media.php
  • edit method tplContent():
public function tplContent() {
    global $INFO;
    if ( empty($INFO['userinfo']) ) {
                echo "<p>No way</p>";  
                return;
    }
    tpl_media();
}

So only users - but not anonymous - can see media manager.

Upvotes: 2

Phil Ide
Phil Ide

Reputation: 1

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' );
        }
    }

Upvotes: 0

phy25
phy25

Reputation: 101

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.

Upvotes: 1

escobrice
escobrice

Reputation: 21

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)
                ));
             }

Upvotes: 2

derpedy-doo
derpedy-doo

Reputation: 3052

I had this question myself recently and found the selected answer to be insufficient for me. I'm pretty sure it didn't work because I'm using the Codowik template rather than the default. This is what I came up with using sivann's answer.

I edited /lib/tpl/codowik/tpl_header.php and added this at the top:

<?php
  if (!$INFO['isadmin']) {
    echo "<script>
        var newStyle = document.createElement('Style');
        newStyle.innerHTML = '#codowiki_search_ul a {display: none;}';
        document.head.appendChild(newStyle);
      </script>";
  }
?>

It rather hackish, but I don't have time to dive deeper into how the template is implemented, and it works!

Upvotes: 0

Qeole
Qeole

Reputation: 9134

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.

Upvotes: 3

Anonymous
Anonymous

Reputation: 4757

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“

Upvotes: -1

sivann
sivann

Reputation: 2131

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
                }
            ?>

Upvotes: 4

Related Questions