Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » How to set security permissions by Page Type?

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

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

Page: 1
Go to End
Author Topic: 1336 Views
  • Jatinder
    Avatar
    Community Member
    23 Posts

    How to set security permissions by Page Type? Link to this post

    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.

  • Hamish
    Avatar
    Community Member
    712 Posts
  • Jatinder
    Avatar
    Community Member
    23 Posts

    Re: How to set security permissions by Page Type? Link to this post

    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"
          );
       }
    }

  • stevanovich
    Avatar
    Community Member
    60 Posts

    Re: How to set security permissions by Page Type? Link to this post

    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.

    1336 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.