Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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