diff --git a/code/BlogEntry.php b/code/BlogEntry.php index 6d1c2a3..6889862 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -1,12 +1,9 @@ ID); + function unpublishPost() { + if(!Permission::check('ADMIN')) { + Security::permissionFailure( + $this, + 'Unpublishing blogs is an administrator task. Please log in.' + ); + } else { + $SQL_id = (int) $this->ID; - $page = DataObject::get_by_id("SiteTree", $SQL_id); + $page = DataObject::get_by_id('SiteTree', $SQL_id); $page->deleteFromStage('Live'); $page->flushCache(); - $page = DataObject::get_by_id("SiteTree", $SQL_id); - $page->Status = "Unpublished"; + $page = DataObject::get_by_id('SiteTree', $SQL_id); + $page->Status = 'Unpublished'; Director::redirect($this->getParent()->Link()); } } } - -?> +?> \ No newline at end of file