]> git.mjollnir.org Git - moodle.git/commitdiff
Converted comments to phpdoc comments - file is in need of additional comments. I...
authordhawes <dhawes>
Sun, 26 Sep 2004 05:10:38 +0000 (05:10 +0000)
committerdhawes <dhawes>
Sun, 26 Sep 2004 05:10:38 +0000 (05:10 +0000)
lib/adminlib.php

index a84008a3d32d926bc7d1b925da3ee837b65c385f..72003ef8d4bdee9f6263841d9830e25b54847443 100644 (file)
@@ -1,27 +1,46 @@
-<?php  // $Id$
-       // Contains functions that only administrators will ever need to use
-
+<?php  //
+       // 
+
+/**
+ * adminlib.php - Contains functions that only administrators will ever need to use
+ *
+ * @author Martin Dougiamas
+ * @version  $Id$
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package moodlecore
+ */
+
+/**
+ * short description (optional)
+ *
+ * long description
+ *
+ * @uses $db
+ * @uses $CFG
+ * @param string  $return The url to prompt the user to continue to
+ * @todo Finish documenting this function
+ */ 
 function upgrade_enrol_plugins($return) {
     global $CFG, $db;
 
-    if (!$mods = get_list_of_plugins("enrol") ) {
-        error("No modules installed!");
+    if (!$mods = get_list_of_plugins('enrol') ) {
+        error('No modules installed!');
     }
 
     foreach ($mods as $mod) {
 
-        $fullmod = "$CFG->dirroot/enrol/$mod";
+        $fullmod = $CFG->dirroot .'/enrol/'. $mod;
 
         unset($module);
 
-        if ( is_readable("$fullmod/version.php")) {
-            include_once("$fullmod/version.php");  // defines $module with version etc
+        if ( is_readable($fullmod .'/version.php')) {
+            include_once($fullmod .'/version.php');  // defines $module with version etc
         } else {
             continue;                              // Nothing to do.
         }
 
-        if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
-            include_once("$fullmod/db/$CFG->dbtype.php");  // defines upgrading function
+        if ( is_readable($fullmod .'/db/'. $CFG->dbtype .'.php')) {
+            include_once($fullmod .'/db/'. $CFG->dbtype .'.php');  // defines upgrading function
         } else {
             continue;
         }
@@ -54,27 +73,27 @@ function upgrade_enrol_plugins($return) {
             // do nothing
         } else if ($CFG->$moduleversion < $module->version) {
             if (empty($updated_modules)) {
-                $strmodulesetup  = get_string("modulesetup");
-                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, "&nbsp;", "&nbsp;");
+                $strmodulesetup  = get_string('modulesetup');
+                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', '', false, '&nbsp;', '&nbsp;');
             }
-            print_heading("$module->name module needs upgrading");
-            $upgrade_function = $module->name."_upgrade";
+            print_heading($module->name .' module needs upgrading');
+            $upgrade_function = $module->name .'_upgrade';
             if (function_exists($upgrade_function)) {
                 $db->debug=true;
                 if ($upgrade_function($CFG->$moduleversion)) {
                     $db->debug=false;
                     // OK so far, now update the modules record
                     set_config($moduleversion, $module->version);
-                    notify(get_string("modulesuccess", "", $module->name), "green");
-                    echo "<hr />";
+                    notify(get_string('modulesuccess', '', $module->name), 'green');
+                    echo '<hr />';
                 } else {
                     $db->debug=false;
-                    notify("Upgrading $module->name from ".$CFG->$moduleversion." to $module->version FAILED!");
+                    notify('Upgrading '. $module->name .' from '. $CFG->$moduleversion .' to '. $module->version .' FAILED!');
                 }
             }
             $updated_modules = true;
         } else {
-            error("Version mismatch: $module->name can't downgrade ".$CFG->$moduleversion." -> $module->version !");
+            error('Version mismatch: '. $module->name .' can\'t downgrade '. $CFG->$moduleversion .' -> '. $module->version .' !');
         }
     }
 
@@ -84,36 +103,43 @@ function upgrade_enrol_plugins($return) {
     }
 }
 
+/**
+ * Find and check all modules and load them up or upgrade them if necessary
+ *
+ * @uses $db
+ * @uses $CFG
+ * @param string $return The url to prompt the user to continue to
+ * @todo Finish documenting this function
+ */ 
 function upgrade_activity_modules($return) {
-/// Find and check all modules and load them up or upgrade them if necessary
 
     global $CFG, $db;
 
-    if (!$mods = get_list_of_plugins("mod") ) {
-        error("No modules installed!");
+    if (!$mods = get_list_of_plugins('mod') ) {
+        error('No modules installed!');
     }
 
     foreach ($mods as $mod) {
 
-        if ($mod == "NEWMODULE") {   // Someone has unzipped the template, ignore it
+        if ($mod == 'NEWMODULE') {   // Someone has unzipped the template, ignore it
             continue;
         }
 
-        $fullmod = "$CFG->dirroot/mod/$mod";
+        $fullmod = $CFG->dirroot .'/mod/'. $mod;
 
         unset($module);
 
-        if ( is_readable("$fullmod/version.php")) {
-            include_once("$fullmod/version.php");  # defines $module with version etc
+        if ( is_readable($fullmod .'/version.php')) {
+            include_once($fullmod .'/version.php');  // defines $module with version etc
         } else {
-            notify("Module $mod: $fullmod/version.php was not readable");
+            notify('Module '. $mod .': '. $fullmod .'/version.php was not readable');
             continue;
         }
 
-        if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
-            include_once("$fullmod/db/$CFG->dbtype.php");  # defines upgrading function
+        if ( is_readable($fullmod .'/db/'. $CFG->dbtype .'.php')) {
+            include_once($fullmod .'/db/'. $CFG->dbtype .'.php');  // defines upgrading function
         } else {
-            notify("Module $mod: $fullmod/db/$CFG->dbtype.php was not readable");
+            notify('Module '. $mod .': '. $fullmod .'/db/'. $CFG->dbtype .'.php was not readable');
             continue;
         }
 
@@ -135,56 +161,56 @@ function upgrade_activity_modules($return) {
 
         $module->name = $mod;   // The name MUST match the directory
         
-        if ($currmodule = get_record("modules", "name", $module->name)) {
+        if ($currmodule = get_record('modules', 'name', $module->name)) {
             if ($currmodule->version == $module->version) {
                 // do nothing
             } else if ($currmodule->version < $module->version) {
                 if (empty($updated_modules)) {
-                    $strmodulesetup  = get_string("modulesetup");
-                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, "&nbsp;", "&nbsp;");
+                    $strmodulesetup  = get_string('modulesetup');
+                    print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', '', false, '&nbsp;', '&nbsp;');
                 }
-                print_heading("$module->name module needs upgrading");
-                $upgrade_function = $module->name."_upgrade";
+                print_heading($module->name .' module needs upgrading');
+                $upgrade_function = $module->name.'_upgrade';
                 if (function_exists($upgrade_function)) {
                     $db->debug=true;
                     if ($upgrade_function($currmodule->version, $module)) {
                         $db->debug=false;
                         // OK so far, now update the modules record
                         $module->id = $currmodule->id;
-                        if (! update_record("modules", $module)) {
-                            error("Could not update $module->name record in modules table!");
+                        if (! update_record('modules', $module)) {
+                            error('Could not update '. $module->name .' record in modules table!');
                         }
-                        notify(get_string("modulesuccess", "", $module->name), "green");
-                        echo "<hr />";
+                        notify(get_string('modulesuccess', '', $module->name), 'green');
+                        echo '<hr />';
                     } else {
                         $db->debug=false;
-                        notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!");
+                        notify('Upgrading '. $module->name .' from '. $currmodule->version .' to '. $module->version .' FAILED!');
                     }
                 }
                 $updated_modules = true;
             } else {
-                error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !");
+                error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
             }
     
         } else {    // module not installed yet, so install it
             if (empty($updated_modules)) {
-                $strmodulesetup    = get_string("modulesetup");
-                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, "&nbsp;", "&nbsp;");
+                $strmodulesetup    = get_string('modulesetup');
+                print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, '', '', false, '&nbsp;', '&nbsp;');
             }
             print_heading($module->name);
             $updated_modules = true;
             $db->debug = true;
             @set_time_limit(0);  // To allow slow databases to complete the long SQL
-            if (modify_database("$fullmod/db/$CFG->dbtype.sql")) {
+            if (modify_database($fullmod .'/db/'. $CFG->dbtype .'.sql')) {
                 $db->debug = false;
-                if ($module->id = insert_record("modules", $module)) {
-                    notify(get_string("modulesuccess", "", $module->name), "green");
-                    echo "<hr />";
+                if ($module->id = insert_record('modules', $module)) {
+                    notify(get_string('modulesuccess', '', $module->name), 'green');
+                    echo '<hr />';
                 } else {
-                    error("$module->name module could not be added to the module list!");
+                    error($module->name .' module could not be added to the module list!');
                 }
             } else { 
-                error("$module->name tables could NOT be set up successfully!");
+                error($module->name .' tables could NOT be set up successfully!');
             }
         }
     }
@@ -195,4 +221,4 @@ function upgrade_activity_modules($return) {
     }
 }
 
-?>
+?>
\ No newline at end of file