Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1761-1781 (lines=21) @@
1758
	 * @return HTMLText
1759
	 * @throws SS_HTTPResponse_Exception
1760
	 */
1761
	public function restoresnapshot(SS_HTTPRequest $request) {
1762
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1763
1764
		/** @var DNDataArchive $dataArchive */
1765
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1766
1767
		if(!$dataArchive) {
1768
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1769
		}
1770
1771
		// We check for canDownload because that implies access to the data.
1772
		// canRestore is later checked on the actual restore action per environment.
1773
		if(!$dataArchive->canDownload()) {
1774
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1775
		}
1776
1777
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1778
1779
		// View currently only available via ajax
1780
		return $form->forTemplate();
1781
	}
1782
1783
	/**
1784
	 * View a form to delete a specific {@link DataArchive}.
@@ 1793-1811 (lines=19) @@
1790
	 * @return HTMLText
1791
	 * @throws SS_HTTPResponse_Exception
1792
	 */
1793
	public function deletesnapshot(SS_HTTPRequest $request) {
1794
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1795
1796
		/** @var DNDataArchive $dataArchive */
1797
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1798
1799
		if(!$dataArchive) {
1800
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1801
		}
1802
1803
		if(!$dataArchive->canDelete()) {
1804
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1805
		}
1806
1807
		$form = $this->getDeleteForm($this->request, $dataArchive);
1808
1809
		// View currently only available via ajax
1810
		return $form->forTemplate();
1811
	}
1812
1813
	/**
1814
	 * @param SS_HTTPRequest $request
@@ 1895-1914 (lines=20) @@
1892
	 * @return HTMLText
1893
	 * @throws SS_HTTPResponse_Exception
1894
	 */
1895
	public function movesnapshot(SS_HTTPRequest $request) {
1896
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1897
1898
		/** @var DNDataArchive $dataArchive */
1899
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1900
1901
		if(!$dataArchive) {
1902
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1903
		}
1904
1905
		// We check for canDownload because that implies access to the data.
1906
		if(!$dataArchive->canDownload()) {
1907
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1908
		}
1909
1910
		$form = $this->getMoveForm($this->request, $dataArchive);
1911
1912
		// View currently only available via ajax
1913
		return $form->forTemplate();
1914
	}
1915
1916
	/**
1917
	 * Build snapshot move form.