Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1701-1721 (lines=21) @@
1698
	 * @return HTMLText
1699
	 * @throws SS_HTTPResponse_Exception
1700
	 */
1701
	public function restoresnapshot(SS_HTTPRequest $request) {
1702
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1703
1704
		/** @var DNDataArchive $dataArchive */
1705
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1706
1707
		if(!$dataArchive) {
1708
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1709
		}
1710
1711
		// We check for canDownload because that implies access to the data.
1712
		// canRestore is later checked on the actual restore action per environment.
1713
		if(!$dataArchive->canDownload()) {
1714
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1715
		}
1716
1717
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1718
1719
		// View currently only available via ajax
1720
		return $form->forTemplate();
1721
	}
1722
1723
	/**
1724
	 * View a form to delete a specific {@link DataArchive}.
@@ 1733-1751 (lines=19) @@
1730
	 * @return HTMLText
1731
	 * @throws SS_HTTPResponse_Exception
1732
	 */
1733
	public function deletesnapshot(SS_HTTPRequest $request) {
1734
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1735
1736
		/** @var DNDataArchive $dataArchive */
1737
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1738
1739
		if(!$dataArchive) {
1740
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1741
		}
1742
1743
		if(!$dataArchive->canDelete()) {
1744
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1745
		}
1746
1747
		$form = $this->getDeleteForm($this->request, $dataArchive);
1748
1749
		// View currently only available via ajax
1750
		return $form->forTemplate();
1751
	}
1752
1753
	/**
1754
	 * @param SS_HTTPRequest $request
@@ 1835-1854 (lines=20) @@
1832
	 * @return HTMLText
1833
	 * @throws SS_HTTPResponse_Exception
1834
	 */
1835
	public function movesnapshot(SS_HTTPRequest $request) {
1836
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1837
1838
		/** @var DNDataArchive $dataArchive */
1839
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1840
1841
		if(!$dataArchive) {
1842
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1843
		}
1844
1845
		// We check for canDownload because that implies access to the data.
1846
		if(!$dataArchive->canDownload()) {
1847
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1848
		}
1849
1850
		$form = $this->getMoveForm($this->request, $dataArchive);
1851
1852
		// View currently only available via ajax
1853
		return $form->forTemplate();
1854
	}
1855
1856
	/**
1857
	 * Build snapshot move form.