Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Help with new admin panel permissions

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 621 Views
  • redactuk
    Avatar
    Community Member
    117 Posts

    Help with new admin panel permissions Link to this post

    I've customised the eventresources module to use a standard left tree display rather than the default. The Admin class starts:

    class EventResourceAdmin extends LeftAndMain {
       static $url_segment = 'events-calendar';
       static $menu_title = 'Bookings';
       static $menu_priority = 0;
       static $url_priority = 41;
       static $url_rule = '/$Action/$ID/$OtherID';
       static $tree_class = "EventResource";
       
       public function init() {
          parent::init();
          Requirements::javascript('eventresources/javascript/EventResourceAdmin_left.js');
          Requirements::javascript('eventresources/javascript/EventResourceAdmin_right.js');      
          Requirements::css('eventresources/css/EventResource.css');
       }

       /**
        * get_resources retrieves all EventResource objects from the database
        *
        * @return DataObjectSet
        */
       public function get_resources() {
          $result = DataObject::get('EventResource');
          return $result;
       }
       
       /**
        * Generate the editform, only if there is a URL ID available
        */
       function getEditForm($id = null) {
          if(!$id)
             $id = $this->urlParams['ID'];
          
          if($id) {
             $currentResource = DataObject::get_by_id('EventResource', $id);
             $fields = $currentResource->getCMSFields();
             
             // required for form actions
             $fields->addFieldToTab('Root.Main', new HiddenField('ID','id #',$id));
       
             $actions = new FieldSet(
                new FormAction('doDeleteResource', _t('EventResourceAdmin.DELETERESOURCE','Delete Resource')),
                new FormAction('doUpdateResource', _t('EventResourceAdmin.UPDATERESOURCE','Update Resource'))
             );

             $form = new Form($this, "EditForm", $fields, $actions);
             
             $form->loadDataFrom($currentResource);

             return $form;
          }
       }   

    Now when I'm logged in as Admin I can access new Admin panel on the top menu, and can access it fine, and add and edit resource records. Yet as soon as I'm logged in as another user in another group, despite the fact there is a record in Permission table with "CMS_ACCESS_EventResourceAdmin" for the correct group, as soon as I access the menu item i just get the Silverstripe logo and 'loading' in top left corner.

    I've read bits of the documentation but I really don't get where I'm supposed to be lookingg. Am i dealing with permissions for LeftandMain, DataObjects or what?

    Any help appreciated

  • redactuk
    Avatar
    Community Member
    117 Posts

    Re: Help with new admin panel permissions Link to this post

    Anyone?

  • redactuk
    Avatar
    Community Member
    117 Posts

    Re: Help with new admin panel permissions Link to this post

    Got one step further with this, it now diplays tree on left hand side, but when selecting item in left tree the right side form displays:

    Fatal error: Call to undefined method SS_HTTPResponse::formHtmlContent() in /home/reddemo/public_html/fulbourn/cms/code/LeftAndMain.php on line 372

    As i said, this only when happens when logged in as user. When logged in as Admin it displays fine.

    My EventResourceAdmin_left.js is:

    Behaviour.register({
       "#Form_EditForm" : {
          getPageFromServer : function(id) {
             statusMessage("loading...");
             var requestURL = 'admin/events-calendar/show/' + id;
             this.loadURLFromServer(requestURL);
             $('sitetree').setCurrentByIdx(id);
          }   
       }   
    });

    Which may be where the problems lies, but I don't see why it should work logged in as Admin and not as a user with lesser permissions. The user does not have permission to 'Edit any page' could that be issue?

    621 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.