Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1840-1860 (lines=21) @@
1837
	 * @return HTMLText
1838
	 * @throws SS_HTTPResponse_Exception
1839
	 */
1840
	public function restoresnapshot(SS_HTTPRequest $request) {
1841
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1842
1843
		/** @var DNDataArchive $dataArchive */
1844
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1845
1846
		if(!$dataArchive) {
1847
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1848
		}
1849
1850
		// We check for canDownload because that implies access to the data.
1851
		// canRestore is later checked on the actual restore action per environment.
1852
		if(!$dataArchive->canDownload()) {
1853
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1854
		}
1855
1856
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1857
1858
		// View currently only available via ajax
1859
		return $form->forTemplate();
1860
	}
1861
1862
	/**
1863
	 * View a form to delete a specific {@link DataArchive}.
@@ 1872-1890 (lines=19) @@
1869
	 * @return HTMLText
1870
	 * @throws SS_HTTPResponse_Exception
1871
	 */
1872
	public function deletesnapshot(SS_HTTPRequest $request) {
1873
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1874
1875
		/** @var DNDataArchive $dataArchive */
1876
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1877
1878
		if(!$dataArchive) {
1879
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1880
		}
1881
1882
		if(!$dataArchive->canDelete()) {
1883
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1884
		}
1885
1886
		$form = $this->getDeleteForm($this->request, $dataArchive);
1887
1888
		// View currently only available via ajax
1889
		return $form->forTemplate();
1890
	}
1891
1892
	/**
1893
	 * @param SS_HTTPRequest $request
@@ 1974-1993 (lines=20) @@
1971
	 * @return HTMLText
1972
	 * @throws SS_HTTPResponse_Exception
1973
	 */
1974
	public function movesnapshot(SS_HTTPRequest $request) {
1975
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1976
1977
		/** @var DNDataArchive $dataArchive */
1978
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1979
1980
		if(!$dataArchive) {
1981
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1982
		}
1983
1984
		// We check for canDownload because that implies access to the data.
1985
		if(!$dataArchive->canDownload()) {
1986
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1987
		}
1988
1989
		$form = $this->getMoveForm($this->request, $dataArchive);
1990
1991
		// View currently only available via ajax
1992
		return $form->forTemplate();
1993
	}
1994
1995
	/**
1996
	 * Build snapshot move form.