@@ 1225-1245 (lines=21) @@ | ||
1222 | * @return HTTPResponse |
|
1223 | * @throws HTTPResponse_Exception |
|
1224 | */ |
|
1225 | public function delete($data, $form) { |
|
1226 | $id = $data['ID']; |
|
1227 | $record = SiteTree::get()->byID($id); |
|
1228 | if($record && !$record->canDelete()) { |
|
1229 | return Security::permissionFailure(); |
|
1230 | } |
|
1231 | if(!$record || !$record->ID) { |
|
1232 | throw new HTTPResponse_Exception("Bad record ID #$id", 404); |
|
1233 | } |
|
1234 | ||
1235 | // Delete record |
|
1236 | $record->delete(); |
|
1237 | ||
1238 | $this->getResponse()->addHeader( |
|
1239 | 'X-Status', |
|
1240 | rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title)) |
|
1241 | ); |
|
1242 | ||
1243 | // Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
|
1244 | return $this->getResponseNegotiator()->respond($this->getRequest()); |
|
1245 | } |
|
1246 | ||
1247 | /** |
|
1248 | * Delete this page from both live and stage |
|
@@ 1255-1276 (lines=22) @@ | ||
1252 | * @return HTTPResponse |
|
1253 | * @throws HTTPResponse_Exception |
|
1254 | */ |
|
1255 | public function archive($data, $form) { |
|
1256 | $id = $data['ID']; |
|
1257 | /** @var SiteTree $record */ |
|
1258 | $record = SiteTree::get()->byID($id); |
|
1259 | if(!$record || !$record->exists()) { |
|
1260 | throw new HTTPResponse_Exception("Bad record ID #$id", 404); |
|
1261 | } |
|
1262 | if(!$record->canArchive()) { |
|
1263 | return Security::permissionFailure(); |
|
1264 | } |
|
1265 | ||
1266 | // Archive record |
|
1267 | $record->doArchive(); |
|
1268 | ||
1269 | $this->getResponse()->addHeader( |
|
1270 | 'X-Status', |
|
1271 | rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title)) |
|
1272 | ); |
|
1273 | ||
1274 | // Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
|
1275 | return $this->getResponseNegotiator()->respond($this->getRequest()); |
|
1276 | } |
|
1277 | ||
1278 | public function publish($data, $form) { |
|
1279 | $data['publish'] = '1'; |