Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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