Code Duplication    Length = 21-22 lines in 2 locations

code/controllers/CMSMain.php 2 locations

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