Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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