mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FEATURE: add permission control for AddForm and EditForm
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@70142 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
93b01711d9
commit
ec6282c808
@ -674,21 +674,23 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
*/
|
||||
public function AddForm() {
|
||||
$newRecord = new $this->modelClass();
|
||||
if($newRecord->hasMethod('getCMSAddFormFields')) {
|
||||
$fields = $newRecord->getCMSAddFormFields();
|
||||
} else {
|
||||
$fields = $newRecord->getCMSFields();
|
||||
}
|
||||
if($newRecord->canCreate()){
|
||||
if($newRecord->hasMethod('getCMSAddFormFields')) {
|
||||
$fields = $newRecord->getCMSAddFormFields();
|
||||
} else {
|
||||
$fields = $newRecord->getCMSFields();
|
||||
}
|
||||
|
||||
$validator = ($newRecord->hasMethod('getCMSValidator')) ? $newRecord->getCMSValidator() : null;
|
||||
$validator = ($newRecord->hasMethod('getCMSValidator')) ? $newRecord->getCMSValidator() : null;
|
||||
|
||||
$actions = new FieldSet(
|
||||
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
|
||||
);
|
||||
$actions = new FieldSet(
|
||||
new FormAction("doCreate", _t('ModelAdmin.ADDBUTTON', "Add"))
|
||||
);
|
||||
|
||||
$form = new Form($this, "AddForm", $fields, $actions, $validator);
|
||||
$form = new Form($this, "AddForm", $fields, $actions, $validator);
|
||||
|
||||
return $form;
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
function doCreate($data, $form, $request) {
|
||||
@ -771,7 +773,11 @@ class ModelAdmin_RecordController extends Controller {
|
||||
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
|
||||
|
||||
$actions = $this->currentRecord->getCMSActions();
|
||||
$actions->push(new FormAction("doSave", _t('ModelAdmin.SAVE', "Save")));
|
||||
if($this->currentRecord->canEdit(Member::currentUser())){
|
||||
$actions->push(new FormAction("doSave", _t('ModelAdmin.SAVE', "Save")));
|
||||
}else{
|
||||
$fields = $fields->makeReadonly();
|
||||
}
|
||||
|
||||
if($this->currentRecord->canDelete(Member::currentUser())) {
|
||||
$actions->insertFirst($deleteAction = new FormAction('doDelete', _t('ModelAdmin.DELETE', 'Delete')));
|
||||
|
Loading…
Reference in New Issue
Block a user