|
@@ 1088-1108 (lines=21) @@
|
| 1085 |
|
* @return SS_HTTPResponse |
| 1086 |
|
* @throws SS_HTTPResponse_Exception |
| 1087 |
|
*/ |
| 1088 |
|
public function delete($data, $form) { |
| 1089 |
|
$id = $data['ID']; |
| 1090 |
|
$record = DataObject::get_by_id("SiteTree", $id); |
| 1091 |
|
if($record && !$record->canDelete()) { |
| 1092 |
|
return Security::permissionFailure(); |
| 1093 |
|
} |
| 1094 |
|
if(!$record || !$record->ID) { |
| 1095 |
|
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1096 |
|
} |
| 1097 |
|
|
| 1098 |
|
// Delete record |
| 1099 |
|
$record->delete(); |
| 1100 |
|
|
| 1101 |
|
$this->getResponse()->addHeader( |
| 1102 |
|
'X-Status', |
| 1103 |
|
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title)) |
| 1104 |
|
); |
| 1105 |
|
|
| 1106 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1107 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1108 |
|
} |
| 1109 |
|
|
| 1110 |
|
/** |
| 1111 |
|
* Delete this page from both live and stage |
|
@@ 1118-1139 (lines=22) @@
|
| 1115 |
|
* @return SS_HTTPResponse |
| 1116 |
|
* @throws SS_HTTPResponse_Exception |
| 1117 |
|
*/ |
| 1118 |
|
public function archive($data, $form) { |
| 1119 |
|
$id = $data['ID']; |
| 1120 |
|
/** @var SiteTree $record */ |
| 1121 |
|
$record = DataObject::get_by_id("SiteTree", $id); |
| 1122 |
|
if(!$record || !$record->exists()) { |
| 1123 |
|
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1124 |
|
} |
| 1125 |
|
if(!$record->canArchive()) { |
| 1126 |
|
return Security::permissionFailure(); |
| 1127 |
|
} |
| 1128 |
|
|
| 1129 |
|
// Archive record |
| 1130 |
|
$record->doArchive(); |
| 1131 |
|
|
| 1132 |
|
$this->getResponse()->addHeader( |
| 1133 |
|
'X-Status', |
| 1134 |
|
rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title)) |
| 1135 |
|
); |
| 1136 |
|
|
| 1137 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1138 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1139 |
|
} |
| 1140 |
|
|
| 1141 |
|
public function publish($data, $form) { |
| 1142 |
|
$data['publish'] = '1'; |