Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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