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