Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / xmldb / actions / get_db_directories / get_db_directories.class.php
blob83b64a92dcb7248710f38960ddc751d2f560fe84
1 <?php // $Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
11 // (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
12 // //
13 // This program is free software; you can redistribute it and/or modify //
14 // it under the terms of the GNU General Public License as published by //
15 // the Free Software Foundation; either version 2 of the License, or //
16 // (at your option) any later version. //
17 // //
18 // This program is distributed in the hope that it will be useful, //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21 // GNU General Public License for more details: //
22 // //
23 // http://www.gnu.org/copyleft/gpl.html //
24 // //
25 ///////////////////////////////////////////////////////////////////////////
27 /// This class will check all the db directories existing under the
28 /// current Moodle installation, sending them to the SESSION->dbdirs array
30 class get_db_directories extends XMLDBAction {
32 /**
33 * Init method, every subclass will have its own
35 function init() {
36 parent::init();
37 /// Set own core attributes
38 $this->can_subaction = ACTION_NONE;
39 //$this->can_subaction = ACTION_HAVE_SUBACTIONS;
41 /// Set own custom attributes
43 /// Get needed strings
44 $this->loadStrings(array(
45 /// 'key' => 'module',
46 ));
49 /**
50 * Invoke method, every class will have its own
51 * returns true/false on completion, setting both
52 * errormsg and output as necessary
54 function invoke() {
55 parent::invoke();
57 $result = true;
59 /// Set own core attributes
60 $this->does_generate = ACTION_NONE;
61 //$this->does_generate = ACTION_GENERATE_HTML;
63 /// These are always here
64 global $CFG, $XMLDB;
66 /// Do the job, setting $result as needed
68 /// Lets go to add all the db directories available inside Moodle
69 /// Create the array if it doesn't exists
70 if (!isset($XMLDB->dbdirs)) {
71 $XMLDB->dbdirs = array();
73 /// First, the main one (lib/db)
74 $dbdir = new stdClass;
75 $dbdir->path = $CFG->libdir . '/db';
76 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
77 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
79 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
81 /// Now, activity modules (mod/xxx/db)
82 if ($plugins = get_list_of_plugins('mod')) {
83 foreach ($plugins as $plugin) {
84 $dbdir = new stdClass;
85 $dbdir->path = $CFG->dirroot . '/mod/' . $plugin . '/db';
86 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
87 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
89 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
93 /// Now, question types (question/type/xxx/db)
94 if ($plugins = get_list_of_plugins('question/type')) {
95 foreach ($plugins as $plugin) {
96 $dbdir = new stdClass;
97 $dbdir->path = $CFG->dirroot . '/question/type/' . $plugin . '/db';
98 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
99 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
101 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
105 /// Now, backup/restore stuff (backup/db)
106 $dbdir = new stdClass;
107 $dbdir->path = $CFG->dirroot . '/backup/db';
108 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
109 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
111 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
113 /// Now, block system stuff (blocks/db)
114 $dbdir = new stdClass;
115 $dbdir->path = $CFG->dirroot . '/blocks/db';
116 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
117 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
119 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
121 /// Now, blocks (blocks/xxx/db)
122 if ($plugins = get_list_of_plugins('blocks', 'db')) {
123 foreach ($plugins as $plugin) {
124 $dbdir = new stdClass;
125 $dbdir->path = $CFG->dirroot . '/blocks/' . $plugin . '/db';
126 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
127 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
129 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
133 /// Now, enrolment plugins (enrol/xxx/db)
134 if ($plugins = get_list_of_plugins('enrol', 'db')) {
135 foreach ($plugins as $plugin) {
136 $dbdir = new stdClass;
137 $dbdir->path = $CFG->dirroot . '/enrol/' . $plugin . '/db';
138 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
139 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
141 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
145 /// Now, groups
146 $dbdir = new stdClass;
147 $dbdir->path = $CFG->dirroot . '/group/db';
148 if (!isset($XMLDB->dbdirs[$dbdir->path])) {
149 $XMLDB->dbdirs[$dbdir->path] = $dbdir;
151 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path); //Update status
153 /// Sort by key
154 ksort($XMLDB->dbdirs);
156 /// Return ok if arrived here
157 return true;