Skip to content

Commit

Permalink
MINOR Making canEdit() method optional on objects handled by LeftAndM…
Browse files Browse the repository at this point in the history
…ain subclasses
  • Loading branch information
chillu committed Apr 23, 2011
1 parent 5bd43af commit 3c54434
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions admin/code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public function Content() {

public function getRecord($id) {
$className = $this->stat('tree_class');
if($id instanceof $className) {
if($className && $id instanceof $className) {
return $id;
} else if(is_numeric($id)) {
return DataObject::get_by_id($className, $id);
Expand Down Expand Up @@ -764,7 +764,7 @@ public function getEditForm($id = null, $fields = null) {
$actions = $record->getCMSActions();
// add default actions if none are defined
if(!$actions || !$actions->Count()) {
if($record->canEdit()) {
if($record->hasMethod('canEdit') && $record->canEdit()) {
$actions->push(new FormAction('save',_t('CMSMain.SAVE','Save')));
}
}
Expand Down Expand Up @@ -794,7 +794,7 @@ public function getEditForm($id = null, $fields = null) {
$form->unsetValidator();
}

if(!$record->canEdit()) {
if($record->hasMethod('canEdit') && !$record->canEdit()) {
$readonlyFields = $form->Fields()->makeReadonly();
$form->setFields($readonlyFields);
}
Expand Down

0 comments on commit 3c54434

Please sign in to comment.