|
@@ 1153-1173 (lines=21) @@
|
| 1150 |
|
* @return SS_HTTPResponse |
| 1151 |
|
* @throws SS_HTTPResponse_Exception |
| 1152 |
|
*/ |
| 1153 |
|
public function delete($data, $form) { |
| 1154 |
|
$id = $data['ID']; |
| 1155 |
|
$record = SiteTree::get()->byID($id); |
| 1156 |
|
if($record && !$record->canDelete()) { |
| 1157 |
|
return Security::permissionFailure(); |
| 1158 |
|
} |
| 1159 |
|
if(!$record || !$record->ID) { |
| 1160 |
|
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1161 |
|
} |
| 1162 |
|
|
| 1163 |
|
// Delete record |
| 1164 |
|
$record->delete(); |
| 1165 |
|
|
| 1166 |
|
$this->getResponse()->addHeader( |
| 1167 |
|
'X-Status', |
| 1168 |
|
rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title)) |
| 1169 |
|
); |
| 1170 |
|
|
| 1171 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1172 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1173 |
|
} |
| 1174 |
|
|
| 1175 |
|
/** |
| 1176 |
|
* Delete this page from both live and stage |
|
@@ 1183-1204 (lines=22) @@
|
| 1180 |
|
* @return SS_HTTPResponse |
| 1181 |
|
* @throws SS_HTTPResponse_Exception |
| 1182 |
|
*/ |
| 1183 |
|
public function archive($data, $form) { |
| 1184 |
|
$id = $data['ID']; |
| 1185 |
|
/** @var SiteTree $record */ |
| 1186 |
|
$record = SiteTree::get()->byID($id); |
| 1187 |
|
if(!$record || !$record->exists()) { |
| 1188 |
|
throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404); |
| 1189 |
|
} |
| 1190 |
|
if(!$record->canArchive()) { |
| 1191 |
|
return Security::permissionFailure(); |
| 1192 |
|
} |
| 1193 |
|
|
| 1194 |
|
// Archive record |
| 1195 |
|
$record->doArchive(); |
| 1196 |
|
|
| 1197 |
|
$this->getResponse()->addHeader( |
| 1198 |
|
'X-Status', |
| 1199 |
|
rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title)) |
| 1200 |
|
); |
| 1201 |
|
|
| 1202 |
|
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode" |
| 1203 |
|
return $this->getResponseNegotiator()->respond($this->getRequest()); |
| 1204 |
|
} |
| 1205 |
|
|
| 1206 |
|
public function publish($data, $form) { |
| 1207 |
|
$data['publish'] = '1'; |