Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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