|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00031 class template extends XMLDBAction { 00032 00036 function init() { 00037 parent::init(); 00038 00039 // Set own custom attributes 00040 00041 // Get needed strings 00042 $this->loadStrings(array( 00043 // 'key' => 'module', 00044 )); 00045 } 00046 00052 function invoke() { 00053 parent::invoke(); 00054 00055 $result = true; 00056 00057 // Set own core attributes 00058 $this->does_generate = ACTION_NONE; 00059 //$this->does_generate = ACTION_GENERATE_HTML; 00060 00061 // These are always here 00062 global $CFG, $XMLDB; 00063 00064 // Do the job, setting result as needed 00065 // Get the dir containing the file 00066 $dirpath = required_param('dir', PARAM_PATH); 00067 $dirpath = $CFG->dirroot . $dirpath; 00068 00069 // Get the correct dirs 00070 if (!empty($XMLDB->dbdirs)) { 00071 $dbdir =& $XMLDB->dbdirs[$dirpath]; 00072 } else { 00073 return false; 00074 } 00075 if (!empty($XMLDB->editeddirs)) { 00076 $editeddir =& $XMLDB->editeddirs[$dirpath]; 00077 $structure =& $editeddir->xml_file->getStructure(); 00078 } 00079 00080 // ADD YOUR CODE HERE 00081 00082 // Launch postaction if exists (leave this here!) 00083 if ($this->getPostAction() && $result) { 00084 return $this->launch($this->getPostAction()); 00085 } 00086 00087 // Return ok if arrived here 00088 return $result; 00089 } 00090 } 00091