Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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