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:
Normann Lou 2009-01-14 04:24:28 +00:00 committed by Sam Minnee
parent 93b01711d9
commit ec6282c808

View File

@ -674,6 +674,7 @@ class ModelAdmin_CollectionController extends Controller {
*/
public function AddForm() {
$newRecord = new $this->modelClass();
if($newRecord->canCreate()){
if($newRecord->hasMethod('getCMSAddFormFields')) {
$fields = $newRecord->getCMSAddFormFields();
} else {
@ -690,6 +691,7 @@ class ModelAdmin_CollectionController extends Controller {
return $form;
}
}
function doCreate($data, $form, $request) {
$className = $this->getModelClass();
@ -771,7 +773,11 @@ class ModelAdmin_RecordController extends Controller {
$validator = ($this->currentRecord->hasMethod('getCMSValidator')) ? $this->currentRecord->getCMSValidator() : null;
$actions = $this->currentRecord->getCMSActions();
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')));