Code Duplication    Length = 19-21 lines in 3 locations

code/control/DNRoot.php 3 locations

@@ 1824-1844 (lines=21) @@
1821
     * @return HTMLText
1822
     * @throws SS_HTTPResponse_Exception
1823
     */
1824
    public function restoresnapshot(SS_HTTPRequest $request)
1825
    {
1826
        $this->setCurrentActionType(self::ACTION_SNAPSHOT);
1827
1828
        /** @var DNDataArchive $dataArchive */
1829
        $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1830
1831
        if (!$dataArchive) {
1832
            throw new SS_HTTPResponse_Exception('Archive not found', 404);
1833
        }
1834
1835
        // We check for canDownload because that implies access to the data.
1836
        // canRestore is later checked on the actual restore action per environment.
1837
        if (!$dataArchive->canDownload()) {
1838
            throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1839
        }
1840
1841
        $form = $this->getDataTransferRestoreForm($this->request, $dataArchive);
1842
1843
        // View currently only available via ajax
1844
        return $form->forTemplate();
1845
    }
1846
1847
    /**
@@ 1857-1875 (lines=19) @@
1854
     * @return HTMLText
1855
     * @throws SS_HTTPResponse_Exception
1856
     */
1857
    public function deletesnapshot(SS_HTTPRequest $request)
1858
    {
1859
        $this->setCurrentActionType(self::ACTION_SNAPSHOT);
1860
1861
        /** @var DNDataArchive $dataArchive */
1862
        $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1863
1864
        if (!$dataArchive) {
1865
            throw new SS_HTTPResponse_Exception('Archive not found', 404);
1866
        }
1867
1868
        if (!$dataArchive->canDelete()) {
1869
            throw new SS_HTTPResponse_Exception('Not allowed to delete archive', 403);
1870
        }
1871
1872
        $form = $this->getDeleteForm($this->request, $dataArchive);
1873
1874
        // View currently only available via ajax
1875
        return $form->forTemplate();
1876
    }
1877
1878
    /**
@@ 1962-1981 (lines=20) @@
1959
     * @return HTMLText
1960
     * @throws SS_HTTPResponse_Exception
1961
     */
1962
    public function movesnapshot(SS_HTTPRequest $request)
1963
    {
1964
        $this->setCurrentActionType(self::ACTION_SNAPSHOT);
1965
1966
        /** @var DNDataArchive $dataArchive */
1967
        $dataArchive = DNDataArchive::get()->byId($request->param('DataArchiveID'));
1968
1969
        if (!$dataArchive) {
1970
            throw new SS_HTTPResponse_Exception('Archive not found', 404);
1971
        }
1972
1973
        // We check for canDownload because that implies access to the data.
1974
        if (!$dataArchive->canDownload()) {
1975
            throw new SS_HTTPResponse_Exception('Not allowed to access archive', 403);
1976
        }
1977
1978
        $form = $this->getMoveForm($this->request, $dataArchive);
1979
1980
        // View currently only available via ajax
1981
        return $form->forTemplate();
1982
    }
1983
1984
    /**