Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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