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