Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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