Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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