Permalink
Browse files

Merge pull request #6 from lingo/master

PermssionFailure instead of 404
  • Loading branch information...
2 parents 46ba67e + cf2830d commit 001726d90b8889107207b5768ff2bfc3ecc7e6c6 Aram Balakjian committed Feb 25, 2012
Showing with 35 additions and 22 deletions.
  1. +17 −11 code/DataObjects/DataObjectAsPage.php
  2. +18 −11 code/Pages/DataObjectAsPageHolder.php
View
28 code/DataObjects/DataObjectAsPage.php
@@ -96,18 +96,24 @@ public function getCMSActions()
$Actions = parent::getCMSActions();
- //Create the Save & Publish action
- $PublishAction = FormAction::create('doPublish', 'Save & Publish');
- $PublishAction->describe("Publish this item");
- $Actions->insertFirst($PublishAction);
-
- //Create the Duplicate action
- $DuplicateAction = FormAction::create('duplicate', 'Duplicate Object');
- $DuplicateAction->describe("Duplicate this item");
- //add it to the existing actions
- $Actions->insertFirst($DuplicateAction);
+ if ($this->canPublish())
+ {
+ //Create the Save & Publish action
+ $PublishAction = FormAction::create('doPublish', 'Save & Publish');
+ $PublishAction->describe("Publish this item");
+ $Actions->insertFirst($PublishAction);
+ }
+
+ if ($this->canCreate())
+ {
+ //Create the Duplicate action
+ $DuplicateAction = FormAction::create('duplicate', 'Duplicate Object');
+ $DuplicateAction->describe("Duplicate this item");
+ //add it to the existing actions
+ $Actions->insertFirst($DuplicateAction);
+ }
- if($this->Status != 'Draft')
+ if($this->Status != 'Draft' && $this->canUnPublish())
{
//Create the Unpublish action
$unPublishAction = FormAction::create('doUnpublish', 'Unpublish');
View
29 code/Pages/DataObjectAsPageHolder.php
@@ -191,17 +191,24 @@ public function getCurrentItem($itemID = null)
*/
function show()
{
- if(($item = $this->getCurrentItem()) && $this->getCurrentItem()->canView())
- {
- $data = array(
- 'Item' => $item,
- 'Breadcrumbs' => $this->ItemBreadcrumbs($item),
- 'MetaTitle' => $item->MetaTitle,
- 'MetaTags' => $this->ItemMetaTags($item),
- 'BackLink' => base64_decode($this->request->getVar('backlink'))
- );
-
- return $this->Customise(new ArrayData($data));
+ if(($item = $this->getCurrentItem()))
+ {
+ if ($this->getCurrentItem()->canView())
+ {
+ $data = array(
+ 'Item' => $item,
+ 'Breadcrumbs' => $this->ItemBreadcrumbs($item),
+ 'MetaTitle' => $item->MetaTitle,
+ 'MetaTags' => $this->ItemMetaTags($item),
+ 'BackLink' => base64_decode($this->request->getVar('backlink'))
+ );
+
+ return $this->customise(new ArrayData($data));
+ }
+ else
+ {
+ return Security::permissionFailure($this);
+ }
}
else
{

0 comments on commit 001726d

Please sign in to comment.