titledk/silverstripe-defaultgroups

Programmatically define default groups

dev-master 2017-03-31 13:40 UTC

This package is not auto-updated.

Last update: 2024-11-21 00:57:02 UTC


README

Programmatically define default groups

Can be added to a member extension like this:

class MemberExtension extends DataExtension {
  
  const APP_ADMIN_GROUP_CODE = 'app-admins';
  const APP_USER_GROUP_CODE = 'app-users';

	public function requireDefaultRecords() {
		parent::requireDefaultRecords();

		DefaultGroupsHelper::default_group(
			MemberExtension::APP_USER_GROUP_CODE, //group code
			_t('MemberExtension.AppUsers','App Users'), //group name
			null, //parent code
			null //permissions
		);
		DefaultGroupsHelper::default_group(
			MemberExtension::APP_ADMIN_GROUP_CODE, //group code
			_t('MemberExtension.AppAdministrators','App Administrators'), //group name
			MemberExtension::APP_USER_GROUP_CODE, // parent code
			//permissions:
			array(
				'APP_ACCESS_ADMIN'
			)
		);		

	}
}