Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

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