|
@@ 1712-1732 (lines=21) @@
|
| 1709 |
|
* @return HTTPResponse |
| 1710 |
|
* @throws HTTPResponse_Exception |
| 1711 |
|
*/ |
| 1712 |
|
public function delete($data, $form) |
| 1713 |
|
{ |
| 1714 |
|
$id = $data['ID']; |
| 1715 |
|
$record = SiteTree::get()->byID($id); |
| 1716 |
|
if ($record && !$record->canDelete()) { |
| 1717 |
|
return Security::permissionFailure(); |
| 1718 |
|
} |
| 1719 |
|
if (!$record || !$record->ID) { |
| 1720 |
|
throw new HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1721 |
|
} |
| 1722 |
|
|
| 1723 |
|
// Delete record |
| 1724 |
|
$record->delete(); |
| 1725 |
|
|
| 1726 |
|
$this->getResponse()->addHeader( |
| 1727 |
|
'X-Status', |
| 1728 |
|
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT', "Removed '%s' from the draft site"), $record->Title)) |
| 1729 |
|
); |
| 1730 |
|
|
| 1731 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1732 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1733 |
|
} |
| 1734 |
|
|
| 1735 |
|
/** |
|
@@ 1743-1764 (lines=22) @@
|
| 1740 |
|
* @return HTTPResponse |
| 1741 |
|
* @throws HTTPResponse_Exception |
| 1742 |
|
*/ |
| 1743 |
|
public function archive($data, $form) |
| 1744 |
|
{ |
| 1745 |
|
$id = $data['ID']; |
| 1746 |
|
/** @var SiteTree $record */ |
| 1747 |
|
$record = SiteTree::get()->byID($id); |
| 1748 |
|
if (!$record || !$record->exists()) { |
| 1749 |
|
throw new HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1750 |
|
} |
| 1751 |
|
if (!$record->canArchive()) { |
| 1752 |
|
return Security::permissionFailure(); |
| 1753 |
|
} |
| 1754 |
|
|
| 1755 |
|
// Archive record |
| 1756 |
|
$record->doArchive(); |
| 1757 |
|
|
| 1758 |
|
$this->getResponse()->addHeader( |
| 1759 |
|
'X-Status', |
| 1760 |
|
rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE', "Archived page '%s'"), $record->Title)) |
| 1761 |
|
); |
| 1762 |
|
|
| 1763 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1764 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1765 |
|
} |
| 1766 |
|
|
| 1767 |
|
public function publish($data, $form) |