Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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