Code Duplication    Length = 21-22 lines in 2 locations

code/controllers/CMSMain.php 2 locations

@@ 1055-1075 (lines=21) @@
1052
	 * @return SS_HTTPResponse
1053
	 * @throws SS_HTTPResponse_Exception
1054
	 */
1055
	public function delete($data, $form) {
1056
		$id = $data['ID'];
1057
		$record = DataObject::get_by_id("SiteTree", $id);
1058
		if($record && !$record->canDelete()) {
1059
			return Security::permissionFailure();
1060
		}
1061
		if(!$record || !$record->ID) {
1062
			throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
1063
		}
1064
1065
		// Delete record
1066
		$record->delete();
1067
1068
		$this->getResponse()->addHeader(
1069
			'X-Status',
1070
			rawurlencode(sprintf(_t('CMSMain.REMOVEDPAGEFROMDRAFT',"Removed '%s' from the draft site"), $record->Title))
1071
		);
1072
1073
		// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1074
		return $this->getResponseNegotiator()->respond($this->getRequest());
1075
	}
1076
1077
	/**
1078
	 * Delete this page from both live and stage
@@ 1085-1106 (lines=22) @@
1082
	 * @return SS_HTTPResponse
1083
	 * @throws SS_HTTPResponse_Exception
1084
	 */
1085
	public function archive($data, $form) {
1086
		$id = $data['ID'];
1087
		/** @var SiteTree $record */
1088
		$record = DataObject::get_by_id("SiteTree", $id);
1089
		if(!$record || !$record->exists()) {
1090
			throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404);
1091
		}
1092
		if(!$record->canArchive()) {
1093
			return Security::permissionFailure();
1094
		}
1095
1096
		// Archive record
1097
		$record->doArchive();
1098
1099
		$this->getResponse()->addHeader(
1100
			'X-Status',
1101
			rawurlencode(sprintf(_t('CMSMain.ARCHIVEDPAGE',"Archived page '%s'"), $record->Title))
1102
		);
1103
1104
		// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
1105
		return $this->getResponseNegotiator()->respond($this->getRequest());
1106
	}
1107
1108
	public function publish($data, $form) {
1109
		$data['publish'] = '1';