Search

While I’m waiting for the release candidate of the Members extension, I’m working on our company’s intranet, using my own hacked version of Alistair’s beta version of the Members extension.

The problem I’m running up against is the visibility of the Members menu to a user who has been given access to the Symphony admin as an Author rather than as a Developer. It doesn’t make sense for anyone other than a Developer to have access to this menu, so I’m wondering how to disable the menu only for Authors.

I thought I could hack the extension a little more to achieve this. The following turns off the members navigation for all admin users:

    public function fetchNavigation(){

        if (1 == 0) {
            return array(
                array(
                    'location' => 330,
                    'name' => __('Members'),
                    'children' => array(

                        array(
                            'name' => __('Roles'),
                            'link' => '/roles/'
                        ),

                        array(
                            'name' => __('Email Templates'),
                            'link' => '/email_templates/'
                        ),

                        array(
                            'name' => __('Setup'),
                            'link' => '/setup/'
                        ),

                    )
                )

            );
        }
    }       

How do I access the isDeveloper() method in the Author class to limit access to the Members menu? Something like the following pseudo code (this just returns a blank page) is what I’m after:

    public function fetchNavigation(){

        if ($this->Author->isDeveloper()) {
            return array(
                array(
                    'location' => 330,
                    'name' => __('Members'),
                    'children' => array(

                        array(
                            'name' => __('Roles'),
                            'link' => '/roles/'
                        ),

                        array(
                            'name' => __('Email Templates'),
                            'link' => '/email_templates/'
                        ),

                        array(
                            'name' => __('Setup'),
                            'link' => '/setup/'
                        ),

                    )
                )

            );
        }
    }       

It’s a mystery to me, with my limited PHP skills, how I would be able to access these sorts of methods from an extension. If this has already been demonstrated by another extension, please let me know. I can’t think of one at the moment.

Just use the Administration::instance()->Author variable. You can also use the limit parameter instead.

I found some methods in the AdministrationPage class which made me wonder why the navigation array does not include an optional argument to limit access to each page.

There are currently three roles that can be used to limit access to a Symphony admin page:

The canAccessPage() method appears to manage the visibility of each item in the navigation.

I have found that kanduvisla’s Author Section extension limits access to the Author configuration details here. But I still can’t figure out how to do something similar for the navigation.

It seems like there should be a third element in the array to specify the access level:

    public function fetchNavigation(){

        return array(
            array(
                'location' => 330,
                'name' => __('Members'),
                'children' => array(

                    array(
                        'name' => __('Roles'),
                        'link' => '/roles/',
                        'limit' => 'developer'
                    ),

                    array(
                        'name' => __('Email Templates'),
                        'link' => '/email_templates/',
                        'limit' => 'developer'
                    ),

                    array(
                        'name' => __('Setup'),
                        'link' => '/setup/',
                        'limit' => 'developer'
                    ),

                )
            )

        );
    }       

I tried this (I’m trying to figure things out by trial and error, rather than actually understanding what I’m doing), but it gave me a blank page:

    public function fetchNavigation(){

        if (Administration::instance()->Author->isDeveloper()) {
            return array(
                array(
                    'location' => 330,
                    'name' => __('Members'),
                    'children' => array(

                        array(
                            'name' => __('Roles'),
                            'link' => '/roles/'
                        ),

                        array(
                            'name' => __('Email Templates'),
                            'link' => '/email_templates/'
                        ),

                        array(
                            'name' => __('Setup'),
                            'link' => '/setup/'
                        ),

                    )
                )

            );
        }
    }       

But it seems like what I suggested in my previous comment, adding another element for ‘limit’ actually works! I apparently just stumbled upon the way it is supposed to work.

Did Rainer’s advice not work? Implemented like so…

public function fetchNavigation(){
    return array(
        array(
            'location' => 330,
            'name' => __('Members'),
            'limit' => 'developer'
            'children' => array(
                array(
                    'name' => __('Roles'),
                    'link' => '/roles/'
                ),
                array(
                    'name' => __('Email Templates'),
                    'link' => '/email_templates/'
                ),
                array(
                    'name' => __('Setup'),
                    'link' => '/setup/'
                ),
            )
        )
    );
}       

It looks like Rainer changed his post from when I first read it. My solution was to assign a limit to each menu item. This would potentially allow you to control access to each item. For example, the Setup menu could be set to the following, so that only the Primary user has access to the menu item.

      array(
          'name' => __('Setup'),
          'link' => '/setup/',
          'limit' => 'primary'
      ),

But Rainer’s suggestion does make more sense for what I’m trying to do. And it does work.

Thanks, @designermonkey.

No probs,

I can agree with you about there needing to be some work done on the Navigation building, especially with Extension development. I hope it’s an area of discussion for Sym 3, as it’s probably too late for Sym 2.2

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details