|
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 00033 class get_db_directories extends XMLDBAction { 00034 00038 function init() { 00039 parent::init(); 00040 // Set own core attributes 00041 $this->can_subaction = ACTION_NONE; 00042 //$this->can_subaction = ACTION_HAVE_SUBACTIONS; 00043 00044 // Set own custom attributes 00045 $this->sesskey_protected = false; // This action doesn't need sesskey protection 00046 00047 // Get needed strings 00048 $this->loadStrings(array( 00049 // 'key' => 'module', 00050 )); 00051 } 00052 00058 function invoke() { 00059 parent::invoke(); 00060 00061 $result = true; 00062 00063 // Set own core attributes 00064 $this->does_generate = ACTION_NONE; 00065 //$this->does_generate = ACTION_GENERATE_HTML; 00066 00067 // These are always here 00068 global $CFG, $XMLDB; 00069 00070 // Do the job, setting $result as needed 00071 00072 // Lets go to add all the db directories available inside Moodle 00073 // Create the array if it doesn't exists 00074 if (!isset($XMLDB->dbdirs)) { 00075 $XMLDB->dbdirs = array(); 00076 } 00077 00078 // get list of all dirs and create objects with status 00079 $db_directories = get_db_directories(); 00080 foreach ($db_directories as $path) { 00081 $dbdir = new stdClass; 00082 $dbdir->path = $path; 00083 if (!isset($XMLDB->dbdirs[$dbdir->path])) { 00084 $XMLDB->dbdirs[$dbdir->path] = $dbdir; 00085 } 00086 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status 00087 } 00088 00089 // Sort by key 00090 ksort($XMLDB->dbdirs); 00091 00092 // Return ok if arrived here 00093 return true; 00094 } 00095 } 00096