source: moodle/trunk/fuentes/admin/tool/xmldb/actions/template/template.class.php @ 136

Last change on this file since 136 was 136, checked in by mabarracus, 4 years ago

Ported code to xenial

File size: 2.6 KB
Line 
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * @package    tool_xmldb
19 * @copyright  2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
20 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21 */
22
23/**
24 * @package    tool_xmldb
25 * @copyright  2003 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
26 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 */
28
29class template extends XMLDBAction {
30
31    /**
32     * Init method, every subclass will have its own
33     */
34    function init() {
35        parent::init();
36
37        // Set own custom attributes
38
39        // Get needed strings
40        $this->loadStrings(array(
41            // 'key' => 'module',
42        ));
43    }
44
45    /**
46     * Invoke method, every class will have its own
47     * returns true/false on completion, setting both
48     * errormsg and output as necessary
49     */
50    function invoke() {
51        parent::invoke();
52
53        $result = true;
54
55        // Set own core attributes
56        $this->does_generate = ACTION_NONE;
57        //$this->does_generate = ACTION_GENERATE_HTML;
58
59        // These are always here
60        global $CFG, $XMLDB;
61
62        // Do the job, setting result as needed
63        // Get the dir containing the file
64        $dirpath = required_param('dir', PARAM_PATH);
65        $dirpath = $CFG->dirroot . $dirpath;
66
67        // Get the correct dirs
68        if (!empty($XMLDB->dbdirs)) {
69            $dbdir = $XMLDB->dbdirs[$dirpath];
70        } else {
71            return false;
72        }
73        if (!empty($XMLDB->editeddirs)) {
74            $editeddir = $XMLDB->editeddirs[$dirpath];
75            $structure = $editeddir->xml_file->getStructure();
76        }
77
78        // ADD YOUR CODE HERE
79
80        // Launch postaction if exists (leave this here!)
81        if ($this->getPostAction() && $result) {
82            return $this->launch($this->getPostAction());
83        }
84
85        // Return ok if arrived here
86        return $result;
87    }
88}
89
Note: See TracBrowser for help on using the repository browser.