Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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