Further modification of permissions

General project discussion. NOT for help questions.
Post Reply
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Further modification of permissions

Post 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
Last edited by Hare on Sat Oct 14, 2006 10:18 am, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Events and user permissions

Post 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]);
    }
Last edited by Anonymous on Wed Oct 04, 2006 4:56 pm, edited 1 time in total.
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Events and user permissions

Post by Hare »

Thanks. I'll try that out.
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Events and user permissions

Post 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.
Last edited by Hare on Tue Oct 10, 2006 7:12 pm, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Events and user permissions

Post 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?
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Events and user permissions

Post 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).
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Events and user permissions

Post 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.
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Events and user permissions

Post 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.
Last edited by Hare on Wed Oct 11, 2006 10:15 am, edited 1 time in total.
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Events and user permissions

Post 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.
Last edited by Hare on Sat Oct 14, 2006 10:41 am, edited 1 time in total.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: Further modification of permissions

Post 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
Hare
Forum Members
Forum Members
Posts: 87
Joined: Sat Jun 03, 2006 11:46 am

Re: Further modification of permissions

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

Return to “General Discussion”