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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to set security permissions by Page Type?


Go to End


4 Posts   1937 Views

Avatar
Jatinder

Community Member, 23 Posts

15 February 2010 at 8:52pm

Hello,

I have created a new page type and its associated data model. Now I want to create a user which should have access to add/edit this particular page type only.

Is this possible in SS? How do I go about it?

Thanks You.

Avatar
Hamish

Community Member, 712 Posts

15 February 2010 at 9:26pm

Avatar
Jatinder

Community Member, 23 Posts

16 February 2010 at 12:14am

Thank you for the response. I have already gone through that particular page but it left quite confused.

Please see my code below. I added new permission and it shows up fine in the CMS when I try to add a new role. The problem is that if I allow just "Add/edit/delete Jobs" to a new role, that user is unable to access the CMS admin panel.

class Vacancies extends Page {

    static $db = array();
    static $has_many = array('Jobs' => 'Job');
	static $allowed_children = array('none');
	static $can_be_root = true;

    function getCMSFields() {
        $fields = parent::getCMSFields();
        $jobsTable = new ComplexTableField($this, 'Jobs', 'Job');
        $fields->addFieldToTab("Root.Content.Jobs", $jobsTable);
        
        return $fields;
    }
	
}

class Vacancies_Controller extends Page_Controller {
	function init() {
        if(!Permission::check("JOB_EDITOR")) Security::permissionFailure();
    }

    function ActiveJobs() {
        return DataObject::get("Job", "ExpiryDate > '".date('Y-m-d')."'");
    }

    function providePermissions(){
		return array(
			"JOB_EDITOR" => "Add/edit/delete Jobs"
		);
	}
}

Avatar
stevanovich

Community Member, 63 Posts

24 August 2011 at 8:01pm

Did you get anywhere with this?? I want to setup a user to access one page type or a particular page and children when setting up user group it doesn't allow to admin area. I am also confused as to the permissions setup.