Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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