Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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