Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1633-1653 (lines=21) @@
1630
	 * @return HTMLText
1631
	 * @throws SS_HTTPResponse_Exception
1632
	 */
1633
	public function restoresnapshot(SS_HTTPRequest $request) {
1634
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1635
1636
		/** @var DNDataArchive $dataArchive */
1637
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1638
1639
		if(!$dataArchive) {
1640
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1641
		}
1642
1643
		// We check for canDownload because that implies access to the data.
1644
		// canRestore is later checked on the actual restore action per environment.
1645
		if(!$dataArchive->canDownload()) {
1646
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1647
		}
1648
1649
		$form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1650
1651
		// View currently only available via ajax
1652
		return $form->forTemplate();
1653
	}
1654
1655
	/**
1656
	 * View a form to delete a specific {@link DataArchive}.
@@ 1665-1683 (lines=19) @@
1662
	 * @return HTMLText
1663
	 * @throws SS_HTTPResponse_Exception
1664
	 */
1665
	public function deletesnapshot(SS_HTTPRequest $request) {
1666
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1667
1668
		/** @var DNDataArchive $dataArchive */
1669
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1670
1671
		if(!$dataArchive) {
1672
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1673
		}
1674
1675
		if(!$dataArchive->canDelete()) {
1676
			throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1677
		}
1678
1679
		$form = $this->getDeleteForm($this->request, $dataArchive);
1680
1681
		// View currently only available via ajax
1682
		return $form->forTemplate();
1683
	}
1684
1685
	/**
1686
	 * @param SS_HTTPRequest $request
@@ 1767-1786 (lines=20) @@
1764
	 * @return HTMLText
1765
	 * @throws SS_HTTPResponse_Exception
1766
	 */
1767
	public function movesnapshot(SS_HTTPRequest $request) {
1768
		$this->setCurrentActionType(self::ACTION_SNAPSHOT);
1769
1770
		/** @var DNDataArchive $dataArchive */
1771
		$dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1772
1773
		if(!$dataArchive) {
1774
			throw new SS_HTTPResponse_Exception('Archive not found', 404);
1775
		}
1776
1777
		// We check for canDownload because that implies access to the data.
1778
		if(!$dataArchive->canDownload()) {
1779
			throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1780
		}
1781
1782
		$form = $this->getMoveForm($this->request, $dataArchive);
1783
1784
		// View currently only available via ajax
1785
		return $form->forTemplate();
1786
	}
1787
1788
	/**
1789
	 * Build snapshot move form.