Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1748-1768 (lines=21) @@
1745
	 * @return HTMLText
1746
	 * @throws SS_HTTPResponse_Exception
1747
	 */
1748
	public function restoresnapshot(\SS_HTTPRequest $request) {
1749
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1750
1751
		/** @var DNDataArchive $dataArchive */
1752
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1753
1754
		if (!$dataArchive) {
1755
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1756
		}
1757
1758
		// We check for canDownload because that implies access to the data.
1759
		// canRestore is later checked on the actual restore action per environment.
1760
		if (!$dataArchive->canDownload()) {
1761
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1762
		}
1763
1764
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1765
1766
		// View currently only available via ajax
1767
		return $form->forTemplate();
1768
	}
1769
1770
	/**
1771
	 * View a form to delete a specific {@link DataArchive}.
@@ 1780-1798 (lines=19) @@
1777
	 * @return HTMLText
1778
	 * @throws SS_HTTPResponse_Exception
1779
	 */
1780
	public function deletesnapshot(\SS_HTTPRequest $request) {
1781
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1782
1783
		/** @var DNDataArchive $dataArchive */
1784
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1785
1786
		if (!$dataArchive) {
1787
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1788
		}
1789
1790
		if (!$dataArchive->canDelete()) {
1791
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1792
		}
1793
1794
		$form = $this->getDeleteForm($this->request, $dataArchive);
1795
1796
		// View currently only available via ajax
1797
		return $form->forTemplate();
1798
	}
1799
1800
	/**
1801
	 * @param \SS_HTTPRequest $request
@@ 1882-1901 (lines=20) @@
1879
	 * @return HTMLText
1880
	 * @throws SS_HTTPResponse_Exception
1881
	 */
1882
	public function movesnapshot(\SS_HTTPRequest $request) {
1883
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1884
1885
		/** @var DNDataArchive $dataArchive */
1886
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1887
1888
		if (!$dataArchive) {
1889
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1890
		}
1891
1892
		// We check for canDownload because that implies access to the data.
1893
		if (!$dataArchive->canDownload()) {
1894
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1895
		}
1896
1897
		$form = $this->getMoveForm($this->request, $dataArchive);
1898
1899
		// View currently only available via ajax
1900
		return $form->forTemplate();
1901
	}
1902
1903
	/**
1904
	 * Build snapshot move form.