Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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