Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Help with new admin panel permissions


Go to End


3 Posts   1736 Views

Avatar
redactuk

Community Member, 117 Posts

21 August 2011 at 10:54am

Edited: 30/08/2011 1:31am

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

Avatar
redactuk

Community Member, 117 Posts

22 August 2011 at 10:39pm

Anyone?

Avatar
redactuk

Community Member, 117 Posts

30 August 2011 at 1:15am

Edited: 30/08/2011 1:42am

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?