I have created second roles for groups with names "Support" and "Redactor".
My controller have second $aloweed_actions = ("SelectByMonth,"mineForm");
1) Support group members must have acces only to action with name "SelectByMonth".
2) Redactor group members must have acces to both actions in controller ("SelectByMonth" and "mineForm").
How to realize it?
Some code from my project:
Class for Database model (mysite/code/mineDataObject.php):
<?php
class mineDataObject extends DataObject{
private static $db = array(
'Name' => 'Varchar(256)',
'Street' => 'Varchar(56)',
'Telephone' => 'Varchar(11)'
);
}
?>
Controller class (mysite/code/mineController.php):
<?php
class mine extends Page{}
class mine_Controller extends Page_Controller{
private static $allowed_actions = array('mineForm');
public function mineForm(){
$fields = new FieldList(
new TextField('Name', 'Name'),
new TextField('Street', 'Street'),
new PhoneNumberField('Telephone', 'Telephone')
);
$actions = new FieldList(
new FormAction('doAdd','Submit')
);
$validator = new RequiredFields('Name', 'Street', 'Telephone');
return new Form($this, 'mineForm', $fields, $actions, $validator);
}
public function doAdd($data, $form) {
$submission = new mineDataObject();
$form->saveInto($submission);
$submission->write();
return $this->redirectBack();
}
}
?>