In dokuwiki how can I hide "media manager" link or any other link on the top, from non logged in users?
问题:
回答1:
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
}
?>
回答2:
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)
));
}
回答3:
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.
回答4:
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.
回答5:
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!
回答6:
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' );
}
}
回答7:
My solution will may be hide too much information, but here we go:
- Login as admin
- Go the management section
- Scroll to ACL (Access Control List) Management
- Set User/Group „@all“ Permissions to „None“