Page 1 of 1
Further modification of permissions
Posted: Tue Oct 03, 2006 10:34 am
by Hare
Edit: The subject used to be "Events and user permissions" but I changed it to something more describing.
Hi
I'm looking for ways to make the admin interface as clear as possible for the less experienced editors. I've been able to remove pretty much all advanced stuff but I haven't found a way hide the events. Any easy ways to do this?
Thanks in advance,
Hare
Re: Events and user permissions
Posted: Wed Oct 04, 2006 4:12 pm
by Dee
Open admin/themes/default/defaultTheme.php (or a custom theme file if you created one).
At the very start, right after
Code: Select all
class defaultTheme extends AdminTheme
{
function renderMenuSection($section, $depth, $maxdepth)
{
add:
Code: Select all
$extensions_items = ($this->menuItems['extensions']['children']);
$key = array_search('eventhandlers', $extensions_items);
if($key !== FALSE) {
unset($this->menuItems['extensions']['children'][$key]);
}
Re: Events and user permissions
Posted: Wed Oct 04, 2006 5:51 pm
by Hare
Thanks. I'll try that out.
Re: Events and user permissions
Posted: Tue Oct 10, 2006 6:47 pm
by Hare
Hmm. Still doesn't work.
Code: Select all
class defaultTheme extends AdminTheme
{
function renderMenuSection($section, $depth, $maxdepth)
{
if ($maxdepth > 0 && $depth > $maxdepth)
{
$extensions_items = ($this->menuItems['extensions']['children']);
$key = array_search('eventhandlers', $extensions_items);
if($key !== FALSE) {
unset($this->menuItems['extensions']['children'][$key]);
}
I removed the permission to setup site preferences and the extensions part is now hidden from the editors but it would have been nice to let the group edit the site preferences but not see any extensions/modules.
Re: Events and user permissions
Posted: Tue Oct 10, 2006 7:27 pm
by Dee
Hare wrote:
Hmm. Still doesn't work.
Odd, I tested the code and it worked here (it hid the Events entry in the Extensions menu). Are you using cmsmadesimple-1.0.2?
Re: Events and user permissions
Posted: Tue Oct 10, 2006 7:33 pm
by Dee
Dee wrote:
At the very start, right after
Code: Select all
class defaultTheme extends AdminTheme
{
function renderMenuSection($section, $depth, $maxdepth)
{
add:
...
So that would be:
Code: Select all
function renderMenuSection($section, $depth, $maxdepth)
{
$extensions_items = ($this->menuItems['extensions']['children']);
$key = array_search('eventhandlers', $extensions_items);
if($key !== FALSE) {
unset($this->menuItems['extensions']['children'][$key]);
}
if ($maxdepth > 0 && $depth > $maxdepth)
{
It hides the Events entry (does that for all admin users, you probably also want some if statement checking permissions around it).
Re: Events and user permissions
Posted: Wed Oct 11, 2006 7:37 am
by Hare
Yes I'm using 1.02. I'm going to make a fresh install and try again. I'll post another message with results.
Thanks for the help.
Re: Events and user permissions
Posted: Wed Oct 11, 2006 10:07 am
by Hare
I don't know what went wrong before but now it works fine. Thanks a lot for your help!
It would be perfect if the system didn't show the extensions part at all if the user doesn't belong in the admin-group. I'll try to modify the code further. It's a bit difficult to make if-conditions without knowing much about the source (what variable contains the group etc use).
Btw. I think the admin section should be more modular when it comes to permissions. Maybe in later versions the permissions will be more detailed? Or maybe someone will write a module that makes it easier to customize user privileges.
Re: Events and user permissions
Posted: Sat Oct 14, 2006 10:17 am
by Hare
I figured how to remove the extensions from the GUI. I'll post the solution, maybe this will help someone else.
Code: Select all
function renderMenuSection($section, $depth, $maxdepth)
{
if(isset($this->menuItems['extensions'])) {
unset($this->menuItems['extensions']);
}
if ($maxdepth > 0 && $depth > $maxdepth)
What I'd like to add is that if the user belongs to the admingroup the extensions would not be hidden. I haven't yet figured out how the group permissions work under the hood so if anyone can tell me which variable to test I'd be more than glad.
Re: Further modification of permissions
Posted: Sat Oct 14, 2006 3:49 pm
by Dee
You can check permissions with the check_permission function:
Code: Select all
check_permission($userid, 'Permission Name')
So, for example:
Code: Select all
check_permission($userid, 'Modify Any Page')
Use $userid = get_userid(); to get the userid.
Also the check_ownership function could be usefull:
Code: Select all
check_ownership($userid, $content_id)
For examples of usage take a look at the code in admin/addcontent.php or admin/editcontent.php
Regards,
D
Re: Further modification of permissions
Posted: Sun Oct 15, 2006 12:22 pm
by Hare
Thanks! Now it's just the way I wanted it
Code: Select all
function renderMenuSection($section, $depth, $maxdepth)
{
if( isset($this->menuItems['extensions']) && check_permission($userid, 'Modify Modules')==false ) {
unset($this->menuItems['extensions']);
}