Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/xmldb/actions/unload_xml_file/unload_xml_file.class.php
Go to the documentation of this file.
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 
00032 class unload_xml_file extends XMLDBAction {
00033 
00037     function init() {
00038         parent::init();
00039 
00040         // Set own custom attributes
00041         $this->sesskey_protected = false; // This action doesn't need sesskey protection
00042 
00043         // Get needed strings
00044         $this->loadStrings(array(
00045             // 'key' => 'module',
00046         ));
00047     }
00048 
00054     function invoke() {
00055         parent::invoke();
00056 
00057         $result = true;
00058 
00059         // Set own core attributes
00060         $this->does_generate = ACTION_NONE;
00061 
00062         // These are always here
00063         global $CFG, $XMLDB;
00064 
00065         // Do the job, setting result as needed
00066 
00067         // Get the dir containing the file
00068         $dirpath = required_param('dir', PARAM_PATH);
00069         $dirpath = $CFG->dirroot . $dirpath;
00070 
00071         // Get the original dir and delete some elements
00072         if (!empty($XMLDB->dbdirs)) {
00073             if (isset($XMLDB->dbdirs[$dirpath])) {
00074                 $dbdir =& $XMLDB->dbdirs[$dirpath];
00075                 if ($dbdir) {
00076                     unset($dbdir->xml_file);
00077                     unset($dbdir->xml_loaded);
00078                     unset($dbdir->xml_changed);
00079                     unset($dbdir->xml_exists);
00080                     unset($dbdir->xml_writeable);
00081                 }
00082             }
00083         }
00084         // Get the edited dir and delete it completely
00085         if (!empty($XMLDB->editeddirs)) {
00086             if (isset($XMLDB->editeddirs[$dirpath])) {
00087                 unset($XMLDB->editeddirs[$dirpath]);
00088             }
00089         }
00090 
00091         // Launch postaction if exists (leave this here!)
00092         if ($this->getPostAction() && $result) {
00093             return $this->launch($this->getPostAction());
00094         }
00095 
00096         // Return ok if arrived here
00097         return $result;
00098     }
00099 }
00100 
 All Data Structures Namespaces Files Functions Variables Enumerations