]> git.mjollnir.org Git - moodle.git/commitdiff
major whitespace cleanup - fixed trailng whitespace in new files and admin area
authorskodak <skodak>
Wed, 20 Sep 2006 21:00:45 +0000 (21:00 +0000)
committerskodak <skodak>
Wed, 20 Sep 2006 21:00:45 +0000 (21:00 +0000)
154 files changed:
admin/auth.php
admin/backup.php
admin/block.php
admin/blocks.php
admin/delete.php
admin/enrol.php
admin/enrol_config.php
admin/filter.php
admin/health.php
admin/index.php
admin/module.php
admin/modules.php
admin/questiontypes.php
admin/report/courseoverview/index.php
admin/report/courseoverview/reportsgraph.php
admin/report/log/index.php
admin/report/simpletest/ex_reporter.php
admin/report/simpletest/ex_simple_test.php
admin/report/simpletest/index.php
admin/report/stats/index.php
admin/roles/allowassign.php
admin/roles/allowoverride.php
admin/roles/assign.html
admin/roles/assign.php
admin/roles/manage.html
admin/roles/manage.php
admin/roles/managetabs.php
admin/roles/override.html
admin/roles/override.php
admin/roles/tabs.php
admin/settings.php
admin/settings/appearance.php
admin/settings/security.php
admin/settings/server.php
admin/settings/users.php
admin/upgradesettings.php
admin/xmldb/README.txt
admin/xmldb/actions/XMLDBAction.class.php
admin/xmldb/actions/create_xml_file/create_xml_file.class.php
admin/xmldb/actions/delete_field/delete_field.class.php
admin/xmldb/actions/delete_index/delete_index.class.php
admin/xmldb/actions/delete_key/delete_key.class.php
admin/xmldb/actions/delete_sentence/delete_sentence.class.php
admin/xmldb/actions/delete_statement/delete_statement.class.php
admin/xmldb/actions/delete_table/delete_table.class.php
admin/xmldb/actions/delete_xml_file/delete_xml_file.class.php
admin/xmldb/actions/edit_field/edit_field.class.php
admin/xmldb/actions/edit_field/edit_field.js
admin/xmldb/actions/edit_field_save/edit_field_save.class.php
admin/xmldb/actions/edit_index/edit_index.class.php
admin/xmldb/actions/edit_index_save/edit_index_save.class.php
admin/xmldb/actions/edit_key/edit_key.class.php
admin/xmldb/actions/edit_key/edit_key.js
admin/xmldb/actions/edit_key_save/edit_key_save.class.php
admin/xmldb/actions/edit_sentence/edit_sentence.class.php
admin/xmldb/actions/edit_sentence_save/edit_sentence_save.class.php
admin/xmldb/actions/edit_statement/edit_statement.class.php
admin/xmldb/actions/edit_statement_save/edit_statement_save.class.php
admin/xmldb/actions/edit_table/edit_table.class.php
admin/xmldb/actions/edit_table_save/edit_table_save.class.php
admin/xmldb/actions/edit_xml_file/edit_xml_file.class.php
admin/xmldb/actions/edit_xml_file_save/edit_xml_file_save.class.php
admin/xmldb/actions/get_db_directories/get_db_directories.class.php
admin/xmldb/actions/load_xml_file/load_xml_file.class.php
admin/xmldb/actions/load_xml_files/load_xml_files.class.php
admin/xmldb/actions/main_view/main_view.class.php
admin/xmldb/actions/move_updown_field/move_updown_field.class.php
admin/xmldb/actions/move_updown_index/move_updown_index.class.php
admin/xmldb/actions/move_updown_key/move_updown_key.class.php
admin/xmldb/actions/move_updown_statement/move_updown_statement.class.php
admin/xmldb/actions/move_updown_table/move_updown_table.class.php
admin/xmldb/actions/new_field/new_field.class.php
admin/xmldb/actions/new_index/new_index.class.php
admin/xmldb/actions/new_key/new_key.class.php
admin/xmldb/actions/new_sentence/new_sentence.class.php
admin/xmldb/actions/new_statement/new_statement.class.php
admin/xmldb/actions/new_table/new_table.class.php
admin/xmldb/actions/new_table_from_mysql/new_table_from_mysql.class.php
admin/xmldb/actions/revert_changes/revert_changes.class.php
admin/xmldb/actions/save_xml_file/save_xml_file.class.php
admin/xmldb/actions/template/template.class.php
admin/xmldb/actions/test/test.class.php
admin/xmldb/actions/unload_xml_file/unload_xml_file.class.php
admin/xmldb/actions/view_field_xml/view_field_xml.class.php
admin/xmldb/actions/view_index_xml/view_index_xml.class.php
admin/xmldb/actions/view_key_xml/view_key_xml.class.php
admin/xmldb/actions/view_reserved_words/view_reserved_words.class.php
admin/xmldb/actions/view_statement_xml/view_statement_xml.class.php
admin/xmldb/actions/view_structure_php/view_structure_php.class.php
admin/xmldb/actions/view_structure_sql/view_structure_sql.class.php
admin/xmldb/actions/view_structure_xml/view_structure_xml.class.php
admin/xmldb/actions/view_table_php/view_table_php.class.php
admin/xmldb/actions/view_table_php/view_table_php.js
admin/xmldb/actions/view_table_sql/view_table_sql.class.php
admin/xmldb/actions/view_table_xml/view_table_xml.class.php
admin/xmldb/actions/view_xml/view_xml.class.php
admin/xmldb/index.php
blocks/rss_client/db/access.php
lib/accesslib.php
lib/adminlib.php
lib/db/access.php
lib/ddllib.php
lib/dmllib.php
lib/xmldb/classes/XMLDBConstants.php
lib/xmldb/classes/XMLDBField.class.php
lib/xmldb/classes/XMLDBFile.class.php
lib/xmldb/classes/XMLDBIndex.class.php
lib/xmldb/classes/XMLDBKey.class.php
lib/xmldb/classes/XMLDBObject.class.php
lib/xmldb/classes/XMLDBStatement.class.php
lib/xmldb/classes/XMLDBStructure.class.php
lib/xmldb/classes/XMLDBTable.class.php
lib/xmldb/classes/generators/XMLDBGenerator.class.php
lib/xmldb/classes/generators/mssql/mssql.class.php
lib/xmldb/classes/generators/mysql/mysql.class.php
lib/xmldb/classes/generators/oci8po/oci8po.class.php
lib/xmldb/classes/generators/postgres7/postgres7.class.php
lib/xmldb/xmldb.xsd
mod/assignment/db/access.php
mod/chat/db/access.php
mod/choice/db/access.php
mod/data/db/access.php
mod/exercise/db/access.php
mod/forum/db/access.php
mod/glossary/db/access.php
mod/hotpot/db/access.php
mod/lams/db/access.php
mod/lesson/db/access.php
mod/quiz/db/access.php
mod/resource/db/access.php
mod/scorm/db/access.php
mod/survey/db/access.php
mod/wiki/db/access.php
mod/workshop/db/access.php
search/README.txt
search/add.php
search/cron.php
search/db/postgres7.sql
search/delete.php
search/documents/document.php
search/documents/forum_document.php
search/documents/glossary_document.php
search/documents/resource_document.php
search/documents/wiki_document.php
search/index.php
search/indexer.php
search/indexersplash.php
search/indexlib.php
search/lib.php
search/query.php
search/querylib.php
search/stats.php
search/tests/index.php
search/update.php

index 42a757323b28768f5603f47ae287a4c23c4bffa2..9f5ab727c20e4bf2c213a4aa39369bae075c54bb 100644 (file)
@@ -26,7 +26,7 @@
         // extract and sanitize the auth key explicitly
         $modules = get_list_of_plugins("auth");
         if (in_array($config['auth'], $modules)) {
-            $auth = $config['auth'];            
+            $auth = $config['auth'];
         } else {
             notify("Error defining the authentication method");
         }
                 if (preg_match('/^pluginconfig_(.+?)$/', $name, $matches)) {
                     $plugin = "auth/$auth";
                     $name   = $matches[1];
-                    if (! set_config($name, $value, $plugin)) {                        
+                    if (! set_config($name, $value, $plugin)) {
                         notify("Problem saving config $name as $value for plugin $plugin");
                     }
-                } else { // normal handling for 
+                } else { // normal handling for
                     if (! set_config($name, $value)) {
                         notify("Problem saving config $name as $value");
                     }
     echo "<form target=\"{$CFG->framename}\" name=\"authmenu\" method=\"post\" action=\"auth.php\">";
     echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\" />";
     print_string("chooseauthmethod","auth");
-    
+
     echo '&nbsp;&nbsp;';
 
     choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
 
     require_once("$CFG->dirroot/auth/$auth/config.html");
     $CFG->pagepath = 'auth/' . $auth;
-    
+
     echo '<tr><td colspan="3">';
     print_heading(get_string('auth_common_settings', 'auth'));
     echo '<td/></tr>';
 // Good enough for most auth plugins
 // but some may want a custom one if they are offering
 // other options
-// Note: pluginconfig_ fields have special handling. 
+// Note: pluginconfig_ fields have special handling.
 function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts, $updateopts) {
 
     echo '<tr><td colspan="3">';
@@ -259,9 +259,9 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
                                 'onlogin'   => get_string('update_onlogin', 'auth'));
     $updateextoptions = array('0'  => get_string('update_never', 'auth'),
                               '1'   => get_string('update_onupdate', 'auth'));
-    
+
     $pluginconfig = get_config("auth/$auth");
-    
+
     // helptext is on a field with rowspan
     if (empty($helptext)) {
                 $helptext = '&nbsp;';
@@ -275,7 +275,7 @@ function print_auth_lock_options ($auth, $user_fields, $helptext, $retrieveopts,
         }
         if(empty($pluginconfig->{"field_updatelocal_$field"})) {
             $pluginconfig->{"field_updatelocal_$field"} = '';
-        }  
+        }
         if (empty($pluginconfig->{"field_updateremote_$field"})) {
             $pluginconfig->{"field_updateremote_$field"} = '';
         }
index defb1c194b1106fa69de99c163eac6ce044a0763..8be76bc139dc10c7d509d704cf48fc845ddeb2e7 100644 (file)
@@ -23,7 +23,7 @@
 
         //First of all we check that everything is correct
         //Check for trailing slash and backslash in backup_sche_destination
-        if (!empty($backup_sche_destination) and 
+        if (!empty($backup_sche_destination) and
             (substr($backup_sche_destination,-1) == "/" or substr($backup_sche_destination,-1) == "\\")) {
             $error = true;
             $sche_destination_error = get_string("pathslasherror");
@@ -43,7 +43,7 @@
             if (isset($a_config[$tocheck])) {
                 $temp .= "1";
             } else {
-                $temp .= "0"; 
+                $temp .= "0";
             }
             unset($a_config[$tocheck]);
             $i++;
@@ -76,7 +76,7 @@
                 foreach ($courses as $course) {
                     //We check if the course exists in backup_course
                     $backup_course = get_record("backup_courses","courseid",$course->id);
-                    //If it doesn't exist, create 
+                    //If it doesn't exist, create
                     if (!$backup_course) {
                         $temp_backup_course->courseid = $course->id;
                         $newid = insert_record("backup_courses",$temp_backup_course);
     //Check for required functions...
     if (!function_exists('utf8_encode')) {
         notify("You need to add XML support to your PHP installation");
-    } 
+    }
     include ("$CFG->dirroot/backup/config.html");
 
     print_simple_box_end();
index 783317824094286740e9018e90869c5497589b69..2cfe566a8f36d9a13092ea9e8de612ca083308e5 100644 (file)
@@ -9,7 +9,7 @@
     require_once($CFG->libdir.'/blocklib.php');
 
     $blockid = required_param('block', PARAM_INT);
-   
+
     if(($blockrecord = blocks_get_record($blockid)) === false) {
         error('This block does not exist');
     }
     $strconfiguration = get_string('configuration');
     $strmanageblocks = get_string('manageblocks');
     $strblockname = $block->get_title();
-    
+
     // $CFG->pagepath is used to generate the body and id attributes for the body tag
     // of the page. It is also used to generate the link to the Moodle Docs for this view.
     $CFG->pagepath = 'block/' . $block->name() . '/config';
-    
+
 
     admin_externalpage_print_header($adminroot);
 
index 15991b343baa2aeff410484877775d56dcc951eb..6d374648096ff0cea5652f5a288958b651dc4748 100644 (file)
         print_heading(get_string('incompatibleblocks', 'admin'));
 
         $table = new flexible_table('admin-blocks-incompatible');
-        
+
         $table->define_columns(array('block', 'delete'));
         $table->define_headers(array($strname, $strdelete));
         $table->define_baseurl($CFG->wwwroot.'/'.$CFG->admin.'/blocks.php');
-    
+
         $table->set_attribute('cellspacing', '0');
         $table->set_attribute('id', 'incompatible');
         $table->set_attribute('class', 'generaltable generalbox');
-    
+
         $table->setup();
 
         foreach ($incompatible as $block) {
index ea524fd08554fa10d7f8299070564b6508384a34..b16f3ecb7f48c904a2b6d6e6efc83b8137ea69a2 100644 (file)
@@ -64,5 +64,5 @@ function delete_subdirectories($rootdir) {
     }
     closedir($dir);
 }
-  
+
 ?>
index 9e1da25dcaebbe842cc853a54a7dd19097de4945..387aaffd5636a74556c6f2e4f8378f16e3c807f5 100644 (file)
@@ -7,7 +7,7 @@
 
     $enrol = optional_param('enrol', $CFG->enrol, PARAM_SAFEDIR);
     $CFG->pagepath = 'enrol';
-    
+
     $adminroot = admin_get_root();
     admin_externalpage_setup('enrolment', $adminroot);
 
@@ -20,7 +20,7 @@
     if ($frm = data_submitted()) {
         if (!confirm_sesskey()) {
             error(get_string('confirmsesskeybad', 'error'));
-        }    
+        }
         if (empty($frm->enable)) {
             $frm->enable = array();
         }
index aafd31a66df5e41c8b20192c9bf6f59698495fc9..6d131527b5618ca36844109b3235bb5ee52a0127 100644 (file)
@@ -4,7 +4,7 @@
 
     require_once("../config.php");
     require_once($CFG->libdir.'/adminlib.php');
-    
+
     $adminroot = admin_get_root();
     admin_externalpage_setup('enrolment', $adminroot);
 
@@ -21,7 +21,7 @@
     if ($frm = data_submitted()) {
         if (!confirm_sesskey()) {
             error(get_string('confirmsesskeybad', 'error'));
-        }    
+        }
         if ($enrolment->process_config($frm)) {
             redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
         }
@@ -55,8 +55,8 @@
                       "document.location='enrol_config.php?enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
 
     echo "</b></p></div>";
-    
-/// Print current enrolment type description    
+
+/// Print current enrolment type description
     print_simple_box_start("center", "80%");
     print_heading($options[$enrol]);
 
@@ -65,7 +65,7 @@
     print_simple_box_end();
 
     echo "<hr />";
-    
+
     $enrolment->config_form($frm);
 
     echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
index b132d7e9be71eb0dab9ca399cd1268efb478eb9e..00778be6ad9dbb9741d7c39dbf8658602836c645 100644 (file)
@@ -21,7 +21,7 @@
     // $CFG->pagepath is used to generate the body and id attributes for the body tag
     // of the page. It is also used to generate the link to the Moodle Docs for this view.
     $CFG->pagepath = 'filter/' . $filtername . '/config';
-    
+
     // get translated strings for use on page
     $txt = new Object;
     $txt->managefilters = get_string( 'managefilters' );
@@ -69,7 +69,7 @@
     //==============================
     // Display logic
     //==============================
-    
+
     $filtername = ucfirst($filtername);
     admin_externalpage_print_header($adminroot);
     print_heading( $filtername );
index 12843f9cfe2e33074da7a368c1716b729015fadb..920410fe020c2d5f6d2086e528b10695e014dae7 100644 (file)
@@ -419,7 +419,7 @@ class problem_000010 extends problem_base {
     }
     function exists() {
         if (!$this->is_enabled()) {
-            return true;   
+            return true;
         }
         if ($this->status() < 1) {
             return true;
@@ -429,7 +429,7 @@ class problem_000010 extends problem_base {
     function severity() {
         if ($this->is_enabled() and $this->status() == 0) {
             return SEVERITY_SIGNIFICANT;
-        } else { 
+        } else {
             return SEVERITY_ANNOYANCE;
         }
     }
@@ -437,9 +437,9 @@ class problem_000010 extends problem_base {
         global $CFG;
         $desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
         if (!$this->is_enabled()) {
-            $desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';   
+            $desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
         } else {
-            $desc .= '<li>slasharguments are enabled in Moodle configuration</li>';   
+            $desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
         }
         if ($this->status() == -1) {
             $desc .= '<li>can not run automatic test, you can verify it <a href="'.$CFG->wwwroot.'/file.php/testslasharguments" target="_blank">here</a> manually</li>';
@@ -470,9 +470,9 @@ class problem_000010 extends problem_base {
             $solution .= 'Congratulations - everything seems OK now :-D';
         }
         if ($status < 1) {
-            $solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>'; 
-            $solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>'; 
-            $solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>'; 
+            $solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
+            $solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
+            $solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
         }
         return $solution;
     }
index 6f9a39aaf90373de14ead227a9ecdffa1a20ee87..8a9ade6608270e9c3d16cd6cdfe5ef3dbd868829 100644 (file)
             blocks_execute_action($page, blocks_get_by_page($page), 'add', (int)$admintree->id, false, false);
             if ($admintreeinstance = get_record('block_instance', 'pagetype', $page->type, 'pageid', SITEID, 'blockid', $admintree->id)) {
                 blocks_execute_action($page, blocks_get_by_page($page), 'moveleft', $admintreeinstance, false, false);
-            } 
+            }
         }
 
         set_config('adminblocks_initialised', 1);
     }
 
 /// Check for any special upgrades that might need to be run
-    if (!empty($CFG->upgrade)) {  
+    if (!empty($CFG->upgrade)) {
         print_simple_box(get_string("upgrade$CFG->upgrade", "admin",
                                     "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"), "center", '60%');
         print_spacer(10,10);
     }
 
 /// Print slightly annoying registration button every six months   ;-)
-/// You can set the "registered" variable to something far in the future 
+/// You can set the "registered" variable to something far in the future
 /// if you really want to prevent this.   eg  9999999999
     if (!isset($CFG->registered) || $CFG->registered < (time() - 3600*24*30*6)) {
         $options = array();
         $table->cellpadding = 5;
         $table->cellspacing = 0;
         $table->width = '40%';
-    
+
         $configdata  = '<div class="adminlink"><a href="config.php">'.get_string('configvariables', 'admin').
             '</a> - <span class="explanation">'.get_string('adminhelpconfigvariables').'</span></div>';
         $configdata .= '<div class="adminlink"><a href="site.php">'.get_string('sitesettings').
             '</a> - <span class="explanation">'.get_string('helpcalendarsettings', 'admin').'</span></div>';
         $configdata .= '<div class="adminlink"><a href="maintenance.php">'.get_string('sitemaintenancemode', 'admin').
             '</a> - <span class="explanation">'.get_string('helpsitemaintenance', 'admin').'</span></div>';
-    
+
         $table->data[] = array('<strong>'.get_string('configuration').'</strong>', $configdata);
-    
+
         $userdata =  '<div class="adminlink"><a href="auth.php?sesskey='.$USER->sesskey.'">'.get_string("authentication").
             '</a> - <span class="explanation">'.get_string('adminhelpauthentication').'</span></div>';
         $userdata .= '<div class="adminlink"><a href="user.php">'.get_string('edituser').
         $userdata .= '<div class="adminlink"><a href="roles/assign.php?contextid='.$context->id.'">'.
             get_string('assignsiteroles').'</a> - <span class="explanation">'.get_string('adminhelpassignsiteroles').
             '</span></div>';
-    
+
         $table->data[] = array('<strong>'.get_string('users').'</strong>', $userdata);
-    
+
         $coursedata = '<div class="adminlink"><a href="../course/index.php?edit=on&amp;sesskey='.$USER->sesskey.'">'.get_string('managecourses').
             '</a> - <span class="explanation">'.get_string('adminhelpcourses').'</span></div>';
         $coursedata .= '<div class="adminlink"><a href="enrol.php?sesskey='.$USER->sesskey.'">'.get_string('enrolmentplugins').
             '</a> - <span class="explanation">'.get_string('adminhelpenrolments').'</span></div>';
-    
-    
+
+
         $table->data[] = array('<strong>'.get_string('courses').'</strong>', $coursedata);
-    
+
         $miscdata = '<div class="adminlink"><a href="../files/index.php?id='.$site->id.'">'.get_string('sitefiles').
             '</a> - <span class="explanation">'.get_string('adminhelpsitefiles').'</span></div>';
         $miscdata .= '<div class="adminlink"><a href="stickyblocks.php">'.get_string('stickyblocks','admin').
             $miscdata .= '<div class="adminlink"><a href="xmldb/index.php">'.get_string('xmldbeditor').
                 '</a> - <span class="explanation">'.get_string('adminhelpxmldbeditor').'</span></div>';
         }
-    
+
         $table->data[] = array('<strong>'.get_string('miscellaneous').'</strong>', $miscdata);
-    
-/*    
-        /// Hooks for Matt Oquists contrib code for repositories and portfolio.  
+
+/*
+        /// Hooks for Matt Oquists contrib code for repositories and portfolio.
         /// The eventual official versions may not look like this
         if (isset($CFG->portfolio) && file_exists("$CFG->dirroot/$CFG->portfolio")) {
             $table->data[] = array("<strong><a href=\"../portfolio/\">".get_string('portfolio','portfolio').'</a></
                     strong>',
                     '<div class="explanation">'.get_string('adminhelpportfolio','portfolio').'</div>');
         }
-    
+
         if (isset($CFG->repo) && file_exists("$CFG->dirroot/$CFG->repo")) {
             $table->data[] = array("<strong><a href=\"../repository/?repoid=1&action=list\">".get_string('repository','
                         repository').'</a></strong>',
                     '<div class="explanation">'.get_string('adminhelprepository','repository').'</div>');
         }
-*/   
-    
-    
+*/
+
+
         print_table($table);
-    
+
     }
 
     //////////////////////////////////////////////////////////////////////////////////////////////////
         echo '</div>';
     }
 
-    
+
     if (optional_param('dbmigrate')) {               // ??? Is this actually used?
         print_simple_box_start('center','60%');
         require_once($CFG->dirroot.'/admin/utfdbmigrate.php');
index 912cd44e77c7fbef34703bb23b1196767fc482ab..28d28423e49ace9dbe00923b1edac69d307bdc52 100644 (file)
     $strconfiguration = get_string("configuration");
     $strmanagemodules = get_string("managemodules");
     $strmodulename = get_string("modulename", $module);
-    
+
     // $CFG->pagepath is used to generate the body and id attributes for the body tag
     // of the page. It is also used to generate the link to the Moodle Docs for this view.
     $CFG->pagepath = 'mod/' . $module . '/config';
-    
+
     admin_externalpage_print_header($adminroot);
 
     print_heading($strmodulename);
index 0e90f09e74b811a30445d60900550bc816bf5c75..06816c056a075a6b45d98fbc5e8ff4204f25b3bf 100644 (file)
@@ -29,9 +29,9 @@
     admin_externalpage_print_header($adminroot);
 
     print_heading($stractivities);
-   
+
     $coursesaffected = false;
-    
+
 
 /// If data submitted, then process and store.
 
     }
 
     if (!empty($delete) and confirm_sesskey()) {
-      
+
         $strmodulename = get_string("modulename", "$delete");
 
         if (!$confirm) {
-            notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename), 
-                         "modules.php?delete=$delete&amp;confirm=1&amp;sesskey=$USER->sesskey", 
+            notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
+                         "modules.php?delete=$delete&amp;confirm=1&amp;sesskey=$USER->sesskey",
                          "modules.php");
             admin_externalpage_print_footer($adminroot);
             exit;
@@ -90,7 +90,7 @@
                 notify("Error occurred while deleting all $strmodulename records in course_modules table");
             }
 
-            // Then delete all the logs 
+            // Then delete all the logs
             if (!delete_records("log", "module", $module->name)) {
                 notify("Error occurred while deleting all $strmodulename records in log table");
             }
                         }
                     }
                 }
-            }  
+            }
             // Delete the capabilities that were defined by this module
             capabilities_cleanup('mod/'.$module->name);
-            
+
             // rebuild_course_cache();  // Because things have changed
             $coursesaffected = true;
 
             notice(get_string("moduledeletefiles", "", $a), "modules.php");
         }
     }
-    
+
     if ($coursesaffected) {
         rebuild_course_cache();  // Because things have changed
     }
-    
+
 
 /// Get and sort the existing modules
 
index 6387ed83eff2b2ab27922f998819beea0c6a403e..62bf3589f475c200803103550d35c545caa1d657 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP // $Id$
       // Allows the admin to manage questiontypes
       // This page is adapted from modules.php
-      
+
       // This page is not yet in service, the whole plug-in architecture
       // for question types is still under construction.
 
     $strquestions = get_string("questions");
     $strquestiontype = get_string("questiontype", 'quiz');
 
-    print_header("$site->shortname: $strquestions", "$site->fullname", 
+    print_header("$site->shortname: $strquestions", "$site->fullname",
                  "<a href=\"index.php\">$stradministration</a> -> ".
                  "<a href=\"configure.php\">$strconfiguration</a> -> $strquestions");
 
     print_heading($strquestions);
-   
+
 
 /// If data submitted, then process and store.
 
     }
 
     if (!empty($delete) and confirm_sesskey()) {
-      
+
         $strqtypename = get_string("qtypename", "qtype_$delete");
 
         if (!$confirm) {
-            notice_yesno(get_string("qtypedeleteconfirm", "admin", $strqtypename), 
-                         "questiontypes.php?delete=$delete&amp;confirm=1&amp;sesskey=$USER->sesskey", 
+            notice_yesno(get_string("qtypedeleteconfirm", "admin", $strqtypename),
+                         "questiontypes.php?delete=$delete&amp;confirm=1&amp;sesskey=$USER->sesskey",
                          "questiontypes.php");
             print_footer();
             exit;
                         }
                     }
                 }
-            }  
+            }
 
             $a->qtype = $strqtypename;
             $a->directory = "$CFG->dirroot/qtype/$delete";
         $count = count_records('quiz_questions', 'qtype', $qtype->id);
 
         $delete = $count ? '' : "<a href=\"questiontypes.php?delete=$qtype->name&amp;sesskey=$USER->sesskey\">$strdelete</a>";
-        
+
         if ($qtype->visible) {
             $visible = "<a href=\"questiontypes.php?hide=$qtype->name&amp;sesskey=$USER->sesskey\" title=\"$strhide\">".
                        "<img src=\"$CFG->pixpath/i/hide.gif\" align=\"middle\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" /></a>";
index c2980f776ee8e6e8abb1b2589ff6b44a886d5961..36b9cf45fda8c1342bd7d451549f443f7af98be4 100644 (file)
@@ -28,7 +28,7 @@
     $strcourseoverview = get_string('courseoverview');
 
     $strnav = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/index.php">'.get_string('administration').'</a> -> <a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/report.php">'.$strreports.'</a> -> '.$strcourseoverview;
-    
+
     $reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
 
     $tableprefix = $CFG->prefix.'stats_';
@@ -36,7 +36,7 @@
     $earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
     $earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
     $earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
-    
+
     if (empty($earliestday)) $earliestday = time();
     if (empty($earliestweek)) $earliestweek = time();
     if (empty($earliestmonth)) $earliestmonth = time();
 
     if (!empty($report) && !empty($time)) {
         $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
-        
+
         $sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
             ." WHERE timeend >= ".$param->timeafter
             ." GROUP BY courseid "
             .$param->extras
             ." ORDER BY ".$param->orderby
             ." LIMIT ".$numcourses;
-        
+
         $courses = get_records_sql($sql);
 
         if (empty($courses)) {
         }
 
         echo '<center><img src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></center>';
-        
+
         $table = new object();
         $table->align = array('left','center','center','center');
         $table->head = array(get_string('course'),$param->line1);
         if (!empty($param->line2)) {
-            $table->head[] = $param->line2; 
+            $table->head[] = $param->line2;
         }
         if (!empty($param->line3)) {
             $table->head[] = $param->line3;
         }
-        
+
         foreach  ($courses as $c) {
             $a = array();
             $a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
         }
         print_table($table);
     }
-    
+
     admin_externalpage_print_footer($adminroot);
 
 ?>
index ab3c77c115bd1388301c3d842c7932c2814f93b2..8c456d53fa6b45c03bf4718f57175e90daa26a42 100644 (file)
@@ -11,7 +11,7 @@
     require_login();
 
     require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID));
-    
+
     stats_check_uptodate($course->id);
 
     $param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
         .$param->extras
         ." ORDER BY ".$param->orderby
         ." LIMIT ".$numcourses;
-    
+
     $courses = get_records_sql($sql);
-    
+
     if (empty($courses)) {
         error(get_string('statsnodata'),$CFG->wwwroot.'/'.$CFG->admin.'/report/course/index.php');
     }
-    
+
 
     $graph = new graph(750,400);
 
@@ -48,5 +48,5 @@
     $graph->y_format['bar1'] = array('colour' => 'blue','bar' => 'fill','legend' => $param->{$param->graphline});
 
     $graph->draw_stack();
-    
+
 ?>
index 5683ebe2c5c3f800f115391958ea5f8665476262..b83c976fe191c85151720f909b2ac755447ae76d 100644 (file)
@@ -16,7 +16,7 @@
 
     print_heading(get_string('chooselogs') .':');
 
-    print_log_selector_form($course); 
+    print_log_selector_form($course);
 
     echo '<br />';
     print_heading(get_string('chooselivelogs') .':');
index 1003abaf72987c8d3b49cdaa6e40b2fcefa1bcb7..26092bb953a986ad254dac54410e43b462201544 100644 (file)
@@ -25,24 +25,24 @@ class ExHtmlReporter extends HtmlReporter {
 
     // Options set when the class is created.
     var $showpasses;
-    
+
     // Lang strings. Set in the constructor.
     var $strrunonlyfolder;
     var $strrunonlyfile;
-    
+
     var $strseparator;
-    
+
     /**
      * Constructor.
-     * 
+     *
      * @param bool $showpasses Whether this reporter should output anything for passes.
      */
     function ExHtmlReporter($showpasses) {
         global $CFG;
-        
+
         $this->HtmlReporter();
         $this->showpasses = $showpasses;
-        
+
         $this->strrunonlyfolder = $this->get_string('runonlyfolder');
         $this->strrunonlyfile = $this->get_string('runonlyfile');
         $this->strseparator = ' <img src="' . $CFG->pixpath . '/a/r_breadcrumb.gif" class="resize" alt="" /> ';
@@ -82,7 +82,7 @@ class ExHtmlReporter extends HtmlReporter {
      */
     function _paintPassFail($passorfail, $message) {
         global $FULLME, $CFG;
-        
+
         print_simple_box_start('', '100%', '', 5, $passorfail . ' generalbox');
         $url = $this->_htmlEntities($this->_stripParameterFromUrl($FULLME, 'path'));
         echo '<b class="', $passorfail, '">', $this->get_string($passorfail), '</b>: ';
@@ -102,7 +102,7 @@ class ExHtmlReporter extends HtmlReporter {
         print_simple_box_end();
         flush();
     }
-   
+
     /**
      * Called when a notice needs to be output.
      */
@@ -154,25 +154,25 @@ class ExHtmlReporter extends HtmlReporter {
         echo $this->get_string('summary', $summarydata);
         echo '</div>';
 
-        echo '<div class="performanceinfo">', 
+        echo '<div class="performanceinfo">',
                 $this->get_string('runat', date('<b>d-m-Y H:i T</b>')),
                 $this->get_string('version', SimpleTestOptions::getVersion()),
                 '</div>';
     }
-    
+
     /**
      * Strip a specified parameter from the query string of a URL, if present.
-     * Adds a separator to the end of the URL, so that a new parameter 
+     * Adds a separator to the end of the URL, so that a new parameter
      * can easily be appended. For example (assuming $param = 'frog'):
-     * 
+     *
      * http://example.com/index.php               -> http://example.com/index.php?
      * http://example.com/index.php?frog=1        -> http://example.com/index.php?
      * http://example.com/index.php?toad=1        -> http://example.com/index.php?toad=1&
      * http://example.com/index.php?frog=1&toad=1 -> http://example.com/index.php?toad=1&
-     * 
+     *
      * @param string $url the URL to modify.
      * @param string $param the parameter to strip from the URL, if present.
-     * 
+     *
      * @return string The modified URL.
      */
     function _stripParameterFromUrl($url, $param) {
index ac9259ad5335c2a594897e6f2c1407142a5c21d6..72b8d6197e0d396985371179f63aea2c18ae564f 100644 (file)
@@ -57,7 +57,7 @@ class AutoGroupTest extends GroupTest {
                 if ($file != 'CVS' && !in_array($file_path, $this->ignorefolders)) {
                     $this->_recurseFolders($file_path);
                 }
-            } elseif (preg_match('/simpletest(\/|\\\\)test.*\.php$/', $file_path) || 
+            } elseif (preg_match('/simpletest(\/|\\\\)test.*\.php$/', $file_path) ||
                     ($this->thorough && preg_match('/simpletest(\/|\\\\)slowtest.*\.php$/', $file_path))) {
 
                 $s_count++;
index f98858344e624b29fd8a4014117b5f4ae9857c58..a77e0f0a08ed36bef7bc2584eee1ed1f42979afa 100644 (file)
@@ -39,20 +39,20 @@ admin_externalpage_print_header($adminroot);
 if (!is_null($path)) {
     // Create the group of tests.
     $test =& new AutoGroupTest($showsearch, $thorough);
-    
-    // OU specific. We use the _nonproject folder for stuff we want to 
+
+    // OU specific. We use the _nonproject folder for stuff we want to
     // keep in CVS, but which is not really relevant. It does no harm
     // to leave this here.
     $test->addIgnoreFolder($CFG->dirroot . '/_nonproject');
-    
+
     // Make the reporter, which is what displays the results.
     $reporter = new ExHtmlReporter($showpasses);
-    
+
     if ($showsearch) {
         print_heading('Searching for test cases');
     }
     flush();
-    
+
     // Work out what to test.
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
@@ -71,7 +71,7 @@ if (!is_null($path)) {
         print_simple_box(get_string('pathdoesnotexist', $langfile, $path), '', '', '', '', 'errorbox');
         $ok = false;
     }
-    
+
     // If we have something to test, do it.
     if ($ok) {
         if ($path == $CFG->dirroot) {
index a75fb857224d77188eb129dfe65c447c777bd846..74b3d5f21d0e77ebd64801bfdd559faba1659b7f 100644 (file)
     }
 
     require_capability('moodle/site:viewreport', get_context_instance(CONTEXT_COURSE, $course->id));
-    
-    add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id); 
+
+    add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
 
     stats_check_uptodate($course->id);
-    
-    
+
+
 //    $strreports = get_string("reports");
 //    $strstats = get_string('stats');
 //
 //             <a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
 //             $strstats";
 
-//    print_header("$course->shortname: $strstats", "$course->fullname", 
+//    print_header("$course->shortname: $strstats", "$course->fullname",
 //                  $crumb, '', '', true, '&nbsp', $menu);
-    
-    
+
+
     require_once($CFG->dirroot.'/course/report/stats/report.php');
-    
+
     admin_externalpage_print_footer($adminroot);
 
 ?>
index fff90940b31e6071d675b952dd05c3fd724cb75a..e116b200234e03a20bf2c02be4dae20c442c41fd 100755 (executable)
@@ -1,7 +1,7 @@
 <?php
 /**
- * this page defines what roles can access (grant user that role and override that roles' 
- * capabilities in different context. For example, we can say that Teachers can only grant 
+ * this page defines what roles can access (grant user that role and override that roles'
+ * capabilities in different context. For example, we can say that Teachers can only grant
  * student role or modify student role's capabilities. Note that you need both the right
  * capability moodle/roles:assign or moodle/roles:manage and this database table roles_deny_grant
  * to be able to grant roles. If a user has moodle/roles:manage at site level assignment
     $site = get_site();
     $stradministration = get_string('administration');
     $strmanageroles = get_string('manageroles');
-    
+
 /// form processiong here
 
 /// get all roles
+
     $roles = get_records('role');
 
     if ($grant = data_submitted()) {
-      
+
         foreach ($grant as $grole => $val) {
             if ($grole == 'dummy') {
-                continue;  
+                continue;
             }
-          
+
             $string = explode('_', $grole);
             $temp[$string[1]][$string[2]] = 1; // if set, means can access
         }
@@ -48,7 +48,7 @@
                     }
                 } else { //if set, means can access, attempt to remove it from db
                     delete_records('role_allow_assign', 'roleid', $srole->id, 'allowassign', $trole->id);
-                }  
+                }
             }
         }
     }
     $table->cellspacing = 0;
     $table->width = '90%';
     $table->align[] = 'right';
-    
+
 /// get all the roles identifier
     foreach ($roles as $role) {
         $rolesname[] = format_string($role->name);
         $roleids[] = $role->id;
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
-    }    
-    
+    }
+
     $table->head = array_merge(array(''), $rolesname);
-    
+
     foreach ($roles as $role) {
         $beta = get_box_list($role->id, $roleids);
         $table->data[] = array_merge(array(format_string($role->name)), $beta);
     }
 
     print_simple_box(get_string('configallowassign', 'admin'), 'center');
-    
+
     echo '<form action="allowassign.php" method="post">';
     print_table($table);
     echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
     echo '<input type="hidden" name="dummy" value="1" />'; // this is needed otherwise we do not know a form has been submitted
     echo '</form>';
-    
+
     admin_externalpage_print_footer($adminroot);
 
 
 
 function get_box_list($roleid, $arraylist){
-    
+
     foreach ($arraylist as $targetid) {
         if (get_record('role_allow_assign', 'roleid', $roleid, 'allowassign', $targetid)) {
             $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
         } else {
-            $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';              
+            $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
         }
     }
     return $array;
index 7904208c62fb86f86a4d1ed0e8fa08e5ec4c9d6c..0122b245f7d986fbc0519f4efe8ae08b14648d19 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 /**
- * this page defines what roles can override (override roles in different context. For example, 
+ * this page defines what roles can override (override roles in different context. For example,
  * we can say that Admin can override teacher roles in a course
  * To be able to override roles. If a user has moodle/roles:overrde at context level
  * and be in the roles_allow_override table.
     $site = get_site();
     $stradministration = get_string('administration');
     $strmanageroles = get_string('manageroles');
-    
+
 /// form processiong here
 
 /// get all roles
+
     $roles = get_records('role');
 
     if ($grant = data_submitted()) {
-      
+
         foreach ($grant as $grole => $val) {
             if ($grole == 'dummy') {
-                continue;  
+                continue;
             }
-          
+
             $string = explode('_', $grole);
             $temp[$string[1]][$string[2]] = 1; // if set, means can access
         }
                     }
                 } else { //if set, means can access, attempt to remove it from db
                     delete_records('role_allow_override', 'roleid', $srole->id, 'allowoverride', $trole->id);
-                }  
+                }
             }
         }
     }
 /// displaying form here
 
     admin_externalpage_print_header($adminroot);
-                 
+
     $currenttab='allowoverride';
     require_once('managetabs.php');
 
     $table->cellspacing = 0;
     $table->width = '90%';
     $table->align[] = 'right';
-    
+
 /// get all the roles identifier
     foreach ($roles as $role) {
         $rolesname[] = format_string($role->name);
         $roleids[] = $role->id;
         $table->align[] = 'center';
         $table->wrap[] = 'nowrap';
-    }    
-    
+    }
+
     $table->head = array_merge(array(''), $rolesname);
-    
+
     foreach ($roles as $role) {
         $beta = get_box_list($role->id, $roleids);
         $table->data[] = array_merge(array(format_string($role->name)), $beta);
     }
 
     print_simple_box(get_string('configallowoverride', 'admin'), 'center');
-    
+
     echo '<form action="allowoverride.php" method="post">';
     print_table($table);
     echo '<div class="singlebutton"><input type="submit" value="'.get_string('savechanges').'"/></div>';
 
 // returns array
 function get_box_list($roleid, $arraylist){
-    
+
     foreach ($arraylist as $targetid) {
         if (get_record('role_allow_override', 'roleid', $roleid, 'allowoverride', $targetid)) {
             $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" checked="checked"/>';
         } else {
-            $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';              
+            $array[] = '<input type="checkbox" name="s_'.$roleid.'_'.$targetid.'" value="1" />';
         }
     }
     return $array;
index 6afef8512cba66e0735f518ed12ef2f9bd854abe..b7c2fa09ed80efaa366ddc5c4d024f651ab7feac 100755 (executable)
@@ -26,13 +26,13 @@ if ($userid) {
                   onFocus="document.studentform.add.disabled=true;
                            document.studentform.remove.disabled=false;
                            document.studentform.addselect.selectedIndex=-1;" />
-          <?php 
+          <?php
               foreach ($contextusers as $contextuser) {
                   $fullname = fullname($contextuser, true);
                   echo "<option value=\"$contextuser->id\">".$fullname.", ".$contextuser->email."</option>\n";
               }
           ?>
-          
+
           </select></td>
       <td valign="top">
         <br />
@@ -47,7 +47,7 @@ if ($userid) {
                            document.studentform.remove.disabled=true;
                            document.studentform.removeselect.selectedIndex=-1;">
           <?php
-      
+
               if (!empty($searchusers)) {
                   echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
                   foreach ($searchusers as $user) {
@@ -73,7 +73,7 @@ if ($userid) {
           ?>
          </select>
          <br />
-         <input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>" 
+         <input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
                   onFocus ="document.studentform.add.disabled=true;
                             document.studentform.remove.disabled=true;
                             document.studentform.removeselect.selectedIndex=-1;
index 85d4934f1c30c673e560d9dea4227d66639ca128..c6c6d3fea1d6f561d7a50df419f18a0d1a483d71 100755 (executable)
     $strshowall = get_string('showall');
     $strparticipants = get_string('participants');
 
-    
+
 
 /// Make sure this user can assign that role
 
     if ($roleid) {
         if (!user_can_assign($context, $roleid)) {
             error ('you can not override this role in this context');
-        }  
+        }
     }
 
     if ($userid) {
             print_header("$fullname", "$fullname",
                      "<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
                       <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> ->".$straction,
-                      "", "", true, "&nbsp;", navmenu($course));      
-        
-        /// site header  
+                      "", "", true, "&nbsp;", navmenu($course));
+
+        /// site header
         } else {
             print_header("$course->fullname: $fullname", "$course->fullname",
-                        "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> -> $straction", "", "", true, "&nbsp;", navmenu($course));     
+                        "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$courseid."\">$fullname</a> -> $straction", "", "", true, "&nbsp;", navmenu($course));
         }
-        
+
         $showroles = 1;
         $currenttab = 'assign';
         include_once($CFG->dirroot.'/user/tabs.php');
     $existinguserarray = array();
 
     if (!$contextusers = get_role_users($roleid, $context)) {
-        $contextusers = array();  
+        $contextusers = array();
     }
 
     foreach ($contextusers as $contextuser) {
         $existinguserarray[] = $contextuser->id;
     }
-    
+
     $existinguserlist = implode(',', $existinguserarray);
     unset($existinguserarray);
 
         }
 
     }
-    
+
     if ($roleid) {
     /// prints a form to swap roles
         echo '<form name="rolesform" action="assign.php" method="post">';
         $table->head = array(get_string('roles', 'role'), get_string('users'));
         $table->wrap = array('nowrap', 'nowrap');
         $table->align = array('right', 'center');
-        
+
         foreach ($assignableroles as $roleid => $rolename) {
             $countusers = 0;
             if ($contextusers = get_role_users($roleid, $context)) {
             }
             $table->data[] = array('<a href="assign.php?contextid='.$context->id.'&amp;roleid='.$roleid.$userparam.'">'.$rolename.'</a>', $countusers);
         }
-    
+
         print_table($table);
     }
 
index bae0aca93cbb10bdcd6242028bfddbf2443145d8..60078931a1ea8af75a6e7cf10f78bf2cebe2db06 100755 (executable)
@@ -18,7 +18,7 @@
 <br />
 <?php print_string('roledescription', 'role'); ?>:
 <?php print_textarea($usehtmleditor, 10, 50, 50, 10, 'description', $role->description); ?>
-<p>            
+<p>
 <table>
 <tr>
 <td><?php print_string('capability','role') ?></td>
 <td><?php print_string('risks','role') ?></td>
 </tr>
 
-<?php 
+<?php
 
 // init these 2
 $contextlevel = 0;
 $component = '';
 
 foreach ($capabilities as $capability) {
-    // prints a breaker if component or name or context level  
+    // prints a breaker if component or name or context level
     if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
         echo ('<tr><td colspan="4"><strong>'.
-               get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');  
+               get_component_string($capability->component, $capability->contextlevel).'</strong></td></tr>');
     }
 
     // these 2 are used to see to group same mod/core capabilities together
@@ -78,8 +78,8 @@ foreach ($capabilities as $capability) {
         ?></td>
         </tr>
 
-<?php } ?>    
-</table>     
+<?php } ?>
+</table>
 </p>
 <br />
 <input type="submit" value="<?php p($submitlabel); ?>" />
index 7106bc49772f218d664d3ccb3d8e650ec9569f50..7850438077de66f417f08f159dfb5b83cd4c7f3d 100755 (executable)
@@ -22,9 +22,9 @@
 
     if ($roleid && $action!='delete') {
         $role = get_record('role', 'id', $roleid);
-        $editingstr = '-> '.get_string('editinga', '', $role->name);  
+        $editingstr = '-> '.get_string('editinga', '', $role->name);
     } else {
-        $editingstr ='';  
+        $editingstr ='';
     }
 
     admin_externalpage_print_header($adminroot);
         switch ($action) {
             case 'add':
 
-                $newrole = create_role($name, $shortname, $description);        
+                $newrole = create_role($name, $shortname, $description);
 
                 $ignore = array('roleid', 'sesskey', 'action', 'name', 'description', 'contextid');
 
                 $data = data_submitted();
 
                 foreach ($data as $capname => $value) {
-                    if (in_array($capname, $ignore)) { 
+                    if (in_array($capname, $ignore)) {
                         continue;
                     }
 
@@ -62,7 +62,7 @@
                 $data = data_submitted();
 
                 foreach ($data as $capname => $value) {
-                    if (in_array($capname, $ignore)) { 
+                    if (in_array($capname, $ignore)) {
                         continue;
                     }
 
@@ -80,7 +80,7 @@
                             $localoverride->permission = $value;
                             $localoverride->timemodified = time();
                             $localoverride->modifierid = $USER->id;
-                            update_record('role_capabilities', $localoverride);    
+                            update_record('role_capabilities', $localoverride);
                         }
                     } else { // insert a record
                         assign_capability($capname, $value, $roleid, $sitecontext->id);
@@ -91,7 +91,7 @@
 
                 $role->id = $roleid;
                 $role->name = $name;
-                $role->description = $description;    
+                $role->description = $description;
 
                 if (!update_record('role', $role)) {
                     error('Could not update role!');
                 break;
 
             case 'delete':
-                if ($confirm) { // deletes a role 
+                if ($confirm) { // deletes a role
 
                     // check for depedencies  XXX TODO
 
                     echo ('<input type="hidden" name="roleid" value="'.$roleid.'">');
                     echo ('<input type="hidden" name="sesskey" value="'.sesskey().'">');
                     echo ('<input type="hidden" name="confirm" value="1">');
-                    notice_yesno(get_string('deleterolesure', 'role'), 
+                    notice_yesno(get_string('deleterolesure', 'role'),
                        'manage.php?action=delete&roleid='.$roleid.'&sesskey='.sesskey().'&confirm=1', 'manage.php');
                     admin_externalpage_print_footer($adminroot);
                     exit;
                 }
 
-                break;      
+                break;
 
                 /// add possible positioning switch here
 
             default:
-                break;      
+                break;
 
         }
 
         if ($roleid) {
             $action='edit';
             $role = get_record('role', 'id', $roleid);
-        } else {    
-            $action='add';              
+        } else {
+            $action='add';
             $role->name='';
             $role->shortname='';
             $role->description='';
         $table->cellspacing = 0;
         $table->width = '90%';
 
-        $table->head = array(get_string('roles', 'role'), 
-                             get_string('description'), 
+        $table->head = array(get_string('roles', 'role'),
+                             get_string('description'),
                              get_string('delete'));
 
         /*************************
 
             $table->data[] = array('<a href="manage.php?roleid='.$role->id.'&amp;sesskey='.sesskey().'">'.format_string($role->name).'</a>', format_text($role->description, FORMAT_HTML), '<a href="manage.php?action=delete&roleid='.$role->id.'&sesskey='.sesskey().'">'.$strdelete.'</a>');
 
-        } 
+        }
         print_table($table);
 
         $options = new object;
index 19c19c901dcd19914b1f1b2d65e5e208c033bf20..2e103ff88ad8c8650f5329a28041ed1d46221ca1 100755 (executable)
@@ -2,13 +2,13 @@
 // this page deals with the 2 tabs for manage.php and grant.php
 
     $toprow[] = new tabobject('manage', $CFG->wwwroot.'/admin/roles/manage.php', get_string('manageroles', 'role'));
-    
+
     $toprow[] = new tabobject('allowassign', $CFG->wwwroot.'/admin/roles/allowassign.php', get_string('allowassign', 'role'));
 
     $toprow[] = new tabobject('allowoverride', $CFG->wwwroot.'/admin/roles/allowoverride.php', get_string('allowoverride', 'role'));
-    
+
     $tabs = array($toprow);
-    
+
     print_tabs($tabs, $currenttab);
 
 ?>
index 41f1b8aeee71cb1092684acc771ce3825a4cdb42..106f5f24438b470b453aeaa49318680e2fd4cea6 100755 (executable)
@@ -1,4 +1,4 @@
-            <form action="override.php" method="post">     
+            <form action="override.php" method="post">
             <input type="hidden" name="contextid" value="<?php p($contextid) ?>">
             <input type="hidden" name="roleid" value="<?php p($roleid) ?>">
 <?php
@@ -17,22 +17,22 @@ if ($courseid) {
                 <td><?php print_string('prohibit','role') ?></td>
                 <td><?php print_string('risks','role') ?></td>
             </tr>
-            <?php 
-            
+            <?php
+
             // init these 2
             $contextlevel = 0;
             $component = '';
 
             foreach ($capabilities as $capability) {
-            // prints a breaker if component or name or context level  
+            // prints a breaker if component or name or context level
                 if ($capability->component != $component or $capability->contextlevel != $contextlevel) {
-                    echo ('<tr><td colspan="5"><b>'.get_component_string($capability->component, $capability->contextlevel).'</b></td></tr>');  
+                    echo ('<tr><td colspan="5"><b>'.get_component_string($capability->component, $capability->contextlevel).'</b></td></tr>');
                 }
-                
+
                 // these 2 are used to see to group same mod/core capabilities together
                 $contextlevel = $capability->contextlevel;
                 $component = $capability->component;
-                
+
                 // check the capability override for this cap, this role in this context
                 if (isset($localoverrides[$capability->name])) {
                     $localpermission = $localoverrides[$capability->name]->permission;
@@ -47,41 +47,41 @@ if ($courseid) {
                 } else {
                     $isallow = 0;
                     $isprevent = 0;
-                    $isprohibit = 0;  
+                    $isprohibit = 0;
                 }
 
                 $isdisabled = $isprohibit || islegacy($capability->name);
-                
+
             ?>
-                
+
             <tr>
               <td><?php echo get_capability_string($capability->name); ?></td>
 
                  <td align="center">
-                 <input type="radio" name="<?php echo $capability->name; ?>" value="0" 
-                    <?php 
-                        if ($localpermission == 0) {echo 'checked="checked"';} 
+                 <input type="radio" name="<?php echo $capability->name; ?>" value="0"
+                    <?php
+                        if ($localpermission == 0) {echo 'checked="checked"';}
                         if ($isdisabled)           {echo 'disabled="disabled"';}?> />
                  </td>
 
                  <td align="center" <?php if ($isallow) {echo 'class="capcurrent"';} ?>>
                  <input type="radio" name="<?php echo $capability->name; ?>"
                     <?php echo ' value="'.CAP_ALLOW.'"';
-                       if ($localpermission == CAP_ALLOW) {echo ' checked="checked"';} 
+                       if ($localpermission == CAP_ALLOW) {echo ' checked="checked"';}
                        if ($isdisabled)                   {echo ' disabled="disabled"';}?> />
                  </td>
 
                  <td align="center" <?php if ($isprevent) {echo 'class="capcurrent"';} ?>>
-                 <input type="radio" name="<?php echo $capability->name; ?>" 
+                 <input type="radio" name="<?php echo $capability->name; ?>"
                     <?php echo ' value="'.CAP_PREVENT.'"';
-                       if ($localpermission == CAP_PREVENT) {echo ' checked="checked"';} 
+                       if ($localpermission == CAP_PREVENT) {echo ' checked="checked"';}
                        if ($isdisabled)                     {echo ' disabled="disabled"';}?> />
                  </td>
 
                  <td align="center" <?php if ($isprohibit) {echo 'class="capcurrent"';} ?>>
                  <input type="radio" name="<?php echo $capability->name; ?>"
                     <?php echo ' value="'.CAP_PROHIBIT.'"';
-                       if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked"';} 
+                       if ($localpermission == CAP_PROHIBIT) {echo ' checked="checked"';}
                        if ($isdisabled)                      {echo ' disabled="disabled"';}?> />
                  </td>
                  <td><?php
@@ -102,9 +102,9 @@ if ($courseid) {
                     }
                  ?></td>
             </tr>
-            
-            <?php } ?>    
-            </table>     
+
+            <?php } ?>
+            </table>
             <br />
             <div align="center"><input type="submit" value="<?php print_string('savechanges') ?>" /></div>
             </form>
index ec1227309d18b326ac658c3dbfe620ffcd9d5c11..9f7e097a1fcedddf915649ca2c65b49a72c86f5c 100755 (executable)
@@ -1,18 +1,18 @@
 <?php
-    
+
     require_once("../../config.php");
-    
+
     $contextid      = required_param('contextid',PARAM_INT); // context id
     $roleid         = optional_param('roleid', 0, PARAM_INT); // required role id
     $userid         = optional_param('userid', 0, PARAM_INT); // needed for user tabs
     $courseid       = optional_param('courseid', 0, PARAM_INT); // needed for user tabs
-    
+
     if ($courseid) {
-        $course = get_record('course', 'id', $courseid);  
+        $course = get_record('course', 'id', $courseid);
     } else {
         $course = $SITE;
     }
-    
+
     $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
     if ($contextid == $sitecontext->id) {
         error ('can not override base role capabilities');
 
     $context = get_record('context', 'id', $contextid);
     $overridableroles = get_overridable_roles($context);
-    
+
 /// Make sure this user can override that role
     if ($roleid) {
         if (!user_can_override($context, $roleid)) {
             error ('you can not override this role in this context');
-        }  
+        }
     }
-    
+
     if ($userid) {
         $user = get_record('user', 'id', $userid);
         $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
     }
-    
+
 /// Print the header and tabs
 
     if ($context->aggregatelevel == CONTEXT_USER) {
-      
+
         /// course header
         if ($course->id != SITEID) {
             print_header("$fullname", "$fullname",
                      "<a href=\"../course/view.php?id=$course->id\">$course->shortname</a> ->
                       <a href=\"".$CFG->wwwroot."/user/index.php?id=$course->id\">$strparticipants</a> -> <a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$course->id."\">$fullname</a> -> $straction",
-                      "", "", true, "&nbsp;", navmenu($course));      
-        
-        /// site header  
+                      "", "", true, "&nbsp;", navmenu($course));
+
+        /// site header
         } else {
             print_header("$course->fullname: $fullname", "$course->fullname",
-                        "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$course->id."\">$fullname</a> -> $straction", "", "", true, "&nbsp;", navmenu($course));     
+                        "<a href=\"".$CFG->wwwroot."/user/view.php?id=".$userid."&course=".$course->id."\">$fullname</a> -> $straction", "", "", true, "&nbsp;", navmenu($course));
         }
         $showroles = 1;
         $currenttab = 'override';
 /// Process incoming role override
      if ($data = data_submitted()) {
 
-        $localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id", 
+        $localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
                                              '', 'capability, permission, id');
 
          foreach ($data as $capname => $value) {
              if ($capname == 'contextid' || $capname == 'roleid') {        // ignore contextid and roleid
-                 continue;  
+                 continue;
              }
-         
+
              if (isset($localoverrides[$capname])) {    // Something exists, so update it
-             
+
                  if ($value == CAP_INHERIT) {       // inherit = delete
-                     delete_records('role_capabilities', 'roleid', $roleid, 'contextid', $contextid, 
+                     delete_records('role_capabilities', 'roleid', $roleid, 'contextid', $contextid,
                                                          'capability', $capname);
                  } else {
                      $localoverride = new object;
                      $localoverride->permission = $value;
                      $localoverride->timemodified = time();
                      $localoverride->modifierid = $USER->id;
-                     
+
                      if (!update_record('role_capabilities', $localoverride)) {
                          debugging('Could not update a capability!');
                      }
                  }
-            
+
             } else { // insert a record
-            
+
                 if ($value != CAP_INHERIT) {    // Ignore inherits
                     $override->capability = $capname;
                     $override->contextid = $contextid;
         } else {
             $parentcontext = $context; // site level in override??
         }
-        
+
         $r_caps = role_context_capabilities($roleid, $parentcontext);
 
-        $localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id", 
+        $localoverrides = get_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id",
                                              '', 'capability, permission, id');
-        
+
         // Get the capabilities overrideable in this context
         if ($capabilities = fetch_context_capabilities($context)) {
             print_simple_box_start("center");
     } else {   // Print overview table
 
         $userparam = (!empty($userid)) ? '&amp;userid='.$userid : '';
-       
+
         $table->tablealign = 'center';
         $table->cellpadding = 5;
         $table->cellspacing = 0;
         $table->head = array(get_string('roles', 'role'), get_string('overrides', 'role'));
         $table->wrap = array('nowrap', 'nowrap');
         $table->align = array('right', 'center');
-        
+
         foreach ($overridableroles as $roleid => $rolename) {
             $countusers = 0;
             $overridecount = count_records_select('role_capabilities', "roleid = $roleid AND contextid = $context->id");
             $table->data[] = array('<a href="override.php?contextid='.$context->id.'&amp;roleid='.$roleid.$userparam.'">'.$rolename.'</a>', $overridecount);
         }
-    
+
         print_table($table);
     }
-    
+
     print_footer($course);
-    
+
 ?>
index efb5432f72de5995c7df95f3a6892358149293bc..b74a598f001db1b61a96f23e6159e0d95aac53f6 100755 (executable)
@@ -71,7 +71,7 @@ if ($currenttab != 'update') {
                     $blockname = print_context_name($context);
                     $navigation = $blockname. ' -> '.$straction;
 
-                    switch ($blockinstance->pagetype) { 
+                    switch ($blockinstance->pagetype) {
                         case 'course-view':
                             if ($course = get_record('course', 'id', $blockinstance->pageid)) {
                                 if ($course->id != SITEID) {
@@ -111,45 +111,45 @@ if ($context->aggregatelevel != CONTEXT_SYSTEM) {    // Print tabs for anything
         $toprow[] = new tabobject('update', $CFG->wwwroot.'/course/mod.php?update='.
                        $context->instanceid.'&amp;return=true&amp;sesskey='.sesskey(), get_string('update'));
 
-    }    
+    }
 
     $toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.
-                               $context->id, get_string('roles')); 
+                               $context->id, get_string('roles'));
 
     if (isset($tabsmode)) {
 
         if (!isset($assignableroles)) {
-            $assignableroles = get_assignable_roles($context);          
+            $assignableroles = get_assignable_roles($context);
         }
         if (!isset($overridableroles)) {
-            $overridableroles = get_overridable_roles($context); 
+            $overridableroles = get_overridable_roles($context);
         }
 
         $inactive[] = 'roles';
         if (!empty($assignableroles)) {
-            $secondrow[] = new tabobject('assign', 
-                                         $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id, 
-                                         get_string('assignroles', 'role'), 
-                                         get_string('showallroles', 'role'), 
-                                         true); 
+            $secondrow[] = new tabobject('assign',
+                                         $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id,
+                                         get_string('assignroles', 'role'),
+                                         get_string('showallroles', 'role'),
+                                         true);
         }
 
-        if (!empty($overridableroles)) {  
-            $secondrow[] = new tabobject('override', 
+        if (!empty($overridableroles)) {
+            $secondrow[] = new tabobject('override',
                                $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$context->id,
-                               get_string('overrideroles', 'role'), 
-                               get_string('showallroles', 'role'),  
-                               true);         
+                               get_string('overrideroles', 'role'),
+                               get_string('showallroles', 'role'),
+                               true);
         }
 
         if ($tabsmode == 'override') {
-            $currenttab = 'override';  
+            $currenttab = 'override';
         } elseif ($tabsmode == 'assign') {
-            $currenttab = 'assign';  
+            $currenttab = 'assign';
         }
 
     } else {
-        $inactive[] = '';  
+        $inactive[] = '';
     }
 
     if (!empty($secondrow)) {
index dd9e8909b83887c0ccf49b35c1676b604ed239a7..9d9098c25c274e880804dc6681d769193813e324 100644 (file)
@@ -7,7 +7,7 @@ require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php');
 
 if ($site = get_site()) {
     require_login();
-} 
+}
 
 
 page_map_class(PAGE_ADMIN, 'page_admin');
@@ -20,7 +20,7 @@ $PAGE->init_extra($section); // hack alert!
 
 $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
 $return       = optional_param('return','', PARAM_ALPHA);
-   
+
 if (!isset($USER->adminediting)) {
     $USER->adminediting = false;
 }
@@ -85,11 +85,11 @@ if ($data = data_submitted()) {
 if (!empty($SITE->fullname)) {
     $pageblocks = blocks_setup($PAGE);
 
-    $preferred_width_left  = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 
+    $preferred_width_left  = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
                                             BLOCK_L_MAX_WIDTH);
-    $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 
+    $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
                                             BLOCK_R_MAX_WIDTH);
-    
+
     // print header stuff
     $PAGE->print_header();
 
index fd2a4fdf96d233b759d4c07445b6d7001b19129d..d7af1530ff0e446aea37e8cf47eeecc0e61db9d5 100644 (file)
@@ -22,10 +22,10 @@ $temp->add(new admin_setting_sitesettext('shortname', get_string('shortsitename'
 $temp->add(new admin_setting_special_frontpagedesc());
 $temp->add(new admin_setting_courselist_frontpage(false)); // non-loggedin version of the setting (that's what the parameter is for :) )
 $temp->add(new admin_setting_courselist_frontpage(true)); // loggedin version of the setting
-$temp->add(new admin_setting_sitesetcheckbox('numsections', get_string('sitesection'), 
+$temp->add(new admin_setting_sitesetcheckbox('numsections', get_string('sitesection'),
                get_string('sitesectionhelp','admin'), 1));
-$temp->add(new admin_setting_sitesetselect('newsitems', get_string('newsitemsnumber'), 
-     '', 3, 
+$temp->add(new admin_setting_sitesetselect('newsitems', get_string('newsitemsnumber'),
+     '', 3,
      array('0' => '0',
            '1' => '1',
            '2' => '2',
index b416a6bacc584a472f4fa044f2989af4348c19b6..94cb38e2e848c143be5aceb9aa702fa3b000a03b 100644 (file)
@@ -12,14 +12,14 @@ $temp->add(new admin_setting_configtext('maxbytes', get_string('maxbytes', 'admi
 $temp->add(new admin_setting_configcheckbox('messaging', get_string('messaging', 'admin'), get_string('configmessaging','admin'), 1));
 $temp->add(new admin_setting_configcheckbox('allowobjectembed', get_string('allowobjectembed', 'admin'), get_string('configallowobjectembed', 'admin'), 0));
 $temp->add(new admin_setting_configcheckbox('enabletrusttext', get_string('enabletrusttext', 'admin'), get_string('configenabletrusttext', 'admin'), 0));
-$temp->add(new admin_setting_configselect('maxeditingtime', get_string('maxeditingtime','admin'), get_string('configmaxeditingtime','admin'), 1800, 
+$temp->add(new admin_setting_configselect('maxeditingtime', get_string('maxeditingtime','admin'), get_string('configmaxeditingtime','admin'), 1800,
              array(60 => get_string('numminutes', '', 1),
                    300 => get_string('numminutes', '', 5),
                    900 => get_string('numminutes', '', 15),
                    1800 => get_string('numminutes', '', 30),
                    2700 => get_string('numminutes', '', 45),
                    3600 => get_string('numminutes', '', 60))));
-$temp->add(new admin_setting_configselect('fullnamedisplay', get_string('fullnamedisplay', 'admin'), get_string('configfullnamedisplay', 'admin'), 
+$temp->add(new admin_setting_configselect('fullnamedisplay', get_string('fullnamedisplay', 'admin'), get_string('configfullnamedisplay', 'admin'),
               'firstname lastname', array('language' => get_string('language'),
               'firstname lastname' => get_string('firstname') . ' + ' . get_string('lastname'),
               'lastname firstname' => get_string('lastname') . ' + ' . get_string('firstname'),
@@ -50,7 +50,7 @@ $temp = new admin_settingpage('modulesecurity', get_string('modulesecurity', 'ad
 $temp->add(new admin_setting_configselect('restrictmodulesfor', get_string('restrictmodulesfor', 'admin'), get_string('configrestrictmodulesfor', 'admin'), 'none', array('none' => 'No courses',
                                                                                                                                                                           'all' => 'All courses',
                                                                                                                                                                           'requested' => 'Requested courses')));
-$temp->add(new admin_setting_configcheckbox('restrictbydefault', get_string('restrictbydefault', 'admin'), get_string('configrestrictbydefault', 'admin'), 0));                                                                                                                                                                  
+$temp->add(new admin_setting_configcheckbox('restrictbydefault', get_string('restrictbydefault', 'admin'), get_string('configrestrictbydefault', 'admin'), 0));
 if (!$options = get_records("modules")) {
     $options = array();
 }
index 2553cc6fa80961121b02e90b65fbdb5fc544430f..2ec29cd4ab9c45e60faa9fe89bb583c34b549228 100644 (file)
@@ -4,8 +4,8 @@
 
 // "systempaths" settingpage
 $temp = new admin_settingpage('systempaths', get_string('systempaths','admin'));
-$temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'), 
-                                                                                                                                                          '1' => get_string('gd1'), 
+$temp->add(new admin_setting_configselect('gdversion', get_string('gdversion','admin'), get_string('configgdversion', 'admin'), check_gd_version(), array('0' => get_string('gdnot'),
+                                                                                                                                                          '1' => get_string('gd1'),
                                                                                                                                                           '2' => get_string('gd2'))));
 $temp->add(new admin_setting_configtext('zip', get_string('pathtozip','admin'), get_string('configzip', 'admin'), '', PARAM_PATH));
 $temp->add(new admin_setting_configtext('unzip', get_string('pathtounzip','admin'), get_string('configunzip', 'admin'), '', PARAM_PATH));
@@ -23,29 +23,29 @@ $temp->add(new admin_setting_configtext('smtppass', get_string('smtppass', 'admi
 $temp->add(new admin_setting_configtext('noreplyaddress', get_string('noreplyaddress', 'admin'), get_string('confignoreplyaddress', 'admin'), 'noreply@' . $_SERVER['HTTP_HOST'], PARAM_NOTAGS));
 $temp->add(new admin_setting_configtext('allowemailaddresses', get_string('allowemailaddresses', 'admin'), get_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS));
 $temp->add(new admin_setting_configtext('denyemailaddresses', get_string('denyemailaddresses', 'admin'), get_string('configdenyemailaddresses', 'admin'), '', PARAM_NOTAGS));
-$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00', 
-                                                                                                                                                          '01' => '01', 
-                                                                                                                                                          '02' => '02', 
-                                                                                                                                                          '03' => '03', 
-                                                                                                                                                          '04' => '04', 
-                                                                                                                                                          '05' => '05', 
-                                                                                                                                                          '06' => '06', 
-                                                                                                                                                          '07' => '07', 
-                                                                                                                                                          '08' => '08', 
-                                                                                                                                                          '09' => '09', 
-                                                                                                                                                          '10' => '10', 
-                                                                                                                                                          '11' => '11', 
-                                                                                                                                                          '12' => '12', 
-                                                                                                                                                          '13' => '13', 
-                                                                                                                                                          '14' => '14', 
-                                                                                                                                                          '15' => '15', 
-                                                                                                                                                          '16' => '16', 
-                                                                                                                                                          '17' => '17', 
-                                                                                                                                                          '18' => '18', 
-                                                                                                                                                          '19' => '19', 
-                                                                                                                                                          '20' => '20', 
-                                                                                                                                                          '21' => '21', 
-                                                                                                                                                          '22' => '22', 
+$temp->add(new admin_setting_configselect('digestmailtime', get_string('digestmailtime', 'admin'), get_string('configdigestmailtime', 'admin'), 17, array('00' => '00',
+                                                                                                                                                          '01' => '01',
+                                                                                                                                                          '02' => '02',
+                                                                                                                                                          '03' => '03',
+                                                                                                                                                          '04' => '04',
+                                                                                                                                                          '05' => '05',
+                                                                                                                                                          '06' => '06',
+                                                                                                                                                          '07' => '07',
+                                                                                                                                                          '08' => '08',
+                                                                                                                                                          '09' => '09',
+                                                                                                                                                          '10' => '10',
+                                                                                                                                                          '11' => '11',
+                                                                                                                                                          '12' => '12',
+                                                                                                                                                          '13' => '13',
+                                                                                                                                                          '14' => '14',
+                                                                                                                                                          '15' => '15',
+                                                                                                                                                          '16' => '16',
+                                                                                                                                                          '17' => '17',
+                                                                                                                                                          '18' => '18',
+                                                                                                                                                          '19' => '19',
+                                                                                                                                                          '20' => '20',
+                                                                                                                                                          '21' => '21',
+                                                                                                                                                          '22' => '22',
                                                                                                                                                           '23' => '23')));
 if (!empty($CFG->unicodedb)) { // These options are only available if running under unicodedb
     unset($options);
@@ -88,7 +88,7 @@ $ADMIN->add('server', $temp);
 $temp = new admin_settingpage('debugging', get_string('debugging', 'admin'));
 $temp->add(new admin_setting_special_debug());
 $temp->add(new admin_setting_special_perfdebug());
-$ADMIN->add('server', $temp); 
+$ADMIN->add('server', $temp);
 
 
 // "stats" settingpage
@@ -116,7 +116,7 @@ $temp->add(new admin_setting_configselect('statsmaxruntime', get_string('statsma
                                                                                                                                                             60*60*8 => '8 '.get_string('hours') )));
 $temp->add(new admin_setting_configtime('statsruntimestarthour', 'statsruntimestartminute', get_string('statsruntimestart', 'admin'), get_string('configstatsruntimestart', 'admin'), array('h' => 0, 'm' => 0)));
 $temp->add(new admin_setting_configtext('statsuserthreshold', get_string('statsuserthreshold', 'admin'), get_string('configstatsuserthreshold', 'admin'), 0, PARAM_INT));
-$ADMIN->add('server', $temp);                                                                                                                                                   
+$ADMIN->add('server', $temp);
 
 
 // "http" settingpage
@@ -125,7 +125,7 @@ $temp->add(new admin_setting_configtext('framename', get_string('framename', 'ad
 $temp->add(new admin_Setting_configcheckbox('slasharguments', get_string('slasharguments', 'admin'), get_string('configslasharguments', 'admin'), 1));
 $temp->add(new admin_setting_configtext('proxyhost', get_string('proxyhost', 'admin'), get_string('configproxyhost', 'admin'), '', PARAM_HOST));
 $temp->add(new admin_setting_configtext('proxyport', get_string('proxyport', 'admin'), get_string('configproxyport', 'admin'), '', PARAM_INT));
-$ADMIN->add('server', $temp); 
+$ADMIN->add('server', $temp);
 
 $ADMIN->add('server', new admin_externalpage('sitefiles', get_string('sitefiles'), $CFG->wwwroot . '/files/index.php?id=' . SITEID));
 
index 0c50cced7e61a8ab0f845a7f13837c97bf351725..9d26d09faebd6efbc5b05413a8b8808b80cd227b 100644 (file)
@@ -33,17 +33,17 @@ if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW
 }
 $assignableroles  = get_assignable_roles($context);
 
-$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'), 
+$temp->add(new admin_setting_configselect('notloggedinroleid', get_string('notloggedinroleid', 'admin'),
               get_string('confignotloggedinroleid', 'admin'), $guestrole->id, $assignableroles ));
-$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'), 
+$temp->add(new admin_setting_configselect('defaultuserroleid', get_string('defaultuserroleid', 'admin'),
               get_string('configdefaultuserroleid', 'admin'), $guestrole->id, $assignableroles));
-$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'), 
+$temp->add(new admin_setting_configselect('defaultcourseroleid', get_string('defaultcourseroleid', 'admin'),
               get_string('configdefaultcourseroleid', 'admin'), $studentrole->id, $assignableroles));
 
 //$temp->add(new admin_setting_configcheckbox('autologinguests', get_string('autologinguests', 'admin'), get_string('configautologinguests', 'admin'), 0));
 //$temp->add(new admin_setting_configcheckbox('allusersaresitestudents', get_string('allusersaresitestudents', 'admin'), get_string('configallusersaresitestudents','admin'), 1));
-$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'), 
-           get_string('confighiddenuserfields', 'admin'), array(), 
+$temp->add(new admin_setting_configmultiselect('hiddenuserfields', get_string('hiddenuserfields', 'admin'),
+           get_string('confighiddenuserfields', 'admin'), array(),
                array('none' => get_string('none'),
                      'description' => get_string('description'),
                      'city' => get_string('city'),
index 8a7e05d80ed2ead06124c47436a8821605dee5c5..b561f20b74f19f71323ae35cb1b8049923ee00b0 100644 (file)
@@ -1,6 +1,6 @@
 <?php // $Id$
 
-// detects settings that were added during an upgrade, displays a screen for the admin to 
+// detects settings that were added during an upgrade, displays a screen for the admin to
 // modify them, and then processes modifications
 
 require_once('../config.php');
@@ -18,7 +18,7 @@ $newsettingshtml = output_new_settings_by_page(admin_get_root());
 
 // first we deal with the case where there are no new settings to be set
 if ($newsettingshtml == '') {
-    redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php');    
+    redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
     die;
 }
 
@@ -74,7 +74,7 @@ admin_externalpage_print_footer($adminroot);
 
 /**
  * Find settings that have not been initialized (e.g. during initial install or an upgrade).
- * 
+ *
  * Tests each setting's get_setting() method. If the result is NULL, we consider the setting
  * to be uninitialized.
  *
@@ -90,9 +90,9 @@ function find_new_settings(&$node) {
             $return = array_merge($return, find_new_settings($node->children[$entry]));
         }
         return $return;
-    } 
+    }
 
-    if (is_a($node, 'admin_settingpage')) { 
+    if (is_a($node, 'admin_settingpage')) {
         $return = array();
         foreach ($node->settings as $setting) {
             if ($setting->get_setting() === NULL) {
@@ -117,9 +117,9 @@ function output_new_settings_by_page(&$node) {
             $return .= output_new_settings_by_page($node->children[$entry]);
         }
         return $return;
-    } 
+    }
 
-    if (is_a($node, 'admin_settingpage')) { 
+    if (is_a($node, 'admin_settingpage')) {
         $newsettings = array();
         foreach ($node->settings as $setting) {
             if ($setting->get_setting() === NULL) {
@@ -133,7 +133,7 @@ function output_new_settings_by_page(&$node) {
             $return = '<tr><td colspan="2"><strong>' . $node->visiblename . '</strong></td></tr>';
             foreach ($newsettings as $newsetting) {
                 $return .= $newsetting->output_html();
-            }        
+            }
         }
         return $return;
     }
index fd1b3a4ccf56cad25bd8ba20276f710a214e2d10..e2b175829dfa90cb7432b2de53f0c51d7e49e897 100644 (file)
@@ -34,7 +34,7 @@ Ciao, Eloy Lafuente (stronk7)
 
 2006-07-11 - Important notes
 
-I've just discovered this some seconds ago, in order 
+I've just discovered this some seconds ago, in order
 to test properly the XMLDB classes and editor:
 
 1.- PHP 5 required for now. Will change this soon.
@@ -48,8 +48,8 @@ Ciao, Eloy Lafuente (stronk7)
 
 2006-07-11 - Initial commit
 
-This directory contains the XMLDB classes to be used 
-under Moodle > 1.7 to store all the DB info in a 
+This directory contains the XMLDB classes to be used
+under Moodle > 1.7 to store all the DB info in a
 neutral form (classes dir). Also it contains one simple
 interface to edit all those structures.
 
@@ -58,7 +58,7 @@ under your moodle/admin dir and point your browser (as admin)
 to http://your.server/moodle/admin/xmldb
 
 The edition interface isn't completed yet (it laks 3 more forms
-to edit fields, keys and indexes) and there isn't any lang file 
+to edit fields, keys and indexes) and there isn't any lang file
 (although I hope everything is really clear).
 
 The edition interface includes one reverse-engineering tool that
@@ -69,10 +69,10 @@ Once the XMLDB format was approved, we'll be able to build all the
 "generators" needed in order to use it to create Moodle DB structures
 for each RDBMS flavour.
 
-Once the interface was finished (2-3 days from now) related documentation 
-will be sent to http://docs.moodle.org/en/XML_database_schema in order 
+Once the interface was finished (2-3 days from now) related documentation
+will be sent to http://docs.moodle.org/en/XML_database_schema in order
 to comment/modify/approve the final XML format.
 
-All the code is, obviously GPL, with its copyrights and so on... 
+All the code is, obviously GPL, with its copyrights and so on...
 
 Ciao, Eloy Lafuente (stronk7) :-)
index 225e36638a83ab228f6e5439d7bf00cab6601632..615dd1e9e1fa173709609af0130a8186677f71d9 100644 (file)
@@ -24,7 +24,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This is the main action class. It implements all the basic 
+/// This is the main action class. It implements all the basic
 /// functionalities to be shared by each action.
 
 class XMLDBAction {
@@ -58,11 +58,11 @@ class XMLDBAction {
      * Constructor to keep PHP5 happy
      */
     function __construct() {
-        $this->XMLDBAction();  
+        $this->XMLDBAction();
     }
 
-    /** 
-     * Init method, every subclass will have its own, 
+    /**
+     * Init method, every subclass will have its own,
      * always calling the parent one
      */
     function init() {
@@ -73,7 +73,7 @@ class XMLDBAction {
         $this->errormsg  = NULL;
         $this->subaction = NULL;
     }
-    
+
     /**
      * returns the type of output of the file
      */
@@ -98,14 +98,14 @@ class XMLDBAction {
     }
 
     /**
-     * getPostAtion method, returns the action to launch after executing 
+     * getPostAtion method, returns the action to launch after executing
      * another one
      */
     function getPostAction() {
         return $this->postaction;
     }
 
-    /** 
+    /**
      * getTitle method returns the title of the action (that is part
      * of the $str array attribute
      */
@@ -131,18 +131,18 @@ class XMLDBAction {
 
     /**
      * main invoke method, it simply sets the postaction attribute
-     * if possible 
+     * if possible
      */
     function invoke() {
 
         global $SESSION;
-    
+
     /// If we are used any dir, save it in the lastused session object
     /// Some actions can use it to perform positioning
         if ($lastused = optional_param ('dir', NULL, PARAM_PATH)) {
             $SESSION->lastused = stripslashes_safe($lastused);
         }
-        
+
         $this->postaction = optional_param ('postaction', NULL, PARAM_ALPHAEXT);
     /// Avoid being recursive
         if ($this->title == $this->postaction) {
@@ -166,7 +166,7 @@ class XMLDBAction {
         $result = false;
         if (file_exists($actionpath) && is_readable($actionpath)) {
             require_once($actionpath);
-            if ($xmldb_action = new $action) { 
+            if ($xmldb_action = new $action) {
                 $result = $xmldb_action->invoke();
                 if ($result) {
                     if ($xmldb_action->does_generate != ACTION_NONE &&
index 6425119c30ea28a729e7f8b6e4bfee2ab3d51a2e..8cc6390c86ab45278c426b0eb67506567903ce2f 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This class will 
+/// This class will
 
 class create_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -75,7 +75,7 @@ class create_xml_file extends XMLDBAction {
         $xmlcomment = 'XMLDB file for Moodle ' . dirname($xmlpath);
 
         $xmltable = strtolower(basename(dirname($xmlpath)));
-        
+
     /// Initial contents
         $c = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
         $c.= '  <XMLDB PATH="' . $xmlpath . '" VERSION="' . $xmlversion .'" COMMENT="' . $xmlcomment .'">' . "\n";
index 409d1073d2e12e5ee50e78e272a2fff9baf4305c..5ceadfc5f94357bad1a7f4583f2d7b799c1929ee 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_field extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -115,7 +115,7 @@ class delete_field extends XMLDBAction {
 
                     /// Recalculate the hash
                         $structure->calculateHash(true);
-                
+
                     /// If the hash has changed from the original one, change the version
                     /// and mark the structure as changed
                         $origstructure =& $dbdir->xml_file->getStructure();
@@ -129,7 +129,7 @@ class delete_field extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 772f0fa971e42ef9a298fd8f8ff42b6aed203349..f04eec5e2b8f7ce989797f704673a2bf1ef0bec5 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_index extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -115,7 +115,7 @@ class delete_index extends XMLDBAction {
 
                     /// Recalculate the hash
                         $structure->calculateHash(true);
-                
+
                     /// If the hash has changed from the original one, change the version
                     /// and mark the structure as changed
                         $origstructure =& $dbdir->xml_file->getStructure();
@@ -129,7 +129,7 @@ class delete_index extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 142978d6b6635aff19da5c0326d3e4f97423581d..0e6cb5cc193ee0a1283685fab9b440556042ac71 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_key extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -115,7 +115,7 @@ class delete_key extends XMLDBAction {
 
                     /// Recalculate the hash
                         $structure->calculateHash(true);
-                
+
                     /// If the hash has changed from the original one, change the version
                     /// and mark the structure as changed
                         $origstructure =& $dbdir->xml_file->getStructure();
@@ -129,7 +129,7 @@ class delete_key extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 5b73f5defe65d66d8c341223e2ff14fe76e102db..e3c88a78c27ef9fb2133c48e80738000c84c0bb4 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_sentence extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -108,7 +108,7 @@ class delete_sentence extends XMLDBAction {
 
                     /// Recalculate the hash
                         $structure->calculateHash(true);
-                
+
                     /// If the hash has changed from the original one, change the version
                     /// and mark the structure as changed
                         $origstructure =& $dbdir->xml_file->getStructure();
@@ -122,7 +122,7 @@ class delete_sentence extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index f5232d917e9cdbc995c1657d0ccbce4975a45adf..ab902dd39bf4ed92f2ddf1717d10678de3efb42d 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_statement extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -104,7 +104,7 @@ class delete_statement extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 18a60c0b10f442b487b14ffd247e95b07b707373..ee67c05ecd2f26806ebd6c58b5663cb48c25c302 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_table extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -104,7 +104,7 @@ class delete_table extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 6ee54d8651f0265c80f26b5fb4f0370fcc36ec2e..c3b1037618725f12e4b31e7c4b4b8c4853ad3a7a 100644 (file)
@@ -28,7 +28,7 @@
 
 class delete_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -100,7 +100,7 @@ class delete_xml_file extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index a257436c92c4f299cc67e466e45968bd3d25a9ad..71e0b04f42eae4904e793d84a5d1813f41cf32f4 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_field extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -193,7 +193,7 @@ class edit_field extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index d9727ae0467b8185d2b6bd3fd95c62bf3b79b611..b4cecf3c7ef8616b70de608ea785698fd45edf36 100644 (file)
@@ -27,7 +27,7 @@
 
 /// Register the needed events
 
-    onload=function() { 
+    onload=function() {
     /// Adjust the form on load
         transformForm();
 
index b3d9e27b3fe52e64ab2f8e325d8953895625fc2b..91f7196e41a30659cde498d8803f9385761069e8 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_field_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -152,7 +152,7 @@ class edit_field_save extends XMLDBAction {
                   $length > 0 && $length <= 20)) {
                 $errors[] = $this->str['integerincorrectlength'];
             }
-            if (!(empty($default) || (is_numeric($default) && 
+            if (!(empty($default) || (is_numeric($default) &&
                                        !empty($default) &&
                                        intval($default)==floatval($default)))) {
                 $errors[] = $this->str['defaultincorrect'];
@@ -164,35 +164,35 @@ class edit_field_save extends XMLDBAction {
                   $length > 0 && $length <= 20)) {
                 $errors[] = $this->str['numberincorrectlength'];
             }
-            if (!(empty($decimals) || (is_numeric($decimals) && 
-                                       !empty($decimals) && 
+            if (!(empty($decimals) || (is_numeric($decimals) &&
+                                       !empty($decimals) &&
                                        intval($decimals)==floatval($decimals) &&
-                                       $decimals >= 0 && 
+                                       $decimals >= 0 &&
                                        $decimals < $length))) {
                 $errors[] = $this->str['numberincorrectdecimals'];
             }
-            if (!(empty($default) || (is_numeric($default) && 
+            if (!(empty($default) || (is_numeric($default) &&
                                        !empty($default)))) {
                 $errors[] = $this->str['defaultincorrect'];
             }
         }
     /// Float checks
         if ($type == XMLDB_TYPE_FLOAT) {
-            if (!(empty($length) || (is_numeric($length) && 
-                                     !empty($length) && 
+            if (!(empty($length) || (is_numeric($length) &&
+                                     !empty($length) &&
                                      intval($length)==floatval($length) &&
-                                     $length > 0 && 
+                                     $length > 0 &&
                                      $length <= 20))) {
                 $errors[] = $this->str['floatincorrectlength'];
             }
-            if (!(empty($decimals) || (is_numeric($decimals) && 
-                                       !empty($decimals) && 
+            if (!(empty($decimals) || (is_numeric($decimals) &&
+                                       !empty($decimals) &&
                                        intval($decimals)==floatval($decimals) &&
-                                       $decimals >= 0 && 
+                                       $decimals >= 0 &&
                                        $decimals < $length))) {
                 $errors[] = $this->str['floatincorrectdecimals'];
             }
-            if (!(empty($default) || (is_numeric($default) && 
+            if (!(empty($default) || (is_numeric($default) &&
                                        !empty($default)))) {
                 $errors[] = $this->str['defaultincorrect'];
             }
@@ -259,7 +259,7 @@ class edit_field_save extends XMLDBAction {
                 }
             } else {
                 $enumerr = true;
-            } 
+            }
             if ($enumerr) {
                 $errors[] = $this->str['enumvaluesincorrect'];
             } else {
@@ -283,8 +283,8 @@ class edit_field_save extends XMLDBAction {
             $tempfield->setDefault($default);
         /// Prepare the output
             $site = get_site();
-            print_header("$site->shortname: XMLDB", 
-                         "$site->fullname", 
+            print_header("$site->shortname: XMLDB",
+                         "$site->fullname",
                          "<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
             notice ('<p>' .implode(', ', $errors) . '</p>
                      <p>' . $tempfield->readableInfo(),
@@ -309,8 +309,8 @@ class edit_field_save extends XMLDBAction {
                     $next->setChanged(true);
                 }
             }
-    
-        /// Set comment 
+
+        /// Set comment
             $field->setComment($comment);
 
         /// Set the rest of fields
@@ -323,7 +323,7 @@ class edit_field_save extends XMLDBAction {
             $field->setEnum($enum);
             $field->setEnumValues($enumvalues);
             $field->setDefault($default);
-     
+
         /// If the hash has changed from the old one, change the version
         /// and mark the structure as changed
             $field->calculateHash(true);
@@ -338,7 +338,7 @@ class edit_field_save extends XMLDBAction {
             }
 
         /// Launch postaction if exists (leave this here!)
-            if ($this->getPostAction() && $result) { 
+            if ($this->getPostAction() && $result) {
                 return $this->launch($this->getPostAction());
             }
         }
index f73dd88426b041e04effe8464c5c133dd3e1539a..5e7a5e7f715035aa209349cf4e8393484d699483 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_index extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -148,7 +148,7 @@ class edit_index extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 0ec2ebd11e468ac8ccb8e48032621d90e060ebb7..8fd2e3b5dc399a8c74ec54625d73b69539f000f6 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_index_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -164,8 +164,8 @@ class edit_index_save extends XMLDBAction {
             $tempindex->setFields($fieldsarr);
         /// Prepare the output
             $site = get_site();
-            print_header("$site->shortname: XMLDB", 
-                         "$site->fullname", 
+            print_header("$site->shortname: XMLDB",
+                         "$site->fullname",
                          "<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
             notice ('<p>' .implode(', ', $errors) . '</p>
                      <p>' . $tempindex->readableInfo(),
@@ -190,14 +190,14 @@ class edit_index_save extends XMLDBAction {
                     $next->setChanged(true);
                 }
             }
-    
-        /// Set comment 
+
+        /// Set comment
             $index->setComment($comment);
 
         /// Set the rest of fields
             $index->setUnique($unique);
             $index->setFields($fieldsarr);
-     
+
         /// If the hash has changed from the old one, change the version
         /// and mark the structure as changed
             $index->calculateHash(true);
@@ -212,7 +212,7 @@ class edit_index_save extends XMLDBAction {
             }
 
         /// Launch postaction if exists (leave this here!)
-            if ($this->getPostAction() && $result) { 
+            if ($this->getPostAction() && $result) {
                 return $this->launch($this->getPostAction());
             }
         }
index 5e2df276ac801c130074386c86a96551a5da3bc6..68812de24daad220d88e8a0936853064c2b8362a 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_key extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -160,7 +160,7 @@ class edit_key extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 8230e0f1434d6f6833a8296db41e7207fbb9b98b..eb3dd67377c509df0b8cf7ec496e8205e732e413 100644 (file)
@@ -27,7 +27,7 @@
 
 /// Register the needed events
 
-    onload=function() { 
+    onload=function() {
     /// Adjust the form on load
         transformForm();
 
index 68297d4873be4c9e44c54e45518e5a3a3b997307..ec663af8229e84ce96668f9fc7d176abe86397ab 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_key_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -187,11 +187,11 @@ class edit_key_save extends XMLDBAction {
             /// Check reftable is not empty
                 if (empty($reftable)) {
                     $errors[] = $this->str['noreftablespecified'];
-                } else 
+                } else
             /// Check reffields are not empty
                 if (empty($reffieldsarr[0])) {
                     $errors[] = $this->str['noreffieldsspecified'];
-                } else  
+                } else
             /// Check the number of fields is correct
                 if (count($fieldsarr) != count($reffieldsarr)) {
                     $errors[] = $this->str['wrongnumberofreffields'];
@@ -240,8 +240,8 @@ class edit_key_save extends XMLDBAction {
             }
         /// Prepare the output
             $site = get_site();
-            print_header("$site->shortname: XMLDB", 
-                         "$site->fullname", 
+            print_header("$site->shortname: XMLDB",
+                         "$site->fullname",
                          "<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
             notice ('<p>' .implode(', ', $errors) . '</p>
                      <p>' . $tempkey->readableInfo(),
@@ -266,8 +266,8 @@ class edit_key_save extends XMLDBAction {
                     $next->setChanged(true);
                 }
             }
-    
-        /// Set comment 
+
+        /// Set comment
             $key->setComment($comment);
 
         /// Set the rest of fields
@@ -278,7 +278,7 @@ class edit_key_save extends XMLDBAction {
                 $key->setRefTable($reftable);
                 $key->setRefFields($reffieldsarr);
             }
-     
+
         /// If the hash has changed from the old one, change the version
         /// and mark the structure as changed
             $key->calculateHash(true);
@@ -293,7 +293,7 @@ class edit_key_save extends XMLDBAction {
             }
 
         /// Launch postaction if exists (leave this here!)
-            if ($this->getPostAction() && $result) { 
+            if ($this->getPostAction() && $result) {
                 return $this->launch($this->getPostAction());
             }
         }
index 5e7ca302c8a5eaa369f0a254509c3bdad75b3afe..24bf5902722e11f50b0e78d331861c0fdd01a7e7 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_sentence extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -137,12 +137,12 @@ class edit_sentence extends XMLDBAction {
             $b .= '&nbsp;<a href="index.php?action=edit_statement&amp;statement=' . urlencode($statementparam) . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['back'] . ']</a>';
             $b .= '</p>';
             $o .= $b;
-    
+
             $this->output = $o;
         }
-    
+
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index c9990ed9c1198aed3555b8852a37c57f1eef66b4..426b6d72bc862a2722325b1f68a093d7e80cc5e8 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_sentence_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -116,12 +116,12 @@ class edit_sentence_save extends XMLDBAction {
         if ($result && count($fields) != count($values)) {
             $errors[] = $this->str['wrongnumberoffieldsorvalues'];
         }
-        
+
         if (!empty($errors)) {
         /// Prepare the output
             $site = get_site();
-            print_header("$site->shortname: XMLDB", 
-                         "$site->fullname", 
+            print_header("$site->shortname: XMLDB",
+                         "$site->fullname",
                          "<a href=\"../index.php\">" . $this->str['administration'] . "</a> -> <a href=\"index.php\">XMLDB</a>");
             notice ('<p>' .implode(', ', $errors) . '</p>
                      <p>' . s($sentence),
@@ -132,7 +132,7 @@ class edit_sentence_save extends XMLDBAction {
     /// Continue if we aren't under errors
         if (empty($errors)) {
             $sentences[$sentenceparam] = $sentence;
-     
+
         /// If the sentence has changed from the old one, change the version
         /// and mark the statement and structure as changed
             if ($oldsentence != $sentence) {
@@ -143,7 +143,7 @@ class edit_sentence_save extends XMLDBAction {
             }
 
         /// Launch postaction if exists (leave this here!)
-            if ($this->getPostAction() && $result) { 
+            if ($this->getPostAction() && $result) {
                 return $this->launch($this->getPostAction());
             }
         }
index c47d59e4fc06ea9582e96d3e0ff221aa0e2a7086..f109b6988348fb7f1499227e825f759f2f28d1c6 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_statement extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -138,7 +138,7 @@ class edit_statement extends XMLDBAction {
         ///$statement->deleteSentence('changeme');
 
     /// Add the fields list
-        $sentences =& $statement->getSentences(); 
+        $sentences =& $statement->getSentences();
         if (!empty($sentences)) {
             $o .= '<h3 class="main">' . $this->str['sentences'] . '</h3>';
             $o .= '<table id="listfields" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -162,7 +162,7 @@ class edit_statement extends XMLDBAction {
                 $b .= '<a href="index.php?action=delete_sentence&amp;sentence=' . $key . '&amp;statement=' . urlencode($statement->getName()) . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';
                 $b .= '</td>';
             /// Print table row
-            $o .= '<tr class="r' . $row . '"><td class="table cell">' . $p . $sentence . $b . '</tr>'; 
+            $o .= '<tr class="r' . $row . '"><td class="table cell">' . $p . $sentence . $b . '</tr>';
                 $row = ($row + 1) % 2;
             }
             $o .= '</table>';
@@ -171,7 +171,7 @@ class edit_statement extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 56016a1aa7047ed721403817a129768667d7c706..b8de4e01c563eaaf894445114ef6c42090e1d1fd 100644 (file)
@@ -29,7 +29,7 @@
 
 class edit_statement_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -93,11 +93,11 @@ class edit_statement_save extends XMLDBAction {
             }
         }
 
-    /// Set comment 
+    /// Set comment
         $statement->setComment($comment);
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 828b38252bd6a41fac06d9ee6a3237438c7aa629..f386e460e8ac6d05034eafbfff60956c8b40f59f 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_table extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -167,7 +167,7 @@ class edit_table extends XMLDBAction {
         $table->deleteIndex('changeme');
 
     /// Add the fields list
-        $fields =& $table->getFields(); 
+        $fields =& $table->getFields();
         if (!empty($fields)) {
             $o .= '<h3 class="main">' . $this->str['fields'] . '</h3>';
             $o .= '<table id="listfields" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -197,7 +197,7 @@ class edit_table extends XMLDBAction {
                 }
                 $b .= '</td><td class="button cell">';
             /// The delete button (if we have more than one and it isn't used
-                if (count($fields) > 1 && 
+                if (count($fields) > 1 &&
                 !$structure->getFieldUses($table->getName(), $field->getName())) {
                     $b .= '<a href="index.php?action=delete_field&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';
                 } else {
@@ -210,13 +210,13 @@ class edit_table extends XMLDBAction {
             /// The readable info
                 $r = '</td><td class="readableinfo cell">' . $field->readableInfo() . '</td>';
             /// Print table row
-            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_field_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $field->getName() . '</a>' . $b . $r . '</tr>'; 
+            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_field_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;field=' . $field->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $field->getName() . '</a>' . $b . $r . '</tr>';
                 $row = ($row + 1) % 2;
             }
             $o .= '</table>';
         }
     /// Add the keys list
-        $keys =& $table->getKeys(); 
+        $keys =& $table->getKeys();
         if (!empty($keys)) {
             $o .= '<h3 class="main">' . $this->str['keys'] . '</h3>';
             $o .= '<table id="listkeys" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -254,13 +254,13 @@ class edit_table extends XMLDBAction {
             /// The readable info
                 $r = '</td><td class="readableinfo cell">' . $key->readableInfo() . '</td>';
             /// Print table row
-            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_key_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $key->getName() . '</a>' . $b . $r .'</tr>'; 
+            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_key_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;key=' . $key->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $key->getName() . '</a>' . $b . $r .'</tr>';
                 $row = ($row + 1) % 2;
             }
             $o .= '</table>';
         }
    /// Add the indexes list
-        $indexes =& $table->getIndexes(); 
+        $indexes =& $table->getIndexes();
         if (!empty($indexes)) {
             $o .= '<h3 class="main">' . $this->str['indexes'] . '</h3>';
             $o .= '<table id="listindexes" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -290,7 +290,7 @@ class edit_table extends XMLDBAction {
             /// The readable info
                 $r = '</td><td class="readableinfo cell">' . $index->readableInfo() . '</td>';
             /// Print table row
-            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_index_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $index->getName() . '</a>' . $b . $r .'</tr>'; 
+            $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_index_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;index=' . $index->getName() . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $index->getName() . '</a>' . $b . $r .'</tr>';
                 $row = ($row + 1) % 2;
             }
             $o .= '</table>';
@@ -299,7 +299,7 @@ class edit_table extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index ca7698308bc8f79e935e9a2697839e7bda4882dd..a2afd3c218d635fda416e3aaf895e513d7df078d 100644 (file)
@@ -29,7 +29,7 @@
 
 class edit_table_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -127,11 +127,11 @@ class edit_table_save extends XMLDBAction {
             }
         }
 
-    /// Set comment 
+    /// Set comment
         $table->setComment($comment);
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 74c93bfa277da8a721b401318925490b53983353..48f2976ec64f71e052eccfadb44a4fab84160458 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -155,7 +155,7 @@ class edit_xml_file extends XMLDBAction {
                 sort($reserved_words);
                 $reserved_words = array_unique($reserved_words);
             /// Add the tables list
-                $tables =& $structure->getTables(); 
+                $tables =& $structure->getTables();
                 if ($tables) {
                     $o .= '<h3 class="main">' . $this->str['tables'] . '</h3>';
                     $o .= '<table id="listtables" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -194,13 +194,13 @@ class edit_xml_file extends XMLDBAction {
                          }
                         $b .= '</td>';
                     /// Print table row
-                        $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_table_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $table->getName() . '</a>' . $b . '</tr>'; 
+                        $o .= '<tr class="r' . $row . '"><td class="table cell"><a href="index.php?action=view_table_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;table=' . $table->getName() . '&amp;select=edited" target="_blank">' . $table->getName() . '</a>' . $b . '</tr>';
                         $row = ($row + 1) % 2;
                     }
                     $o .= '</table>';
                 }
             ///Add the statements list
-                $statements =& $structure->getStatements(); 
+                $statements =& $structure->getStatements();
                 if ($statements) {
                     $o .= '<h3 class="main">' . $this->str['statements'] . '</h3>';
                     $o .= '<table id="liststatements" border="0" align="center"  cellpadding="5" cellspacing="1" class="flexible">';
@@ -229,7 +229,7 @@ class edit_xml_file extends XMLDBAction {
                         $b .= '<a href="index.php?action=delete_statement&amp;statement=' . $statement->getName() . '&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '">[' . $this->str['delete'] . ']</a>';
                         $b .= '</td>';
                     /// Print statement row
-                        $o .= '<tr class="r' . $row . '"><td class="statement cell"><a href="index.php?action=view_statement_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;statement=' . $statement->getName() . '&amp;select=edited" target="_blank">' . $statement->getName() . '</a>' . $b . '</tr>'; 
+                        $o .= '<tr class="r' . $row . '"><td class="statement cell"><a href="index.php?action=view_statement_xml&amp;dir=' . urlencode(str_replace($CFG->dirroot, '', $dirpath)) . '&amp;statement=' . $statement->getName() . '&amp;select=edited" target="_blank">' . $statement->getName() . '</a>' . $b . '</tr>';
                         $row = ($row + 1) % 2;
                     }
                     $o .= '</table>';
index 52b4714ced509f4f4aa3c4ea8a947e01df44116c..ac6e89d72dd1a013208c09b6838de976a2940a02 100644 (file)
@@ -28,7 +28,7 @@
 
 class edit_xml_file_save extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -89,7 +89,7 @@ class edit_xml_file_save extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index e8b10d6329bf8fe29ac6d729a07545ddbfec01fb..172f2e6b6b506db2cd0e1c0896609dec0522e591 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This class will check all the db directories existing under the 
+/// This class will check all the db directories existing under the
 /// current Moodle installation, sending them to the SESSION->dbdirs array
 
 class get_db_directories extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -89,7 +89,7 @@ class get_db_directories extends XMLDBAction {
                 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path);  //Update status
             }
         }
-        
+
     /// Now, question types (question/type/xxx/db)
         if ($plugins = get_list_of_plugins('question/type')) {
             foreach ($plugins as $plugin) {
@@ -101,7 +101,7 @@ class get_db_directories extends XMLDBAction {
                 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path);  //Update status
             }
         }
-        
+
     /// Now, backup/restore stuff (backup/db)
         $dbdir = new stdClass;
         $dbdir->path = $CFG->dirroot . '/backup/db';
@@ -129,7 +129,7 @@ class get_db_directories extends XMLDBAction {
                 $XMLDB->dbdirs[$dbdir->path]->path_exists = file_exists($dbdir->path);  //Update status
             }
         }
-        
+
     /// Now, enrolment plugins (enrol/xxx/db)
         if ($plugins = get_list_of_plugins('enrol', 'db')) {
             foreach ($plugins as $plugin) {
@@ -143,7 +143,7 @@ class get_db_directories extends XMLDBAction {
         }
     /// Sort by key
         ksort($XMLDB->dbdirs);
-        
+
     /// Return ok if arrived here
         return true;
     }
index 32c35464b9745457e4ff4c73d9726f8d38510b5c..0922b2b2cfb246fb79f928d3dd24e3f2e32848ae 100644 (file)
@@ -28,7 +28,7 @@
 
 class load_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index 008bd9afd86629c24108f7099a15fd8d25e531d1..509e9d56ed9696a10ef9c0fc75fd61e67515c599 100644 (file)
@@ -28,7 +28,7 @@
 
 class load_xml_files extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index 44a72015f0b7a05cfc4cba426814054a1e23309a..3f0d941ce6f0dc34beb12802ddd3fcfbee2204f1 100644 (file)
@@ -28,7 +28,7 @@
 
 class main_view extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index a66a3fb413e6d65d0d9f7611959a1b138bf838ec..db866808186d3c534305a6ad83b1d675e79ad7e4 100644 (file)
@@ -28,7 +28,7 @@
 
 class move_updown_field extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -119,7 +119,7 @@ class move_updown_field extends XMLDBAction {
 
     /// Table has changed
         $table->setChanged(true);
-        
+
     /// Reorder the fields
         $table->orderFields($fields);
 
@@ -135,7 +135,7 @@ class move_updown_field extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index b1174ff45a930476ee3c86c8d1d064f6fd05037f..5ed9957a7e85af1c6775bb9c107d9ece54f664f0 100644 (file)
@@ -28,7 +28,7 @@
 
 class move_updown_index extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -119,7 +119,7 @@ class move_updown_index extends XMLDBAction {
 
     /// Table has changed
         $table->setChanged(true);
-        
+
     /// Reorder the indexes
         $table->orderIndexes($indexes);
 
@@ -135,7 +135,7 @@ class move_updown_index extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 5477387f99359323bd850d98000612b02648f71d..f39a1425d9499e302754b15ca99241564df5bd48 100644 (file)
@@ -28,7 +28,7 @@
 
 class move_updown_key extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -119,7 +119,7 @@ class move_updown_key extends XMLDBAction {
 
     /// Table has changed
         $table->setChanged(true);
-        
+
     /// Reorder the keys
         $table->orderKeys($keys);
 
@@ -135,7 +135,7 @@ class move_updown_key extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 15116bfa1817998b6d2cf2de6382acb5dc517eb6..91e2db6a9fd34865e3dcfbfdd668c54e27fd2d51 100644 (file)
@@ -28,7 +28,7 @@
 
 class move_updown_statement extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -112,7 +112,7 @@ class move_updown_statement extends XMLDBAction {
 
     /// Statement has changed
         $statement->setChanged(true);
-        
+
     /// Reorder the structure
         $structure->orderStatements($statements);
     /// Send statements back to structure (the order above break refs)
@@ -129,7 +129,7 @@ class move_updown_statement extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index b2dd3ed891f3cab3e6e0b75984e14cec459af04c..2355ed6ac724d39461960f176d0e36cbfc2387a2 100644 (file)
@@ -28,7 +28,7 @@
 
 class move_updown_table extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -112,7 +112,7 @@ class move_updown_table extends XMLDBAction {
 
     /// Table has changed
         $table->setChanged(true);
-        
+
     /// Reorder the structure
         $structure->orderTables($tables);
     /// Send tables back to structure (the order above break refs)
@@ -129,7 +129,7 @@ class move_updown_table extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index d4b8425207b9ea4bfe951a731e77ad9b66492ee6..d590a355b78b0150cc2cc3541bb0a8e05ea5ee5a 100644 (file)
@@ -28,7 +28,7 @@
 
 class new_field extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -98,7 +98,7 @@ class new_field extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 8417bda4d4f0c99a881f9bc81ca2632cf07ede07..08decba315649da49e55dc4508cdccc143758b6c 100644 (file)
@@ -28,7 +28,7 @@
 
 class new_index extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -97,7 +97,7 @@ class new_index extends XMLDBAction {
             $structure->setChanged(true);
         }
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index ddf0495d96fa553d000e8c5260508d33fca99aad..8b720bdfdcb9181cd1b62a810e8db590dcaa2e8a 100644 (file)
@@ -28,7 +28,7 @@
 
 class new_key extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -97,7 +97,7 @@ class new_key extends XMLDBAction {
             $structure->setChanged(true);
         }
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 305b34c667e042742490d08e25eb0534f1a8016d..502ba1ff9597a706a941d7763df1a127874154af 100644 (file)
@@ -30,7 +30,7 @@
 
 class new_sentence extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -109,7 +109,7 @@ class new_sentence extends XMLDBAction {
         $structure->setChanged(true);
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 526d58d0efc6d46c3a368eb2fc796b07cf3ef9ea..b6a72b265eda892c27f1a7fa334f9ce871e9182c 100644 (file)
@@ -29,7 +29,7 @@
 
 class new_statement extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -116,7 +116,7 @@ class new_statement extends XMLDBAction {
             $this->output = $o;
 
 
-    /// If table, retrofit information and, if everything works, 
+    /// If table, retrofit information and, if everything works,
     /// go to the table edit action
         } else {
         /// Get some params (table is mandatory here)
@@ -150,7 +150,7 @@ class new_statement extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index da7b34228742a333d176ad10cda3cdf5a96cefa7..08cf5d927547024a5797a131340e5f0b60c91ee3 100644 (file)
@@ -28,7 +28,7 @@
 
 class new_table extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -110,7 +110,7 @@ class new_table extends XMLDBAction {
             $structure->addTable($table);
         }
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index df3cd84f8fc81c76565e4a3241f5e8d1c0cb1205..4fd62e84b54f345d9424308244fa9edc24abeab0 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This class will ask and retrofit all the information from one 
+/// This class will ask and retrofit all the information from one
 /// mysql table present in the Moodle DB to one XMLDBTable structure
 
 class new_table_from_mysql extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -120,7 +120,7 @@ class new_table_from_mysql extends XMLDBAction {
             $this->output = $o;
 
 
-    /// If table, retrofit information and, if everything works, 
+    /// If table, retrofit information and, if everything works,
     /// go to the table edit action
         } else {
         /// Get some params (table is mandatory here)
@@ -180,7 +180,7 @@ class new_table_from_mysql extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 0a063a502feecac4ba93bdb402fa51cea173d1f2..1c7d74c469f1773f452bf1338809fa5d8f2d32ec 100644 (file)
@@ -28,7 +28,7 @@
 
 class revert_changes extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -106,7 +106,7 @@ class revert_changes extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 60f5810cf85adce78e9f1267cd4d6f799607f037..89ed224a3161c88bca210440b8b695e963251300 100644 (file)
@@ -28,7 +28,7 @@
 
 class save_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -64,7 +64,7 @@ class save_xml_file extends XMLDBAction {
         $dirpath = required_param('dir', PARAM_PATH);
         $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
 
-    /// Get the edited dir 
+    /// Get the edited dir
         if (!empty($XMLDB->editeddirs)) {
             if (isset($XMLDB->editeddirs[$dirpath])) {
                 $editeddir =& $XMLDB->editeddirs[$dirpath];
@@ -102,7 +102,7 @@ class save_xml_file extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index c187dfa3d6f2716ed9cbd12f2c7f356b2363a88c..1df34a9244219f01bb2a080fdbe0f24ba885fa5d 100644 (file)
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This class will 
+/// This class will
 
 class template extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -80,7 +80,7 @@ class template extends XMLDBAction {
 
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 890d95db5fd66a74948a03553bc49c31a50362cd..49b357a2fa5c6e8587f3a8606faae1bb628ca7b8 100644 (file)
@@ -29,7 +29,7 @@
 
 class test extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -185,7 +185,7 @@ class test extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index c04cdd4369468b4e3c3f5421ec0f9bb746adab49..eba9d001f3cb7118527b120517bb8a7cd128f910 100644 (file)
@@ -28,7 +28,7 @@
 
 class unload_xml_file extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -86,7 +86,7 @@ class unload_xml_file extends XMLDBAction {
         }
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 0fbba22f0e7efe8b61dbf71ea58172a90aac4704..a18505b57c31c19a45fcd027cefeb239b9168def 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_field_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index d8c569777481a77b0a39579977073f26332429d1..016c16d3e87e7deb177c15aba36fd909379d1302 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_index_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index 86c3ace7f59003d604de7f7ffe2a8c4f106a8e2b..d271f5b119994a208b9b776105b8f1d6f7e011a4 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_key_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index d7e4356d01caf9c07a79778f9a4d6c84f5601f8d..d19665b1ab200d054faf4976f51c4f9dc58c09bc 100644 (file)
@@ -31,7 +31,7 @@
 
 class view_reserved_words extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -93,7 +93,7 @@ class view_reserved_words extends XMLDBAction {
                         }
                     }
                     $wronguses[] = $this->str['table'] . ' - ' . $table . ' (' . implode(', ',$list_of_db) . ')';
-                    
+
                 }
                 $dbfields = $db->MetaColumns($dbtable);
                 if ($dbfields) {
@@ -142,7 +142,7 @@ class view_reserved_words extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index 6332b221c163d801cae4ec3ee650c08971c68e44..89fea5cbcef813ee9ee856151d6999d2f8ee71f2 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_statement_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index df0b7b625607d6d12367d0babed79104be1b030e..b23fa6dfbc8fa60673d6090393cae2031904b62f 100644 (file)
@@ -29,7 +29,7 @@
 
 class view_structure_php extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -78,7 +78,7 @@ class view_structure_php extends XMLDBAction {
             $structure =& $editeddir->xml_file->getStructure();
         }
     /// ADD YOUR CODE HERE
-      
+
         $tables =& $structure->getTables();
         $table = reset($tables);
         $defaulttable = null;
@@ -97,7 +97,7 @@ class view_structure_php extends XMLDBAction {
         $o = $b;
 
     /// Calculate the popup of commands
-        $commands = array('create_table', 
+        $commands = array('create_table',
                          'drop_table',
                          'rename_table');
         foreach ($commands as $command) {
@@ -136,7 +136,7 @@ class view_structure_php extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
@@ -145,9 +145,9 @@ class view_structure_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * create one table using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table code to be created
      * @return string PHP code to be used to create the table
@@ -220,9 +220,9 @@ class view_structure_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * drop one table using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table code to be dropped
      * @return string PHP code to be used to drop the table
@@ -258,9 +258,9 @@ class view_structure_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * rename one table using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table code to be renamed
      * @return string PHP code to be used to rename the table
index 36fbb8e753275c6e593e4adba2bd041e404de944..0786004fabd0d801863f35a4ba6d40bd6c2f7370 100644 (file)
@@ -29,7 +29,7 @@
 
 class view_structure_sql extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -123,7 +123,7 @@ class view_structure_sql extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index bdae8e3eb74a2ddf354d11fa384afbd0dd169a87..b84528509a90efe2cbbcdd67375972a883310460 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_structure_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index 764b26d2bee2db7301ee46392858a4109cdb677e..6c4584d4a91c48903ec4c6d9bd6d7a81009e6250 100644 (file)
@@ -29,7 +29,7 @@
 
 class view_table_php extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -82,7 +82,7 @@ class view_table_php extends XMLDBAction {
     /// ADD YOUR CODE HERE
 
         $tableparam = required_param('table', PARAM_PATH);
-      
+
         $table =& $structure->getTable($tableparam);
         $fields = $table->getFields();
         $field = reset($fields);
@@ -108,7 +108,7 @@ class view_table_php extends XMLDBAction {
         $o .= '<h3 class="main">' . $this->str['table'] . ': ' . s($tableparam) . '</h3>';
 
     /// Calculate the popup of commands
-        $commands = array('add_field', 
+        $commands = array('add_field',
                          'drop_field',
                          'rename_field');
         foreach ($commands as $command) {
@@ -171,7 +171,7 @@ class view_table_php extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
@@ -180,9 +180,9 @@ class view_table_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * create one field using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table name
      * @param string field field name to be created
@@ -224,9 +224,9 @@ class view_table_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * drop one field using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table name
      * @param string field field name to be dropped
@@ -267,9 +267,9 @@ class view_table_php extends XMLDBAction {
     }
 
     /**
-     * This function will generate all the PHP code needed to 
+     * This function will generate all the PHP code needed to
      * rename one field using XMLDB objects and functions
-     * 
+     *
      * @param XMLDBStructure structure object containing all the info
      * @param string table table name
      * @param string field field name to be renamed
index fcd9dded1f9fca348f42f1886ee944875843d550..1fb1d888bfe0ce4619a2a8730c54110e0bbde6aa 100644 (file)
 /**
  * This function disables some elements from the fields/keys/indexes drop down
  */
-function disablePopupHeads() {    
-    var popup = document.getElementById("menufieldkeyindex");    
-    var i = popup.length;    
-    while (i--) {        
-        option = popup[i];        
-        if (option.value == "fieldshead" || option.value == "keyshead" || option.value == "indexeshead") { 
-            popup[i].disabled = true;        
-        }    
+function disablePopupHeads() {
+    var popup = document.getElementById("menufieldkeyindex");
+    var i = popup.length;
+    while (i--) {
+        option = popup[i];
+        if (option.value == "fieldshead" || option.value == "keyshead" || option.value == "indexeshead") {
+            popup[i].disabled = true;
+        }
     }
 }
index cb6de34e75116a5e3edde41e8c9ebdb5a90f15ad..c1488f97ec6fb9b18c428dcd7d4174108d27a508 100644 (file)
@@ -29,7 +29,7 @@
 
 class view_table_sql extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -128,7 +128,7 @@ class view_table_sql extends XMLDBAction {
         $this->output = $o;
 
     /// Launch postaction if exists (leave this here!)
-        if ($this->getPostAction() && $result) { 
+        if ($this->getPostAction() && $result) {
             return $this->launch($this->getPostAction());
         }
 
index d8070510cdeade4acebaa4aff690d7fc55c59b7e..36ad3f771764e755597666fd058d947cf7ffb2d3 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_table_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
index e1bd483e33ddf6ab919f98e9f31fc5f7cd54f0de..5e5872d44594aefe6f12e5e13155f857a01150ec 100644 (file)
@@ -28,7 +28,7 @@
 
 class view_xml extends XMLDBAction {
 
-    /** 
+    /**
      * Init method, every subclass will have its own
      */
     function init() {
@@ -66,7 +66,7 @@ class view_xml extends XMLDBAction {
     /// Get the file parameter
         $file = required_param('file', PARAM_PATH);
         $file = $CFG->dirroot . stripslashes_safe($file);
-    /// File must be under $CFG->wwwroot and 
+    /// File must be under $CFG->wwwroot and
     ///  under one db directory (simple protection)
         if (substr($file, 0, strlen($CFG->dirroot)) == $CFG->dirroot &&
             substr(dirname($file), -2, 2) == 'db') {
index 6b03c05e85270e34899c4b2b672a7d6d65a74790..91632a3818d8b10c82e8bc1e02a0db6acd23316a 100644 (file)
@@ -46,7 +46,7 @@
     require_once('../../lib/xmldb/classes/XMLDBIndex.class.php');
     require_once('../../lib/xmldb/classes/XMLDBStatement.class.php');
 
-/// Add Moodle config script (this is loaded AFTER all the rest 
+/// Add Moodle config script (this is loaded AFTER all the rest
 /// of classes because it starts the SESSION and classes to be
 /// stored there MUST be declared before in order to avoid
 /// getting "incomplete" objects
@@ -81,7 +81,7 @@
     $stradministration = get_string('administration');
 
 /// Body of the script, based on action, we delegate the work
-    $action = optional_param ('action', 'main_view', PARAM_ALPHAEXT); 
+    $action = optional_param ('action', 'main_view', PARAM_ALPHAEXT);
 
 /// Get the action path and invoke it
     $actionsroot = "$CFG->dirroot/$CFG->admin/xmldb/actions";
             /// Based on getDoesGenerate()
                 switch ($xmldb_action->getDoesGenerate()) {
                     case ACTION_GENERATE_HTML:
-                    /// Define $CFG->javascript to use our custom javascripts. 
+                    /// Define $CFG->javascript to use our custom javascripts.
                     /// Save the original one to add it from ours. Global too! :-(
                         global $standard_javascript;
                         $standard_javascript = $CFG->javascript;  // Save original javascript file
                         $CFG->javascript = $CFG->dirroot.'/admin/xmldb/javascript.php';  //Use our custom javascript code
                     /// Go with standard header
-                        print_header("$site->shortname: XMLDB", 
-                                     "$site->fullname", 
+                        print_header("$site->shortname: XMLDB",
+                                     "$site->fullname",
                                      "<a href=\"../index.php\">$stradministration</a> -> <a href=\"index.php\">XMLDB</a>");
                         print_heading($xmldb_action->getTitle());
                         echo $xmldb_action->getOutput();
         error ("Error: wrong action specified ($action)");
     }
 
-    if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {  
+    if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {
         if (debugging()) {
             ///print_object($XMLDB);
         }
index f46264d97a5d55741e801424963efe113c0e4a25..a04b5a02c8cee3a78e9d507756bba3670843696c 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $block_rss_client_capabilities = array(
-    
+
     'block/rss_client:createprivatefeeds' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -46,9 +46,9 @@ $block_rss_client_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'block/rss_client:createsharedfeeds' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -60,9 +60,9 @@ $block_rss_client_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'block/rss_client:manageownfeeds' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -74,9 +74,9 @@ $block_rss_client_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'block/rss_client:manageanyfeeds' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -88,7 +88,7 @@ $block_rss_client_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
\ No newline at end of file
index a961b709f2f99305c8d76dce9d6c63d730a359c2..e7c825a38da67f53a4323f47e7ee220fa7c72796 100755 (executable)
@@ -69,10 +69,10 @@ function load_guest_role($context=NULL) {
         }
     }
 
-    if ($capabilities = get_records_select('role_capabilities', 
+    if ($capabilities = get_records_select('role_capabilities',
                                            "roleid = $guestrole->id AND contextid = $sitecontext->id")) {
         foreach ($capabilities as $capability) {
-            $USER->capabilities[$context->id][$capability->capability] = $capability->permission;     
+            $USER->capabilities[$context->id][$capability->capability] = $capability->permission;
         }
     }
 
@@ -81,7 +81,7 @@ function load_guest_role($context=NULL) {
 
 /**
  * Load default not logged in role capabilities when user is not logged in
- * @return bool 
+ * @return bool
  */
 function load_notloggedin_role() {
     global $CFG, $USER;
@@ -98,10 +98,10 @@ function load_notloggedin_role() {
         }
     }
 
-    if ($capabilities = get_records_select('role_capabilities', 
+    if ($capabilities = get_records_select('role_capabilities',
                                      "roleid = $CFG->notloggedinroleid AND contextid = $sitecontext->id")) {
         foreach ($capabilities as $capability) {
-            $USER->capabilities[$sitecontext->id][$capability->capability] = $capability->permission;     
+            $USER->capabilities[$sitecontext->id][$capability->capability] = $capability->permission;
         }
     }
 
@@ -110,7 +110,7 @@ function load_notloggedin_role() {
 
 /**
  * Load default not logged in role capabilities when user is not logged in
- * @return bool 
+ * @return bool
  */
 function load_defaultuser_role() {
     global $CFG, $USER;
@@ -127,18 +127,18 @@ function load_defaultuser_role() {
         }
     }
 
-    if ($capabilities = get_records_select('role_capabilities', 
+    if ($capabilities = get_records_select('role_capabilities',
                                      "roleid = $CFG->defaultuserroleid AND contextid = $sitecontext->id")) {
         foreach ($capabilities as $capability) {
             if (!isset($USER->capabilities[$sitecontext->id][$capability->capability])) {  // Don't overwrite
-                $USER->capabilities[$sitecontext->id][$capability->capability] = $capability->permission;     
+                $USER->capabilities[$sitecontext->id][$capability->capability] = $capability->permission;
             }
         }
 
-        // SPECIAL EXCEPTION:  If the default user role is actually a guest role, then 
+        // SPECIAL EXCEPTION:  If the default user role is actually a guest role, then
         // remove some capabilities so this user doesn't get confused with a REAL guest
         if (isset($USER->capabilities[$sitecontext->id]['moodle/legacy:guest']) and $USER->username != 'guest') {
-            unset($USER->capabilities[$sitecontext->id]['moodle/legacy:guest']); 
+            unset($USER->capabilities[$sitecontext->id]['moodle/legacy:guest']);
             unset($USER->capabilities[$sitecontext->id]['moodle/course:view']);  // No access to courses by default
         }
     }
@@ -167,9 +167,9 @@ function get_guest_role() {
  * @return array of contextids
  */
 function get_parent_cats($context, $type) {
-    
+
     $parents = array();
-    
+
     switch ($type) {
         case CONTEXT_COURSECAT:
             if (!$cat = get_record('course_categories','id',$context->instanceid)) {
@@ -184,7 +184,7 @@ function get_parent_cats($context, $type) {
                 $cat = get_record('course_categories','id',$cat->parent);
             }
         break;
-        
+
         case CONTEXT_COURSE:
             if (!$course = get_record('course', 'id', $context->instanceid)) {
                 break;
@@ -207,7 +207,7 @@ function get_parent_cats($context, $type) {
                 $cat = get_record('course_categories','id',$cat->parent);
             }
         break;
-        
+
         default:
         break;
     }
@@ -226,7 +226,7 @@ function get_parent_cats($context, $type) {
  * @param string $errorstring - an errorstring
  * @param string $stringfile - which stringfile to get it from
  */
-function require_capability($capability, $context=NULL, $userid=NULL, $doanything=true, 
+function require_capability($capability, $context=NULL, $userid=NULL, $doanything=true,
                             $errormessage="nopermissions", $stringfile='') {
 
     global $USER;
@@ -240,7 +240,7 @@ function require_capability($capability, $context=NULL, $userid=NULL, $doanythin
             require_login();
         }
     }
-   
+
 /// OK, if they still don't have the capability then print a nice error message
 
     if (!has_capability($capability, $context, $userid, $doanything)) {
@@ -306,9 +306,9 @@ function has_capability($capability, $context=NULL, $userid=NULL, $doanything=tr
         if (isset($capabilities[$sitecontext->id]['moodle/site:doanything'])) {
             return (0 < $capabilities[$sitecontext->id]['moodle/site:doanything']);
         }
-    
+
         switch ($context->aggregatelevel) {
-        
+
             case CONTEXT_COURSECAT:
                 // Check parent cats.
                 $parentcats = get_parent_cats($context, CONTEXT_COURSECAT);
@@ -531,7 +531,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
     $usercontexts = array();
 
     if ($context) { // if context is specified
-        $usercontexts = get_parent_contexts($context);          
+        $usercontexts = get_parent_contexts($context);
     } else { // else, we load everything
         if ($userroles = get_records('role_assignments','userid',$userid)) {
             foreach ($userroles as $userrole) {
@@ -553,7 +553,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
     if ($capability) {
         $capsearch = " AND rc.capability = '$capability' ";
     } else {
-        $capsearch ="";  
+        $capsearch ="";
     }
 
 /// Then we use 1 giant SQL to bring out all relevant capabilities.
@@ -565,7 +565,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
     $SQL = " SELECT  rc.capability, c1.id, (c1.aggregatelevel * 100) AS aggrlevel,
                      SUM(rc.permission) AS sum
                      FROM
-                     {$CFG->prefix}role_assignments ra, 
+                     {$CFG->prefix}role_assignments ra,
                      {$CFG->prefix}role_capabilities rc,
                      {$CFG->prefix}context c1
                      WHERE
@@ -573,7 +573,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
                      ra.roleid=rc.roleid AND
                      ra.userid=$userid AND
                      $searchcontexts1
-                     rc.contextid=$siteinstance->id 
+                     rc.contextid=$siteinstance->id
                      $capsearch
               GROUP BY
                      rc.capability, (c1.aggregatelevel * 100), c1.id
@@ -590,14 +590,14 @@ function load_user_capability($capability='', $context ='', $userid='') {
                      {$CFG->prefix}context c2
                      WHERE
                      ra.contextid=c1.id AND
-                     ra.roleid=rc.roleid AND 
-                     ra.userid=$userid AND         
-                     rc.contextid=c2.id AND             
+                     ra.roleid=rc.roleid AND
+                     ra.userid=$userid AND
+                     rc.contextid=c2.id AND
                      $searchcontexts1
                      $searchcontexts2
                      rc.contextid != $siteinstance->id
                      $capsearch
-                  
+
               GROUP BY
                      rc.capability, (c1.aggregatelevel * 100 + c2.aggregatelevel), c1.id
                      HAVING
@@ -615,7 +615,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
         while (!$rs->EOF) {
             $array = $rs->fields;
             $temprecord = new object;
-              
+
             foreach ($array as $key=>$val) {
                 if ($key == 'aggrlevel') {
                     $temprecord->aggregatelevel = $val;
@@ -627,14 +627,14 @@ function load_user_capability($capability='', $context ='', $userid='') {
             $rs->MoveNext();
         }
     }
-    
+
     /* so up to this point we should have somethign like this
      * $capabilities[1]    ->aggregatelevel = 1000
                            ->module = SITEID
                            ->capability = do_anything
                            ->id = 1 (id is the context id)
                            ->sum = 0
-                           
+
      * $capabilities[2]     ->aggregatelevel = 1000
                             ->module = SITEID
                             ->capability = post_messages
@@ -652,7 +652,7 @@ function load_user_capability($capability='', $context ='', $userid='') {
                             ->capability = view_course_activities
                             ->id = 26
                             ->sum = 0 (this is another course)
-                            
+
      * $capabilities[5]     ->aggregatelevel = 3050
                             ->module = course
                             ->capability = view_course_activities
@@ -680,21 +680,21 @@ function load_user_capability($capability='', $context ='', $userid='') {
         $context = get_context_instance_by_id($capability->id);
 
         if (!empty($otheruserid)) { // we are pulling out other user's capabilities, do not write to session
-            
+
             if (capability_prohibits($capability->capability, $context, $capability->sum, $usercap)) {
                 $usercap[$capability->id][$capability->capability] = -9000;
                 continue;
             }
 
-            $usercap[$capability->id][$capability->capability] = $capability->sum;          
-          
+            $usercap[$capability->id][$capability->capability] = $capability->sum;
+
         } else {
 
             if (capability_prohibits($capability->capability, $context, $capability->sum)) { // if any parent or parent's parent is set to prohibit
                 $USER->capabilities[$capability->id][$capability->capability] = -9000;
                 continue;
             }
-    
+
             // if no parental prohibit set
             // just write to session, i am not sure this is correct yet
             // since 3050 shows up after 3000, and 3070 shows up after 3050,
@@ -705,12 +705,12 @@ function load_user_capability($capability='', $context ='', $userid='') {
             $USER->capabilities[$capability->id][$capability->capability] = $capability->sum;
         }
     }
-    
+
     // now we don't care about the huge array anymore, we can dispose it.
     unset($capabilities);
-    
+
     if (!empty($otheruserid)) {
-        return $usercap; // return the array  
+        return $usercap; // return the array
     }
     // see array in session to see what it looks like
 
@@ -718,13 +718,13 @@ function load_user_capability($capability='', $context ='', $userid='') {
 
 /*
  * Check all the login enrolment information for the given user object
- * by querying the enrolment plugins 
+ * by querying the enrolment plugins
  */
 function check_enrolment_plugins(&$user) {
     global $CFG;
 
     require_once($CFG->dirroot .'/enrol/enrol.class.php');
-   
+
     if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
         $plugins = array($CFG->enrol);
     }
@@ -770,21 +770,21 @@ function capability_prohibits($capability, $context, $sum='', $array='') {
         // If this capability is set to prohibit.
         return true;
     }
-    
+
     if (isset($array)) {
-        if (isset($array[$context->id][$capability]) 
+        if (isset($array[$context->id][$capability])
                 && $array[$context->id][$capability] < -8000) {
             return true;
-        }    
+        }
     } else {
         // Else if set in session.
-        if (isset($USER->capabilities[$context->id][$capability]) 
+        if (isset($USER->capabilities[$context->id][$capability])
                 && $USER->capabilities[$context->id][$capability] < -8000) {
             return true;
         }
     }
     switch ($context->aggregatelevel) {
-        
+
         case CONTEXT_SYSTEM:
             // By now it's a definite an inherit.
             return 0;
@@ -858,7 +858,7 @@ function capability_prohibits($capability, $context, $sum='', $array='') {
  */
 function print_capabilities($modid=0) {
     global $CFG;
-    
+
     $capabilities = array();
 
     if ($modid) {
@@ -868,7 +868,7 @@ function print_capabilities($modid=0) {
         // Call the function that grabs the file and parse.
         $cm = get_record('course_modules', 'id', $modid);
         $module = get_record('modules', 'id', $cm->module);
-        
+
     } else {
         // Print all capabilities.
         foreach ($capabilities as $capability) {
@@ -886,20 +886,20 @@ function print_capabilities($modid=0) {
 function moodle_install_roles() {
 
     global $CFG, $db;
-    
+
     // Create a system wide context for assignemnt.
     $systemcontext = $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
 
 
     // Create default/legacy roles and capabilities.
     // (1 legacy capability per legacy role at system level).
-    $adminrole = create_role(get_string('administrator'), 'admin', get_string('administratordescription'), 'moodle/legacy:admin');   
+    $adminrole = create_role(get_string('administrator'), 'admin', get_string('administratordescription'), 'moodle/legacy:admin');
     if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
         error('Could not assign moodle/site:doanything to the admin role');
     }
-    $coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'moodle/legacy:coursecreator');   
-    $editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'moodle/legacy:editingteacher');    
-    $noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'moodle/legacy:teacher');    
+    $coursecreatorrole = create_role(get_string('coursecreators'), 'coursecreator', get_string('coursecreatorsdescription'), 'moodle/legacy:coursecreator');
+    $editteacherrole = create_role(get_string('defaultcourseteacher'), 'editingteacher', get_string('defaultcourseteacherdescription'), 'moodle/legacy:editingteacher');
+    $noneditteacherrole = create_role(get_string('noneditingteacher'), 'teacher', get_string('noneditingteacherdescription'), 'moodle/legacy:teacher');
     $studentrole = create_role(get_string('defaultcoursestudent'), 'student', get_string('defaultcoursestudentdescription'), 'moodle/legacy:student');
     $guestrole = create_role(get_string('guest'), 'guest', get_string('guestdescription'), 'moodle/legacy:guest');
 
@@ -908,14 +908,14 @@ function moodle_install_roles() {
     // assign above new roles. If a user has both teacher and student role,
     // only teacher role is assigned. The assignment should be system level.
     $dbtables = $db->MetaTables('TABLES');
-    
+
 
     /**
      * Upgrade the admins.
      * Sort using id ASC, first one is primary admin.
      */
     if (in_array($CFG->prefix.'user_admins', $dbtables)) {
-        if ($useradmins = get_records_sql('SELECT * from '.$CFG->prefix.'user_admins ORDER BY ID ASC')) { 
+        if ($useradmins = get_records_sql('SELECT * from '.$CFG->prefix.'user_admins ORDER BY ID ASC')) {
             foreach ($useradmins as $admin) {
                 role_assign($adminrole, $admin->userid, 0, $systemcontext->id);
             }
@@ -966,7 +966,7 @@ function moodle_install_roles() {
      */
     if (in_array($CFG->prefix.'user_students', $dbtables)) {
         if ($userstudents = get_records('user_students')) {
-            foreach ($userstudents as $student) {  
+            foreach ($userstudents as $student) {
                 // populate the user_lastaccess table
                 unset($access);
                 $access->timeaccess = $student->timeaccess;
@@ -989,31 +989,31 @@ function moodle_install_roles() {
     }
 
     /**
-     * Insert the correct records for legacy roles 
+     * Insert the correct records for legacy roles
      */
     allow_assign($adminrole, $adminrole);
     allow_assign($adminrole, $coursecreatorrole);
     allow_assign($adminrole, $noneditteacherrole);
-    allow_assign($adminrole, $editteacherrole);   
+    allow_assign($adminrole, $editteacherrole);
     allow_assign($adminrole, $studentrole);
     allow_assign($adminrole, $guestrole);
-    
+
     allow_assign($coursecreatorrole, $noneditteacherrole);
     allow_assign($coursecreatorrole, $editteacherrole);
-    allow_assign($coursecreatorrole, $studentrole);     
+    allow_assign($coursecreatorrole, $studentrole);
     allow_assign($coursecreatorrole, $guestrole);
-    
-    allow_assign($editteacherrole, $noneditteacherrole);     
-    allow_assign($editteacherrole, $studentrole);      
+
+    allow_assign($editteacherrole, $noneditteacherrole);
+    allow_assign($editteacherrole, $studentrole);
     allow_assign($editteacherrole, $guestrole);
-    
+
     /// overrides
     allow_override($adminrole, $adminrole);
     allow_override($adminrole, $coursecreatorrole);
     allow_override($adminrole, $noneditteacherrole);
-    allow_override($adminrole, $editteacherrole);   
+    allow_override($adminrole, $editteacherrole);
     allow_override($adminrole, $studentrole);
-    allow_override($adminrole, $guestrole);    
+    allow_override($adminrole, $guestrole);
 
 
     // Should we delete the tables after we are done? Not yet.
@@ -1032,11 +1032,11 @@ function moodle_install_roles() {
  * @return boolean - success or failure.
  */
 function assign_legacy_capabilities($capability, $legacyperms) {
-    
+
     foreach ($legacyperms as $type => $perm) {
-        
+
         $systemcontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
-        
+
         // The legacy capabilities are:
         //   'moodle/legacy:guest'
         //   'moodle/legacy:student'
@@ -1044,7 +1044,7 @@ function assign_legacy_capabilities($capability, $legacyperms) {
         //   'moodle/legacy:editingteacher'
         //   'moodle/legacy:coursecreator'
         //   'moodle/legacy:admin'
-        
+
         if ($roles = get_roles_with_capability('moodle/legacy:'.$type, CAP_ALLOW)) {
             foreach ($roles as $role) {
                 // Assign a site level capability.
@@ -1065,9 +1065,9 @@ function assign_legacy_capabilities($capability, $legacyperms) {
  */
 function islegacy($capabilityname) {
     if (strstr($capabilityname, 'legacy') === false) {
-        return false;  
+        return false;
     } else {
-        return true;  
+        return true;
     }
 }
 
@@ -1180,46 +1180,46 @@ function get_local_override($roleid, $contextid, $capability) {
  * @return id or false
  */
 function create_role($name, $shortname, $description, $legacy='') {
-          
+
     // check for duplicate role name
-                
+
     if ($role = get_record('role','name', $name)) {
-        error('there is already a role with this name!');  
+        error('there is already a role with this name!');
     }
-    
+
     if ($role = get_record('role','shortname', $shortname)) {
-        error('there is already a role with this shortname!');  
+        error('there is already a role with this shortname!');
     }
 
     $role->name = $name;
     $role->shortname = $shortname;
     $role->description = $description;
-    
-    $context = get_context_instance(CONTEXT_SYSTEM, SITEID);                           
-    
+
+    $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+
     if ($id = insert_record('role', $role)) {
-        if ($legacy) {        
-            assign_capability($legacy, CAP_ALLOW, $id, $context->id);            
+        if ($legacy) {
+            assign_capability($legacy, CAP_ALLOW, $id, $context->id);
         }
-        
+
         /// By default, users with role:manage at site level
         /// should be able to assign users to this new role, and override this new role's capabilities
-        
+
         // find all admin roles
         if ($adminroles = get_roles_with_capability('moodle/role:manage', CAP_ALLOW, $context)) {
             // foreach admin role
             foreach ($adminroles as $arole) {
                 // write allow_assign and allow_overrid
                 allow_assign($arole->id, $id);
-                allow_override($arole->id, $id);  
+                allow_override($arole->id, $id);
             }
         }
-        
+
         return $id;
     } else {
-        return false;  
+        return false;
     }
-  
+
 }
 
 /**
@@ -1231,13 +1231,13 @@ function create_role($name, $shortname, $description, $legacy='') {
  * @param permission - int 1,-1 or -1000
  */
 function assign_capability($capability, $permission, $roleid, $contextid, $overwrite=false) {
-    
+
     global $USER;
-    
+
     if (empty($permission) || $permission == 0) { // if permission is not set
-        unassign_capability($capability, $roleid, $contextid);      
+        unassign_capability($capability, $roleid, $contextid);
     }
-    
+
     $existing = get_record('role_capabilities', 'contextid', $contextid, 'roleid', $roleid, 'capability', $capability);
 
     if ($existing and !$overwrite) {   // We want to keep whatever is there already
@@ -1268,7 +1268,7 @@ function assign_capability($capability, $permission, $roleid, $contextid, $overw
  * @return boolean - success or failure
  */
 function unassign_capability($capability, $roleid, $contextid=NULL) {
-    
+
     if (isset($contextid)) {
         $status = delete_records('role_capabilities', 'capability', $capability,
                 'roleid', $roleid, 'contextid', $contextid);
@@ -1292,20 +1292,20 @@ function unassign_capability($capability, $roleid, $contextid=NULL) {
 function get_roles_with_capability($capability, $permission=NULL, $context='') {
 
     global $CFG;
-    
+
     if ($context) {
         if ($contexts = get_parent_contexts($context)) {
             $listofcontexts = '('.implode(',', $contexts).')';
         } else {
             $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
-            $listofcontexts = '('.$sitecontext->id.')'; // must be site  
-        }  
+            $listofcontexts = '('.$sitecontext->id.')'; // must be site
+        }
         $contextstr = "AND (rc.contextid = '$context->id' OR  rc.contextid IN $listofcontexts)";
     } else {
         $contextstr = '';
     }
-    
-    $selectroles = "SELECT r.* 
+
+    $selectroles = "SELECT r.*
                       FROM {$CFG->prefix}role r,
                            {$CFG->prefix}role_capabilities rc
                      WHERE rc.capability = '$capability'
@@ -1345,7 +1345,7 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time
         notify('Either userid or groupid must be provided');
         return false;
     }
-    
+
     if ($userid && !record_exists('user', 'id', $userid)) {
         notify('User does not exist!');
         return false;
@@ -1426,7 +1426,7 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time
     /// Make sure they have an entry in user_lastaccess for courses they can access
     //    role_add_lastaccess_entries($userid, $context);
     }
-    
+
     /// now handle metacourse role assignments if in course context
     if ($success and $context->aggregatelevel == CONTEXT_COURSE) {
         if ($parents = get_records('course_meta', 'child_course', $context->instanceid)) {
@@ -1451,7 +1451,7 @@ function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $time
 function role_unassign($roleid=0, $userid=0, $groupid=0, $contextid=0) {
 
     global $USER, $CFG;
-    
+
     $success = true;
 
     $args = array('roleid', 'userid', 'groupid', 'contextid');
@@ -1512,8 +1512,8 @@ function role_unassign($roleid=0, $userid=0, $groupid=0, $contextid=0) {
     return $success;
 }
 
-/* 
- * A convenience function to take care of the common case where you 
+/*
+ * A convenience function to take care of the common case where you
  * just want to enrol someone using the default role into a course
  *
  * @param object $course
@@ -1536,9 +1536,9 @@ function enrol_into_course($course, $user, $enrol) {
         if (role_assign($role->id, $user->id, 0, $context->id, $timestart, $timeend, 0, $enrol)) {
             return false;
         }
-    
+
         email_welcome_message_to_user($course, $user);
-    
+
         add_to_log($course->id, 'course', 'enrol', 'view.php?id='.$course->id, $user->id);
 
         return true;
@@ -1590,7 +1590,7 @@ function role_add_lastaccess_entries($userid, $context) {
                  }
              }
              break;
-    
+
 
         case CONTEXT_COURSE:   // For a whole course
              if ($course = get_record('course', 'id', $context->instanceid)) {
@@ -1628,7 +1628,7 @@ function load_capability_def($component) {
         $varprefix = 'moodle';
     } else {
         $compparts = explode('/', $component);
-        
+
         if ($compparts[0] == 'block') {
             // Blocks are an exception. Blocks directory is 'blocks', and not
             // 'block'. So we need to jump through hoops.
@@ -1641,7 +1641,7 @@ function load_capability_def($component) {
         }
     }
     $capabilities = array();
-    
+
     if (file_exists($defpath)) {
         require_once($defpath);
         $capabilities = ${$varprefix.'_capabilities'};
@@ -1675,13 +1675,13 @@ function get_cached_capabilities($component='moodle') {
  *
  * Note that the absence of the db/access.php capabilities definition file
  * will cause any stored capabilities for the component to be removed from
- * the database. 
+ * the database.
  *
  * @param $component - examples: 'moodle', 'mod/forum', 'block/quiz_results'
  * @return boolean
  */
 function update_capabilities($component='moodle') {
-    
+
     $storedcaps = array();
 
     $filecaps = load_capability_def($component);
@@ -1708,9 +1708,9 @@ function update_capabilities($component='moodle') {
 
     // Are there new capabilities in the file definition?
     $newcaps = array();
-    
+
     foreach ($filecaps as $filecap => $def) {
-        if (!$storedcaps || 
+        if (!$storedcaps ||
                 ($storedcaps && in_array($filecap, $storedcaps) === false)) {
             if (!array_key_exists('riskbitmask', $def)) {
                 $def['riskbitmask'] = 0; // no risk if not specified
@@ -1726,11 +1726,11 @@ function update_capabilities($component='moodle') {
         $capability->contextlevel = $capdef['contextlevel'];
         $capability->component = $component;
         $capability->riskbitmask = $capdef['riskbitmask'];
-        
+
         if (!insert_record('capabilities', $capability, false, 'id')) {
             return false;
         }
-        
+
         global $db;
         $db->debug= 999;
         // Do we need to assign the new capabilities to roles that have the
@@ -1744,7 +1744,7 @@ function update_capabilities($component='moodle') {
     // definition that we need to delete from the stored capabilities and
     // role assignments?
     capabilities_cleanup($component, $filecaps);
-    
+
     return true;
 }
 
@@ -1758,14 +1758,14 @@ function update_capabilities($component='moodle') {
  * @return int - number of deprecated capabilities that have been removed
  */
 function capabilities_cleanup($component, $newcapdef=NULL) {
-    
+
     $removedcount = 0;
-    
+
     if ($cachedcaps = get_cached_capabilities($component)) {
         foreach ($cachedcaps as $cachedcap) {
             if (empty($newcapdef) ||
                         array_key_exists($cachedcap->name, $newcapdef) === false) {
-            
+
                 // Remove from capabilities cache.
                 if (!delete_records('capabilities', 'name', $cachedcap->name)) {
                     error('Could not delete deprecated capability '.$cachedcap->name);
@@ -1868,7 +1868,7 @@ function print_context_name($context) {
 
 
 /**
- * Extracts the relevant capabilities given a contextid. 
+ * Extracts the relevant capabilities given a contextid.
  * All case based, example an instance of forum context.
  * Will fetch all forum related capabilities, while course contexts
  * Will fetch all capabilities
@@ -1882,11 +1882,11 @@ function print_context_name($context) {
  * `component` varchar(100) NOT NULL,
  */
 function fetch_context_capabilities($context) {
-      
+
     global $CFG;
 
     $sort = 'ORDER BY contextlevel,component,id';   // To group them sensibly for display
-      
+
     switch ($context->aggregatelevel) {
 
         case CONTEXT_SYSTEM: // all
@@ -1896,11 +1896,11 @@ function fetch_context_capabilities($context) {
         case CONTEXT_PERSONAL:
             $SQL = "select * from {$CFG->prefix}capabilities where contextlevel = ".CONTEXT_PERSONAL;
         break;
-        
+
         case CONTEXT_USER:
             $SQL = "select * from {$CFG->prefix}capabilities where contextlevel = ".CONTEXT_USER;
         break;
-        
+
         case CONTEXT_COURSECAT: // all
             $SQL = "select * from {$CFG->prefix}capabilities";
         break;
@@ -1915,7 +1915,7 @@ function fetch_context_capabilities($context) {
         case CONTEXT_MODULE: // mod caps
             $cm = get_record('course_modules', 'id', $context->instanceid);
             $module = get_record('modules', 'id', $cm->module);
-        
+
             $SQL = "select * from {$CFG->prefix}capabilities where contextlevel = ".CONTEXT_MODULE."
                     and component = 'mod/$module->name'";
         break;
@@ -1923,7 +1923,7 @@ function fetch_context_capabilities($context) {
         case CONTEXT_BLOCK: // block caps
             $cb = get_record('block_instance', 'id', $context->instanceid);
             $block = get_record('block', 'id', $cb->blockid);
-        
+
             $SQL = "select * from {$CFG->prefix}capabilities where contextlevel = ".CONTEXT_BLOCK."
                     and component = 'block/$block->name'";
         break;
@@ -1953,7 +1953,7 @@ function fetch_context_capabilities($context) {
     }
     // end of special sorting
     return $records;
-    
+
 }
 
 
@@ -1963,13 +1963,13 @@ function fetch_context_capabilities($context) {
  * @return array of capability records from the capabilities table.
  */
 function fetch_context_independent_capabilities() {
-    
+
     $contextindependentcaps = array(
         'moodle/site:accessallgroups'
         );
 
     $records = array();
-    
+
     foreach ($contextindependentcaps as $capname) {
         $record = get_record('capabilities', 'name', $capname);
         array_push($records, $record);
@@ -1989,42 +1989,42 @@ function fetch_context_independent_capabilities() {
  */
 function role_context_capabilities($roleid, $context, $cap='') {
     global $CFG;
-    
+
     $contexts = get_parent_contexts($context);
     $contexts[] = $context->id;
     $contexts = '('.implode(',', $contexts).')';
-    
+
     if ($cap) {
         $search = " AND rc.capability = '$cap' ";
     } else {
-        $search = '';  
+        $search = '';
     }
-    
-    $SQL = "SELECT rc.* 
-            FROM {$CFG->prefix}role_capabilities rc, 
+
+    $SQL = "SELECT rc.*
+            FROM {$CFG->prefix}role_capabilities rc,
                  {$CFG->prefix}context c
             WHERE rc.contextid in $contexts
                  AND rc.roleid = $roleid
                  AND rc.contextid = c.id $search
-            ORDER BY c.aggregatelevel DESC, 
-                     rc.capability DESC";  
+            ORDER BY c.aggregatelevel DESC,
+                     rc.capability DESC";
 
     $capabilities = array();
-    
+
     if ($records = get_records_sql($SQL)) {
         // We are traversing via reverse order.
         foreach ($records as $record) {
             // If not set yet (i.e. inherit or not set at all), or currently we have a prohibit
             if (!isset($capabilities[$record->capability]) || $record->permission<-500) {
                 $capabilities[$record->capability] = $record->permission;
-            }  
+            }
         }
     }
     return $capabilities;
 }
 
 /**
- * Recursive function which, given a context, find all parent context ids, 
+ * Recursive function which, given a context, find all parent context ids,
  * and return the array in reverse order, i.e. parent first, then grand
  * parent, etc.
  * @param object $context
@@ -2045,7 +2045,7 @@ function get_parent_contexts($context) {
                 return array($parent->id);
             }
         break;
-        
+
         case CONTEXT_USER:
             if (!$parent = get_context_instance(CONTEXT_SYSTEM, SITEID)) {
                 return array();
@@ -2053,7 +2053,7 @@ function get_parent_contexts($context) {
                 return array($parent->id);
             }
         break;
-        
+
         case CONTEXT_COURSECAT: // Coursecat -> coursecat or site
             if (!$coursecat = get_record('course_categories','id',$context->instanceid)) {
                 return array();
@@ -2126,7 +2126,7 @@ function get_parent_contexts($context) {
  */
 function get_related_contexts_string($context) {
     if ($parents = get_parent_contexts($context)) {
-        return (' IN ('.$context->id.','.implode(',', $parents).')');    
+        return (' IN ('.$context->id.','.implode(',', $parents).')');
     } else {
         return (' ='.$context->id);
     }
@@ -2157,19 +2157,19 @@ function get_role_context_capability($contextid, $capability, $capabilities) {
  * @param $capabilityname - e.g. mod/choice:readresponses
  */
 function get_capability_string($capabilityname) {
-    
+
     // Typical capabilityname is mod/choice:readresponses
 
     $names = split('/', $capabilityname);
     $stringname = $names[1];                 // choice:readresponses
-    $components = split(':', $stringname);   
+    $components = split(':', $stringname);
     $componentname = $components[0];               // choice
 
     switch ($names[0]) {
         case 'mod':
             $string = get_string($stringname, $componentname);
         break;
-        
+
         case 'block':
             $string = get_string($stringname, 'block_'.$componentname);
         break;
@@ -2177,15 +2177,15 @@ function get_capability_string($capabilityname) {
         case 'moodle':
             $string = get_string($stringname, 'role');
         break;
-        
+
         case 'enrol':
             $string = get_string($stringname, 'enrol_'.$componentname);
-        break;  
-        
+        break;
+
         default:
             $string = get_string($stringname);
-        break;  
-      
+        break;
+
     }
     return $string;
 }
@@ -2240,7 +2240,7 @@ function get_component_string($component, $contextlevel) {
         default:
             error ('This is an unknown context!');
         return false;
-      
+
     }
     return $string;
 }
@@ -2254,35 +2254,35 @@ function get_roles_used_in_context($context) {
 
     global $CFG;
     $contextlist = get_related_contexts_string($context);
-    
+
     $sql = "SELECT DISTINCT r.id,
                    r.name,
                    r.shortname,
                    r.sortorder
               FROM {$CFG->prefix}role_assignments ra,
-                   {$CFG->prefix}role r 
-             WHERE r.id = ra.roleid 
+                   {$CFG->prefix}role r
+             WHERE r.id = ra.roleid
                AND ra.contextid $contextlist
           ORDER BY r.sortorder ASC";
-    
+
     return get_records_sql($sql);
 }
 
-/** this function is used to print roles column in user profile page. 
+/** this function is used to print roles column in user profile page.
  * @param int userid
  * @param int contextid
  * @return string
  */
 function get_user_roles_in_context($userid, $contextid){
     global $CFG;
-    
+
     $rolestring = '';
     $SQL = 'select * from '.$CFG->prefix.'role_assignments ra, '.$CFG->prefix.'role r where ra.userid='.$userid.' and ra.contextid='.$contextid.' and ra.roleid = r.id';
     if ($roles = get_records_sql($SQL)) {
         foreach ($roles as $userrole) {
             $rolestring .= '<a href="'.$CFG->wwwroot.'/user/index.php?contextid='.$userrole->contextid.'&amp;roleid='.$userrole->roleid.'">'.$userrole->name.'</a>, ';
-        }   
-        
+        }
+
     }
     return rtrim($rolestring, ', ');
 }
@@ -2298,7 +2298,7 @@ function user_can_override($context, $targetroleid) {
     // first check if user has override capability
     // if not return false;
     if (!has_capability('moodle/role:override', $context)) {
-        return false;  
+        return false;
     }
     // pull out all active roles of this user from this context(or above)
     if ($userroles = get_user_roles($context)) {
@@ -2309,9 +2309,9 @@ function user_can_override($context, $targetroleid) {
             }
         }
     }
-    
+
     return false;
-  
+
 }
 
 /**
@@ -2321,11 +2321,11 @@ function user_can_override($context, $targetroleid) {
  * @return boolean
  */
 function user_can_assign($context, $targetroleid) {
-    
+
     // first check if user has override capability
     // if not return false;
     if (!has_capability('moodle/role:assign', $context)) {
-        return false;  
+        return false;
     }
     // pull out all active roles of this user from this context(or above)
     if ($userroles = get_user_roles($context)) {
@@ -2336,8 +2336,8 @@ function user_can_assign($context, $targetroleid) {
             }
         }
     }
-    
-    return false; 
+
+    return false;
 }
 
 /**
@@ -2373,12 +2373,12 @@ function get_user_roles($context, $userid=0, $checkparentcontexts=true) {
                              WHERE ra.userid = '.$userid.
                            '   AND ra.roleid = r.id
                                AND ra.contextid = c.id
-                               AND '.$contexts. 
+                               AND '.$contexts.
                            ' ORDER BY c.aggregatelevel DESC');
 }
 
 /**
- * Creates a record in the allow_override table 
+ * Creates a record in the allow_override table
  * @param int sroleid - source roleid
  * @param int troleid - target roleid
  * @return int - id or false
@@ -2390,7 +2390,7 @@ function allow_override($sroleid, $troleid) {
 }
 
 /**
- * Creates a record in the allow_assign table 
+ * Creates a record in the allow_assign table
  * @param int sroleid - source roleid
  * @param int troleid - target roleid
  * @return int - id or false
@@ -2437,15 +2437,15 @@ function get_overridable_roles ($context) {
             }
         }
     }
-    
-    return $options;  
+
+    return $options;
 }
 
 /*
  *  Returns a role object that is the default role for new enrolments
  *  in a given course
  *
- *  @param object $course 
+ *  @param object $course
  *  @return object $role
  */
 function get_default_course_role($course) {
@@ -2483,28 +2483,28 @@ function get_default_course_role($course) {
  * @param $fields - fields to be pulled
  * @param $sort - the sort order
  * @param $limitfrom - number of records to skip (offset)
- * @param $limitnum - number of records to fetch 
+ * @param $limitnum - number of records to fetch
  * @param $groups - single group or array of groups - group(s) user is in
  * @param $exceptions - list of users to exclude
  */
-function get_users_by_capability($context, $capability, $fields='', $sort='', 
+function get_users_by_capability($context, $capability, $fields='', $sort='',
                                  $limitfrom='', $limitnum='', $groups='', $exceptions='') {
     global $CFG;
-    
+
 /// Sorting out groups
     if ($groups) {
         $groupjoin = 'INNER JOIN '.$CFG->prefix.'groups_members gm ON gm.userid = ra.userid';
-        
+
         if (is_array($groups)) {
             $groupsql = 'AND gm.groupid IN ('.implode(',', $groups).')';
         } else {
-            $groupsql = 'AND gm.groupid = '.$groups; 
+            $groupsql = 'AND gm.groupid = '.$groups;
         }
     } else {
         $groupjoin = '';
-        $groupsql = '';  
+        $groupsql = '';
     }
-    
+
 /// Sorting out exceptions
     $exceptionsql = $exceptions ? "AND u.id NOT IN ($exceptions)" : '';
 
@@ -2518,8 +2518,8 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
         $sort = 'ul.timeaccess';
     }
 
-    $sortby = $sort ? " ORDER BY $sort " : '';  
-    
+    $sortby = $sort ? " ORDER BY $sort " : '';
+
 /// If context is a course, then construct sql for ul
     if ($context->aggregatelevel == CONTEXT_COURSE) {
         $courseid = $context->instanceid;
@@ -2536,23 +2536,23 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
         if ($caps[$capability] > 0) { // resolved capability > 0
             $validroleids[] = $prole->id;
         }
-    }  
+    }
     $roleids =  '('.implode(',', $validroleids).')';
 
 /// Construct the main SQL
     $select = " SELECT $fields";
-    $from   = " FROM {$CFG->prefix}user u 
-                INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id 
+    $from   = " FROM {$CFG->prefix}user u
+                INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id
                 LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul ON ul.userid = u.id
                 $groupjoin";
-    $where  = " WHERE ra.contextid ".get_related_contexts_string($context)." 
-                  AND u.deleted = 0 
-                  AND ra.roleid in $roleids 
+    $where  = " WHERE ra.contextid ".get_related_contexts_string($context)."
+                  AND u.deleted = 0
+                  AND ra.roleid in $roleids
                       $exceptionsql
                       $coursesql
                       $groupsql";
 
-    return get_records_sql($select.$from.$where.$sortby, $limitfrom, $limitnum);  
+    return get_records_sql($select.$from.$where.$sortby, $limitfrom, $limitnum);
 }
 
 /**
@@ -2564,28 +2564,28 @@ function get_users_by_capability($context, $capability, $fields='', $sort='',
  */
 function get_role_users($roleid, $context, $parent=false) {
     global $CFG;
-    
+
     if ($parent) {
         if ($contexts = get_parent_contexts($context)) {
             $parentcontexts = 'r.contextid IN ('.implode(',', $contexts).')';
         } else {
-            $parentcontexts = ''; 
+            $parentcontexts = '';
         }
     } else {
-        $parentcontexts = '';  
-    }
-    
-    $SQL = "select u.* 
-            from {$CFG->prefix}role_assignments r, 
-                 {$CFG->prefix}user u 
-            where (r.contextid = $context->id $parentcontexts) 
-            and r.roleid = $roleid 
+        $parentcontexts = '';
+    }
+
+    $SQL = "select u.*
+            from {$CFG->prefix}role_assignments r,
+                 {$CFG->prefix}user u
+            where (r.contextid = $context->id $parentcontexts)
+            and r.roleid = $roleid
             and u.id = r.userid"; // join now so that we can just use fullname() later
-    
+
     return get_records_sql($SQL);
 }
 
-/** 
+/**
  * This function gets the list of courses that this user has a particular capability in
  * This is not the most efficient way of doing this
  * @param string capability
@@ -2593,19 +2593,19 @@ function get_role_users($roleid, $context, $parent=false) {
  * @return array
  */
 function get_user_capability_course($capability, $userid='') {
-    
+
     global $USER;
     if (!$userid) {
-        $userid = $USER->id;  
+        $userid = $USER->id;
     }
-    
+
     $usercourses = array();
     $courses = get_records_select('course', '', '', 'id, id');
-    
+
     foreach ($courses as $course) {
         if (has_capability($capability, get_context_capability(CONTEXT_COURSE, $course->id))) {
             $usercourses[] = $course;
         }
     }
-    return $usercourses;  
+    return $usercourses;
 }
\ No newline at end of file
index 1fce4e7cd0b80942f09b940b8e36c6e4041941a6..d571befad72d29a6efcc05c4c82a17c9997b798d 100644 (file)
@@ -17,7 +17,7 @@
  * @param string $type The type of plugins that should be updated (e.g. 'enrol', 'qtype')
  * @param string $dir  The directory where the plugins are located (e.g. 'question/questiontypes')
  * @param string $return The url to prompt the user to continue to
- */ 
+ */
 function upgrade_plugins($type, $dir, $return) {
     global $CFG, $db;
 
@@ -62,7 +62,7 @@ function upgrade_plugins($type, $dir, $return) {
                 $info->currentmoodle = $CFG->version;
                 $info->requiremoodle = $plugin->requires;
                 if (!$updated_plugins) {
-                    print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', 
+                    print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
                         '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
                         false, '&nbsp;', '&nbsp;');
                 }
@@ -81,12 +81,12 @@ function upgrade_plugins($type, $dir, $return) {
         if (!isset($CFG->$pluginversion)) {
             set_config($pluginversion, 0);
         }
-        
+
         if ($CFG->$pluginversion == $plugin->version) {
             // do nothing
         } else if ($CFG->$pluginversion < $plugin->version) {
             if (!$updated_plugins) {
-                print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '', 
+                print_header($strpluginsetup, $strpluginsetup, $strpluginsetup, '',
                         '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
                         false, '&nbsp;', '&nbsp;');
             }
@@ -104,12 +104,12 @@ function upgrade_plugins($type, $dir, $return) {
                     $status = install_from_xmldb_file($fullplug . '/db/install.xml'); //New method
                 } else if (file_exists($fullplug .'/db/'. $CFG->dbtype .'.sql')) {
                     $status = modify_database($fullplug .'/db/'. $CFG->dbtype .'.sql'); //Old method
-                } else { 
+                } else {
                     $status = true;
                 }
 
                 $db->debug = false;
-            /// Continue with the instalation, roles and other stuff 
+            /// Continue with the instalation, roles and other stuff
                 if ($status) {
                     // OK so far, now update the plugins record
                     set_config($pluginversion, $plugin->version);
@@ -180,7 +180,7 @@ function upgrade_plugins($type, $dir, $return) {
  * @uses $CFG
  * @param string $return The url to prompt the user to continue to
  * @todo Finish documenting this function
- */ 
+ */
 function upgrade_activity_modules($return) {
 
     global $CFG, $db;
@@ -231,7 +231,7 @@ function upgrade_activity_modules($return) {
                 $info->currentmoodle = $CFG->version;
                 $info->requiremoodle = $module->requires;
                 if (!$updated_modules) {
-                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', 
+                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
                             '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
                             false, '&nbsp;', '&nbsp;');
                 }
@@ -244,7 +244,7 @@ function upgrade_activity_modules($return) {
         }
 
         $module->name = $mod;   // The name MUST match the directory
-        
+
         if ($currmodule = get_record('modules', 'name', $module->name)) {
             if ($currmodule->version == $module->version) {
                 // do nothing
@@ -256,7 +256,7 @@ function upgrade_activity_modules($return) {
                     continue;
                 }
                 if (!$updated_modules) {
-                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', 
+                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
                             '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
                             false, '&nbsp;', '&nbsp;');
                 }
@@ -308,15 +308,15 @@ function upgrade_activity_modules($return) {
                 }
 
                 $updated_modules = true;
-                
+
             } else {
                 upgrade_log_start();
                 error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
             }
-    
+
         } else {    // module not installed yet, so install it
             if (!$updated_modules) {
-                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', 
+                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '',
                         '<script type="text/javascript" src="' . $CFG->wwwroot . '/lib/scroll_to_errors.js"></script>',
                         false, '&nbsp;', '&nbsp;');
             }
@@ -346,7 +346,7 @@ function upgrade_activity_modules($return) {
                 } else {
                     error($module->name .' module could not be added to the module list!');
                 }
-            } else { 
+            } else {
                 error($module->name .' tables could NOT be set up successfully!');
             }
         }
@@ -366,7 +366,7 @@ function upgrade_activity_modules($return) {
         if ( is_readable($fullmod .'/defaults.php')) {
             // Insert default values for any important configuration variables
             unset($defaults);
-            include_once($fullmod .'/defaults.php'); 
+            include_once($fullmod .'/defaults.php');
             if (!empty($defaults)) {
                 foreach ($defaults as $name => $value) {
                     if (!isset($CFG->$name)) {
@@ -386,7 +386,7 @@ function upgrade_activity_modules($return) {
     }
 }
 
-/** 
+/**
  * This function will return FALSE if the lock fails to be set (ie, if it's already locked)
  *
  * @param string  $name ?
@@ -620,12 +620,12 @@ function is_dataroot_insecure() {
 /// This file performs the following tasks:
 ///  -it defines the necessary objects and interfaces to build the Moodle
 ///   admin hierarchy
-///  -it defines the admin_externalpage_setup(), admin_externalpage_print_header(), 
+///  -it defines the admin_externalpage_setup(), admin_externalpage_print_header(),
 ///   and admin_externalpage_print_footer() functions used on admin pages
 
 /// ADMIN_SETTING OBJECTS
 
-/// Moodle settings are represented by objects that inherit from the admin_setting 
+/// Moodle settings are represented by objects that inherit from the admin_setting
 /// class. These objects encapsulate how to read a setting, how to write a new value
 /// to a setting, and how to appropriately display the HTML to modify the setting.
 
@@ -648,7 +648,7 @@ function is_dataroot_insecure() {
 /// admin/settings/first.php (at the end of the file) or to some other file in
 /// admin/settings:
 
-///    $ADMIN->add('userinterface', new admin_externalpage('foo', get_string('foo'), 
+///    $ADMIN->add('userinterface', new admin_externalpage('foo', get_string('foo'),
 ///        $CFG->wwwdir . '/' . '$CFG->admin . '/foo.php', 'some_role_permission'));
 
 /// Next, in foo.php, your file structure would resemble the following:
@@ -733,9 +733,9 @@ class part_of_admin_tree {
      * @param string $name The internal name of the part_of_admin_tree we're searching for.
      * @return mixed An object reference or a NULL reference.
      */
-    function &locate($name) { 
-        trigger_error('Admin class does not implement method <strong>locate()</strong>', E_USER_WARNING); 
-        return; 
+    function &locate($name) {
+        trigger_error('Admin class does not implement method <strong>locate()</strong>', E_USER_WARNING);
+        return;
     }
 
     /**
@@ -745,9 +745,9 @@ class part_of_admin_tree {
      * @return boolean success.
      */
     function prune($name) {
-        trigger_error('Admin class does not implement method <strong>prune()</strong>', E_USER_WARNING); 
+        trigger_error('Admin class does not implement method <strong>prune()</strong>', E_USER_WARNING);
         return;
-    } 
+    }
 
     /**
      * Verifies current user's access to this part_of_admin_tree.
@@ -761,11 +761,11 @@ class part_of_admin_tree {
      *
      * @return bool True if the user has access, false if she doesn't.
      */
-    function check_access() { 
-        trigger_error('Admin class does not implement method <strong>check_access()</strong>', E_USER_WARNING); 
-        return; 
+    function check_access() {
+        trigger_error('Admin class does not implement method <strong>check_access()</strong>', E_USER_WARNING);
+        return;
     }
-    
+
     /**
      * Determines the path to $name in the admin tree.
      *
@@ -785,9 +785,9 @@ class part_of_admin_tree {
      * @param array $path Not used on external calls. Defaults to empty array.
      * @return mixed If found, an array containing the internal names of each part_of_admin_tree that leads to $name. If not found, NULL.
      */
-    function path($name, $path = array()) { 
-        trigger_error('Admin class does not implement method <strong>path()</strong>', E_USER_WARNING); 
-        return; 
+    function path($name, $path = array()) {
+        trigger_error('Admin class does not implement method <strong>path()</strong>', E_USER_WARNING);
+        return;
     }
 }
 
@@ -796,14 +796,14 @@ class part_of_admin_tree {
  *
  * The pseudointerface implemented by any part_of_admin_tree that can be a parent
  * to other part_of_admin_tree's. (For now, this only includes admin_category.) Apart
- * from ensuring part_of_admin_tree compliancy, it also ensures inheriting methods 
+ * from ensuring part_of_admin_tree compliancy, it also ensures inheriting methods
  * include an add method for adding other part_of_admin_tree objects as children.
  *
  * @author Vincenzo K. Marcovecchio
  * @package admin
  */
 class parentable_part_of_admin_tree extends part_of_admin_tree {
-    
+
     /**
      * Adds a part_of_admin_tree object to the admin tree.
      *
@@ -816,16 +816,16 @@ class parentable_part_of_admin_tree extends part_of_admin_tree {
      * @param part_of_admin_tree &$something The object to be added.
      * @return bool True on success, false on failure.
      */
-    function add($destinationname, &$something) { 
-        trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING); 
-        return; 
+    function add($destinationname, &$something) {
+        trigger_error('Admin class does not implement method <strong>add()</strong>', E_USER_WARNING);
+        return;
     }
-    
+
 }
 
 /**
  * The object used to represent folders (a.k.a. categories) in the admin tree block.
- * 
+ *
  * Each admin_category object contains a number of part_of_admin_tree objects.
  *
  * @author Vincenzo K. Marcovecchio
@@ -837,17 +837,17 @@ class admin_category extends parentable_part_of_admin_tree {
      * @var mixed An array of part_of_admin_tree objects that are this object's children
      */
     var $children;
-    
+
     /**
      * @var string An internal name for this category. Must be unique amongst ALL part_of_admin_tree objects
      */
     var $name;
-    
+
     /**
      * @var string The displayed name for this category. Usually obtained through get_string()
      */
     var $visiblename;
-    
+
     // constructor for an empty admin category
     // $name is the internal name of the category. it MUST be unique in the entire hierarchy
     // $visiblename is the displayed name of the category. use a get_string for this
@@ -864,7 +864,7 @@ class admin_category extends parentable_part_of_admin_tree {
         $this->name = $name;
         $this->visiblename = $visiblename;
     }
-    
+
     /**
      * Finds the path to the part_of_admin_tree called $name.
      *
@@ -873,21 +873,21 @@ class admin_category extends parentable_part_of_admin_tree {
      * @return mixed An array of internal names that leads to $name, or NULL if not found.
      */
     function path($name, $path = array()) {
-    
+
         $path[count($path)] = $this->name;
-    
+
         if ($this->name == $name) {
             return $path;
         }
-        
+
         foreach($this->children as $child) {
             if ($return = $child->path($name, $path)) {
                 return $return;
             }
         }
-        
+
         return NULL;
-    
+
     }
 
     /**
@@ -897,11 +897,11 @@ class admin_category extends parentable_part_of_admin_tree {
      * @return mixed A reference to the object with internal name $name if found, otherwise a reference to NULL.
      */
     function &locate($name) {
-        
+
         if ($this->name == $name) {
             return $this;
         }
-    
+
         foreach($this->children as $child) {
             if ($return =& $child->locate($name)) {
                 return $return;
@@ -926,7 +926,7 @@ class admin_category extends parentable_part_of_admin_tree {
         foreach($this->children as $precedence => $child) {
             if ($child->name == $name) {
                 // found it!
-                unset($this->children[$precedence]); 
+                unset($this->children[$precedence]);
                 return true;
             }
             if ($this->children[$precedence]->prune($name)) {
@@ -945,7 +945,7 @@ class admin_category extends parentable_part_of_admin_tree {
      * @return bool True if successfully added, false if &$something is not a part_of_admin_tree or if $name is not found.
      */
     function add($destinationname, &$something, $precedence = '') {
-    
+
         if (!is_a($something, 'part_of_admin_tree')) {
             return false;
         }
@@ -961,11 +961,11 @@ class admin_category extends parentable_part_of_admin_tree {
             }
             return true;
         }
-        
+
         unset($entries);
-        
+
         $entries = array_keys($this->children);
-        
+
         foreach($entries as $entry) {
             $child =& $this->children[$entry];
             if (is_a($child, 'parentable_part_of_admin_tree')) {
@@ -974,27 +974,27 @@ class admin_category extends parentable_part_of_admin_tree {
                 }
             }
         }
-        
+
         return false;
-        
+
     }
-    
+
     /**
      * Checks if the user has access to anything in this category.
      *
      * @return bool True if the user has access to atleast one child in this category, false otherwise.
      */
     function check_access() {
-    
+
         $return = false;
         foreach ($this->children as $child) {
             $return = $return || $child->check_access();
         }
-    
+
         return $return;
-    
+
     }
-    
+
 }
 
 /**
@@ -1007,26 +1007,26 @@ class admin_category extends parentable_part_of_admin_tree {
  */
 class admin_externalpage extends part_of_admin_tree {
 
-    /** 
+    /**
      * @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects
      */
     var $name;
-    
+
     /**
      * @var string The displayed name for this external page. Usually obtained through get_string().
      */
     var $visiblename;
-    
+
     /**
      * @var string The external URL that we should link to when someone requests this external page.
      */
     var $url;
-    
+
     /**
      * @var string The role capability/permission a user must have to access this external page.
      */
     var $role;
-    
+
     /**
      * Constructor for adding an external page into the admin tree.
      *
@@ -1041,7 +1041,7 @@ class admin_externalpage extends part_of_admin_tree {
         $this->url = $url;
         $this->role = $role;
     }
-    
+
     /**
      * Finds the path to the part_of_admin_tree called $name.
      *
@@ -1057,7 +1057,7 @@ class admin_externalpage extends part_of_admin_tree {
             return NULL;
         }
     }
-    
+
     /**
      * Returns a reference to the part_of_admin_tree object with internal name $name.
      *
@@ -1084,7 +1084,7 @@ class admin_externalpage extends part_of_admin_tree {
         if (!get_site()) {
             return true; // no access check before site is fully set up
         }
-        $context = get_context_instance(CONTEXT_SYSTEM, SITEID); 
+        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
         return has_capability($this->role, $context);
     }
 
@@ -1098,11 +1098,11 @@ class admin_externalpage extends part_of_admin_tree {
  */
 class admin_settingpage extends part_of_admin_tree {
 
-    /** 
+    /**
      * @var string An internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects
      */
     var $name;
-    
+
     /**
      * @var string The displayed name for this external page. Usually obtained through get_string().
      */
@@ -1111,12 +1111,12 @@ class admin_settingpage extends part_of_admin_tree {
      * @var mixed An array of admin_setting objects that are part of this setting page.
      */
     var $settings;
-    
+
     /**
      * @var string The role capability/permission a user must have to access this external page.
      */
     var $role;
-    
+
     // see admin_category
     function path($name, $path = array()) {
         if ($name == $this->name) {
@@ -1126,7 +1126,7 @@ class admin_settingpage extends part_of_admin_tree {
             return NULL;
         }
     }
-    
+
     // see admin_category
     function &locate($name) {
         $return = ($this->name == $name ? $this : NULL);
@@ -1145,7 +1145,7 @@ class admin_settingpage extends part_of_admin_tree {
         $this->visiblename = $visiblename;
         $this->role = $role;
     }
-    
+
     // not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
     // n.b. each admin_setting in an admin_settingpage must have a unique internal name
     // &$setting is the admin_setting object you want to add
@@ -1157,16 +1157,16 @@ class admin_settingpage extends part_of_admin_tree {
         }
         return false;
     }
-    
+
     // see admin_externalpage
     function check_access() {
         if (!get_site()) {
             return true; // no access check before site is fully set up
         }
-        $context = get_context_instance(CONTEXT_SYSTEM, SITEID); 
+        $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
         return has_capability($this->role, $context);
     }
-    
+
     // outputs this page as html in a table (suitable for inclusion in an admin pagetype)
     // returns a string of the html
     function output_html() {
@@ -1211,19 +1211,19 @@ class admin_setting {
         $this->description = $description;
         $this->defaultsetting = $defaultsetting;
     }
-    
+
     function get_setting() {
         return NULL; // has to be overridden
     }
-    
+
     function write_setting($data) {
         return; // has to be overridden
     }
-    
+
     function output_html() {
         return; // has to be overridden
     }
-        
+
 }
 
 
@@ -1241,7 +1241,7 @@ class admin_setting_configtext extends admin_setting {
         global $CFG;
         return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
     }
-    
+
     // $data is a string
     function write_setting($data) {
         if (is_string($this->paramtype)) {
@@ -1283,7 +1283,7 @@ class admin_setting_configcheckbox extends admin_setting {
         global $CFG;
         return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
         if ($data == '1') {
             return (set_config($this->name,1) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
@@ -1308,7 +1308,7 @@ class admin_setting_configcheckbox extends admin_setting {
 class admin_setting_configselect extends admin_setting {
 
     var $choices;
-    
+
     function admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices) {
         $this->choices = $choices;
         parent::admin_setting($name, $visiblename, $description, $defaultsetting);
@@ -1318,17 +1318,17 @@ class admin_setting_configselect extends admin_setting {
         global $CFG;
         return (isset($CFG->{$this->name}) ? $CFG->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
          // check that what we got was in the original choices
          // or that the data is the default setting - needed during install when choices can not be constructed yet
          if ($data != $this->defaultsetting and ! in_array($data, array_keys($this->choices))) {
              return 'Error setting ' . $this->visiblename . '<br />';
          }
-         
+
          return (set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
         if ($this->get_setting() === NULL) {
             $current = $this->defaultsetting;
@@ -1370,16 +1370,16 @@ class admin_setting_configtime extends admin_setting {
         global $CFG;
         return (isset($CFG->{$this->name}) && isset($CFG->{$this->name2}) ? array('h' => $CFG->{$this->name}, 'm' => $CFG->{$this->name2}) : NULL);
     }
-    
+
     function write_setting($data) {
          // check that what we got was in the original choices
          if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
              return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
          }
-         
+
          return (set_config($this->name, $data['h']) && set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
         if ($this->get_setting() === NULL) {
           $currentsetting = $this->defaultsetting;
@@ -1393,7 +1393,7 @@ class admin_setting_configtime extends admin_setting {
         $return .= '</select>&nbsp;&nbsp;&nbsp;<select name="s_' . $this->name . '[m]">';
         foreach ($this->choices2 as $key => $value) {
             $return .= '<option value="' . $key . '"' . ($key == $currentsetting['m'] ? ' selected="selected"' : '') . '>' . $value . '</option>';
-        }        
+        }
         $return .= '</select></td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
         return $return;
     }
@@ -1410,17 +1410,17 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
         global $CFG;
         return (isset($CFG->{$this->name}) ? explode(',', $CFG->{$this->name}) : NULL);;
     }
-    
+
     function write_setting($data) {
         foreach ($data as $datum) {
             if (! in_array($datum, array_keys($this->choices))) {
                 return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
             }
         }
-        
+
         return (set_config($this->name, implode(',',$data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
         if ($this->get_setting() === NULL) {
           $currentsetting = $this->defaultsetting;
@@ -1438,7 +1438,7 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
 }
 
 class admin_setting_special_adminseesall extends admin_setting_configcheckbox {
-    
+
     function admin_setting_special_adminseesall() {
         $name = 'calendar_adminseesall';
         $visiblename = get_string('adminseesall', 'admin');
@@ -1461,14 +1461,14 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
 
         $this->id = SITEID;
         parent::admin_setting_configselect($name, $visiblename, $description, $defaultsetting, $choices);
-    
+
     }
-    
+
     function get_setting() {
         $site = get_site();
         return (isset($site->{$this->name}) ? $site->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
         if (!in_array($data, array_keys($this->choices))) {
             return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
@@ -1480,7 +1480,7 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
         $record->timemodified = time();
         return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
 }
 
 
@@ -1503,12 +1503,12 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect {
         $defaults = FRONTPAGECOURSELIST.',,,';
         parent::admin_setting_configselect($name, $visiblename, $description, $defaults, $choices);
     }
-    
+
     function get_setting() {
         global $CFG;
         return (isset($CFG->{$this->name}) ? explode(',', $CFG->{$this->name}) : NULL);
     }
-    
+
     function write_setting($data) {
         if (empty($data)) {
             $data = array();
@@ -1522,7 +1522,7 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect {
         }
         return (set_config($this->name, implode(',', $data)) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
         if ($this->get_setting() === NULL) {
             $currentsetting = $this->defaultsetting;
@@ -1536,7 +1536,7 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect {
         }
         $return = '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td><td align="left">';
         for ($i = 0; $i < count($this->choices) - 1; $i++) {
-            $return .='<select name="s_' . $this->name .'[]">';        
+            $return .='<select name="s_' . $this->name .'[]">';
             foreach ($this->choices as $key => $value) {
                 $return .= '<option value="' . $key . '"' . ($key == $currentsetting[$i] ? ' selected="selected"' : '') . '>' . $value . '</option>';
             }
@@ -1546,7 +1546,7 @@ class admin_setting_courselist_frontpage extends admin_setting_configselect {
             }
         }
         $return .= '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
-        return $return;    
+        return $return;
     }
 }
 
@@ -1558,14 +1558,14 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
 
         $this->id = SITEID;
         parent::admin_setting_configcheckbox($name, $visiblename, $description, $defaultsetting);
-    
+
     }
-    
+
     function get_setting() {
         $site = get_site();
         return (isset($site->{$this->name}) ? $site->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
         $record = new stdClass();
         $record->id = $this->id;
@@ -1574,7 +1574,7 @@ class admin_setting_sitesetcheckbox extends admin_setting_configcheckbox {
         $record->timemodified = time();
         return (update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
 }
 
 class admin_setting_sitesettext extends admin_setting_configtext {
@@ -1585,9 +1585,9 @@ class admin_setting_sitesettext extends admin_setting_configtext {
 
         $this->id = SITEID;
         parent::admin_setting_configtext($name, $visiblename, $description, $defaultsetting, $paramtype);
-    
+
     }
-    
+
     function get_setting() {
         $site = get_site();
         return (isset($site->{$this->name}) ? $site->{$this->name} : NULL);
@@ -1601,7 +1601,7 @@ class admin_setting_sitesettext extends admin_setting_configtext {
         } else {
             $data = clean_param($data, $this->paramtype);
         }
-        
+
         $record = new stdClass();
         $record->id = $this->id;
         $record->{$this->name} = $data;
@@ -1612,13 +1612,13 @@ class admin_setting_sitesettext extends admin_setting_configtext {
     function validate($data) {
         return preg_match($this->paramtype, $data);
     }
-        
+
 }
 
 class admin_setting_special_frontpagedesc extends admin_setting {
 
     var $id;
-    
+
     function admin_setting_special_frontpagedesc() {
         $this->id = SITEID;
         $name = 'summary';
@@ -1628,50 +1628,50 @@ class admin_setting_special_frontpagedesc extends admin_setting {
     }
 
     function output_html() {
-    
+
         if ($this->get_setting() === NULL) {
             $currentsetting = $this->defaultsetting;
         } else {
             $currentsetting = $this->get_setting();
         }
-    
+
         $usehtmleditor = can_use_html_editor();
-    
+
         $return = '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td>' .
                    '<td>';
-                   
+
         ob_start();  // double-check the number of columns below... might overrun some screen resolutions
         print_textarea($usehtmleditor, 20, 40, 0, 0, 's_' . $this->name, $currentsetting);
-        
+
         if ($usehtmleditor) {
             use_html_editor();
-        }    
+        }
         $return .= ob_get_contents();
-        ob_end_clean();        
+        ob_end_clean();
         $return .= '</td></tr><tr><td>&nbsp;</td><td>' . $this->description . '</td></tr>';
         return $return;
-    
+
     }
-    
+
     function get_setting() {
-    
+
         $site = get_site();
         return (isset($site->{$this->name}) ? $site->{$this->name} : NULL);
-    
+
     }
-    
+
     function write_setting($data) {
-    
+
         $data = addslashes(clean_param($data, PARAM_CLEANHTML));
-        
+
         $record = new stdClass();
         $record->id = $this->id;
         $temp = $this->name;
         $record->$temp = $data;
         $record->timemodified = time();
-        
+
         return(update_record('course', $record) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
-    
+
     }
 
 }
@@ -1706,7 +1706,7 @@ class admin_setting_special_editorfontlist extends admin_setting {
                           'v8' => 'wingdings');
         parent::admin_setting($name, $visiblename, $description, $defaults);
     }
-    
+
     function get_setting() {
         global $CFG;
         if (isset($CFG->editorfontlist)) {
@@ -1724,16 +1724,16 @@ class admin_setting_special_editorfontlist extends admin_setting {
             return NULL;
         }
     }
-    
+
     function write_setting($data) {
-    
+
         // there miiight be an easier way to do this :)
         // if this is changed, make sure the $defaults array above is modified so that this
         // function processes it correctly
-        
+
         $keys = array();
         $values = array();
-        
+
         foreach ($data as $key => $value) {
             if (substr($key,0,1) == 'k') {
                 $keys[substr($key,1)] = $value;
@@ -1741,27 +1741,27 @@ class admin_setting_special_editorfontlist extends admin_setting {
                 $values[substr($key,1)] = $value;
             }
         }
-        
+
         $result = '';
         for ($i = 0; $i < count($keys); $i++) {
             if (($keys[$i] !== '') && ($values[$i] !== '')) {
                 $result .= clean_param($keys[$i],PARAM_NOTAGS) . ':' . clean_param($values[$i], PARAM_NOTAGS) . ';';
             }
         }
-        
+
         $result = substr($result, 0, -1); // trim the last semicolon
-        
+
         return (set_config($this->name, $result) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
-        
+
         if ($this->get_setting() === NULL) {
             $currentsetting = $this->defaultsetting;
         } else {
             $currentsetting = $this->get_setting();
         }
-        
+
         $return = '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td><td align="left">';
         for ($i = 0; $i < count($currentsetting) / 2; $i++) {
             $return .= '<input type="text" name="s_editorfontlist[k' . $i . ']" value="' . $currentsetting['k' . $i] . '" size="20" />';
@@ -1774,10 +1774,10 @@ class admin_setting_special_editorfontlist extends admin_setting {
         $return .= '<input type="text" name="s_editorfontlist[k' . ($i + 1) . ']" value="" size="20" />';
         $return .= '&nbsp;&nbsp;';
         $return .= '<input type="text" name="s_editorfontlist[v' . ($i + 1) . ']" value="" size="40" />';
-        $return .= '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';    
+        $return .= '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
         return $return;
     }
-    
+
 }
 
 class admin_setting_special_editordictionary extends admin_setting_configselect {
@@ -1790,7 +1790,7 @@ class admin_setting_special_editordictionary extends admin_setting_configselect
         if (! is_array($choices)) {
             $choices = array('');
         }
-    
+
         parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
     }
 
@@ -1799,7 +1799,7 @@ class admin_setting_special_editordictionary extends admin_setting_configselect
     /// Get all installed dictionaries in the system
 
         global $CFG;
-    
+
 //        error_reporting(E_ALL); // for debug, final version shouldn't have this...
         clearstatcache();
 
@@ -1812,7 +1812,7 @@ class admin_setting_special_editordictionary extends admin_setting_configselect
         if (!function_exists('popen')) {
             return 'Popen function disabled!';
         }
-    
+
         $cmd          = $CFG->aspellpath;
         $output       = '';
         $dictionaries = array();
@@ -1848,7 +1848,7 @@ class admin_setting_special_editordictionary extends admin_setting_configselect
         return 'Error! Check your aspell installation!';
     }
 
-    
+
 
 }
 
@@ -1927,29 +1927,29 @@ class admin_setting_special_editorhidebuttons extends admin_setting {
     }
 
     function output_html() {
-    
+
         global $CFG;
-        
+
         // checkboxes with input name="$this->name[$key]" value="1"
         // we do 15 fields per column
-        
+
         if ($this->get_setting() === NULL) {
             $currentsetting = $this->defaultsetting;
         } else {
             $currentsetting = $this->get_setting();
         }
-        
+
         $return = '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td><td align="left">';
-        
+
         $return .= '<table><tr><td valign="top" align="right">';
-        
+
         $count = 0;
-        
+
         foreach($this->items as $key => $value) {
             if ($count % 15 == 0) {
                 $return .= '</div></td><td valign="top" align="right">';
             }
-            
+
             $return .= ($value == '' ? get_string($key,'editor') : '<img width="18" height="18" src="' . $CFG->wwwroot . '/lib/editor/htmlarea/images/' . $value . '" alt="' . get_string($key,'editor') . '" title="' . get_string($key,'editor') . '" />') . '&nbsp;';
             $return .= '<input type="checkbox" value="1" name="s_' . $this->name . '[' . $key . ']"' . (in_array($key,$currentsetting) ? ' checked="checked"' : '') . ' />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
             $count++;
@@ -1957,8 +1957,8 @@ class admin_setting_special_editorhidebuttons extends admin_setting {
                 $return .= '<br /><br />';
             }
         }
-        
-        $return .= '</td></tr>';    
+
+        $return .= '</td></tr>';
         $return .= '</table>';
         $return .= '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
 
@@ -1977,13 +1977,13 @@ class admin_setting_backupselect extends admin_setting_configselect {
         $backup_config =  backup_get_config();
         return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
          // check that what we got was in the original choices
          if (! in_array($data, array_keys($this->choices))) {
              return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
          }
-         
+
          return (backup_set_config($this->name, $data) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
 
@@ -1997,12 +1997,12 @@ class admin_setting_special_backupsaveto extends admin_setting_configtext {
         $description = get_string('backupsavetohelp');
         parent::admin_setting_configtext($name, $visiblename, $description, '', PARAM_PATH);
     }
-    
+
     function get_setting() {
         $backup_config =  backup_get_config();
         return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
     }
-    
+
     function write_setting($data) {
         $data = clean_param($data, PARAM_PATH);
         if (!empty($data) and (substr($data,-1) == '/' or substr($data,-1) == '\\')) {
@@ -2028,7 +2028,7 @@ class admin_setting_backupcheckbox extends admin_setting_configcheckbox {
             return (backup_set_config($this->name, 0) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
         }
     }
-    
+
     function get_setting() {
         $backup_config =  backup_get_config();
         return (isset($backup_config->{$this->name}) ? $backup_config->{$this->name} : NULL);
@@ -2046,21 +2046,21 @@ class admin_setting_special_backuptime extends admin_setting_configtime {
         $default = array('h' => 0, 'm' => 0);
         parent::admin_setting_configtime($name, $name2, $visiblename, $description, $default);
     }
-    
+
     function get_setting() {
         $backup_config =  backup_get_config();
         return (isset($backup_config->{$this->name}) && isset($backup_config->{$this->name}) ? array($backup_config->{$this->name}, $backup_config->{$this->name2}) : NULL);
     }
-    
+
     function write_setting($data) {
          // check that what we got was in the original choices
          if (!(in_array($data['h'], array_keys($this->choices)) && in_array($data['m'], array_keys($this->choices2)))) {
              return get_string('errorsetting', 'admin') . $this->visiblename . '<br />';
          }
-         
-         return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');    
+
+         return (backup_set_config($this->name, $data['h']) && backup_set_config($this->name2, $data['m']) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
 }
 
 class admin_setting_special_backupdays extends admin_setting {
@@ -2071,7 +2071,7 @@ class admin_setting_special_backupdays extends admin_setting {
         $description = get_string('backupschedulehelp');
         parent::admin_setting($name, $visiblename, $description, array());
     }
-    
+
     function get_setting() {
         $backup_config =  backup_get_config();
         if (isset($backup_config->{$this->name})) {
@@ -2087,36 +2087,36 @@ class admin_setting_special_backupdays extends admin_setting {
             return NULL;
         }
     }
-    
+
     function output_html() {
-    
+
         if ($this->get_setting() === NULL) {
             $currentsetting = $this->defaultsetting;
         } else {
             $currentsetting = $this->get_setting();
         }
-        
+
         // rewrite for simplicity
-        $currentsetting = $currentsetting['u'] . $currentsetting['m'] . $currentsetting['t'] . $currentsetting['w'] . 
+        $currentsetting = $currentsetting['u'] . $currentsetting['m'] . $currentsetting['t'] . $currentsetting['w'] .
                           $currentsetting['r'] . $currentsetting['f'] . $currentsetting['s'];
-        
+
         return '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td><td align="left">' .
-        '<table><tr><td><div align="center">&nbsp;&nbsp;' . get_string('sunday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . 
+        '<table><tr><td><div align="center">&nbsp;&nbsp;' . get_string('sunday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('monday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('tuesday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('wednesday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('thursday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('friday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('saturday', 'calendar') . '&nbsp;&nbsp;</div></td></tr><tr>' .
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[u]" value="1" ' . (substr($currentsetting,0,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[m]" value="1" ' . (substr($currentsetting,1,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[t]" value="1" ' . (substr($currentsetting,2,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[w]" value="1" ' . (substr($currentsetting,3,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[r]" value="1" ' . (substr($currentsetting,4,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[f]" value="1" ' . (substr($currentsetting,5,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[s]" value="1" ' . (substr($currentsetting,6,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '</tr></table>' .                                                 
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[u]" value="1" ' . (substr($currentsetting,0,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[m]" value="1" ' . (substr($currentsetting,1,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[t]" value="1" ' . (substr($currentsetting,2,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[w]" value="1" ' . (substr($currentsetting,3,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[r]" value="1" ' . (substr($currentsetting,4,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[f]" value="1" ' . (substr($currentsetting,5,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[s]" value="1" ' . (substr($currentsetting,6,1) == '1' ? 'checked="checked"' : '') . ' /></div></td>' .
+        '</tr></table>' .
         '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
-    
+
     }
-    
+
     // we're using the array trick (see http://ca.php.net/manual/en/faq.html.php#faq.html.arrays) to get the data passed to use without having to modify
     // admin_settingpage (note that admin_settingpage only calls write_setting with the data that matches $this->name... so if we have multiple form fields,
     // they MUST go into an array named $this->name, or else we won't receive them here
@@ -2124,7 +2124,7 @@ class admin_setting_special_backupdays extends admin_setting {
         $week = 'umtwrfs';
         $result = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0);
         foreach($data as $key => $value) {
-          if ($value == '1') { 
+          if ($value == '1') {
               $result[strpos($week, $key)] = 1;
           }
         }
@@ -2189,18 +2189,18 @@ class admin_setting_special_calendar_weekend extends admin_setting {
             return NULL;
         }
     }
-    
+
     function write_setting($data) {
         $week = 'umtwrfs';
         $result = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0);
         foreach($data as $key => $value) {
-          if ($value == '1') { 
+          if ($value == '1') {
               $result[strpos($week, $key)] = 1;
           }
         }
         return (set_config($this->name, bindec(implode('',$result))) ? '' : get_string('errorsetting', 'admin') . $this->visiblename . '<br />');
     }
-    
+
     function output_html() {
 
         if ($this->get_setting() === NULL) {
@@ -2210,20 +2210,20 @@ class admin_setting_special_calendar_weekend extends admin_setting {
         }
 
         return '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td><td align="left">' .
-        '<table><tr><td><div align="center">&nbsp;&nbsp;' . get_string('sunday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . 
+        '<table><tr><td><div align="center">&nbsp;&nbsp;' . get_string('sunday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('monday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('tuesday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('wednesday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('thursday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' .
         get_string('friday', 'calendar') . '&nbsp;&nbsp;</div></td><td><div align="center">&nbsp;&nbsp;' . get_string('saturday', 'calendar') . '&nbsp;&nbsp;</div></td></tr><tr>' .
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[u]" value="1" ' . ($currentsetting['u'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[m]" value="1" ' . ($currentsetting['m'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[t]" value="1" ' . ($currentsetting['t'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[w]" value="1" ' . ($currentsetting['w'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[r]" value="1" ' . ($currentsetting['r'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[f]" value="1" ' . ($currentsetting['f'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[s]" value="1" ' . ($currentsetting['s'] ? 'checked="checked"' : '') . ' /></div></td>' . 
-        '</tr></table>' .                                                 
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[u]" value="1" ' . ($currentsetting['u'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[m]" value="1" ' . ($currentsetting['m'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[t]" value="1" ' . ($currentsetting['t'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[w]" value="1" ' . ($currentsetting['w'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[r]" value="1" ' . ($currentsetting['r'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[f]" value="1" ' . ($currentsetting['f'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '<td><div align="center"><input type="checkbox" name="s_'. $this->name .'[s]" value="1" ' . ($currentsetting['s'] ? 'checked="checked"' : '') . ' /></div></td>' .
+        '</tr></table>' .
         '</td></tr><tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
-    
+
     }
 
 }
@@ -2252,7 +2252,7 @@ class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
         } else {
             $currentsetting = $this->get_setting();
         }
-    
+
         return '<tr><td width="100" align="right" valign="top">' . $this->visiblename . '</td>' .
             '<td align="left"><input type="checkbox" size="50" name="s_'. $this->name .'" value="1" ' . ($currentsetting == 15 ? 'checked="checked"' : '') . ' /></td></tr>' .
             '<tr><td>&nbsp;</td><td align="left">' . $this->description . '</td></tr>';
@@ -2265,10 +2265,10 @@ class admin_setting_special_perfdebug extends admin_setting_configcheckbox {
 function admin_externalpage_setup($section, $adminroot) {
 
     global $CFG, $PAGE, $USER;
-    
+
     require_once($CFG->libdir . '/blocklib.php');
     require_once($CFG->dirroot . '/'.$CFG->admin.'/pagelib.php');
-    
+
     page_map_class(PAGE_ADMIN, 'page_admin');
 
     $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number
@@ -2294,13 +2294,13 @@ function admin_externalpage_setup($section, $adminroot) {
         error(get_string('accessdenied', 'admin'));
         die;
     }
-    
+
     $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
-    
+
     if (!isset($USER->adminediting)) {
         $USER->adminediting = false;
     }
-    
+
     if ($PAGE->user_allowed_editing()) {
         if ($adminediting == 1) {
             $USER->adminediting = true;
@@ -2308,19 +2308,19 @@ function admin_externalpage_setup($section, $adminroot) {
             $USER->adminediting = false;
         }
     }
-    
+
 }
 
 function admin_externalpage_print_header($adminroot) {
 
     global $CFG, $PAGE, $SITE;
-    
+
     if (!empty($SITE->fullname)) {
         $pageblocks = blocks_setup($PAGE);
 
-        $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 
+        $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
                                                BLOCK_L_MAX_WIDTH);
-    
+
         $PAGE->print_header();
         echo '<table id="layout-table"><tr>';
         echo '<td style="width: ' . $preferred_width_left . 'px;" id="left-column">';
@@ -2369,7 +2369,7 @@ function admin_get_root() {
             }
         }
     }
-    
+
     return $ADMIN;
 }
 
@@ -2386,9 +2386,9 @@ function apply_default_settings(&$node) {
             apply_default_settings($node->children[$entry]);
         }
         return;
-    } 
+    }
 
-    if (is_a($node, 'admin_settingpage')) { 
+    if (is_a($node, 'admin_settingpage')) {
         foreach ($node->settings as $setting) {
                 $CFG->{$setting->name} = $setting->defaultsetting;
                 $setting->write_setting($setting->defaultsetting);
index c590a5dcb883ac0230d0d503ab5cb9e5e8ecea24..94e22bd52b9ffa34f9de6b65828ad287d96363a9 100644 (file)
 
 
 $moodle_capabilities = array(
-    
+
     'moodle/site:doanything' => array(
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG,
         'captype' => 'admin',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
+
     'moodle/legacy:guest' => array(
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/legacy:student' => array(
         'riskbitmask' => RISK_SPAM,
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/legacy:teacher' => array(
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/legacy:editingteacher' => array(
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/legacy:coursecreator' => array(
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/legacy:admin' => array(
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG,
         'captype' => 'legacy',
         'contextlevel' => CONTEXT_SYSTEM
     ),
-    
-    
+
+
     'moodle/site:config' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS | RISK_CONFIG,
 
         'captype' => 'write',
@@ -95,9 +95,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:readallmessages' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -109,9 +109,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:approvecourse' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -123,9 +123,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:import' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
 
         'captype' => 'write',
@@ -139,9 +139,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:backup' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
 
         'captype' => 'write',
@@ -155,9 +155,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:restore' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL | RISK_XSS,
 
         'captype' => 'write',
@@ -171,9 +171,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:manageblocks' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_XSS,
 
         'captype' => 'write',
@@ -187,9 +187,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:accessallgroups' => array(
-        
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -201,9 +201,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:viewfullnames' => array(
-        
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -215,9 +215,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-        
+
     'moodle/site:viewparticipants' => array(
-        
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -229,9 +229,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:viewreports' => array(
-    
+
         'riskbitmask' => RISK_PERSONAL,
 
         'captype' => 'read',
@@ -245,9 +245,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/site:trustcontent' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -261,9 +261,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:create' => array(
-    
+
         'riskbitmask' => RISK_SPAM | RISK_PERSONAL,
 
         'captype' => 'write',
@@ -277,9 +277,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:delete' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -291,9 +291,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:update' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -307,9 +307,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:viewdetails' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -323,7 +323,7 @@ $moodle_capabilities = array(
     ),
 
     'moodle/user:viewhiddendetails' => array(
-    
+
         'riskbitmask' => RISK_PERSONAL,
 
         'captype' => 'read',
@@ -337,9 +337,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/role:assign' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -351,9 +351,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/role:override' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -365,9 +365,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/role:manage' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_SYSTEM,
         'legacy' => array(
@@ -405,9 +405,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/category:create' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSECAT,
         'legacy' => array(
@@ -419,9 +419,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/category:delete' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSECAT,
         'legacy' => array(
@@ -433,9 +433,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/category:update' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSECAT,
         'legacy' => array(
@@ -447,9 +447,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/category:visibility' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSECAT,
         'legacy' => array(
@@ -461,9 +461,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:create' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -477,9 +477,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:delete' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -491,9 +491,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:update' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -507,9 +507,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -521,9 +521,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewhiddenuserfields' => array(
-    
+
         'riskbitmask' => RISK_PERSONAL,
 
         'captype' => 'read',
@@ -537,9 +537,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewhiddencourses' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -551,9 +551,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:visibility' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -565,9 +565,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managefiles' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -581,9 +581,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managequestions' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -597,9 +597,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:manageactivities' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -613,9 +613,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managemetacourse' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -627,9 +627,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:activityvisibility' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -641,9 +641,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewhiddenactivities' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -655,9 +655,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewparticipants' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -669,9 +669,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewscales' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -683,9 +683,9 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managescales' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
         'legacy' => array(
@@ -697,7 +697,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managegroups' => array(
 
         'captype' => 'write',
@@ -711,7 +711,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:reset' => array(
 
         'captype' => 'write',
@@ -725,7 +725,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/blog:view' => array(
 
         'captype' => 'read',
@@ -739,7 +739,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/blog:create' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -755,7 +755,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/blog:manageofficialtags' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -771,7 +771,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/blog:managepersonaltags' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -787,7 +787,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/blog:manageentries' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -803,7 +803,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/calendar:manageownentries' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -819,7 +819,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/calendar:manageentries' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -835,8 +835,8 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
-    // The next 3 might make no sense for some roles, e.g teacher, etc. 
+
+    // The next 3 might make no sense for some roles, e.g teacher, etc.
     // since the next level up is site. These are more for the parent role
     'moodle/user:readuserposts' => array(
         'captype' => 'read',
@@ -850,7 +850,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:readuserblogs' => array(
         'captype' => 'read',
         'contextlevel' => CONTEXT_USER,
@@ -863,7 +863,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:viewuseractivitiesreport' => array(
         'captype' => 'read',
         'contextlevel' => CONTEXT_USER,
@@ -876,7 +876,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:editprofile' => array(
 
         'riskbitmask' => RISK_SPAM,
@@ -892,7 +892,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/question:import' => array(
 
         'riskbitmask' => RISK_XSS,
@@ -908,7 +908,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/question:export' => array(
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
@@ -921,7 +921,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/question:managecategory' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -934,7 +934,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/question:manage' => array(
 
         'riskbitmask' => RISK_XSS,
@@ -963,7 +963,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:sectionvisibility' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -976,7 +976,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-   
+
     'moodle/course:useremail' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -989,7 +989,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-      
+
     'moodle/course:viewhiddensections' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -1002,7 +1002,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:setcurrentsection' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -1015,7 +1015,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:viewcoursegrades' => array(
         'captype' => 'read',
         'contextlevel' => CONTEXT_COURSE,
@@ -1028,7 +1028,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/course:managegrades' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
@@ -1041,7 +1041,7 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'moodle/user:viewusergrades' => array(
         'captype' => 'write',
         'contextlevel' => CONTEXT_COURSE,
index 0ae3541e5e748e49d446b712a4ccc9718ce963a3..30b60c8714bff84bf97925a1bf340c196802686f 100644 (file)
 
 // This library includes all the required functions used to handle the DB
 // structure (DDL) independently of the underlying RDBMS in use. All the functions
-// rely on the XMLDBDriver classes to be able to generate the correct SQL 
+// rely on the XMLDBDriver classes to be able to generate the correct SQL
 // syntax needed by each DB.
 //
-// To define any structure to be created we'll use the schema defined 
+// To define any structure to be created we'll use the schema defined
 // by the XMLDB classes, for tables, fields, indexes, keys and other
 // statements instead of direct handling of SQL sentences.
 //
@@ -59,7 +59,7 @@
 
 /// Add other libraries
     require_once($CFG->libdir . '/xmlize.php');
-    
+
 
 /**
  * Add a new field to a table, or modify an existing one (if oldfield is defined).
@@ -244,7 +244,7 @@ function table_column($table, $oldfield, $field, $type='integer', $size='10',
  * SQL statements, specific for each RDBMS ($CFG->dbtype) and, finally, it
  * will execute all those statements against the DB.
  *
- * @uses $CFG, $db 
+ * @uses $CFG, $db
  * @param $file full path to the XML file to be used
  * @return boolean (true on success, false on error)
  */
@@ -279,7 +279,7 @@ function install_from_xmldb_file($file) {
  * This function will create the table passed as argument with all its
  * fields/keys/indexes/sequences, everything based in the XMLDB object
  *
- * @uses $CFG, $db 
+ * @uses $CFG, $db
  * @param XMLDBTable table object (full specs are required)
  * @param boolean continue to specify if must continue on error (true) or stop (false)
  * @param boolean feedback to specify to show status info (true) or not (false)
@@ -307,7 +307,7 @@ function create_table($table, $continue=true, $feedback=true) {
  * and all the associated objects (keys, indexes, constaints, sequences, triggers)
  * will be dropped too.
  *
- * @uses $CFG, $db 
+ * @uses $CFG, $db
  * @param XMLDBTable table object (just the name is mandatory)
  * @param boolean continue to specify if must continue on error (true) or stop (false)
  * @param boolean feedback to specify to show status info (true) or not (false)
@@ -333,7 +333,7 @@ function drop_table($table, $continue=true, $feedback=true) {
 /**
  * This function will add the field to the table passed as arguments
  *
- * @uses $CFG, $db 
+ * @uses $CFG, $db
  * @param XMLDBTable table object (just the name is mandatory)
  * @param XMLDBField field object (full specs are required)
  * @param boolean continue to specify if must continue on error (true) or stop (false)
@@ -363,7 +363,7 @@ function add_field($table, $field, $continue=true, $feedback=true) {
 /**
  * This function will drop the field from the table passed as arguments
  *
- * @uses $CFG, $db 
+ * @uses $CFG, $db
  * @param XMLDBTable table object (just the name is mandatory)
  * @param XMLDBField field object (just the name is mandatory)
  * @param boolean continue to specify if must continue on error (true) or stop (false)
index defb681c136d3292dd4d49a1043975610d71ee05..1e84bf062df80c9462fd8940869be1228a35af26 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This library contains all the Data Manipulation Language (DML) functions 
+/// This library contains all the Data Manipulation Language (DML) functions
 /// used to interact with the DB. All the dunctions in this library must be
 /// generic and work against the major number of RDBMS possible. This is the
 /// list of currently supported and tested DBs: mysql, postresql, mssql, oracle
@@ -101,7 +101,7 @@ function begin_sql() {
     return true;
 }
 /**
-* on DBs that support it, commit the transaction 
+* on DBs that support it, commit the transaction
 */
 function rollback_sql() {
 /// Completely general function - it just runs some SQL and reports success.
@@ -132,7 +132,7 @@ function db_lowercase() {
 }
 
 /**
-* on DBs that support it, commit the transaction 
+* on DBs that support it, commit the transaction
 */
 function commit_sql() {
 /// Completely general function - it just runs some SQL and reports success.
@@ -155,7 +155,7 @@ function commit_sql() {
  *
  * @uses $CFG
  * @param string $sqlfile The path where a file with sql commands can be found on the server.
- * @param string $sqlstring If no path is supplied then a string with semicolon delimited sql 
+ * @param string $sqlstring If no path is supplied then a string with semicolon delimited sql
  * commands can be supplied in this argument.
  * @return bool Returns true if databse was modified successfully.
  */
@@ -332,11 +332,11 @@ function count_records_select($table, $select='', $countitem='COUNT(*)') {
  */
 function count_records_sql($sql) {
     $rs = get_recordset_sql($sql);
-    
+
     if ($rs) {
         return reset($rs->fields);
     } else {
-        return 0;   
+        return 0;
     }
 }
 
@@ -370,12 +370,12 @@ function get_record($table, $field1, $value1, $field2='', $value2='', $field3=''
  * The SQL statement should normally only return one record. In debug mode
  * you will get a warning if more record is returned (unless you
  * set $expectmultiple to true). In non-debug mode, it just returns
- * the first record. 
+ * the first record.
  *
  * @uses $CFG
  * @uses $db
  * @param string $sql The SQL string you wish to be executed, should normally only return one record.
- * @param bool $expectmultiple If the SQL cannot be written to conviniently return just one record, 
+ * @param bool $expectmultiple If the SQL cannot be written to conviniently return just one record,
  *      set this to true to hide the debug message.
  * @param bool $nolimit sometimes appending ' LIMIT 1' to the SQL causes an error. Set this to true
  *      to stop your SQL being modified. This argument should probably be deprecated.
@@ -392,7 +392,7 @@ function get_record_sql($sql, $expectmultiple=false, $nolimit=false) {
 /// Only a few uses of the 2nd and 3rd parameter have been found
 /// I think that we should avoid to use them completely, one
 /// record is one record, and everything else should return error.
-/// So the proposal is to change all the uses, (4-5 inside Moodle 
+/// So the proposal is to change all the uses, (4-5 inside Moodle
 /// Core), drop them from the definition and delete the next two
 /// "if" sentences. (eloy, 2006-08-19)
 
@@ -404,20 +404,20 @@ function get_record_sql($sql, $expectmultiple=false, $nolimit=false) {
         $limitnum  = 1;
     } else if (debugging()) {
         // Debugging mode - don't use a limit of 1, but do change the SQL, because sometimes that
-        // causes errors, and in non-debug mode you don't see the error message and it is 
+        // causes errors, and in non-debug mode you don't see the error message and it is
         // impossible to know what's wrong.
         $limitfrom = 0;
         $limitnum  = 100;
     }
 
     if (!$rs = get_recordset_sql($sql, $limitfrom, $limitnum)) {
-        return false;   
+        return false;
     }
-    
+
     $recordcount = $rs->RecordCount();
 
     if ($recordcount == 0) {          // Found no records
-        return false; 
+        return false;
 
     } else if ($recordcount == 1) {    // Found one record
     /// DIRTY HACK to retrieve all the ' ' (1 space) fields converted back
@@ -467,23 +467,23 @@ function get_record_select($table, $select='', $fields='*') {
  * Get a number of records as an ADODB RecordSet.
  *
  * Selects records from the table $table.
- * 
+ *
  * If specified, only records where the field $field has value $value are retured.
- * 
+ *
  * If specified, the results will be sorted as specified by $sort. This
  * is added to the SQL as "ORDER BY $sort". Example values of $sort
  * mightbe "time ASC" or "time DESC".
- * 
+ *
  * If $fields is specified, only those fields are returned.
  *
- * This function is internal to datalib, and should NEVER should be called directly 
+ * This function is internal to datalib, and should NEVER should be called directly
  * from general Moodle scripts.  Use get_record, get_records etc.
- * 
+ *
  * If you only want some of the records, specify $limitfrom and $limitnum.
  * The query will skip the first $limitfrom records (according to the sort
  * order) and then return the next $limitnum records. If either of $limitfrom
  * or $limitnum is specified, both must be present.
- * 
+ *
  * The return value is an ADODB RecordSet object
  * @link http://phplens.com/adodb/reference.functions.adorecordset.html
  * if the query succeeds. If an error occurrs, false is returned.
@@ -504,7 +504,7 @@ function get_recordset($table, $field='', $value='', $sort='', $fields='*', $lim
     } else {
         $select = '';
     }
-    
+
     return get_recordset_select($table, $select, $sort, $fields, $limitfrom, $limitnum);
 }
 
@@ -513,8 +513,8 @@ function get_recordset($table, $field='', $value='', $sort='', $fields='*', $lim
  *
  * If given, $select is used as the SELECT parameter in the SQL query,
  * otherwise all records from the table are returned.
- * 
- * Other arguments and the return type as for @see function get_recordset. 
+ *
+ * Other arguments and the return type as for @see function get_recordset.
  *
  * @uses $CFG
  * @param string $table the table to query.
@@ -552,8 +552,8 @@ function get_recordset_select($table, $select='', $sort='', $fields='*', $limitf
  * Only records where $field takes one of the values $values are returned.
  * $values should be a comma-separated list of values, for example "4,5,6,10"
  * or "'foo','bar','baz'".
- * 
- * Other arguments and the return type as for @see function get_recordset. 
+ *
+ * Other arguments and the return type as for @see function get_recordset.
  *
  * @param string $table the table to query.
  * @param string $field a field to check (optional).
@@ -577,10 +577,10 @@ function get_recordset_list($table, $field='', $values='', $sort='', $fields='*'
 
 /**
  * Get a number of records as an ADODB RecordSet.  $sql must be a complete SQL query.
- * This function is internal to datalib, and should NEVER should be called directly 
+ * This function is internal to datalib, and should NEVER should be called directly
  * from general Moodle scripts.  Use get_record, get_records etc.
- *  
- * The return type is as for @see function get_recordset. 
+ *
+ * The return type is as for @see function get_recordset.
  *
  * @uses $CFG
  * @uses $db
@@ -620,7 +620,7 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
 
 /**
  * Utility function used by the following 4 methods.
- * 
+ *
  * @param object an ADODB RecordSet object.
  * @return mixed mixed an array of objects, or false if an error occured or the RecordSet was empty.
  */
@@ -654,7 +654,7 @@ function recordset_to_array($rs) {
     }
 }
 
-/** 
+/**
  * This function is used to convert all the Oracle 1-space defaults to the empty string
  * like a really DIRTY HACK to allow it to work better until all those NOT NULL DEFAULT ''
  * fields will be out from Moodle.
@@ -671,7 +671,7 @@ function onespace2empty(&$item, $key) {
  *
  * If the query succeeds and returns at least one record, the
  * return value is an array of objects, one object for each
- * record found. The array key is the value from the first 
+ * record found. The array key is the value from the first
  * column of the result set. The object associated with that key
  * has a member variable for each column of the results.
  *
@@ -728,7 +728,7 @@ function get_records_list($table, $field='', $values='', $sort='', $fields='*',
  * Get a number of records as an array of objects.
  *
  * Return value as for @see function get_records.
- * 
+ *
  * @param string $sql the SQL select query to execute.
  * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
  * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
@@ -741,7 +741,7 @@ function get_records_sql($sql, $limitfrom='', $limitnum='') {
 
 /**
  * Utility function used by the following 3 methods.
- * 
+ *
  * @param object an ADODB RecordSet object with two columns.
  * @return mixed an associative array, or false if an error occured or the RecordSet was empty.
  */
@@ -764,7 +764,7 @@ function recordset_to_menu($rs) {
  * Get the first two columns from a number of records as an associative array.
  *
  * Arguments as for @see function get_recordset.
- * 
+ *
  * If no errors occur, and at least one records is found, the return value
  * is an associative whose keys come from the first field of each record,
  * and whose values are the corresponding second fields. If no records are found,
@@ -867,7 +867,7 @@ function get_field_sql($sql) {
 }
 
 /**
- * Get an array of data from one or more fields from a database 
+ * Get an array of data from one or more fields from a database
  * use to get a column, or a series of distinct values
  *
  * @uses $CFG
@@ -1027,16 +1027,16 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
 
 /// Postgres doesn't have the concept of primary key built in
 /// and will return the OID which isn't what we want.
-/// The efficient and transaction-safe strategy is to 
+/// The efficient and transaction-safe strategy is to
 /// move the sequence forward first, and make the insert
 /// with an explicit id.
     if ( $CFG->dbtype === 'postgres7' && $returnid == true ) {
         if ($nextval = (int)get_field_sql("SELECT NEXTVAL('{$CFG->prefix}{$table}_{$primarykey}_seq')")) {
-            $dataobject->{$primarykey} = $nextval;            
-        } 
+            $dataobject->{$primarykey} = $nextval;
+        }
     }
 
-/// First basic support of insert for Oracle. As it doesn't 
+/// First basic support of insert for Oracle. As it doesn't
 /// support autogenerated fields, we rely on the corresponding
 /// sequence. It will work automatically, unless we need to
 /// return the primary from the function, in this case we
@@ -1049,7 +1049,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
         $generator->setPrefix($CFG->prefix);
         $seqname = $generator->getNameForObject($table, $primarykey, 'seq');
         if ($nextval = (int)get_field_sql("SELECT $seqname.NEXTVAL from dual")) {
-            $dataobject->{$primarykey} = $nextval;            
+            $dataobject->{$primarykey} = $nextval;
         }
     }
 /// Also, for Oracle DB, empty strings are converted to NULLs in DB
@@ -1059,7 +1059,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
 /// What we are going to do is to examine all the data being inserted and if it's
 /// an empty string (NULL for Oracle) and the field is defined as NOT NULL, we'll modify
 /// such data in the best form possible ("0" for booleans and numbers and " " for the
-/// rest of strings. It isn't optimal, but the only way to do so. 
+/// rest of strings. It isn't optimal, but the only way to do so.
 /// In the oppsite, when retrieving records from Oracle, we'll decode " " back to
 /// empty strings to allow everything to work properly. DIRTY HACK.
     if ( $CFG->dbtype === 'oci8po') {
@@ -1130,9 +1130,9 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
     }
 
 /// This only gets triggered with non-Postgres databases
-/// however we have some postgres fallback in case we failed 
+/// however we have some postgres fallback in case we failed
 /// to find the sequence.
-    $id = $db->Insert_ID();  
+    $id = $db->Insert_ID();
 
     if ($CFG->dbtype === 'postgres7') {
         // try to get the primary key based on id
@@ -1140,7 +1140,7 @@ function insert_record($table, $dataobject, $returnid=true, $primarykey='id') {
              && ($rs->RecordCount() == 1) ) {
             trigger_error("Retrieved $primarykey from oid on table $table because we could not find the sequence.");
             return (integer)reset($rs->fields);
-        } 
+        }
         trigger_error('Failed to retrieve primary key after insert: SELECT '. $primarykey .
                       ' FROM '. $CFG->prefix . $table .' WHERE oid = '. $id);
         return false;
@@ -1257,7 +1257,7 @@ function sql_ilike() {
 
 /**
  * Returns the proper SQL (for the dbms in use) to concatenate $firstname and $lastname
- * 
+ *
  * @uses $CFG
  * @param string $firstname User's first name
  * @param string $lastname User's last name
@@ -1295,7 +1295,7 @@ function sql_isnull($fieldname) {
     }
 }
 
-/** 
+/**
  * Returns the proper AS keyword to be used to aliase columns
  * SQL defines the keyword as optional and nobody but PG
  * seems to require it. This function should be used inside all
@@ -1318,7 +1318,7 @@ function sql_as() {
 
 /**
  * Returns the SQL text to be used to order by one TEXT (clob) column, because
- * some RDBMS doesn't support direct ordering of such fields. 
+ * some RDBMS doesn't support direct ordering of such fields.
  * Note that the use or queries being ordered by TEXT columns must be minimised,
  * because it's really slooooooow.
  * @param string fieldname the name of the TEXT field we need to order by
@@ -1341,13 +1341,13 @@ function sql_order_by_text($fieldname, $numchars=32) {
     }
 }
 
-/** 
+/**
  * Prepare a SQL WHERE clause to select records where the given fields match the given values.
- * 
+ *
  * Prepares a where clause of the form
  *     WHERE field1 = value1 AND field2 = value2 AND field3 = value3
  * except that you need only specify as many arguments (zero to three) as you need.
- * 
+ *
  * @param string $field1 the first field to check (optional).
  * @param string $value1 the value field1 must have (requred if field1 is given, else optional).
  * @param string $field2 the second field to check (optional).
index f6d38e66d58d9a1b36e1332bc5132fc7438290f6..85ac444a7db73f832d87a3ddba5c582996db8eb1 100644 (file)
@@ -24,7 +24,7 @@
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-/// This file contains all the constants and variables used 
+/// This file contains all the constants and variables used
 /// by the XMLDB interface
 
 /// First, some constants to be used by actions
@@ -35,9 +35,9 @@
 
 /// Now the allowed DB Field Types
     define ('XMLDB_TYPE_INCORRECT',   0);  //Wrong DB Type
-    define ('XMLDB_TYPE_INTEGER',     1);  //Integer 
-    define ('XMLDB_TYPE_NUMBER',      2);  //Decimal number 
-    define ('XMLDB_TYPE_FLOAT',       3);  //Floating Point number 
+    define ('XMLDB_TYPE_INTEGER',     1);  //Integer
+    define ('XMLDB_TYPE_NUMBER',      2);  //Decimal number
+    define ('XMLDB_TYPE_FLOAT',       3);  //Floating Point number
     define ('XMLDB_TYPE_CHAR',        4);  //String
     define ('XMLDB_TYPE_TEXT',        5);  //Text
     define ('XMLDB_TYPE_BINARY',      6);  //Binary
@@ -46,9 +46,9 @@
 
 /// Now the allowed DB Keys
     define ('XMLDB_KEY_INCORRECT',     0);  //Wrong DB Key
-    define ('XMLDB_KEY_PRIMARY',       1);  //Primary Keys 
+    define ('XMLDB_KEY_PRIMARY',       1);  //Primary Keys
     define ('XMLDB_KEY_UNIQUE',        2);  //Unique Keys
-    define ('XMLDB_KEY_FOREIGN',       3);  //Foreign Keys 
+    define ('XMLDB_KEY_FOREIGN',       3);  //Foreign Keys
     define ('XMLDB_KEY_CHECK',         4);  //Check Constraints - NOT USED!
     define ('XMLDB_KEY_FOREIGN_UNIQUE',5);  //Foreign Key + Unique Key
 
index 5bf2c0aa9fc8ce4a148ab9f49f56b1b4583f89e0..798973f1b53bdc72038aeadd4b4802ccdd64e03a 100644 (file)
@@ -27,7 +27,7 @@
 /// This class represent one XMLDB Field
 
 class XMLDBField extends XMLDBObject {
+
     var $type;
     var $length;
     var $unsigned;
@@ -395,7 +395,7 @@ class XMLDBField extends XMLDBObject {
         if (isset($xmlarr['@']['DECIMALS'])) {
             $decimals = trim($xmlarr['@']['DECIMALS']);
         /// Check for integer values
-            if ($this->type == XMLDB_TYPE_NUMBER || 
+            if ($this->type == XMLDB_TYPE_NUMBER ||
                 $this->type == XMLDB_TYPE_FLOAT) {
                 if (!(is_numeric($decimals)&&(intval($decimals)==floatval($decimals)))) {
                     $this->errormsg = 'Incorrect DECIMALS attribute for number field';
@@ -446,7 +446,7 @@ class XMLDBField extends XMLDBObject {
     function getXMLDBFieldType($type) {
 
         $result = XMLDB_TYPE_INCORRECT;
-        
+
         switch (strtolower($type)) {
             case 'int':
                 $result = XMLDB_TYPE_INTEGER;
@@ -481,7 +481,7 @@ class XMLDBField extends XMLDBObject {
     function getXMLDBTypeName($type) {
 
         $result = "";
-        
+
         switch (strtolower($type)) {
             case XMLDB_TYPE_INTEGER:
                 $result = 'int';
@@ -526,7 +526,7 @@ class XMLDBField extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      *This function will output the XML text for one field
      */
     function xmlOutput() {
@@ -642,7 +642,7 @@ class XMLDBField extends XMLDBObject {
                 $this->type = XMLDB_TYPE_TEXT;
         }
     /// Calculate the length of the field
-        if ($adofield->max_length > 0 && 
+        if ($adofield->max_length > 0 &&
                ($this->type == XMLDB_TYPE_INTEGER ||
                 $this->type == XMLDB_TYPE_NUMBER  ||
                 $this->type == XMLDB_TYPE_FLOAT   ||
@@ -683,13 +683,13 @@ class XMLDBField extends XMLDBObject {
         }
     /// Calculate the decimals of the field
         if ($adofield->max_length > 0 &&
-            $adofield->scale && 
+            $adofield->scale &&
                ($this->type == XMLDB_TYPE_NUMBER ||
                 $this->type == XMLDB_TYPE_FLOAT)) {
             $this->decimals = $adofield->scale;
         }
     /// Calculate the unsigned field
-        if ($adofield->unsigned && 
+        if ($adofield->unsigned &&
                ($this->type == XMLDB_TYPE_INTEGER ||
                 $this->type == XMLDB_TYPE_NUMBER  ||
                 $this->type == XMLDB_TYPE_FLOAT)) {
@@ -702,7 +702,7 @@ class XMLDBField extends XMLDBObject {
     /// Calculate the default field
         if ($adofield->has_default) {
             $this->default = $adofield->default_value;
-        } 
+        }
     /// Calculate the sequence field
         if ($adofield->auto_increment) {
             $this->sequence = true;
index 24e4010470064c6ec51e2868f6eb05075ac9f83b..571aa99ba2736fda822f5c2a9180c33a5844e460 100644 (file)
@@ -94,7 +94,7 @@ class XMLDBFile extends XMLDBObject {
         return $structure;
     }
 
-    /** 
+    /**
      * This function saves the whole XMLDBStructure to its file
      */
     function saveXMLFile() {
index 8333b42d5e9186a420557e5a0470325fea14f1d1..c23e5f25b175997a19c1cb3f891803e003183a92 100644 (file)
@@ -27,7 +27,7 @@
 /// This class represent one XMLDB Index
 
 class XMLDBIndex extends XMLDBObject {
+
     var $unique;
     var $fields;
 
@@ -72,7 +72,7 @@ class XMLDBIndex extends XMLDBObject {
         $this->fields = $fields;
     }
 
-    /** 
+    /**
      * Get the index fields
      */
     function &getFields() {
@@ -113,7 +113,7 @@ class XMLDBIndex extends XMLDBObject {
                 $this->errormsg = 'Undefined UNIQUE attribute';
                 $result = false;
         }
-          
+
         if (isset($xmlarr['@']['FIELDS'])) {
             $fields = strtolower(trim($xmlarr['@']['FIELDS']));
             if ($fields) {
@@ -169,7 +169,7 @@ class XMLDBIndex extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      *This function will output the XML text for one index
      */
     function xmlOutput() {
@@ -236,7 +236,7 @@ class XMLDBIndex extends XMLDBObject {
         return $result;
     }
 
-    /**     
+    /**
      * Shows info in a readable format
      */
     function readableInfo() {
index 76fab318fad50cb456117516dc5c83d624a8efd3..61555431ad8c353b97849aa3f0097c712fd262ff 100644 (file)
@@ -27,7 +27,7 @@
 /// This class represent one XMLDB Key
 
 class XMLDBKey extends XMLDBObject {
+
     var $type;
     var $fields;
     var $reftable;
@@ -94,7 +94,7 @@ class XMLDBKey extends XMLDBObject {
         $this->reffields = $reffields;
     }
 
-    /** 
+    /**
      * Get the key fields
      */
     function &getFields() {
@@ -127,7 +127,7 @@ class XMLDBKey extends XMLDBObject {
     /// print_object ($GLOBALS['traverse_array']);  //Debug
     /// $GLOBALS['traverse_array']="";              //Debug
 
-    /// Process key attributes (name, type, fields, reftable, 
+    /// Process key attributes (name, type, fields, reftable,
     /// reffields, comment, previous, next)
         if (isset($xmlarr['@']['NAME'])) {
             $this->name = trim($xmlarr['@']['NAME']);
@@ -175,8 +175,8 @@ class XMLDBKey extends XMLDBObject {
 
         if (isset($xmlarr['@']['REFTABLE'])) {
         /// Check we are in a FK
-            if ($this->type == XMLDB_KEY_FOREIGN || 
-                $this->type == XMLDB_KEY_FOREIGN_UNIQUE) { 
+            if ($this->type == XMLDB_KEY_FOREIGN ||
+                $this->type == XMLDB_KEY_FOREIGN_UNIQUE) {
                 $reftable = strtolower(trim($xmlarr['@']['REFTABLE']));
                 if (!$reftable) {
                     $this->errormsg = 'Empty REFTABLE attribute';
@@ -258,7 +258,7 @@ class XMLDBKey extends XMLDBObject {
     function getXMLDBKeyType($type) {
 
         $result = XMLDB_KEY_INCORRECT;
-        
+
         switch (strtolower($type)) {
             case 'primary':
                 $result = XMLDB_KEY_PRIMARY;
@@ -287,7 +287,7 @@ class XMLDBKey extends XMLDBObject {
     function getXMLDBKeyName($type) {
 
         $result = '';
-        
+
         switch (strtolower($type)) {
             case XMLDB_KEY_PRIMARY:
                 $result = 'primary';
@@ -326,7 +326,7 @@ class XMLDBKey extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      *This function will output the XML text for one key
      */
     function xmlOutput() {
@@ -392,14 +392,14 @@ class XMLDBKey extends XMLDBObject {
             case XMLDB_KEY_FOREIGN:
                 $result .= 'XMLDB_KEY_FOREIGN' . ', ';
                 break;
-        }       
+        }
     /// The fields
         $keyfields = $this->getFields();
         if (!empty($keyfields)) {
             $result .= 'array(' . "'".  implode("', '", $keyfields) . "')";
         } else {
             $result .= 'null';
-        }   
+        }
     /// The FKs attributes
         if ($this->getType() == XMLDB_KEY_FOREIGN) {
         /// The reftable
@@ -408,7 +408,7 @@ class XMLDBKey extends XMLDBObject {
                 $result .= ", '" . $reftable . "', ";
             } else {
                 $result .= 'null, ';
-            }   
+            }
         /// The reffields
             $reffields = $this->getRefFields();
             if (!empty($reffields)) {
@@ -421,9 +421,9 @@ class XMLDBKey extends XMLDBObject {
         return $result;
     }
 
-    /**     
+    /**
      * Shows info in a readable format
-     */ 
+     */
     function readableInfo() {
         $o = '';
     /// type
index efd6f1f6941c4de5a21b251b8512ba44305d1a0a..41c3cab554097dd86673ed55a3471f0b065be3ba 100644 (file)
@@ -28,7 +28,7 @@
 /// are defined
 
 class XMLDBObject {
+
     var $name;
     var $comment;
     var $previous;
@@ -66,14 +66,14 @@ class XMLDBObject {
         return $this->changed;
     }
 
-    /** 
+    /**
      * This function returns the comment of one XMLDBObject
      */
     function getComment() {
         return $this->comment;
     }
 
-    /** 
+    /**
      * This function returns the hash of one XMLDBObject
      */
     function getHash() {
@@ -189,7 +189,7 @@ class XMLDBObject {
         return $result;
     }
 
-    /** 
+    /**
      * This function will check that all the elements in one array
      * have a consistent info in their previous/next fields
      */
@@ -316,9 +316,9 @@ class XMLDBObject {
     function &findObjectInArray($objectname, $arr) {
         foreach ($arr as $i => $object) {
             if ($objectname == $object->getName()) {
-                return $i; 
-            }   
-        }   
+                return $i;
+            }
+        }
         $null = NULL;
         return $null;
     }
@@ -332,7 +332,7 @@ class XMLDBObject {
     }
 
     /**
-     * Returns one array of elements from one comma separated string, 
+     * Returns one array of elements from one comma separated string,
      * supporting quoted strings containing commas and concat function calls
      */
     function comma2array($string) {
index 2844ea879c57ec1fde234285a0b4ffeb5df2f563..0fa063ed37c1c7b9102dbebb2d69fccd60e35505 100644 (file)
@@ -29,7 +29,7 @@
 /// (only INSERT is allowed for now)
 
 class XMLDBStatement extends XMLDBObject {
+
     var $table;     // Table we are handling
     var $type;      // XMLDB_STATEMENT_TYPE
     var $sentences; // Collection of sentences in the statement
@@ -136,7 +136,7 @@ class XMLDBStatement extends XMLDBObject {
                 }
             }
         }
-          
+
     /// Finally, set the array of sentences
         $this->sentences = $sentencesarr;
 
@@ -200,7 +200,7 @@ class XMLDBStatement extends XMLDBObject {
     function getXMLDBStatementType($type) {
 
         $result = XMLDB_STATEMENT_INCORRECT;
-        
+
         switch (strtolower($type)) {
             case 'insert':
                 $result = XMLDB_STATEMENT_INSERT;
@@ -218,7 +218,7 @@ class XMLDBStatement extends XMLDBObject {
     /// Return the normalized XMLDB_STATEMENT
         return $result;
     }
-    
+
     /**
      * This function returns the correct name value for the
      * XMLDB_STATEMENT_XXX passed as argument
@@ -226,7 +226,7 @@ class XMLDBStatement extends XMLDBObject {
     function getXMLDBStatementName($type) {
 
         $result = '';
-        
+
         switch (strtolower($type)) {
             case XMLDB_STATEMENT_INSERT:
                 $result = 'insert';
@@ -257,7 +257,7 @@ class XMLDBStatement extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will output the XML text for one statement
      */
     function xmlOutput() {
@@ -302,7 +302,7 @@ class XMLDBStatement extends XMLDBObject {
         $this->changed = true;
     }
 
-    /**     
+    /**
      * Shows info in a readable format
      */
     function readableInfo() {
@@ -323,7 +323,7 @@ class XMLDBStatement extends XMLDBObject {
      * This function will return an array of fields from one INSERT sentence
      */
     function getFieldsFromInsertSentence($sentence) {
-        
+
         $fields = array();
 
     /// Get first part from the sentence (before VALUES)
@@ -344,7 +344,7 @@ class XMLDBStatement extends XMLDBObject {
      * This function will return an array of values from one INSERT sentence
      */
     function getValuesFromInsertSentence($sentence) {
-        
+
         $values = array();
 
     /// Get second part from the sentence (after VALUES)
@@ -364,7 +364,7 @@ class XMLDBStatement extends XMLDBObject {
     /**
      * This function will return the code needed to execute a collection
      * of sentences present inside one statement for the specified BD
-     * and prefix. 
+     * and prefix.
      * For now it only supports INSERT statements
      */
     function getExecuteStatementSQL ($dbtype, $prefix, $statement_end=true) {
index d711f57f83efe337a339bee34594dec4df1f4fac..4d64e27038d81d442f3e7fec1c9ed6a61d51313f 100644 (file)
@@ -27,7 +27,7 @@
 /// This class represent one XMLDB structure
 
 class XMLDBStructure extends XMLDBObject {
+
     var $path;
     var $version;
     var $tables;
@@ -63,7 +63,7 @@ class XMLDBStructure extends XMLDBObject {
      */
     function &getTable($tablename) {
         $i = $this->findTableInArray($tablename);
-        if ($i !== NULL) { 
+        if ($i !== NULL) {
             return $this->tables[$i];
         }
         $null = NULL;
@@ -134,7 +134,7 @@ class XMLDBStructure extends XMLDBObject {
      */
     function &getStatement($statementname) {
         $i = $this->findStatementInArray($statementname);
-        if ($i !== NULL) { 
+        if ($i !== NULL) {
             return $this->statements[$i];
         }
         $null = NULL;
@@ -148,7 +148,7 @@ class XMLDBStructure extends XMLDBObject {
         return $this->statements;
     }
 
-    /** 
+    /**
      * Set the structure version
      */
     function setVersion($version) {
@@ -311,14 +311,14 @@ class XMLDBStructure extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * Set the tables
      */
     function setTables(&$tables) {
         $this->tables = $tables;
     }
 
-    /** 
+    /**
      * Set the statements
      */
     function setStatements(&$statements) {
@@ -412,7 +412,7 @@ class XMLDBStructure extends XMLDBObject {
                 }
             }
         }
-    
+
     /// Perform some general checks over statements
         if ($result && $this->statements) {
         /// Check statements names are ok (lowercase, a-z _-)
@@ -470,7 +470,7 @@ class XMLDBStructure extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will output the XML text for one structure
      */
     function xmlOutput() {
@@ -508,7 +508,7 @@ class XMLDBStructure extends XMLDBObject {
 
     /**
      * This function returns the number of uses of one table inside
-     * a whole XMLDStructure. Useful to detect if the table must be 
+     * a whole XMLDStructure. Useful to detect if the table must be
      * locked. Return false if no uses are found.
      */
     function getTableUses($tablename) {
@@ -543,7 +543,7 @@ class XMLDBStructure extends XMLDBObject {
 
     /**
      * This function returns the number of uses of one field inside
-     * a whole XMLDBStructure. Useful to detect if the field must be 
+     * a whole XMLDBStructure. Useful to detect if the field must be
      * locked. Return false if no uses are found.
      */
     function getFieldUses($tablename, $fieldname) {
@@ -558,7 +558,7 @@ class XMLDBStructure extends XMLDBObject {
                     in_array($fieldname, $key->getRefFields())) {
                         $uses[] = 'table ' . $table->getName() . ' key ' . $key->getName();
                 }
-            }          
+            }
         }
     /// Check if any index in the table is using it
         $table = $this->getTable($tablename);
@@ -567,7 +567,7 @@ class XMLDBStructure extends XMLDBObject {
                 if (in_array($fieldname, $index->getFields())) {
                     $uses[] = 'table ' . $table->getName() . ' index ' . $index->getName();
                 }
-            }          
+            }
         }
     /// Check if some foreign key in the whole structure is using it
     /// By comparing the reftable and refields with the field)
@@ -600,7 +600,7 @@ class XMLDBStructure extends XMLDBObject {
 
     /**
      * This function returns the number of uses of one key inside
-     * a whole XMLDBStructure. Useful to detect if the key must be 
+     * a whole XMLDBStructure. Useful to detect if the key must be
      * locked. Return false if no uses are found.
      */
     function getKeyUses($tablename, $keyname) {
@@ -639,7 +639,7 @@ class XMLDBStructure extends XMLDBObject {
 
     /**
      * This function returns the number of uses of one index inside
-     * a whole XMLDBStructure. Useful to detect if the index must be 
+     * a whole XMLDBStructure. Useful to detect if the index must be
      * locked. Return false if no uses are found.
      */
     function getIndexUses($tablename, $indexname) {
@@ -657,7 +657,7 @@ class XMLDBStructure extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will return all the errors found in one structure
      * looking recursively inside each table/statement. Returns
      * an array of errors or false
@@ -673,7 +673,7 @@ class XMLDBStructure extends XMLDBObject {
         if ($tables = $this->getTables()) {
             foreach ($tables as $table) {
                 if ($tableerrors = $table->getAllErrors()) {
-    
+
                 }
             }
         /// Add them to the errors array
@@ -697,14 +697,14 @@ class XMLDBStructure extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to create the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
     function getCreateStructureSQL ($dbtype, $prefix, $statement_end=true) {
 
         $results = array();
-        
+
         if ($tables = $this->getTables()) {
             foreach ($tables as $table) {
                 $results = array_merge($results, $table->getCreateTableSQL($dbtype, $prefix, $statement_end));
index 1f869bb592cc8ff4a12be03f92ac84fadaa914ce..d2bda59d7c6141463e5acf8cd0f41b0bf1215ad9 100644 (file)
@@ -27,7 +27,7 @@
 /// This class represent one XMLDB table
 
 class XMLDBTable extends XMLDBObject {
+
     var $fields;
     var $keys;
     var $indexes;
@@ -625,7 +625,7 @@ class XMLDBTable extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will output the XML text for one table
      */
     function xmlOutput() {
@@ -706,7 +706,7 @@ class XMLDBTable extends XMLDBObject {
         $key->setAttributes($type, $fields, $reftable, $reffields);
         $this->addKey($key);
     }
-    
+
     /**
      * This function will add one new index to the table with all
      * its attributes defined
@@ -720,8 +720,8 @@ class XMLDBTable extends XMLDBObject {
         $index->setAttributes($type, $fields);
         $this->addIndex($index);
     }
-    
-    /** 
+
+    /**
      * This function will return all the errors found in one table
      * looking recursively inside each field/key/index. Returns
      * an array of errors or false
@@ -765,7 +765,7 @@ class XMLDBTable extends XMLDBObject {
         }
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to create the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
@@ -783,7 +783,7 @@ class XMLDBTable extends XMLDBObject {
         return $results;
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to create the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
@@ -801,7 +801,7 @@ class XMLDBTable extends XMLDBObject {
         return $results;
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to drop the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
@@ -819,7 +819,7 @@ class XMLDBTable extends XMLDBObject {
         return $results;
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to add one field to the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
@@ -837,7 +837,7 @@ class XMLDBTable extends XMLDBObject {
         return $results;
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to drop one field from the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
@@ -855,7 +855,7 @@ class XMLDBTable extends XMLDBObject {
         return $results;
     }
 
-    /** 
+    /**
      * This function will return the SQL code needed to rename one field from the table for the specified DB and
      * prefix. Just one simple wrapper over generators.
      */
index b15278aead13a3b05fff69a6d4e77c14acd8fd97..10baa0a13eae724f5665fb400fd1ea70f488ab2a 100644 (file)
 ///////////////////////////////////////////////////////////////////////////
 
 /// This class represent the base generator class where all the
-/// needed functions to generate proper SQL are defined. 
+/// needed functions to generate proper SQL are defined.
 
 /// The rest of classes will inherit, by default, the same logic.
 /// Functions will be overriden as needed to generate correct SQL.
 
 class XMLDBgenerator {
 
-/// Please, avoid editing this defaults in this base class! 
+/// Please, avoid editing this defaults in this base class!
 /// It could change the behaviour of the rest of generators
 /// that, by default, inherit this configuration.
 /// To change any of them, do it in extended classes instead.
@@ -403,7 +403,7 @@ class XMLDBgenerator {
         } else {
         /// We force default '' for not null char columns without proper default
         /// some day this should be out!
-            if ($this->default_for_char !== NULL && 
+            if ($this->default_for_char !== NULL &&
                 $xmldb_field->getType() == XMLDB_TYPE_CHAR &&
                 $xmldb_field->getNotNull()) {
                 $default .= ' default ' . "'" . $this->default_for_char . "'";
@@ -415,7 +415,7 @@ class XMLDBgenerator {
     /**
      * Given one correct XMLDBTable and the new name, returns the SQL statements
      * to rename it (inside one array)
-     */ 
+     */
     function getRenameTableSQL($xmldb_table, $newname) {
 
         $results = array();  //Array where all the sentences will be stored
@@ -437,7 +437,7 @@ class XMLDBgenerator {
     /**
      * Given one correct XMLDBTable and the new name, returns the SQL statements
      * to drop it (inside one array)
-     */ 
+     */
     function getDropTableSQL($xmldb_table) {
 
         $results = array();  //Array where all the sentences will be stored
@@ -607,7 +607,7 @@ class XMLDBgenerator {
                  foreach($values as $key => $value) {
                  /// Trim single quotes
                      $value = trim($value,"'");
-                     if (stristr($value, 'CONCAT') !== false){ 
+                     if (stristr($value, 'CONCAT') !== false){
                      /// Look for data between parentesis
                          preg_match("/CONCAT\s*\((.*)\)$/is", trim($value), $matches);
                          if (isset($matches[1])) {
@@ -665,7 +665,7 @@ class XMLDBgenerator {
         }
     }
 
-    /** 
+    /**
      * Given one string (or one array), ends it with statement_end
      */
     function getEndedStatements ($input) {
@@ -674,7 +674,7 @@ class XMLDBgenerator {
             foreach ($input as $key=>$content) {
                 $input[$key] = $this->getEndedStatements($content);
             }
-            return $input; 
+            return $input;
         } else {
             $input = trim($input) . $this->statement_end;
             return $input;
@@ -705,7 +705,7 @@ class XMLDBgenerator {
     }
 
     /**
-     * Returns the code (array of statements) needed 
+     * Returns the code (array of statements) needed
      * to create one sequence for the xmldb_table and xmldb_field passes
      */
     function getCreateSequenceSQL ($xmldb_table, $xmldb_field) {
@@ -741,7 +741,7 @@ class XMLDBgenerator {
     /// Some well-know reserved words
         $reserved_words = array (
             'user', 'scale', 'type', 'comment', 'view', 'value', 'table', 'index', 'key', 'sequence', 'trigger'
-        );  
+        );
         return $reserved_words;
     }
 
@@ -753,7 +753,7 @@ class XMLDBgenerator {
     /// Some well-known tables to be created without prefix
         $tables = array (
             'adodb_logsql'
-        );  
+        );
         return $tables;
     }
 }
index 151078002cd36ec99aa9f0a8683141379170567c..366ff044e0d57922b9aa2b5c8a0d737ac495674d 100644 (file)
@@ -125,11 +125,11 @@ class XMLDBmssql extends XMLDBgenerator {
         return $dbtype;
     }
 
-    /**         
+    /**
      * Returns the code needed to create one enum for the xmldb_table and xmldb_field passes
-     */     
+     */
     function getEnumExtraSQL ($xmldb_table, $xmldb_field) {
-        
+
         $sql = 'CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck');
         $sql.= ' CHECK (' . $this->getEncQuoted($xmldb_field->getName()) . ' IN (' . implode(', ', $xmldb_field->getEnumValues()) . '))';
 
@@ -180,36 +180,36 @@ class XMLDBmssql extends XMLDBgenerator {
     /// This file contains the reserved words for MSSQL databases
     /// from http://msdn2.microsoft.com/en-us/library/ms189822.aspx
         $reserved_words = array (
-            'add', 'all', 'alter', 'and', 'any', 'as', 'asc', 'authorization', 
-            'avg', 'backup', 'begin', 'between', 'break', 'browse', 'bulk', 
-            'by', 'cascade', 'case', 'check', 'checkpoint', 'close', 'clustered', 
-            'coalesce', 'collate', 'column', 'commit', 'committed', 'compute', 
-            'confirm', 'constraint', 'contains', 'containstable', 'continue', 
-            'controlrow', 'convert', 'count', 'create', 'cross', 'current', 
-            'current_date', 'current_time', 'current_timestamp', 'current_user', 
-            'cursor', 'database', 'dbcc', 'deallocate', 'declare', 'default', 'delete', 
-            'deny', 'desc', 'disk', 'distinct', 'distributed', 'double', 'drop', 'dummy', 
-            'dump', 'else', 'end', 'errlvl', 'errorexit', 'escape', 'except', 'exec', 
-            'execute', 'exists', 'exit', 'fetch', 'file', 'fillfactor', 'floppy', 
-            'for', 'foreign', 'freetext', 'freetexttable', 'from', 'full', 'function', 
-            'goto', 'grant', 'group', 'having', 'holdlock', 'identity', 'identitycol', 
-            'identity_insert', 'if', 'in', 'index', 'inner', 'insert', 'intersect', 'into', 
-            'is', 'isolation', 'join', 'key', 'kill', 'left', 'level', 'like', 'lineno', 
-            'load', 'max', 'min', 'mirrorexit', 'national', 'nocheck', 'nonclustered', 
-            'not', 'null', 'nullif', 'of', 'off', 'offsets', 'on', 'once', 'only', 'open', 
-            'opendatasource', 'openquery', 'openrowset', 'openxml', 'option', 'or', 'order', 
-            'outer', 'over', 'percent', 'perm', 'permanent', 'pipe', 'plan', 'precision', 
-            'prepare', 'primary', 'print', 'privileges', 'proc', 'procedure', 'processexit', 
-            'public', 'raiserror', 'read', 'readtext', 'reconfigure', 'references', 
-            'repeatable', 'replication', 'restore', 'restrict', 'return', 'revoke', 
-            'right', 'rollback', 'rowcount', 'rowguidcol', 'rule', 'save', 'schema', 
-            'select', 'serializable', 'session_user', 'set', 'setuser', 'shutdown', 'some', 
-            'statistics', 'sum', 'system_user', 'table', 'tape', 'temp', 'temporary', 
-            'textsize', 'then', 'to', 'top', 'tran', 'transaction', 'trigger', 'truncate', 
-            'tsequal', 'uncommitted', 'union', 'unique', 'update', 'updatetext', 'use', 
-            'user', 'values', 'varying', 'view', 'waitfor', 'when', 'where', 'while', 
+            'add', 'all', 'alter', 'and', 'any', 'as', 'asc', 'authorization',
+            'avg', 'backup', 'begin', 'between', 'break', 'browse', 'bulk',
+            'by', 'cascade', 'case', 'check', 'checkpoint', 'close', 'clustered',
+            'coalesce', 'collate', 'column', 'commit', 'committed', 'compute',
+            'confirm', 'constraint', 'contains', 'containstable', 'continue',
+            'controlrow', 'convert', 'count', 'create', 'cross', 'current',
+            'current_date', 'current_time', 'current_timestamp', 'current_user',
+            'cursor', 'database', 'dbcc', 'deallocate', 'declare', 'default', 'delete',
+            'deny', 'desc', 'disk', 'distinct', 'distributed', 'double', 'drop', 'dummy',
+            'dump', 'else', 'end', 'errlvl', 'errorexit', 'escape', 'except', 'exec',
+            'execute', 'exists', 'exit', 'fetch', 'file', 'fillfactor', 'floppy',
+            'for', 'foreign', 'freetext', 'freetexttable', 'from', 'full', 'function',
+            'goto', 'grant', 'group', 'having', 'holdlock', 'identity', 'identitycol',
+            'identity_insert', 'if', 'in', 'index', 'inner', 'insert', 'intersect', 'into',
+            'is', 'isolation', 'join', 'key', 'kill', 'left', 'level', 'like', 'lineno',
+            'load', 'max', 'min', 'mirrorexit', 'national', 'nocheck', 'nonclustered',
+            'not', 'null', 'nullif', 'of', 'off', 'offsets', 'on', 'once', 'only', 'open',
+            'opendatasource', 'openquery', 'openrowset', 'openxml', 'option', 'or', 'order',
+            'outer', 'over', 'percent', 'perm', 'permanent', 'pipe', 'plan', 'precision',
+            'prepare', 'primary', 'print', 'privileges', 'proc', 'procedure', 'processexit',
+            'public', 'raiserror', 'read', 'readtext', 'reconfigure', 'references',
+            'repeatable', 'replication', 'restore', 'restrict', 'return', 'revoke',
+            'right', 'rollback', 'rowcount', 'rowguidcol', 'rule', 'save', 'schema',
+            'select', 'serializable', 'session_user', 'set', 'setuser', 'shutdown', 'some',
+            'statistics', 'sum', 'system_user', 'table', 'tape', 'temp', 'temporary',
+            'textsize', 'then', 'to', 'top', 'tran', 'transaction', 'trigger', 'truncate',
+            'tsequal', 'uncommitted', 'union', 'unique', 'update', 'updatetext', 'use',
+            'user', 'values', 'varying', 'view', 'waitfor', 'when', 'where', 'while',
             'with', 'work', 'writetext'
-        );  
+        );
         return $reserved_words;
     }
 }
index 936ec7a3dcdb3b40c69c34ffc55fcd3268e56f79..ea26ce798a385b536bd8cb3f70a61bfe1fac44f6 100644 (file)
@@ -161,7 +161,7 @@ class XMLDBmysql extends XMLDBGenerator {
     function getCommentSQL ($xmldb_table) {
 
         $comment = '';
-        
+
         if ($xmldb_table->getComment()) {
             $comment .= 'ALTER TABLE ' . $this->getEncQuoted($this->prefix . $xmldb_table->getName());
             $comment .= " COMMENT='" . substr($xmldb_table->getComment(), 0, 250) . "'";
@@ -216,7 +216,7 @@ class XMLDBmysql extends XMLDBGenerator {
             'utc_timestamp', 'values', 'varbinary', 'varchar', 'varcharacter',
             'varying', 'when', 'where', 'while', 'with', 'write', 'x509',
             'xor', 'year_month', 'zerofill'
-        );  
+        );
         return $reserved_words;
     }
 }
index 77c660c05bdf69e6577e60d5167049388635540e..6e434adb3b4879bd42264821de9c097d1ee6b3d4 100644 (file)
@@ -114,11 +114,11 @@ class XMLDBoci8po extends XMLDBgenerator {
         return $dbtype;
     }
 
-    /**         
+    /**
      * Returns the code needed to create one enum for the xmldb_table and xmldb_field passes
-     */     
+     */
     function getEnumExtraSQL ($xmldb_table, $xmldb_field) {
-        
+
         $sql = 'CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck');
         $sql.= ' CHECK (' . $this->getEncQuoted($xmldb_field->getName()) . ' IN (' . implode(', ', $xmldb_field->getEnumValues()) . '))';
 
@@ -131,14 +131,14 @@ class XMLDBoci8po extends XMLDBgenerator {
     function getCreateSequenceSQL ($xmldb_table, $xmldb_field) {
 
         $sequence_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'seq');
-        
+
         $sequence = "CREATE SEQUENCE " . $sequence_name;
         $sequence.= "\n    START WITH 1";
         $sequence.= "\n    INCREMENT BY 1";
         $sequence.= "\n    NOMAXVALUE";
 
         $trigger_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'trg');
+
         $trigger = "CREATE OR REPLACE TRIGGER " . $trigger_name;
         $trigger.= "\n    BEFORE INSERT";
         $trigger.= "\nON " . $this->getEncQuoted($this->prefix . $xmldb_table->getName());
@@ -158,11 +158,11 @@ class XMLDBoci8po extends XMLDBgenerator {
     function getDropSequenceSQL ($xmldb_table, $xmldb_field, $include_trigger=false) {
 
         $sequence_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'seq');
-        
+
         $sequence = "DROP SEQUENCE " . $sequence_name;
 
         $trigger_name = $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'trg');
+
         $trigger = "DROP TRIGGER " . $trigger_name;
 
         if ($include_trigger) {
@@ -222,7 +222,7 @@ class XMLDBoci8po extends XMLDBgenerator {
             'unique', 'update', 'user', 'validate', 'values',
             'varchar', 'varchar2', 'view', 'whenever',
             'where', 'with'
-        );  
+        );
         return $reserved_words;
     }
 }
index ba8bd60e6e181066e9d7f56cc9cf37d41c1bc629..333a0823b370cbb157742b604742e37fed41290f 100644 (file)
@@ -114,11 +114,11 @@ class XMLDBpostgres7 extends XMLDBgenerator {
         return $dbtype;
     }
 
-    /**         
+    /**
      * Returns the code needed to create one enum for the xmldb_table and xmldb_field passes
-     */     
+     */
     function getEnumExtraSQL ($xmldb_table, $xmldb_field) {
-        
+
         $sql = 'CONSTRAINT ' . $this->getNameForObject($xmldb_table->getName(), $xmldb_field->getName(), 'ck');
         $sql.= ' CHECK (' . $this->getEncQuoted($xmldb_field->getName()) . ' IN (' . implode(', ', $xmldb_field->getEnumValues()) . '))';
 
@@ -143,21 +143,21 @@ class XMLDBpostgres7 extends XMLDBgenerator {
     /// This file contains the reserved words for PostgreSQL databases
     /// http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
         $reserved_words = array (
-            'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 
-            'asymmetric', 'authorization', 'between', 'binary', 'both', 'case', 
-            'cast', 'check', 'collate', 'column', 'constraint', 'create', 'cross', 
-            'current_date', 'current_role', 'current_time', 'current_timestamp', 
-            'current_user', 'default', 'deferrable', 'desc', 'distinct', 'do', 
-            'else', 'end', 'except', 'false', 'for', 'foreign', 'freeze', 'from', 
-            'full', 'grant', 'group', 'having', 'ilike', 'in', 'initially', 'inner', 
-            'intersect', 'into', 'is', 'isnull', 'join', 'leading', 'left', 'like', 
-            'limit', 'localtime', 'localtimestamp', 'natural', 'new', 'not', 
-            'notnull', 'null', 'off', 'offset', 'old', 'on', 'only', 'or', 'order', 
-            'outer', 'overlaps', 'placing', 'primary', 'references', 'right', 'select', 
-            'session_user', 'similar', 'some', 'symmetric', 'table', 'then', 'to', 
-            'trailing', 'true', 'union', 'unique', 'user', 'using', 'verbose', 
+            'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc',
+            'asymmetric', 'authorization', 'between', 'binary', 'both', 'case',
+            'cast', 'check', 'collate', 'column', 'constraint', 'create', 'cross',
+            'current_date', 'current_role', 'current_time', 'current_timestamp',
+            'current_user', 'default', 'deferrable', 'desc', 'distinct', 'do',
+            'else', 'end', 'except', 'false', 'for', 'foreign', 'freeze', 'from',
+            'full', 'grant', 'group', 'having', 'ilike', 'in', 'initially', 'inner',
+            'intersect', 'into', 'is', 'isnull', 'join', 'leading', 'left', 'like',
+            'limit', 'localtime', 'localtimestamp', 'natural', 'new', 'not',
+            'notnull', 'null', 'off', 'offset', 'old', 'on', 'only', 'or', 'order',
+            'outer', 'overlaps', 'placing', 'primary', 'references', 'right', 'select',
+            'session_user', 'similar', 'some', 'symmetric', 'table', 'then', 'to',
+            'trailing', 'true', 'union', 'unique', 'user', 'using', 'verbose',
             'when', 'where'
-        );  
+        );
         return $reserved_words;
     }
 }
index 0829bb1b293ae351bc8e28b2958556e1be02d89e..ee0e594b7595e587b5309be8c1cc2d2c6575e332 100644 (file)
@@ -19,7 +19,7 @@
      <xs:pattern value='[0-9a-z_]{1,30}'/>
     </xs:restriction >
   </xs:simpleType >
-  
+
   <xs:simpleType name="fieldType">
     <xs:restriction base="xs:NMTOKEN">
       <xs:enumeration value="int" />
@@ -43,7 +43,7 @@
      <xs:pattern value='[0-9a-z_, ]+'/>
     </xs:restriction >
   </xs:simpleType >
-  
+
   <xs:simpleType name="keyType">
     <xs:restriction base="xs:NMTOKEN">
       <xs:enumeration value="primary" />
index 9e4a92e79e305f0f341693a7927143e35e1e3c6e..ef2185253b492b7ba4760f9c903da7642821ec58 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_assignment_capabilities = array(
-    
+
     'mod/assignment:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_assignment_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/assignment:submit' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_assignment_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/assignment:grade' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
index b8d8a33a310d18e5d778e9ebdbca9d8bfa3f24d4..4c7ebfae8d28f50978a90d5bc171ba0767a87706 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_chat_capabilities = array(
-    
+
     'mod/chat:chat' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -48,9 +48,9 @@ $mod_chat_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/chat:readlog' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -62,9 +62,9 @@ $mod_chat_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/chat:deletelog' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -76,7 +76,7 @@ $mod_chat_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
index c975baf32ed014053a1176744520213bf6b81a8b..cbe4d0c16755149950d29ae955edc7358f6cb534 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_choice_capabilities = array(
-    
+
     'mod/choice:choose' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_choice_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/choice:readresponses' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_choice_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/choice:deleteresponses' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -74,9 +74,9 @@ $mod_choice_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/choice:downloadresponses' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
index c9d39796aa0cda5d07f5c457bf7008f7810e56de..aee820c1c62bddfdea972466853d0e998c4c51d7 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_data_capabilities = array(
-    
+
     'mod/data:viewentry' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:writeentry' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -62,9 +62,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:comment' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -78,9 +78,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:viewrating' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -92,9 +92,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:rate' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -106,9 +106,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:approve' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -120,9 +120,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:manageentries' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -134,9 +134,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:managecomments' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -148,9 +148,9 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/data:managetemplates' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -164,7 +164,7 @@ $mod_data_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
\ No newline at end of file
index 1cdcea5c45903c66d3f60d2924421efb0535fe8d..6ae31c75d8664e79b6a0a13f03bcba7ccd07eab7 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_exercise_capabilities = array(
-    
+
     'mod/exercise:assess' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,7 +46,7 @@ $mod_exercise_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
\ No newline at end of file
index 819e5089b9b8e7d6b871e5e4c144615e0f395a67..8beac410dd8c18f9088a6e041b4203b04c753a56 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_forum_capabilities = array(
-    
+
     'mod/forum:viewforum' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewdiscussion' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewhiddentimedposts' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -74,9 +74,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:startdiscussion' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -90,9 +90,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:replypost' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -106,9 +106,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewrating' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -120,9 +120,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewanyrating' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -134,9 +134,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:rate' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -148,9 +148,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:createattachment' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -164,9 +164,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:deleteownpost' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -178,9 +178,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:deleteanypost' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -192,9 +192,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:splitdiscussions' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -206,9 +206,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:movediscussions' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -220,9 +220,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:editanypost' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -236,9 +236,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewqandawithoutposting' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -250,9 +250,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:viewsubscribers' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -264,9 +264,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:managesubscriptions' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -278,9 +278,9 @@ $mod_forum_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/forum:throttlingapplies' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
index a39cd21d8ba579ff65d8b04814a2827d9a1861c7..32572f8b1ce258536f81b8beebbb5cfdfbb80175 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_glossary_capabilities = array(
-    
+
     'mod/glossary:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:write' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -62,9 +62,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:manageentries' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -76,9 +76,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:managecategories' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -90,9 +90,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:comment' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -106,9 +106,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:managecomments' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -120,9 +120,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:import' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -136,9 +136,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:export' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -150,9 +150,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:approve' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -164,9 +164,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:rate' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -178,9 +178,9 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/glossary:viewrating' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -192,7 +192,7 @@ $mod_glossary_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
 );
 
 ?>
index d1fdc12b49d040bd8cba0c8e2137f4c7ac9c03b8..b7b52b6c45dc997245a82641b69dd76b5ac57fe2 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_hotpot_capabilities = array(
-    
+
     'mod/hotpot:attempt' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_hotpot_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/hotpot:viewreport' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_hotpot_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/hotpot:grade' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -74,9 +74,9 @@ $mod_hotpot_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/hotpot:deleteattempt' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -88,7 +88,7 @@ $mod_hotpot_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
\ No newline at end of file
index 1c3030e4acec4c7951152d067b12a25bc417ad68..9d50638f2fb0cd7dfd40f71801e160599380a45c 100644 (file)
@@ -1,7 +1,7 @@
 <?php // $Id$
 /**
  * Capability definitions for the lams module.
- * 
+ *
  * For naming conventions, see lib/db/access.php.
  */
 $mod_lams_capabilities = array(
index e7e71b258e2f21bed57487c3f515f900a80effaf..9e3934d8869c913a0725cde02e15bb479a1ea4d2 100644 (file)
@@ -1,13 +1,13 @@
 <?php // $Id$
 /**
  * Capability definitions for the lesson module.
- * 
+ *
  * For naming conventions, see lib/db/access.php.
  */
 $mod_lesson_capabilities = array(
 
     'mod/lesson:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -21,7 +21,7 @@ $mod_lesson_capabilities = array(
     ),
 
     'mod/lesson:edit' => array(
-    
+
         'riskbitmask' => RISK_XSS,
 
         'captype' => 'write',
@@ -37,7 +37,7 @@ $mod_lesson_capabilities = array(
     ),
 
     'mod/lesson:manage' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
index d10cbe19e48f8904386e59c29c067a7411a0254b..eacce0c20e22e5d77531e176f3a412ce138af9a5 100644 (file)
@@ -1,7 +1,7 @@
 <?php // $Id$
 /**
  * Capability definitions for the quiz module.
- * 
+ *
  * For naming conventions, see lib/db/access.php.
  */
 $mod_quiz_capabilities = array(
@@ -9,7 +9,7 @@ $mod_quiz_capabilities = array(
     // Ability to see that the quiz exists, and the basic information
     // about it, for example the start date and time limit.
     'mod/quiz:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -24,7 +24,7 @@ $mod_quiz_capabilities = array(
 
     // Ability to do the quiz as a 'student'.
     'mod/quiz:attempt' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -39,7 +39,7 @@ $mod_quiz_capabilities = array(
 
     // Edit the quiz settings, add and remove questions.
     'mod/quiz:manage' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -54,7 +54,7 @@ $mod_quiz_capabilities = array(
 
     // Preview the quiz.
     'mod/quiz:preview' => array(
-    
+
         'captype' => 'write', // Only just a write.
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -69,7 +69,7 @@ $mod_quiz_capabilities = array(
 
     // Manually grade and comment on student attempts at a question.
     'mod/quiz:grade' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -84,7 +84,7 @@ $mod_quiz_capabilities = array(
 
     // View the quiz reports.
     'mod/quiz:viewreports' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -99,7 +99,7 @@ $mod_quiz_capabilities = array(
 
     // Delete attempts using the overview report.
     'mod/quiz:deleteattempts' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
index 002d5031dbd2aeec7b478effb2e900d3ed073218..90bf7e8c228ba4d8e4dbe441b37ec9bbdc37c303 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_resource_capabilities = array(
-    
+
     'mod/resource:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,7 +46,7 @@ $mod_resource_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
index b481a112318521afd7225759b8b2494874ef3607..f30fd0056c669d4795208dac886bbeacf96235cd 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_scorm_capabilities = array(
-    
+
     'mod/scorm:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_scorm_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/scorm:viewreport' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_scorm_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/scorm:savetrack' => array(
-    
+
         'captype' => 'write',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -74,9 +74,9 @@ $mod_scorm_capabilities = array(
             'admin' => CAP_PREVENT
         )
     ),
-    
+
     'mod/scorm:viewscores' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -88,7 +88,7 @@ $mod_scorm_capabilities = array(
             'admin' => CAP_PREVENT
         )
     )
-    
+
 );
 
 ?>
index ce6fde659326323bd24ca5cad2f25d6f9700af96..d589f5a27876639b25a22fb4932092ffa024cc7f 100644 (file)
@@ -32,9 +32,9 @@
 
 
 $mod_survey_capabilities = array(
-    
+
     'mod/survey:participate' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -46,9 +46,9 @@ $mod_survey_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/survey:readresponses' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -60,9 +60,9 @@ $mod_survey_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
-    
+
     'mod/survey:download' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -74,7 +74,7 @@ $mod_survey_capabilities = array(
             'admin' => CAP_ALLOW
         )
     )
-    
+
 );
 
 ?>
\ No newline at end of file
index bb48107eb4cd5f2af1a49ebb7bc76b3428f14604..b8e996475da7e345c3159472c71151ea077f51f4 100644 (file)
@@ -1,7 +1,7 @@
 <?php // $Id$
 /**
  * Capability definitions for the wiki module.
- * 
+ *
  * For naming conventions, see lib/db/access.php.
  */
 $mod_wiki_capabilities = array(
index c16de6759ff2c674e42afa154a013cd7ae663eb9..7fbfaff9a23fd82e35128c31aae53c4391c2a7d9 100644 (file)
@@ -1,13 +1,13 @@
 <?php // $Id$
 /**
  * Capability definitions for the workshop module.
- * 
+ *
  * For naming conventions, see lib/db/access.php.
  */
 $mod_workshop_capabilities = array(
 
     'mod/workshop:view' => array(
-    
+
         'captype' => 'read',
         'contextlevel' => CONTEXT_MODULE,
         'legacy' => array(
@@ -21,7 +21,7 @@ $mod_workshop_capabilities = array(
     ),
 
     'mod/workshop:participate' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
@@ -37,7 +37,7 @@ $mod_workshop_capabilities = array(
     ),
 
     'mod/workshop:manage' => array(
-    
+
         'riskbitmask' => RISK_SPAM,
 
         'captype' => 'write',
index 14cc4f79d6840c8a7ad9d2ab2dc716c461f5dc99..64296be2f0b56ccfa6ccbc25ba907d7f0885a490 100644 (file)
@@ -16,7 +16,7 @@ current value for the index - this is to take into account the fact that
 deleted documents are in fact not removed from the index, but instead just
 marked as deleted and not returned in search results. The actual document
 still features in the index, and skews sizes. When the index optimiser is
-completed in ZFS, then these deleted documents will be pruned, thus 
+completed in ZFS, then these deleted documents will be pruned, thus
 correctly modifying the index size.
 
 Additional commenting added.
index b430316aa5e25e30938f9a0c407864c7e22946e7..f6f2607e0caa1d7dc0050d61b58ee66a7d6840ef 100644 (file)
@@ -2,92 +2,92 @@
 
   require_once('../config.php');
   require_once("$CFG->dirroot/search/lib.php");
-  
+
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-    
+
   //check for php5 (lib.php)
   if (!search_check_php5()) {
     $phpversion = phpversion();
     mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
     exit(0);
-  } //if  
-    
-  require_once("$CFG->dirroot/search/indexlib.php");   
-  
+  } //if
+
+  require_once("$CFG->dirroot/search/indexlib.php");
+
   $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
   $dbcontrol = new IndexDBControl();
   $addition_count = 0;
-  
+
   $indexdate = $CFG->search_indexer_run_date;
-  
+
   mtrace('<pre>Starting index update (additions)...');
   mtrace('Index size before: '.$CFG->search_index_size."\n");
-  
+
   //get all modules
   if ($mods = get_records_select('modules')) {
   //append virtual modules onto array
   $mods = array_merge($mods, search_get_additional_modules());
-   
+
   foreach ($mods as $mod) {
     //build include file and function names
-    $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';    
+    $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
     $db_names_function = $mod->name.'_db_names';
     $get_document_function = $mod->name.'_single_document';
-    $additions = array();    
-    
+    $additions = array();
+
     if (file_exists($class_file)) {
       require_once($class_file);
-    
+
       //if both required functions exist
       if (function_exists($db_names_function) and function_exists($get_document_function)) {
         mtrace("Checking $mod->name module for additions.");
         $values = $db_names_function();
-        $where = (isset($values[4])) ? $values[4] : ''; 
-        
+        $where = (isset($values[4])) ? $values[4] : '';
+
         //select records in MODULE table, but not in SEARCH_DATABASE_TABLE
         $sql =  "select id, ".$values[0]." as docid from ".$values[1].
                 " where id not in".
                 " (select docid from ".SEARCH_DATABASE_TABLE." where doctype like '$mod->name')".
                 " and ".$values[2]." > $indexdate".
-                " $where";                 
+                " $where";
+
+        $records = get_records_sql($sql);
 
-        $records = get_records_sql($sql);     
-        
         //foreach record, build a module specific search document using the get_document function
-        if (is_array($records)) {       
+        if (is_array($records)) {
           foreach($records as $record) {
             $additions[] = $get_document_function($record->id);
           } //foreach
-        } //if    
-          
+        } //if
+
         //foreach document, add it to the index and database table
         foreach ($additions as $add) {
           ++$addition_count;
-          
+
           //object to insert into db
-          $dbid = $dbcontrol->addDocument($add);          
-              
+          $dbid = $dbcontrol->addDocument($add);
+
           //synchronise db with index
-          $add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));          
-          
+          $add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));
+
           mtrace("  Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)");
-                            
+
           $index->addDocument($add);
         } //foreach
-                    
+
         mtrace("Finished $mod->name.\n");
-      } //if              
+      } //if
     } //if
   } //foreach
   } //if
-  
+
   //commit changes
   $index->commit();
-  
+
   //update index date and size
   set_config("search_indexer_run_date", time());
   set_config("search_index_size", (int)$CFG->search_index_size + (int)$addition_count);
index 245ffa1a48be9e0bb80a63d6bc5185f6a0e178e6..36797e3c140b155fb5b8d91ebc3587cb37bed577 100644 (file)
@@ -1,22 +1,22 @@
 <?php
 
   /* cron script to perform all the periodic search tasks
-   * 
+   *
    * delete.php
    *   updates the index by pruning deleted documents
-   * 
+   *
    * update.php
    *   updates document info in the index if the document has been modified since indexing
-   * 
+   *
    * add.php
    *   adds documents created since the last index run
    */
 
   require_once('../config.php');
   require_once("$CFG->dirroot/search/lib.php");
-  
+
   mtrace("<pre>Starting cron...\n");
-  
+
   mtrace("--DELETE----");
   require_once("$CFG->dirroot/search/delete.php");
   mtrace("--UPDATE----");
index 7a2d7a56434d85fd0aa8f872dd322507128f19d9..a4a64fa6ee97b2e3d0765e55418609fd8f957ee8 100644 (file)
@@ -1,11 +1,11 @@
 CREATE TABLE prefix_search_documents (
    id SERIAL8 PRIMARY KEY,
    docid int4 NOT NULL,
-   doctype varchar(12) NOT NULL DEFAULT 'none', 
-   title varchar(100) NOT NULL default '', 
-   url varchar(100) NOT NULL default '', 
+   doctype varchar(12) NOT NULL DEFAULT 'none',
+   title varchar(100) NOT NULL default '',
+   url varchar(100) NOT NULL default '',
    docdate timestamp NOT NULL,
-   updated timestamp NOT NULL DEFAULT NOW(), 
-   courseid int4,    
+   updated timestamp NOT NULL DEFAULT NOW(),
+   courseid int4,
    groupid int4
 );
index 7f8ef834058bbc5ddddd851a09746b421a17d826..2e0bc7991b66effcf824869e308e7c534412a3fe 100644 (file)
@@ -2,84 +2,84 @@
 
   require_once('../config.php');
   require_once("$CFG->dirroot/search/lib.php");
-    
+
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-    
+
   //check for php5 (lib.php)
   if (!search_check_php5()) {
     $phpversion = phpversion();
     mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
     exit(0);
-  } //if  
-  
-  require_once("$CFG->dirroot/search/indexlib.php");  
-  
+  } //if
+
+  require_once("$CFG->dirroot/search/indexlib.php");
+
   $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
   $dbcontrol = new IndexDBControl();
-  $deletion_count = 0;   
-  
+  $deletion_count = 0;
+
   mtrace('<pre>Starting clean-up of removed records...');
   mtrace('Index size before: '.$CFG->search_index_size."\n");
-  
+
   if ($mods = get_records_select('modules')) {
   $mods = array_merge($mods, search_get_additional_modules());
-  
+
   foreach ($mods as $mod) {
     //build function names
     $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
     $delete_function = $mod->name.'_delete';
     $db_names_function = $mod->name.'_db_names';
-    $deletions = array();    
-    
+    $deletions = array();
+
     if (file_exists($class_file)) {
       require_once($class_file);
-    
+
       if (function_exists($delete_function) and function_exists($db_names_function)) {
         mtrace("Checking $mod->name module for deletions.");
         $values = $db_names_function();
-        
+
         $sql = "select id, docid from ".SEARCH_DATABASE_TABLE.
                 " where doctype like '$mod->name'".
                 " and docid not in".
                 " (select ".$values[0]." from ".$values[1].")";
 
-        $records = get_records_sql($sql);     
-        
+        $records = get_records_sql($sql);
+
         //build an array of all the deleted records
-        if (is_array($records)) {       
+        if (is_array($records)) {
           foreach($records as $record) {
             $deletions[] = $delete_function($record->docid);
           } //foreach
-        } //if    
-          
-        foreach ($deletions as $delete) {        
+        } //if
+
+        foreach ($deletions as $delete) {
           //find the specific document in the index, using it's docid and doctype as keys
-          $doc = $index->find("+docid:$delete +doctype:$mod->name");            
-          
+          $doc = $index->find("+docid:$delete +doctype:$mod->name");
+
           //get the record, should only be one
           foreach ($doc as $thisdoc) {
             ++$deletion_count;
             mtrace("  Delete: $thisdoc->title (database id = $thisdoc->dbid, index id = $thisdoc->id, moodle instance id = $thisdoc->docid)");
-            
+
             //remove it from index and database table
             $dbcontrol->delDocument($thisdoc);
-            $index->delete($thisdoc->id);              
+            $index->delete($thisdoc->id);
           } //foreach
         } //foreach
-                    
+
         mtrace("Finished $mod->name.\n");
-      } //if              
+      } //if
     } //if
   } //foreach
   } //if
-  
+
   //commit changes
   $index->commit();
-  
+
   //update index date and index size
   set_config("search_indexer_run_date", time());
   set_config("search_index_size", (int)$CFG->search_index_size - (int)$deletion_count);
index 98e732a2dfe8855cc9b270b5ead4640a9011e8ac..466302fdc70b47025efd55fe3ac1183c7eb4ebd6 100644 (file)
@@ -2,23 +2,23 @@
   /* Base search document from which other module/block types can
    * extend.
    * */
-  
-  abstract class SearchDocument extends Zend_Search_Lucene_Document {  
-    public function __construct(&$doc, &$data, $document_type, $course_id, $group_id) {      
+
+  abstract class SearchDocument extends Zend_Search_Lucene_Document {
+    public function __construct(&$doc, &$data, $document_type, $course_id, $group_id) {
       $this->addField(Zend_Search_Lucene_Field::Keyword('docid', $doc->docid));
       $this->addField(Zend_Search_Lucene_Field::Text('title', $doc->title));
       $this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author));
       $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents));
       $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url));
       $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date));
-      
+
       //additional data added on a per-module basis
       $this->addField(Zend_Search_Lucene_Field::Binary('data', serialize($data)));
-      
+
       $this->addField(Zend_Search_Lucene_Field::Keyword('doctype', $document_type));
-      $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id));    
-      $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id));      
-    } //constructor    
+      $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id));
+      $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id));
+    } //constructor
   } //SearchDocument
-    
+
 ?>
\ No newline at end of file
index 84904f5a2917919132ae220b8da0c49a40371906..0dacc209382000409cd72f7142b9151afca6e838 100644 (file)
@@ -4,51 +4,51 @@
 
   require_once("$CFG->dirroot/search/documents/document.php");
   require_once("$CFG->dirroot/mod/forum/lib.php");
-  
-  class ForumSearchDocument extends SearchDocument {  
+
+  class ForumSearchDocument extends SearchDocument {
     public function __construct(&$post, $forum_id, $course_id, $group_id) {
-      // generic information     
+      // generic information
       $doc->docid     = $post['id'];
       $doc->title     = $post['subject'];
       $doc->author    = $post['firstname']." ".$post['lastname'];
       $doc->contents  = $post['message'];
       $doc->date      = $post['created'];
-      
-      $doc->url       = forum_make_link($post['discussion'], $post['id']);      
-      
+
+      $doc->url       = forum_make_link($post['discussion'], $post['id']);
+
       // module specific information
       $data->forum      = $forum_id;
       $data->discussion = $post['discussion'];
-      
+
       parent::__construct($doc, $data, SEARCH_TYPE_FORUM, $course_id, $group_id);
-    } //constructor    
+    } //constructor
   } //ForumSearchDocument
-  
+
   function forum_make_link($discussion_id, $post_id) {
     global $CFG;
     return $CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion_id.'#'.$post_id;
   } //forum_make_link
-  
+
   function forum_iterator() {
-      //no @ = Undefined index:  82 in moodle/lib/datalib.php on line 2671    
+      //no @ = Undefined index:  82 in moodle/lib/datalib.php on line 2671
       return @get_all_instances_in_courses("forum", get_courses());
   } //forum_iterator
-  
+
   function forum_get_content_for_index(&$forum) {
-      $documents = array();  
+      $documents = array();
       if (!$forum) return $documents;
-    
-      $posts = forum_get_discussions_fast($forum->id);     
+
+      $posts = forum_get_discussions_fast($forum->id);
       if (!$posts) return $documents;
-      
+
       while (!$posts->EOF) {
         $post = $posts->fields;
-        
+
         if (is_array($post)) {
           if (strlen($post['message']) > 0 && ($post['deleted'] != 1)) {
             $documents[] = new ForumSearchDocument($post, $forum->id, $forum->course, $post['groupid']);
           } //if
-            
+
           if ($children = forum_get_child_posts_fast($post['id'], $forum->id)) {
             while (!$children->EOF) {
               $child = $children->fields;
             } //foreach
           } //if
         } //if
-        
+
         $posts->MoveNext();
       } //foreach
-            
+
       return $documents;
   } //forum_get_content_for_index
-  
+
   //returns a single forum search document based on a forum_entry id
   function forum_single_document($id) {
     $posts = get_recordset('forum_posts', 'id', $id);
     $post = $posts->fields;
-    
+
     $discussions = get_recordset('forum_discussions', 'id', $post['discussion']);
     $discussion = $discussions->fields;
-    
+
     $forums = get_recordset('forum', 'id', $discussion['forum']);
     $forum = $forums->fields;
-    
+
     return new ForumSearchDocument($post, $forum['id'], $forum['course'], $post['groupid']);
-  } //forum_single_document    
-    
+  } //forum_single_document
+
   function forum_delete($info) {
-    return $info;            
+    return $info;
   } //forum_delete
-  
+
   //returns the var names needed to build a sql query for addition/deletions
   function forum_db_names() {
     //[primary id], [table name], [time created field name], [time modified field name]
-    return array('id', 'forum_posts', 'created', 'modified');            
-  } //forum_db_names      
-  
+    return array('id', 'forum_posts', 'created', 'modified');
+  } //forum_db_names
+
   //reworked faster version from /mod/forum/lib.php
   function forum_get_discussions_fast($forum) {
     global $CFG, $USER;
-    
+
     $timelimit='';
-  
+
     if (!empty($CFG->forum_enabletimedposts)) {
       if (!((isadmin() and !empty($CFG->admineditalways)) || isteacher(get_field('forum', 'course', 'id', $forum)))) {
         $now = time();
         $timelimit .= ')';
       }
     }
-  
+
     if ($CFG->dbtype == 'postgres7') {
         return get_recordset_sql("SELECT p.id, p.subject, p.discussion, p.message,
-                                  p.deleted, d.groupid, u.firstname, u.lastname 
+                                  p.deleted, d.groupid, u.firstname, u.lastname
                               FROM {$CFG->prefix}forum_discussions d
                               JOIN {$CFG->prefix}forum_posts p ON p.discussion = d.id
                               JOIN {$CFG->prefix}user u ON p.userid = u.id
                           ORDER BY d.timemodified DESC");
     } //else
   } //forum_get_discussions_fast
-  
+
   //reworked faster version from /mod/forum/lib.php
   function forum_get_child_posts_fast($parent, $forumid) {
     global $CFG;
-  
+
     return get_recordset_sql("SELECT p.id, p.subject, p.discussion, p.message, p.deleted,
                               $forumid AS forum, u.firstname, u.lastname
                               FROM {$CFG->prefix}forum_posts p
                              WHERE p.parent = '$parent'
                           ORDER BY p.created ASC");
   } //forum_get_child_posts_fast
-  
+
 ?>
\ No newline at end of file
index 2147e880a7ac37f3bfd52c8f2bccd69e5bc3943a..bfa692544be5a3aa8ebb18afd23752e1d6fb3029 100644 (file)
@@ -7,82 +7,82 @@
    * */
 
   require_once("$CFG->dirroot/search/documents/document.php");
-  
-  class GlossarySearchDocument extends SearchDocument {  
+
+  class GlossarySearchDocument extends SearchDocument {
     public function __construct(&$entry, $glossary_id, $course_id, $group_id) {
       // generic information; required
       $doc->docid     = $entry['id'];
       $doc->title     = $entry['concept'];
       $doc->date      = $entry['timecreated'];
-                  
+
       $user = get_recordset('user', 'id', $entry['userid'])->fields;
-      
+
       $doc->author    = $user['firstname'].' '.$user['lastname'];
       $doc->contents  = $entry['definition'];
-      $doc->url       = glossary_make_link($entry['id']);      
-      
+      $doc->url       = glossary_make_link($entry['id']);
+
       // module specific information; optional
       $data->glossary = $glossary_id;
-      
+
       // construct the parent class
       parent::__construct($doc, $data, SEARCH_TYPE_GLOSSARY, $course_id, $group_id);
-    } //constructor    
-  } //GlossarySearchDocument  
+    } //constructor
+  } //GlossarySearchDocument
 
   function glossary_make_link($entry_id) {
     global $CFG;
-    
+
     //links directly to entry
     //return $CFG->wwwroot.'/mod/glossary/showentry.php?eid='.$entry_id;
-    
+
     //preserve glossary pop-up, be careful where you place your ' and "s
     //this function is meant to return a url that is placed between href='[url here]'
-    return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid=$entry_id\", \"entry\", \"menubar=0,location=0,scrollbars,resizable,width=600,height=450\", 0);";    
-  } //glossary_make_link 
-    
+    return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid=$entry_id\", \"entry\", \"menubar=0,location=0,scrollbars,resizable,width=600,height=450\", 0);";
+  } //glossary_make_link
+
   function glossary_iterator() {
-    return get_all_instances_in_courses("glossary", get_courses());  
+    return get_all_instances_in_courses("glossary", get_courses());
   } //glossary_iterator
-  
+
   function glossary_get_content_for_index(&$glossary) {
     $documents = array();
-    
-    $entries = get_recordset('glossary_entries', 'glossaryid', $glossary->id);   
-    
+
+    $entries = get_recordset('glossary_entries', 'glossaryid', $glossary->id);
+
     while (!$entries->EOF) {
       $entry = $entries->fields;
-      
+
       if ($entry and strlen($entry['definition']) > 0) {
         $documents[] = new GlossarySearchDocument($entry, $glossary->id, $glossary->course, -1);
       } //if
-      
+
       $entries->MoveNext();
     } //foreach
-    
+
     return $documents;
   } //glossary_get_content_for_index
-  
+
   //returns a single glossary search document based on a glossary_entry id
   function glossary_single_document($id) {
     $entries = get_recordset('glossary_entries', 'id', $id);
     $entry = $entries->fields;
-    
+
     $glossaries = get_recordset('glossary', 'id', $entry['glossaryid']);
     $glossary = $glossaries->fields;
-    
+
     return new GlossarySearchDocument($entry, $entry['glossaryid'], $glossary['course'], -1);
-  } //glossary_single_document    
-    
+  } //glossary_single_document
+
   //dummy delete function that converts docid from the search table to itself..
   //this was here for a reason, but I can't remember it at the moment.
   function glossary_delete($info) {
-    return $info;            
+    return $info;
   } //glossary_delete
-  
+
   //returns the var names needed to build a sql query for addition/deletions
   function glossary_db_names() {
     //[primary id], [table name], [time created field name], [time modified field name]
-    return array('id', 'glossary_entries', 'timecreated', 'timemodified');            
-  } //glossary_db_names    
-  
+    return array('id', 'glossary_entries', 'timecreated', 'timemodified');
+  } //glossary_db_names
+
 ?>
\ No newline at end of file
index db15d6a2b8101a3d877c927612e2addcdbb0dc98..c65b632236499f32294aebae6fb48f95cb3782a5 100644 (file)
@@ -1,63 +1,63 @@
 <?php
 
   require_once("$CFG->dirroot/search/documents/document.php");
-  
-  class ResourceSearchDocument extends SearchDocument {  
+
+  class ResourceSearchDocument extends SearchDocument {
     public function __construct(&$resource) {
       // generic information; required
       $doc->docid     = $resource['id'];
       $doc->title     = strip_tags($resource['name']);
       $doc->date      = $resource['timemodified'];
-                      
+
       $doc->author    = '';
       $doc->contents  = strip_tags($resource['summary']).' '.strip_tags($resource['alltext']);
-      $doc->url       = resource_make_link($resource['id']);      
-      
+      $doc->url       = resource_make_link($resource['id']);
+
       // module specific information; optional
       $data = array();
-      
+
       // construct the parent class
       parent::__construct($doc, $data, SEARCH_TYPE_RESOURCE, $resource['course'], -1);
-    } //constructor    
-  } //ResourceSearchDocument  
+    } //constructor
+  } //ResourceSearchDocument
 
   function resource_make_link($resource_id) {
-    global $CFG;    
-    return $CFG->wwwroot.'/mod/resource/view.php?r='.$resource_id;    
+    global $CFG;
+    return $CFG->wwwroot.'/mod/resource/view.php?r='.$resource_id;
   } //resource_make_link
-    
+
   function resource_iterator() {
     //trick to leave search indexer functionality intact, but allow
     //this document to only use the below function to return info
     //to be searched
-    return array(true);   
+    return array(true);
   } //resource_iterator
-  
+
   //this function does not need a content iterator, returns all the info
   //itself; remember to fake the iterator array though
   function resource_get_content_for_index(&$notneeded) {
     $documents = array();
-    
+
     $resources = get_recordset_sql('SELECT *
                               FROM `resource`
                               WHERE alltext NOT LIKE ""
                               AND alltext NOT LIKE " "
                               AND alltext NOT LIKE "&nbsp;"
-                              AND TYPE != "file"');       
-    
+                              AND TYPE != "file"');
+
     while (!$resources->EOF) {
       $resource = $resources->fields;
-      
+
       if ($resource) {
         $documents[] = new ResourceSearchDocument($resource);
       } //if
-      
+
       $resources->MoveNext();
     } //foreach
-    
+
     return $documents;
   } //resource_get_content_for_index
-  
+
   //returns a single resource search document based on a resource_entry id
   function resource_single_document($id) {
     $resources = get_recordset_sql('SELECT *
                               AND alltext NOT LIKE " "
                               AND alltext NOT LIKE "&nbsp;"
                               AND TYPE != "file",
-                              AND id = '.$id);  
-                                      
+                              AND id = '.$id);
+
     $resource = $resources->fields;
-        
+
     return new ResourceSearchDocument($resource);
-  } //resource_single_document    
-    
+  } //resource_single_document
+
   function resource_delete($info) {
-    return $info;            
+    return $info;
   } //resource_delete
-  
+
   //returns the var names needed to build a sql query for addition/deletions
   function resource_db_names() {
     //[primary id], [table name], [time created field name], [time modified field name], [additional where conditions for sql]
-    return array('id', 'resource', 'timemodified', 'timemodified', "WHERE alltext NOT LIKE '' AND alltext NOT LIKE ' ' AND alltext NOT LIKE '&nbsp;' AND TYPE != 'file'");            
-  } //resource_db_names                                      
-  
+    return array('id', 'resource', 'timemodified', 'timemodified', "WHERE alltext NOT LIKE '' AND alltext NOT LIKE ' ' AND alltext NOT LIKE '&nbsp;' AND TYPE != 'file'");
+  } //resource_db_names
+
 ?>
\ No newline at end of file
index ad207b63fc052f3bc371f6f8f9e10745a949a59e..ea1662e1437766854fc1be5642b858d8974c2835 100644 (file)
@@ -9,64 +9,64 @@
 
   require_once("$CFG->dirroot/search/documents/document.php");
   require_once("$CFG->dirroot/mod/wiki/lib.php");
-  
+
   /* All the $doc->___ fields are required by the base document class!
    * Each and every module that requires search functionality must correctly
    * map their internal fields to the five $doc fields (id, title, author, contents
    * and url). Any module specific data can be added to the $data object, which is
    * serialised into a binary field in the index.
-   * */  
-  class WikiSearchDocument extends SearchDocument {  
+   * */
+  class WikiSearchDocument extends SearchDocument {
     public function __construct(&$page, $wiki_id, $course_id, $group_id) {
       // generic information; required
       $doc->docid     = $page->id;
       $doc->title     = $page->pagename;
       $doc->date      = $page->timemodified;
-      
+
       //remove '(ip.ip.ip.ip)' from wiki author field
       $doc->author    = preg_replace('/\(.*?\)/', '', $page->author);
       $doc->contents  = $page->content;
-      $doc->url       = wiki_make_link($wiki_id, $page->pagename, $page->version);      
-      
+      $doc->url       = wiki_make_link($wiki_id, $page->pagename, $page->version);
+
       // module specific information; optional
       $data->version  = $page->version;
       $data->wiki     = $wiki_id;
-      
+
       // construct the parent class
       parent::__construct($doc, $data, SEARCH_TYPE_WIKI, $course_id, $group_id);
-    } //constructor    
+    } //constructor
   } //WikiSearchDocument
-  
+
   function wiki_name_convert($str) {
     return str_replace(' ', '+', $str);
   } //wiki_name_convert
 
   function wiki_make_link($wiki_id, $title, $version) {
-    global $CFG;    
+    global $CFG;
     return $CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki_id.'&page='.wiki_name_convert($title).'&version='.$version;
   } //wiki_make_link
-  
+
   //rescued and converted from ewikimoodlelib.php
   //retrieves latest version of a page
-  function wiki_get_latest_page(&$entry, $pagename, $version=0) { 
+  function wiki_get_latest_page(&$entry, $pagename, $version=0) {
     $pagename = "'".addslashes($pagename)."'";
-    
+
     if ($version > 0 and is_int($version)) {
       $version = "AND (version=$version)";
     } else {
       $version = '';
     } //else
-  
+
     $select = "(pagename=$pagename) AND wiki=".$entry->id." $version ";
     $sort   = 'version DESC';
-    
+
     //change this to recordset_select, as per http://docs.moodle.org/en/Datalib_Notes
-    if ($result_arr = get_records_select('wiki_pages', $select, $sort, '*', 0, 1)) {    
+    if ($result_arr = get_records_select('wiki_pages', $select, $sort, '*', 0, 1)) {
       foreach ($result_arr as $obj) {
-        $result_obj = $obj;                 
+        $result_obj = $obj;
       } //foreach
     } //if
-      
+
     if (isset($result_obj))  {
       $result_obj->meta = @unserialize($result_obj->meta);
       return $result_obj;
       return false;
     } //else
   } //wiki_get_latest_page
-  
+
   //fetches all pages, including old versions
-  function wiki_get_pages(&$entry) {   
+  function wiki_get_pages(&$entry) {
     return get_records('wiki_pages', 'wiki', $entry->id);
   } //wiki_get_pages
-  
+
   //fetches all the latest versions of all the pages
   function wiki_get_latest_pages(&$entry) {
     //== (My)SQL for this
       from wiki_pages group by pagename) as a
       on ((wiki_pages.version = a.ver) and
       (wiki_pages.pagename like a.pagename)) */
-    
-    $pages = array();    
-    
+
+    $pages = array();
+
     //http://moodle.org/bugs/bug.php?op=show&bugid=5877&pos=0
-    //if ($ids = get_records('wiki_pages', 'wiki', $entry->id, '', 'distinct pagename')) { 
+    //if ($ids = get_records('wiki_pages', 'wiki', $entry->id, '', 'distinct pagename')) {
     if ($rs = get_recordset('wiki_pages', 'wiki', $entry->id, '', 'distinct pagename')) {
       $ids = $rs->GetRows();
-    //--    
-      foreach ($ids as $id) {      
+    //--
+      foreach ($ids as $id) {
         $pages[] = wiki_get_latest_page($entry, $id[0]);
       } //foreach
     } else {
       return false;
-    } //else  
-      
-    return $pages;   
+    } //else
+
+    return $pages;
   } //wiki_get_latest_pages
-  
+
   function wiki_iterator() {
-    return get_all_instances_in_courses("wiki", get_courses());  
+    return get_all_instances_in_courses("wiki", get_courses());
   } //wiki_iterator
-  
+
   function wiki_get_content_for_index(&$wiki) {
     $documents = array();
-    
-    $entries = wiki_get_entries($wiki);    
+
+    $entries = wiki_get_entries($wiki);
     foreach($entries as $entry) {
       //all pages
       //$pages = wiki_get_pages($entry);
-      
+
       //latest pages
       $pages = wiki_get_latest_pages($entry);
-      
+
       if (is_array($pages)) {
         foreach($pages as $page) {
           if (strlen($page->content) > 0) {
         } //foreach
       } //if
     } //foreach
-    
+
     return $documents;
-  } //wiki_get_content_for_index 
-  
+  } //wiki_get_content_for_index
+
   //returns a single wiki search document based on a wiki_entry id
   function wiki_single_document($id) {
     $pages = get_recordset('wiki_pages', 'id', $id);
     $page = $pages->fields;
-    
+
     $entries = get_recordset('wiki_entries', 'id', $page['wiki']);
     $entry = $entries->fields;
-    
+
     return new WikiSearchDocument($page, $entry['wikiid'], $entry['course'], $entry['groupid']);
-  } //wiki_single_document    
-    
+  } //wiki_single_document
+
   function wiki_delete($info) {
-    return $info;            
+    return $info;
   } //wiki_delete
-  
+
   //returns the var names needed to build a sql query for addition/deletions
   function wiki_db_names() {
     //[primary id], [table name], [time created field name], [time modified field name]
-    return array('id', 'wiki_pages', 'created', 'lastmodified');            
-  } //wiki_db_names    
-  
+    return array('id', 'wiki_pages', 'created', 'lastmodified');
+  } //wiki_db_names
+
 ?>
\ No newline at end of file
index 7ae73089ab5593cff3e01d4e4c0a1682bc9b5f8c..3bf5495bc8de2e1f6267681fdbb9dbd99d2e43fe 100644 (file)
@@ -1,8 +1,8 @@
-<?php  
+<?php
   /* Entry page for /search
    * Redirects to query.php, because that is the most likely place a
    * user intended to go to when typing moodle.site/search
    * */
 
-  header("Location: query.php");    
+  header("Location: query.php");
 ?>
\ No newline at end of file
index 24f329ab48fcd026426f26e40ae7d7bb38ea8fc3..32300a58b35dbbfe2308e978a5e6417a0d055bb5 100644 (file)
   //this'll take some time, set up the environment
   @set_time_limit(0);
   @ob_implicit_flush(true);
-  @ob_end_flush();  
+  @ob_end_flush();
 
   require_once('../config.php');
-  require_once("$CFG->dirroot/search/lib.php");  
+  require_once("$CFG->dirroot/search/lib.php");
 
-  //only administrators can index the moodle installation, because access to all pages is required   
+  //only administrators can index the moodle installation, because access to all pages is required
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-  
+
   //confirmation flag to prevent accidental reindexing (indexersplash.php is the correct entry point)
   $sure = strtolower(optional_param('areyousure', '', PARAM_ALPHA));
-  
+
   if ($sure != 'yes') {
     mtrace("<pre>Sorry, you need to confirm indexing via <a href='indexersplash.php'>indexersplash.php</a>"
           .". (<a href='index.php'>Back to query page</a>).</pre>");
-          
+
     exit(0);
-  } //if  
-  
+  } //if
+
   //check for php5 (lib.php)
   if (!search_check_php5()) {
     $phpversion = phpversion();
     mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
     exit(0);
   } //if
-    
+
   //php5 found, continue including php5-only files
   //require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
-  require_once("$CFG->dirroot/search/indexlib.php");  
-    
+  require_once("$CFG->dirroot/search/indexlib.php");
+
   mtrace('<pre>Server Time: '.date('r',time())."\n");
 
   if ($CFG->search_indexer_busy == '1') {
 
   //turn on busy flag
   set_config('search_indexer_busy', '1');
-  
+
   //paths
   $index_path = SEARCH_INDEX_PATH;
   $index_db_file = "$CFG->dirroot/search/db/$CFG->dbtype.sql";
-  $dbcontrol = new IndexDBControl();  
-  
+  $dbcontrol = new IndexDBControl();
+
   //setup directory in data root
   if (!file_exists($index_path)) {
     mtrace("Data directory ($index_path) does not exist, attempting to create.");
   } else {
     mtrace("Using $index_path as data directory.");
   } //else
-  
+
   $index = new Zend_Search_Lucene($index_path, true);
-  
+
   if (!$dbcontrol->checkDB()) {
     search_pexit("Database error. Please check settings/files.");
-  } //if     
+  } //if
 
   //begin timer
   search_stopwatch();
   mtrace("Starting activity modules\n");
-  
+
   //the presence of the required search functions -
   // * mod_iterator
   // * mod_get_content_for_index
   //are the sole basis for including a module in the index at the moment.
-  
+
   if ($mods = get_records_select('modules' /*'index this module?' where statement*/)) {
-    //add virtual modules onto the back of the array        
-    $mods = array_merge($mods, search_get_additional_modules());    
-    
-    foreach ($mods as $mod) {            
-      $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';              
-      
+    //add virtual modules onto the back of the array
+    $mods = array_merge($mods, search_get_additional_modules());
+
+    foreach ($mods as $mod) {
+      $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
+
       if (file_exists($class_file)) {
         include_once($class_file);
-        
+
         //build function names
         $iter_function = $mod->name.'_iterator';
         $index_function = $mod->name.'_get_content_for_index';
-                
+
         $counter = 0;
         $doc = new stdClass;
-                
+
         if (function_exists($index_function) && function_exists($iter_function)) {
           mtrace("Processing module function $index_function ...");
-                     
+
           foreach ($iter_function() as $i) {
             $documents = $index_function($i);
-            
+
             //begin transaction
-            
+
             foreach($documents as $document) {
               $counter++;
-                            
+
               //object to insert into db
               $dbid = $dbcontrol->addDocument($document);
-              
+
               //synchronise db with index
               $document->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));
-              
+
               //add document to index
-              $index->addDocument($document);                  
-                            
-              //commit every x new documents, and print a status message                            
+              $index->addDocument($document);
+
+              //commit every x new documents, and print a status message
               if (($counter%2000) == 0) {
                 $index->commit();
                 mtrace(".. $counter");
             } //foreach
 
             //end transaction
-            
+
           } //foreach
-                  
-          //commit left over documents, and finish up  
+
+          //commit left over documents, and finish up
           $index->commit();
-          
+
           mtrace("-- $counter documents indexed");
-          mtrace("done.\n");          
+          mtrace("done.\n");
         } //if
       } //if
     } //foreach
   } //if
-  
+
   //finished modules
   mtrace('Finished activity modules');
   search_stopwatch();
-  
+
   //now blocks...
   //
-  
+
   mtrace(".<br><a href='index.php'>Back to query page</a>.");
   mtrace('</pre>');
-  
+
   //finished, turn busy flag off
   set_config("search_indexer_busy", "0");
-  
+
   //mark the time we last updated
   set_config("search_indexer_run_date", time());
-  
+
   //and the index size
   set_config("search_index_size", (int)$index->count());
-  
+
 ?>
\ No newline at end of file
index c0899b669c2f81143e577f24c984d6c11ce1c218..a187fbd6ff5e810e081aeb2c0c491a4a8d9db7e3 100644 (file)
@@ -3,27 +3,27 @@
    * it is in place to prevent accidental reindexing which can lead to a loss
    * of time, amongst other things.
    * */
-  
+
   require_once('../config.php');
-  require_once("$CFG->dirroot/search/lib.php");  
+  require_once("$CFG->dirroot/search/lib.php");
 
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-  
+
   //check for php5 (lib.php)
   if (!search_check_php5()) {
     $phpversion = phpversion();
     mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
     exit(0);
   } //if
-  
-  require_once("$CFG->dirroot/search/indexlib.php");    
+
+  require_once("$CFG->dirroot/search/indexlib.php");
   $indexinfo = new IndexInfo();
-    
-  if ($indexinfo->valid()) {    
+
+  if ($indexinfo->valid()) {
     mtrace("<pre>The data directory ($indexinfo->path) contains $indexinfo->filecount files, and\n"
           ."there are ".$indexinfo->dbcount." records in the <em>search_documents</em> table.\n"
           ."\n"
@@ -40,5 +40,5 @@
           ."</pre>");
   } else {
     header('Location: indexer.php?areyousure=yes');
-  } //else    
+  } //else
 ?>
\ No newline at end of file
index f2335921b0e5fef1de71999c5450e4f86dd9847e..cc479e866270d32d90a94e3498bc478f8afc8f31 100644 (file)
@@ -7,7 +7,7 @@
    * */
 
   require_once("$CFG->dirroot/search/lib.php");
-  require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");   
+  require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
 
   class IndexInfo {
     private $path,        //index data directory
             $types,       //array of [document types => count]
             $complete,    //is index completely formed?
             $time;        //date index was generated
-    
+
     public function __construct($path=SEARCH_INDEX_PATH) {
       global $CFG, $db;
-      
+
       $this->path = $path;
-      
+
       //test to see if there is a valid index on disk, at the specified path
       try {
         $test_index = new Zend_Search_Lucene($this->path, false);
-        $validindex = true;        
-      } catch(Exception $e) {    
+        $validindex = true;
+      } catch(Exception $e) {
         $validindex = false;
       } //catch
 
-      //retrieve file system info about the index if it is valid            
-      if ($validindex) {      
+      //retrieve file system info about the index if it is valid
+      if ($validindex) {
         $this->size = display_size(get_directory_size($this->path));
         $index_dir  = get_directory_list($this->path, '', false, false);
         $this->filecount = count($index_dir);
       } //else
 
       $db_exists = false; //for now
-            
+
       //get all the current tables in moodle
       $admin_tables = $db->MetaTables();
-      
+
       //TODO: use new IndexDBControl class for database checks?
-      
+
       //check if our search table exists
       if (in_array($CFG->prefix.SEARCH_DATABASE_TABLE, $admin_tables)) {
         //retrieve database information if it does
         $db_exists = true;
-        
+
         //total documents
         $this->dbcount = count_records(SEARCH_DATABASE_TABLE);
 
         //individual document types
         $types = search_get_document_types();
         sort($types);
-  
+
         foreach($types as $type) {
           $c = count_records(SEARCH_DATABASE_TABLE, 'doctype', $type);
           $this->types[$type] = (int)$c;
       } else {
         $this->dbcount = 0;
         $this->types = array();
-      } //else      
-      
+      } //else
+
       //check if the busy flag is set
       if ($CFG->search_indexer_busy == '1') {
         $this->complete = false;
       } else {
         $this->complete = true;
       } //if
-      
+
       //get the last run date for the indexer
       if ($this->valid() && $CFG->search_indexer_run_date) {
         $this->time = $CFG->search_indexer_run_date;
         $this->time = 0;
       } //else
     } //__construct
-    
+
     //returns false on error, and the error message via referenced variable $err
     public function valid(&$err=null) {
       $err = array();
       $ret = true;
-      
+
       if (!$this->is_valid_dir()) {
         $err['dir'] = 'Index directory either contains an invalid index, or nothing at all.';
         $ret = false;
       } //if
-      
+
       if (!$this->is_valid_db()) {
         $err['db'] = 'Database table is not present, or contains no index records.';
         $ret = false;
       } //if
-      
+
       if (!$this->complete) {
         $err['index'] = 'Indexing was not successfully completed, please restart it.';
         $ret = false;
       } //if
-      
-      return $ret;      
+
+      return $ret;
     } //valid
-    
+
     //is the index dir valid
     public function is_valid_dir() {
       if ($this->filecount > 0) {
         return false;
       } //else
     } //is_valid_dir
-    
+
     //is the db table valid
     public function is_valid_db() {
       if ($this->dbcount > 0) {
       } else {
         return false;
       } //else
-    } //is_valid_db      
-        
+    } //is_valid_db
+
     //shorthand get method for the class variables
-    public function __get($var) {      
+    public function __get($var) {
       if (in_array($var, array_keys(get_class_vars(get_class($this))))) {
         return $this->$var;
       } //if
-    } //__get        
+    } //__get
   } //IndexInfo
-  
-  
-  /* DB Index control class 
-   * 
+
+
+  /* DB Index control class
+   *
    * Used to control the search index database table
    * */
-   
-  class IndexDBControl {  
+
+  class IndexDBControl {
     //does the table exist?
     public function checkTableExists() {
       global $CFG, $db;
-      
+
       $table = SEARCH_DATABASE_TABLE;
       $tables = $db->MetaTables();
-      
+
       if (in_array($CFG->prefix.$table, $tables)) {
         return true;
       } else {
         return false;
       } //else
     } //checkTableExists
-    
+
     //is our database setup valid?
     public function checkDB() {
       global $CFG, $db;
-            
+
       $sqlfile = "$CFG->dirroot/search/db/$CFG->dbtype.sql";
-      $ret = false;     
-   
-      if ($this->checkTableExists()) {                 
+      $ret = false;
+
+      if ($this->checkTableExists()) {
         execute_sql('drop table '.$CFG->prefix.SEARCH_DATABASE_TABLE, false);
       } //if
-        
+
       ob_start(); //turn output buffering on - to hide modify_database() output
       $ret = modify_database($sqlfile, '', false);
       ob_end_clean(); //chuck the buffer and resume normal operation
-      
+
       return $ret;
     } //checkDB
-    
+
     //add a document record to the table
     public function addDocument($document=null) {
       global $db;
-      
+
       if ($document == null) {
         return false;
       } //if
-      
-      //object to insert into db                            
+
+      //object to insert into db
       $doc->doctype   = $document->doctype;
       $doc->docid     = $document->docid;
       $doc->title     = search_escape_string($document->title);
-      $doc->url       = search_escape_string($document->url);              
-      $doc->update    = time();  
-      $doc->docdate   = $document->date;                          
-      $doc->courseid  = $document->course_id;              
-      $doc->groupid   = $document->group_id;              
-        
+      $doc->url       = search_escape_string($document->url);
+      $doc->update    = time();
+      $doc->docdate   = $document->date;
+      $doc->courseid  = $document->course_id;
+      $doc->groupid   = $document->group_id;
+
       //insert summary into db
       $id = insert_record(SEARCH_DATABASE_TABLE, $doc);
-              
+
       return $id;
     } //addDocument
-    
+
     //remove a document record from the index
     public function delDocument($document) {
       global $db;
-      
+
       delete_records(SEARCH_DATABASE_TABLE, 'id', $document->dbid);
     } //delDocument
   } //IndexControl
-      
+
 ?>
\ No newline at end of file
index a5641c27859cb3881762aca51f4d6dff64617465..92d5e753ecd7963f9e3844f3f29e930a8c8bcf84 100644 (file)
@@ -6,32 +6,32 @@
    * This file must not contain any PHP 5, because it is used to test for PHP 5
    * itself, and needs to be able to be executed on PHP 4 installations.
    * */
-  
+
   define('SEARCH_INDEX_PATH', "$CFG->dataroot/search");
   define('SEARCH_DATABASE_TABLE', 'search_documents');
-  
-  //document types that can be searched  
+
+  //document types that can be searched
   //define('SEARCH_TYPE_NONE', 'none');
   define('SEARCH_TYPE_WIKI', 'wiki');
   define('SEARCH_TYPE_FORUM', 'forum');
   define('SEARCH_TYPE_GLOSSARY', 'glossary');
   define('SEARCH_TYPE_RESOURCE', 'resource');
-  
+
   //returns all the document type constants
   function search_get_document_types($prefix='SEARCH_TYPE') {
     $ret = array();
-    
+
     foreach (get_defined_constants() as $key=>$value) {
       if (substr($key, 0, strlen($prefix)) == $prefix) {
         $ret[$key] = $value;
       } //if
     } //foreach
-    
+
     sort($ret);
-    
+
     return $ret;
   } //search_get_document_types
-  
+
   // additional virtual modules to index
   //
   // By adding 'moo' to the extras array, an additional document type
   function search_get_additional_modules() {
     $extras = array(/* additional keywords go here */);
     $ret = array();
-    
+
     foreach($extras as $extra) {
       $temp->name = $extra;
       $ret[] = clone($temp);
     } //foreach
-    
+
     return $ret;
-  } //search_get_additional_modules  
-    
+  } //search_get_additional_modules
+
   //shortens a url so it can fit on the results page
-  function search_shorten_url($url, $length=30) {    
+  function search_shorten_url($url, $length=30) {
     return substr($url, 0, $length)."...";
   } //search_shorten_url
-  
+
   function search_escape_string($str) {
     global $CFG;
-     
+
     switch ($CFG->dbtype) {
       case 'mysql':
         $s = mysql_real_escape_string($str);
       default:
         $s = addslashes($str);
     } //switch
-    
+
     return $s;
   } //search_escape_string
 
-  //get a real php 5 version number, using 5.0.0 arbitrarily  
+  //get a real php 5 version number, using 5.0.0 arbitrarily
   function search_check_php5($feedback=false) {
     if (!check_php_version("5.0.0")) {
       if ($feedback) {
         $phpversion = phpversion();
         print_heading("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
       } //if
-      
+
       return false;
     } else {
       return true;
     } //else
   } //search_check_php5
-  
+
   //simple timer function, outputs result on 2nd call
   function search_stopwatch($cli = false) {
     if (!empty($GLOBALS['search_script_start_time'])) {
       if (!$cli) print '<em>';
       print round(microtime(true) - $GLOBALS['search_script_start_time'], 6).' seconds';
       if (!$cli) print '</em>';
-      
+
       unset($GLOBALS['search_script_start_time']);
     } else {
       $GLOBALS['search_script_start_time'] = microtime(true);
     } //else
   } //search_stopwatch
-  
+
   //print and exit (for debugging)
   function search_pexit($str = "") {
     if (is_array($str) or is_object($str)) {
     } else if ($str) {
       print $str."<br>";
     } //if
-    
+
     exit(0);
   } //search_pexit
 
index 0d2b90e7a5ca24a7eab4164fcf3c72cb5f0ff95e..7426833d0e50a5847938bd5049e26a2a7c852c7c 100644 (file)
@@ -3,7 +3,7 @@
   /* The query page - accepts a user-entered query string and returns results.
    *
    * Queries are boolean-aware, e.g.:
-   * 
+   *
    * '+'      term required
    * '-'      term must not be present
    * ''       (no modifier) term's presence increases rank, but isn't required
    *
    * '+author:helen +author:foster'
    *   All articles written by Helen Foster
-   *   
+   *
    * */
 
   require_once('../config.php');
-  require_once("$CFG->dirroot/search/lib.php"); 
-    
+  require_once("$CFG->dirroot/search/lib.php");
+
   //check for php5, but don't die yet (see line 52)
-  if ($check = search_check_php5()) {      
+  if ($check = search_check_php5()) {
     require_once("$CFG->dirroot/search/querylib.php");
-    
+
     $page_number  = optional_param('page', -1, PARAM_INT);
-    $pages        = ($page_number == -1) ? false : true;               
-    $advanced     = (optional_param('a', '0', PARAM_INT) == '1') ? true : false;       
-    $query_string = optional_param('query_string', '', PARAM_CLEAN); 
-      
+    $pages        = ($page_number == -1) ? false : true;
+    $advanced     = (optional_param('a', '0', PARAM_INT) == '1') ? true : false;
+    $query_string = optional_param('query_string', '', PARAM_CLEAN);
+
     if ($pages && isset($_SESSION['search_advanced_query'])) {
       //if both are set, then we are busy browsing through the result pages of an advanced query
       $adv = unserialize($_SESSION['search_advanced_query']);
@@ -44,7 +44,7 @@
 
       //chars to strip from strings (whitespace)
       $chars = " \t\n\r\0\x0B,-+";
-            
+
       //retrieve advanced query variables
       $adv->mustappear  = trim(optional_param('mustappear', '', PARAM_CLEAN), $chars);
       $adv->notappear   = trim(optional_param('notappear', '', PARAM_CLEAN), $chars);
       $adv->module      = optional_param('module', '', PARAM_CLEAN);
       $adv->title       = trim(optional_param('title', '', PARAM_CLEAN), $chars);
       $adv->author      = trim(optional_param('author', '', PARAM_CLEAN), $chars);
-    } //else      
-    
+    } //else
+
     if ($advanced) {
       //parse the advanced variables into a query string
       //TODO: move out to external query class (QueryParse?)
-                  
-      $query_string = '';      
-      
+
+      $query_string = '';
+
       //get all available module types
-      $module_types = array_merge(array('All'), array_values(search_get_document_types()));      
+      $module_types = array_merge(array('All'), array_values(search_get_document_types()));
       $adv->module = in_array($adv->module, $module_types) ? $adv->module : 'All';
-      
-      //convert '1 2' into '+1 +2' for required words field    
+
+      //convert '1 2' into '+1 +2' for required words field
       if (strlen(trim($adv->mustappear)) > 0) {
         $query_string  = ' +'.implode(' +', preg_split("/[\s,;]+/", $adv->mustappear));
       } //if
-      
+
       //convert '1 2' into '-1 -2' for not wanted words field
       if (strlen(trim($adv->notappear)) > 0) {
         $query_string .= ' -'.implode(' -', preg_split("/[\s,;]+/", $adv->notappear));
       } //if
-      
+
       //this field is left untouched, apart from whitespace being stripped
-      if (strlen(trim($adv->canappear)) > 0) { 
+      if (strlen(trim($adv->canappear)) > 0) {
         $query_string .= ' '.implode(' ', preg_split("/[\s,;]+/", $adv->canappear));
       } //if
-      
+
       //add module restriction
       if ($adv->module != 'All') {
         $query_string .= ' +doctype:'.$adv->module;
       } //if
-      
+
       //create title search string
       if (strlen(trim($adv->title)) > 0) {
         $query_string .= ' +title:'.implode(' +title:', preg_split("/[\s,;]+/", $adv->title));
       } //if
-      
+
       //create author search string
       if (strlen(trim($adv->author)) > 0) {
         $query_string .= ' +author:'.implode(' +author:', preg_split("/[\s,;]+/", $adv->author));
-      } //if     
-      
+      } //if
+
       //save our options if the query is valid
       if (!empty($query_string)) {
         $_SESSION['search_advanced_query'] = serialize($adv);
-      } //if 
+      } //if
     } //if
-    
+
     //normalise page number
     if ($page_number < 1) {
       $page_number = 1;
-    } //if    
-    
+    } //if
+
     //run the query against the index
-    $sq = new SearchQuery($query_string, $page_number, 10, false);  
+    $sq = new SearchQuery($query_string, $page_number, 10, false);
   } //if
-  
+
   if (!$site = get_site()) {
     redirect("index.php");
   } //if
-    
+
   $strsearch = "Search"; //get_string();
   $strquery  = "Enter your search query"; //get_string();
 
-  print_header("$site->shortname: $strsearch: $strquery", "$site->fullname", 
+  print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
                "<a href=\"index.php\">$strsearch</a> -> $strquery");
-  
+
   //keep things pretty, even if php5 isn't available
   if (!$check) {
     print_heading(search_check_php5(true));
     print_footer();
     exit(0);
   } //if
-  
+
   print_simple_box_start('center', '100%', '', 20);
   print_heading($strquery);
-  
+
   print_simple_box_start('center', '', '', 20);
-      
+
   $vars = get_object_vars($adv);
-  
+
   foreach ($vars as $key => $value) {
     $adv->$key = stripslashes(htmlentities($value));
-  } //foreach  
-  
+  } //foreach
+
 ?>
 
 <form name="query" method="get" action="query.php">
   <?php if (!$advanced) { ?>
     <input type="text" name="query_string" length="50" value="<?php print stripslashes(htmlentities($query_string)) ?>"/>
-    &nbsp;<input type="submit" value="Search"/>&nbsp;&nbsp; 
+    &nbsp;<input type="submit" value="Search"/>&nbsp;&nbsp;
     <a href="query.php?a=1">Advanced search</a>
     <a href="stats.php">Statistics</a>
   <?php } else {
-    print_simple_box_start('center', '', 'white', 10);    
-  ?>    
+    print_simple_box_start('center', '', 'white', 10);
+  ?>
     <input type="hidden" name="a" value="<?php print $advanced; ?>"/>
-     
+
     <table border="0" cellpadding="3" cellspacing="3">
-    
+
     <tr>
       <td width="240">These words must appear:</td>
       <td><input type="text" name="mustappear" length="50" value="<?php print $adv->mustappear; ?>"/></td>
     </tr>
-    
+
     <tr>
       <td>These words must not appear:</td>
       <td><input type="text" name="notappear" length="50" value="<?php print $adv->notappear; ?>"/></td>
     <tr>
       <td>These words help improve rank:</td>
       <td><input type="text" name="canappear" length="50" value="<?php print $adv->canappear; ?>"/></td>
-    </tr>    
-    
+    </tr>
+
     <tr>
       <td>Which modules to search?:</td>
       <td>
-        <select name="module">          
+        <select name="module">
           <?php foreach($module_types as $mod) {
             if ($mod == $adv->module) {
               print "<option value='$mod' selected>$mod</option>\n";
         </select>
       </td>
     </tr>
-    
+
     <tr>
       <td>Words in title:</td>
       <td><input type="text" name="title" length="50" value="<?php print $adv->title; ?>"/></td>
     </tr>
-    
+
     <tr>
       <td>Author name:</td>
       <td><input type="text" name="author" length="50" value="<?php print $adv->author; ?>"/></td>
     </tr>
-    
+
     <tr>
       <td colspan="3" align="center"><br><input type="submit" value="Search"/></td>
     </tr>
-    
+
     <tr>
       <td colspan="3" align="center">
         <table border="0" cellpadding="0" cellspacing="0">
         </table>
       </td>
     </tr>
-    </table>           
+    </table>
   <?php
     print_simple_box_end();
   } //if
 
   print '<div align="center">';
   print 'Searching: ';
-  
+
   if ($sq->is_valid_index()) {
     //use cached variable to show up-to-date index size (takes deletions into account)
     print $CFG->search_index_size;
   } else {
     print "0";
   } //else
-  
+
   print ' documents.';
-  
+
   if (!$sq->is_valid_index() and isadmin()) {
     print "<br><br>Admin: There appears to be no index, click <a href='indexersplash.php'>here</a> to create one.";
   } //if
   print '</div>';
 
   print_simple_box_end();
-  
+
   if ($sq->is_valid()) {
     print_simple_box_start('center', '50%', 'white', 10);
-    
-    search_stopwatch();              
-    $hit_count = $sq->count();    
-    
+
+    search_stopwatch();
+    $hit_count = $sq->count();
+
     print "<br>";
 
     print $hit_count." results returned for '".stripslashes($query_string)."'.";
     print "<br>";
-      
-    if ($hit_count > 0) {     
-      $page_links = $sq->page_numbers();     
+
+    if ($hit_count > 0) {
+      $page_links = $sq->page_numbers();
       $hits       = $sq->results();
-      
+
       if ($advanced) {
-        //if in advanced mode, search options are saved in the session, so 
+        //if in advanced mode, search options are saved in the session, so
         //we can remove the query string var from the page links, and replace
         //it with a=1 (Advanced = on) instead
         $page_links = preg_replace("/query_string=[^&]+/", 'a=1', $page_links);
       } //if
-        
+
       print "<ol>";
-        
+
       foreach ($hits as $listing) {
         print "<li value='".($listing->number+1)."'><a href='".$listing->url."'>$listing->title</a><br>\n"
-             ."<em>".search_shorten_url($listing->url, 70)."</em><br>\n"        
-             ."Type: ".$listing->doctype.", score: ".round($listing->score, 3).", author: ".$listing->author."<br>\n"            
+             ."<em>".search_shorten_url($listing->url, 70)."</em><br>\n"
+             ."Type: ".$listing->doctype.", score: ".round($listing->score, 3).", author: ".$listing->author."<br>\n"
              ."<br></li>\n";
       } //for
-      
+
       print "</ol>";
       print $page_links;
-    } //if        
-    
+    } //if
+
     print_simple_box_end();
 ?>
 
 
 <?php
   } //if (sq is valid)
-  
+
   print_simple_box_end();
   print_footer();
 ?>
\ No newline at end of file
index e435b0dd2745ef3521d6f87b52d16466091bd695..65d4b066545f7ed521664caeb31438c481f210f6 100644 (file)
@@ -3,7 +3,7 @@
 
   class SearchResult {
     public  $url,
-            $title,            
+            $title,
             $doctype,
             $author,
             $score,
   class SearchCache {
     private $mode,
             $valid;
-                
+
     public function __construct($mode='session') {
       $accepted_modes = array('session');
-      
+
       if (in_array($mode, $accepted_modes)) {
         $this->mode = $mode;
       } else {
         $this->mode = 'session';
       } //else
-      
+
       $this->valid = true;
     } //constructor
-    
+
     public function can_cache() {
       return $this->valid;
     } //can_cache
-    
+
     public function cache($id=false, $object=false) {
       //see if there was a previous query
       $last_term = $this->fetch('search_last_term');
-      
+
       //if this query is different from the last, clear out the last one
       if ($id != false and $last_term != $id) {
         $this->clear($last_term);
       } //if
-      
+
       //store the new query if id and object are passed in
       if ($object and $id) {
         $this->store('search_last_term', $id);
         $this->store($id, $object);
         return true;
       //otherwise return the stored results
-      } else if ($id and $this->exists($id)) {        
+      } else if ($id and $this->exists($id)) {
         return $this->fetch($id);
       } //else
     } //cache
-    
+
     private function exists($id) {
       switch ($this->mode) {
         case 'session' :
           return isset($_SESSION[$id]);
       } //switch
     } //exists
-        
+
     private function clear($id) {
       switch ($this->mode) {
         case 'session' :
           session_unregister($id);
           return;
       } //switch
-    } //clear    
-        
+    } //clear
+
     private function fetch($id) {
       switch ($this->mode) {
         case 'session' :
           return ($this->exists($id)) ? unserialize($_SESSION[$id]) : false;
       } //switch
     } //fetch
-    
+
     private function store($id, $object) {
       switch ($this->mode) {
         case 'session' :
           $_SESSION[$id] = serialize($object);
           return;
       } //switch
-    } //store        
+    } //store
   } //SearchCache
-  
-  
+
+
   class SearchQuery {
     private $index,
             $term,
-            $pagenumber,            
+            $pagenumber,
             $cache,
             $validquery,
-            $validindex,            
+            $validindex,
             $results,
             $results_per_page,
             $total_results;
-    
+
     public function __construct($term='', $page=1, $results_per_page=10, $cache=false) {
       global $CFG;
-      
+
       $this->term       = $term;
       $this->pagenumber = $page;
       $this->cache      = $cache;
       $this->validquery = true;
-      $this->validindex = true;      
-      $this->results_per_page = $results_per_page;      
-      
+      $this->validindex = true;
+      $this->results_per_page = $results_per_page;
+
       $index_path = SEARCH_INDEX_PATH;
-      
+
       try {
         $this->index = new Zend_Search_Lucene($index_path, false);
-      } catch(Exception $e) {    
-        $this->validindex = false;        
+      } catch(Exception $e) {
+        $this->validindex = false;
         return;
       } //catch
-            
+
       if (empty($this->term)) {
         $this->validquery = false;
       } else {
         $this->set_query($this->term);
-      } //else      
+      } //else
     } //constructor
-    
-    public function set_query($term='') {            
+
+    public function set_query($term='') {
       if (!empty($term)) {
         $this->term = $term;
       } //if
-      
+
       if (empty($this->term)) {
         $this->validquery = false;
       } else {
         $this->validquery = true;
       } //else
-      
+
       if ($this->validquery and $this->validindex) {
         $this->results = $this->get_results();
       } else {
         $this->results = array();
-      } //else      
+      } //else
     } //set_query
-    
+
     public function results() {
       return $this->results;
     } //results
-        
+
     private function process_results($all=false) {
       global $USER;
 
-      $term = strtolower($this->term);         
-      
+      $term = strtolower($this->term);
+
       //experimental - return more results
-      $strip_arr = array('author:', 'title:', '+', '-', 'doctype:');   
+      $strip_arr = array('author:', 'title:', '+', '-', 'doctype:');
       $stripped_term = str_replace($strip_arr, '', $term);
-      
+
       $hits = $this->index->find($term." title:".$stripped_term." author:".$stripped_term);
       //--
-      
+
       $hitcount = count($hits);
-      $this->total_results = $hitcount; 
-            
+      $this->total_results = $hitcount;
+
       if ($hitcount == 0) return array();
-      
+
       $totalpages = ceil($hitcount/$this->results_per_page);
-      
+
       if (!$all) {
         if ($hitcount < $this->results_per_page) {
           $this->pagenumber = 1;
         } else if ($this->pagenumber > $totalpages) {
           $this->pagenumber  =$totalpages;
-        } //if      
-        
+        } //if
+
         $start = ($this->pagenumber - 1) * $this->results_per_page;
         $end = $start + $this->results_per_page;
-        
+
         if ($end > $hitcount) {
           $end = $hitcount;
-        } //if        
+        } //if
       } else {
         $start = 0;
         $end = $hitcount;
       } //else
-      
+
       $resultdoc  = new SearchResult();
-      $resultdocs = array();      
-                  
+      $resultdocs = array();
+
       for ($i = $start; $i < $end; $i++) {
         $hit = $hits[$i];
-                           
+
         //check permissions on each result
         if ($this->can_display($USER, $hit->id, $hit->doctype, $hit->course_id, $hit->group_id)) {
           $resultdoc->number  = $i;
           $resultdoc->score   = $hit->score;
           $resultdoc->doctype = $hit->doctype;
           $resultdoc->author  = $hit->author;
-        
+
           //and store it
-          $resultdocs[] = clone($resultdoc);          
+          $resultdocs[] = clone($resultdoc);
         } //if
       } //foreach
-            
+
       return $resultdocs;
     } //process_results
-              
+
     private function get_results() {
       $cache = new SearchCache();
-      
-      if ($this->cache and $cache->can_cache()) {        
+
+      if ($this->cache and $cache->can_cache()) {
         if (!($resultdocs = $cache->cache($this->term))) {
           $resultdocs = $this->process_results();
           //cache the results so we don't have to compute this on every page-load
-          $cache->cache($this->term, $resultdocs);          
+          $cache->cache($this->term, $resultdocs);
           //print "Using new results.";
-        } else {            
+        } else {
           //There was something in the cache, so we're using that to save time
           //print "Using cached results.";
-        } //else                
+        } //else
       } else {
         //no caching :(
         //print "Caching disabled!";
       } //else
 
       return $resultdocs;
-    } //get_results  
-    
+    } //get_results
+
     public function page_numbers() {
       $pages  = $this->total_pages();
-      $query  = htmlentities($this->term);     
+      $query  = htmlentities($this->term);
       $page   = $this->pagenumber;
       $next   = "Next";
       $back   = "Back";
-      
-      $ret = "<div align='center' id='search_page_links'>";    
-      
+
+      $ret = "<div align='center' id='search_page_links'>";
+
       //Back is disabled if we're on page 1
       if ($page > 1) {
         $ret .= "<a href='query.php?query_string=$query&page=".($page-1)."'>< $back</a>&nbsp;";
       } else {
         $ret .= "< $back&nbsp;";
       } //else
-      
+
       //don't <a href> the current page
       for ($i = 1; $i <= $pages; $i++) {
         if ($page == $i) {
           $ret .= "<a href='query.php?query_string=$query&page=$i'>$i</a>&nbsp;";
         } //else
       } //for
-      
+
       //Next disabled if we're on the last page
-      if ($page < $pages) {      
+      if ($page < $pages) {
         $ret .= "<a href='query.php?query_string=$query&page=".($page+1)."'>$next ></a>&nbsp;";
       } else {
         $ret .= "$next >&nbsp;";
       } //else
-      
-      $ret .= "</div>";    
-      
+
+      $ret .= "</div>";
+
       //shorten really long page lists, to stop table distorting width-ways
       if (strlen($ret) > 70) {
         $start = 4;
-        $end = $page - 5;     
+        $end = $page - 5;
         $ret = preg_replace("/<a\D+\d+\D+>$start<\/a>.*?<a\D+\d+\D+>$end<\/a>/", '...', $ret);
-  
+
         $start = $page + 5;
-        $end = $pages - 3;      
+        $end = $pages - 3;
         $ret = preg_replace("/<a\D+\d+\D+>$start<\/a>.*?<a\D+\d+\D+>$end<\/a>/", '...', $ret);
       } //if
-     
+
       return $ret;
-    } //page_numbers    
+    } //page_numbers
 
-    //can the user see this result?          
+    //can the user see this result?
     private function can_display(&$user, $this_id, $doctype, $course_id, $group_id) {
       //this function should return true/false depending on
       //whether or not a user can see this resource
       //..
       //if one of you nice moodlers see this, feel free to
-      //implement it for me .. :-P      
+      //implement it for me .. :-P
       return true;
     } //can_display
-    
+
     public function count() {
       return $this->total_results;
     } //count
-    
+
     public function is_valid() {
       return ($this->validquery and $this->validindex);
     } //is_valid
-    
+
     public function is_valid_query() {
       return $this->validquery;
     } //is_valid_query
     public function is_valid_index() {
       return $this->validindex;
     } //is_valid_index
-    
+
     public function total_pages() {
       return ceil($this->count()/$this->results_per_page);
-    } //pages    
-    
+    } //pages
+
     public function get_pagenumber() {
       return $this->pagenumber;
     } //get_pagenumber
-    
+
     public function get_results_per_page() {
       return $this->results_per_page;
-    } //get_results_per_page        
+    } //get_results_per_page
   } //SearchQuery
 
 ?>
\ No newline at end of file
index f54d72aceec507136f042e5ca775bf34214956a2..948c8b0521abe779ddc7629441c8d61ef142eac3 100644 (file)
@@ -1,41 +1,41 @@
 <?php
   /* Prints some basic statistics about the current index.
    *
-   * Does some diagnostics if you are logged in as an administrator.   
+   * Does some diagnostics if you are logged in as an administrator.
    * */
-  
-  require_once('../config.php');  
-  require_once("$CFG->dirroot/search/lib.php");  
+
+  require_once('../config.php');
+  require_once("$CFG->dirroot/search/lib.php");
 
   //check for php5, but don't die yet
   if ($check = search_check_php5()) {
-    require_once("$CFG->dirroot/search/indexlib.php");    
-    
+    require_once("$CFG->dirroot/search/indexlib.php");
+
     $indexinfo = new IndexInfo();
   } //if
-  
+
   if (!$site = get_site()) {
     redirect("index.php");
   } //if
-  
+
   $strsearch = "Search"; //get_string();
   $strquery  = "Search statistics"; //get_string();
 
-  print_header("$site->shortname: $strsearch: $strquery", "$site->fullname", 
+  print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
                "<a href=\"index.php\">$strsearch</a> -> $strquery");
-  
+
   //keep things pretty, even if php5 isn't available
   if (!$check) {
     print_heading(search_check_php5(true));
     print_footer();
     exit(0);
   } //if
-    
+
   print_simple_box_start('center', '100%', '', 20);
   print_heading($strquery);
-  
+
   print_simple_box_start('center', '', '', 20);
-  
+
   //this table is only for admins, shows index directory size and location
   if (isadmin()) {
     $admin_table->tablealign = "center";
     $admin_table->cellpadding = 5;
     $admin_table->cellspacing = 0;
     $admin_table->width = '500';
-  
+
     $admin_table->data[] = array('<strong>Data directory</strong>', '<em><strong>'.$indexinfo->path.'</strong></em>');
     $admin_table->data[] = array('Files in index directory', $indexinfo->filecount);
     $admin_table->data[] = array('Total size', $indexinfo->size);
-    
+
     if ($indexinfo->time > 0) {
       $admin_table->data[] = array('Created on', date('r', $indexinfo->time));
     } else {
       $admin_table->data[] = array('Created on', '-');
     } //else
-          
+
     if (!$indexinfo->valid($errors)) {
       $admin_table->data[] = array('<strong>Errors</strong>', '&nbsp;');
-    
+
       foreach ($errors as $key=>$value) {
         $admin_table->data[] = array($key.' ... ', $value);
       } //foreach
         $admin_table->data[] = array('Check DB', 'Check your database for any problems.');
       } //if
 
-      $admin_table->data[] = array('Run indexer test', '<a href=\'tests/index.php\'>tests/index.php</a>');      
-      $admin_table->data[] = array('Run indexer', '<a href=\'indexersplash.php\'>indexersplash.php</a>');      
+      $admin_table->data[] = array('Run indexer test', '<a href=\'tests/index.php\'>tests/index.php</a>');
+      $admin_table->data[] = array('Run indexer', '<a href=\'indexersplash.php\'>indexersplash.php</a>');
     } //if
   } //if
-  
+
   //this is the standard summary table for normal users, shows document counts
   $table->tablealign = "center";
   $table->align = array ("right", "left");
   $table->cellpadding = 5;
   $table->cellspacing = 0;
   $table->width = '500';
-  
+
   $table->data[] = array('<strong>Database</strong>', '<em><strong>search_documents<strong></em>');
-  
+
   //add extra fields if we're admin
   if (isadmin()) {
     //don't want to confuse users if the two totals don't match (hint: they should)
     $table->data[] = array('Documents in index', $indexinfo->indexcount);
-    
+
     //*cough* they should match if deletions were actually removed from the index,
     //as it turns out, they're only marked as deleted and not returned in search results
     $table->data[] = array('Deletions in index', (int)$indexinfo->indexcount - (int)$indexinfo->dbcount);
   } //if
-  
+
   $table->data[] = array('Documents in database', $indexinfo->dbcount);
-  
+
   foreach($indexinfo->types as $key => $value) {
     $table->data[] = array("'$key' documents", $value);
-  } //foreach    
+  } //foreach
 
   if (isadmin()) {
     print_table($admin_table);
     print_spacer(20);
   } //if
-  
+
   print_table($table);
-   
+
   print_simple_box_end();
   print_simple_box_end();
   print_footer();
index 37de0dc00e9a78b16723ce8a7576b65f7b1e178b..927f9d517b894cab5aa5a922a955f7553d04930e 100644 (file)
@@ -5,26 +5,26 @@
    * is expected to exist, along with the db schema files and the search data
    * directory.
    * */
-  
+
   @set_time_limit(0);
   @ob_implicit_flush(true);
-  @ob_end_flush();  
+  @ob_end_flush();
 
   require_once('../../config.php');
-  require_once("$CFG->dirroot/search/lib.php");  
+  require_once("$CFG->dirroot/search/lib.php");
 
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-    
+
   mtrace('<pre>Server Time: '.date('r',time()));
   mtrace("Testing global search capabilities:\n");
-  
+
   $phpversion = phpversion();
-  
-  if (!search_check_php5()) {    
+
+  if (!search_check_php5()) {
     mtrace("ERROR: PHP 5.0.0 or later required (currently using version $phpversion).");
     exit(0);
   } else {
   //fix paths for testing
   set_include_path(get_include_path().":../");
   require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
-  
+
   mtrace("Checking activity modules:\n");
-  
+
   //the presence of the required search functions -
   // * mod_iterator
   // * mod_get_content_for_index
   //are the sole basis for including a module in the index at the moment.
-  
+
   if ($mods = get_records_select('modules')) {
     $mods = array_merge($mods, search_get_additional_modules());
-    
+
     foreach ($mods as $mod) {
-      $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';              
-      
+      $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
+
       if (file_exists($class_file)) {
         include_once($class_file);
-        
+
         if (!defined('SEARCH_TYPE_'.strtoupper($mod->name))) {
           mtrace("ERROR: Constant 'SEARCH_TYPE_".strtoupper($mod->name)."' is not defined in /search/lib.php");
           continue;
         } //if
-        
+
         $iter_function = $mod->name.'_iterator';
         $index_function = $mod->name.'_get_content_for_index';
-                                
+
         if (function_exists($index_function) && function_exists($iter_function)) {
           if (is_array($iter_function())) {
             $documents = $index_function(array_pop($iter_function()));
-            
+
             if (is_array($documents)) {
               mtrace("Success: '$mod->name' module seems to be ready for indexing.");
             } else {
       } //else
     } //foreach
   } //if
-  
+
   //finished modules
   mtrace("\nFinished checking activity modules.");
-  
+
   //now blocks...
   //
-  
+
   mtrace("<br><a href='../index.php'>Back to query page</a> or <a href='../indexersplash.php'>Start indexing</a>.");
   mtrace('</pre>');
 
index d784acd4f131812db5b095118216251bf74ac27e..0217afd3e4027b0ef42a882e54be597ab0ecf191 100644 (file)
 
   require_once('../config.php');
   require_once("$CFG->dirroot/search/lib.php");
-  
+
   require_login();
 
   if (!isadmin()) {
     error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
   } //if
-    
+
   //check for php5 (lib.php)
   if (!search_check_php5()) {
     $phpversion = phpversion();
     mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version $phpversion)");
     exit(0);
-  } //if  
-    
-  require_once("$CFG->dirroot/search/indexlib.php");   
-  
+  } //if
+
+  require_once("$CFG->dirroot/search/indexlib.php");
+
   $index = new Zend_Search_Lucene(SEARCH_INDEX_PATH);
   $dbcontrol = new IndexDBControl();
   $update_count = 0;
-  
+
   $indexdate = $CFG->search_indexer_run_date;
 
-  mtrace("<pre>Starting index update (updates)...\n");  
-  
+  mtrace("<pre>Starting index update (updates)...\n");
+
   if ($mods = get_records_select('modules')) {
   $mods = array_merge($mods, search_get_additional_modules());
-  
+
   foreach ($mods as $mod) {
     $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
     $get_document_function = $mod->name.'_single_document';
     $delete_function = $mod->name.'_delete';
     $db_names_function = $mod->name.'_db_names';
-    $updates = array();    
-    
+    $updates = array();
+
     if (file_exists($class_file)) {
       require_once($class_file);
-    
+
       if (function_exists($delete_function) and function_exists($db_names_function) and function_exists($get_document_function)) {
         mtrace("Checking $mod->name module for updates.");
         $values = $db_names_function();
-        
+
         //TODO: check 'in' syntax with other RDBMS' (add and update.php as well)
         $sql = "select id, ".$values[0]." as docid from ".$values[1].
                " where ".$values[3]." > $indexdate".
                " and id in (select docid from ".SEARCH_DATABASE_TABLE.")";
-                
-        $records = get_records_sql($sql);     
-        
-        if (is_array($records)) {       
+
+        $records = get_records_sql($sql);
+
+        if (is_array($records)) {
           foreach($records as $record) {
             $updates[] = $delete_function($record->docid);
           } //foreach
-        } //if    
-          
+        } //if
+
         foreach ($updates as $update) {
           ++$update_count;
-                
-          //delete old document  
-          $doc = $index->find("+docid:$update +doctype:$mod->name");            
-          
+
+          //delete old document
+          $doc = $index->find("+docid:$update +doctype:$mod->name");
+
           //get the record, should only be one
-          foreach ($doc as $thisdoc) {            
+          foreach ($doc as $thisdoc) {
             mtrace("  Delete: $thisdoc->title (database id = $thisdoc->dbid, index id = $thisdoc->id, moodle instance id = $thisdoc->docid)");
-            
+
             $dbcontrol->delDocument($thisdoc);
-            $index->delete($thisdoc->id);              
+            $index->delete($thisdoc->id);
           } //foreach
-          
+
           //add new modified document back into index
           $add = $get_document_function($update);
-          
+
           //object to insert into db
-          $dbid = $dbcontrol->addDocument($add);                   
-              
+          $dbid = $dbcontrol->addDocument($add);
+
           //synchronise db with index
-          $add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));          
-          
+          $add->addField(Zend_Search_Lucene_Field::Keyword('dbid', $dbid));
+
           mtrace("  Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)");
-                            
-          $index->addDocument($add);          
+
+          $index->addDocument($add);
         } //foreach
-                    
+
         mtrace("Finished $mod->name.\n");
-      } //if              
+      } //if
     } //if
   } //foreach
   } //if
-  
+
   //commit changes
   $index->commit();
-  
+
   //update index date
   set_config("search_indexer_run_date", time());
 
-  mtrace("Finished $update_count updates.</pre>");  
+  mtrace("Finished $update_count updates.</pre>");
 
 ?>
\ No newline at end of file