Semicolon
Semicolon

Reputation: 1914

SilverStripe default content author permissions

The default value for Manage site configuration is off security > groups > content authors > permissions

enter image description here

Although it's possible to simply check the box and activate this, I would rather have this on by default for every SS installation.

How can the default value for this be set to on?

Upvotes: 1

Views: 131

Answers (1)

Barry
Barry

Reputation: 3318

This should do as required, make an extension of Group and add a requireDefaultRecords function, this is called on every dev build.

This function is to look for that permission and if not existing create it...

class GroupExtension extends DataExtension {

    function requireDefaultRecords() {

        //get the content-authors group
        if ($group = Group::get()->filter('Code','content-authors')->first()) {

            //expected permission record content
            $arrPermissionData = array(
                'Arg'       => 0,
                'Type'      => 1,
                'Code'      => 'EDIT_SITECONFIG',
                'GroupID'   => $group->ID
            );

            //if the permission is not found, then create it
            if (!Permission::get()->filter($arrPermissionData)->first())
                Permission::create($arrPermissionData)->write();
        }
    }

}

As ever to register the extension add this to your config.yml...

Group:
  extensions:
    - GroupExtension

Upvotes: 1

Related Questions