Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1740-1760 (lines=21) @@
1737
	 * @return HTMLText
1738
	 * @throws SS_HTTPResponse_Exception
1739
	 */
1740
	public function restoresnapshot(SS_HTTPRequest $request) {
1741
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1742
1743
		/** @var DNDataArchive $dataArchive */
1744
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1745
1746
		if(!$dataArchive) {
1747
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1748
		}
1749
1750
		// We check for canDownload because that implies access to the data.
1751
		// canRestore is later checked on the actual restore action per environment.
1752
		if(!$dataArchive->canDownload()) {
1753
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1754
		}
1755
1756
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1757
1758
		// View currently only available via ajax
1759
		return $form->forTemplate();
1760
	}
1761
1762
	/**
1763
	 * View a form to delete a specific {@link DataArchive}.
@@ 1772-1790 (lines=19) @@
1769
	 * @return HTMLText
1770
	 * @throws SS_HTTPResponse_Exception
1771
	 */
1772
	public function deletesnapshot(SS_HTTPRequest $request) {
1773
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1774
1775
		/** @var DNDataArchive $dataArchive */
1776
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1777
1778
		if(!$dataArchive) {
1779
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1780
		}
1781
1782
		if(!$dataArchive->canDelete()) {
1783
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1784
		}
1785
1786
		$form = $this->getDeleteForm($this->request, $dataArchive);
1787
1788
		// View currently only available via ajax
1789
		return $form->forTemplate();
1790
	}
1791
1792
	/**
1793
	 * @param SS_HTTPRequest $request
@@ 1874-1893 (lines=20) @@
1871
	 * @return HTMLText
1872
	 * @throws SS_HTTPResponse_Exception
1873
	 */
1874
	public function movesnapshot(SS_HTTPRequest $request) {
1875
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1876
1877
		/** @var DNDataArchive $dataArchive */
1878
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1879
1880
		if(!$dataArchive) {
1881
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1882
		}
1883
1884
		// We check for canDownload because that implies access to the data.
1885
		if(!$dataArchive->canDownload()) {
1886
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1887
		}
1888
1889
		$form = $this->getMoveForm($this->request, $dataArchive);
1890
1891
		// View currently only available via ajax
1892
		return $form->forTemplate();
1893
	}
1894
1895
	/**
1896
	 * Build snapshot move form.