Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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