Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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