Further modification of permissions
Further modification of permissions
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
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
Last edited by Hare on Sat Oct 14, 2006 10:18 am, edited 1 time in total.
Re: Events and user permissions
Open admin/themes/default/defaultTheme.php (or a custom theme file if you created one).
At the very start, right after
add:
At the very start, right after
Code: Select all
class defaultTheme extends AdminTheme
{
function renderMenuSection($section, $depth, $maxdepth)
{
Code: Select all
$extensions_items = ($this->menuItems['extensions']['children']);
$key = array_search('eventhandlers', $extensions_items);
if($key !== FALSE) {
unset($this->menuItems['extensions']['children'][$key]);
}
Last edited by Anonymous on Wed Oct 04, 2006 4:56 pm, edited 1 time in total.
Re: Events and user permissions
Thanks. I'll try that out.
Re: Events and user permissions
Hmm. Still doesn't work.
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.
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]);
}
Last edited by Hare on Tue Oct 10, 2006 7:12 pm, edited 1 time in total.
Re: Events and user permissions
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?Hare wrote: Hmm. Still doesn't work.
Re: Events and user permissions
So that would be:Dee wrote: At the very start, right afteradd:Code: Select all
class defaultTheme extends AdminTheme { function renderMenuSection($section, $depth, $maxdepth) {
...
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)
{
Re: Events and user permissions
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.
Thanks for the help.
Re: Events and user permissions
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.
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.
Last edited by Hare on Wed Oct 11, 2006 10:15 am, edited 1 time in total.
Re: Events and user permissions
I figured how to remove the extensions from the GUI. I'll post the solution, maybe this will help someone else.
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.
Code: Select all
function renderMenuSection($section, $depth, $maxdepth)
{
if(isset($this->menuItems['extensions'])) {
unset($this->menuItems['extensions']);
}
if ($maxdepth > 0 && $depth > $maxdepth)
Last edited by Hare on Sat Oct 14, 2006 10:41 am, edited 1 time in total.
Re: Further modification of permissions
You can check permissions with the check_permission function:
So, for example:
Use $userid = get_userid(); to get the userid.
Also the check_ownership function could be usefull:
For examples of usage take a look at the code in admin/addcontent.php or admin/editcontent.php
Regards,
D
Code: Select all
check_permission($userid, 'Permission Name')
Code: Select all
check_permission($userid, 'Modify Any Page')
Also the check_ownership function could be usefull:
Code: Select all
check_ownership($userid, $content_id)
Regards,
D
Re: Further modification of permissions
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']);
}