Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1780-1800 (lines=21) @@
1777
	 * @return HTMLText
1778
	 * @throws SS_HTTPResponse_Exception
1779
	 */
1780
	public function restoresnapshot(SS_HTTPRequest $request) {
1781
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1782
1783
		/** @var DNDataArchive $dataArchive */
1784
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1785
1786
		if(!$dataArchive) {
1787
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1788
		}
1789
1790
		// We check for canDownload because that implies access to the data.
1791
		// canRestore is later checked on the actual restore action per environment.
1792
		if(!$dataArchive->canDownload()) {
1793
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1794
		}
1795
1796
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1797
1798
		// View currently only available via ajax
1799
		return $form->forTemplate();
1800
	}
1801
1802
	/**
1803
	 * View a form to delete a specific {@link DataArchive}.
@@ 1812-1830 (lines=19) @@
1809
	 * @return HTMLText
1810
	 * @throws SS_HTTPResponse_Exception
1811
	 */
1812
	public function deletesnapshot(SS_HTTPRequest $request) {
1813
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1814
1815
		/** @var DNDataArchive $dataArchive */
1816
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1817
1818
		if(!$dataArchive) {
1819
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1820
		}
1821
1822
		if(!$dataArchive->canDelete()) {
1823
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1824
		}
1825
1826
		$form = $this->getDeleteForm($this->request, $dataArchive);
1827
1828
		// View currently only available via ajax
1829
		return $form->forTemplate();
1830
	}
1831
1832
	/**
1833
	 * @param SS_HTTPRequest $request
@@ 1914-1933 (lines=20) @@
1911
	 * @return HTMLText
1912
	 * @throws SS_HTTPResponse_Exception
1913
	 */
1914
	public function movesnapshot(SS_HTTPRequest $request) {
1915
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1916
1917
		/** @var DNDataArchive $dataArchive */
1918
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1919
1920
		if(!$dataArchive) {
1921
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1922
		}
1923
1924
		// We check for canDownload because that implies access to the data.
1925
		if(!$dataArchive->canDownload()) {
1926
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1927
		}
1928
1929
		$form = $this->getMoveForm($this->request, $dataArchive);
1930
1931
		// View currently only available via ajax
1932
		return $form->forTemplate();
1933
	}
1934
1935
	/**
1936
	 * Build snapshot move form.