Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/tool/xmldb/actions/load_xml_files/load_xml_files.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 load_xml_files extends XMLDBAction {
00033 
00037     function init() {
00038         parent::init();
00039         // Set own core attributes
00040         $this->can_subaction = ACTION_NONE;
00041         //$this->can_subaction = ACTION_HAVE_SUBACTIONS;
00042 
00043         // Set own custom attributes
00044 
00045         // Get needed strings
00046         $this->loadStrings(array(
00047             // 'key' => 'module',
00048         ));
00049     }
00050 
00056     function invoke() {
00057         parent::invoke();
00058 
00059         $result = true;
00060 
00061         // Set own core attributes
00062         $this->does_generate = ACTION_NONE;
00063         //$this->does_generate = ACTION_GENERATE_HTML;
00064 
00065         // These are always here
00066         global $CFG, $XMLDB;
00067 
00068         // Do the job, setting $result as needed
00069 
00070         // Iterate over $XMLDB->dbdirs, loading their XML data to memory
00071         if ($XMLDB->dbdirs) {
00072             $dbdirs =& $XMLDB->dbdirs;
00073             foreach ($dbdirs as $dbdir) {
00074                 // Set some defaults
00075                 $dbdir->xml_exists = false;
00076                 $dbdir->xml_writeable = false;
00077                 $dbdir->xml_loaded  = false;
00078                 // Only if the directory exists
00079                 if (!$dbdir->path_exists) {
00080                     continue;
00081                 }
00082                 $xmldb_file = new xmldb_file($dbdir->path . '/install.xml');
00083                 // Set dbdir as necessary
00084                 if ($xmldb_file->fileExists()) {
00085                     $dbdir->xml_exists = true;
00086                 }
00087                 if ($xmldb_file->fileWriteable()) {
00088                     $dbdir->xml_writeable = true;
00089                 }
00090                 // Load the XML contents to structure
00091                 $loaded = $xmldb_file->loadXMLStructure();
00092                 if ($loaded && $xmldb_file->isLoaded()) {
00093                     $dbdir->xml_loaded = true;
00094                 }
00095                 $dbdir->xml_file = $xmldb_file;
00096             }
00097         }
00098         return $result;
00099     }
00100 }
00101 
 All Data Structures Namespaces Files Functions Variables Enumerations