### Eclipse Workspace Patch 1.0
#P moodle
Index: lang/en_utf8/admin.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/admin.php,v
retrieving revision 1.43
diff -u -r1.43 admin.php
--- lang/en_utf8/admin.php	21 Sep 2006 09:16:56 -0000	1.43
+++ lang/en_utf8/admin.php	23 Sep 2006 08:44:07 -0000
@@ -144,7 +144,7 @@
 $string['sessioncookie'] = 'Cookie prefix';
 $string['sessioncookiepath'] = 'Cookie path';
 $string['enablerssfeeds'] = 'Enable RSS feeds';
-$string['debug'] = 'Debug notices';
+$string['debug'] = 'Debug messages';
 $string['perfdebug'] = 'Performance info';
 $string['enablestats'] = 'Enable statistics';
 $string['statsfirstrun'] = 'Maximum processing interval';
@@ -304,13 +304,11 @@
 $string['dbmigrateconnecerror'] = 'Could not connect to the database specified.';
 $string['dbmigrateencodingerror'] = 'The database specified has encoding $a rather than required UNICODE/UTF8.<br />Please specify another.';
 $string['dbmigratepostgres'] = 'It seems that you are using PostgreSQL as the database server. To continue the migration process you need to manually create a new database with encoding \"UNICODE\"(PostgreSQL 7) or \"UTF8\" (PostgreSQL 8) to store the migrated data. Please enter your new database connection settings below to continue:';
-$string['debugnone'] = 'Do not show any debugging notices';
-$string['debugerror'] = 'E_ERROR: Show only fatal errors';
-$string['debugwarning'] = 'E_WARNING: show only serious warnings';
-$string['debugparse'] = 'E_PARSE: show parsing errors';
-$string['debugnotice'] = 'E_NOTICE: show informational notices';
-$string['debugall'] = 'E_ALL: show all reasonable feedback';
-$string['debugstrict'] = 'E_STRICT: show absolutely everything, even very minor errors';
+$string['debugnone'] = 'NONE: Do not show any errors or warnings';
+$string['debugminimal'] = 'MINIMAL: Show only fatal errors';
+$string['debugnormal'] = 'NORMAL: Show errors, warnings and notices';
+$string['debugall'] = 'ALL: Show all reasonable PHP debug messages';
+$string['debugdeveloper'] = 'DEVELOPER: extra Moodle debug messages for developers';
 $string['density'] = 'Density';
 $string['download'] = 'Download';
 $string['edithelpdocs'] = 'Edit help documents';
Index: lib/moodlelib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v
retrieving revision 1.762
diff -u -r1.762 moodlelib.php
--- lib/moodlelib.php	23 Sep 2006 06:10:48 -0000	1.762
+++ lib/moodlelib.php	23 Sep 2006 08:44:20 -0000
@@ -213,6 +213,17 @@
  */
 define('PAGE_COURSE_VIEW', 'course-view');
 
+/// Debug levels ///
+/** no warnings at all */
+define ('DEBUG_NONE', 0);
+/** E_ERROR | E_PARSE */
+define ('DEBUG_MINIMAL', 5);
+/** E_ERROR | E_PARSE | E_WARNING | E_NOTICE */
+define ('DEBUG_NORMAL', 15);
+/** E_ALL without E_STRICT and E_RECOVERABLE_ERROR for now */
+define ('DEBUG_ALL', 2047);
+/** DEBUG_ALL with extra Moodle debug messages - (DEBUG_ALL | 32768) */
+define ('DEBUG_DEVELOPER', 34815);
 
 /// PARAMETER HANDLING ////////////////////////////////////////////////////
 
@@ -6698,4 +6709,4 @@
 
 
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
-?>
+?>
\ No newline at end of file
Index: lib/weblib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v
retrieving revision 1.653
diff -u -r1.653 weblib.php
--- lib/weblib.php	22 Sep 2006 18:08:53 -0000	1.653
+++ lib/weblib.php	23 Sep 2006 08:44:28 -0000
@@ -5341,19 +5341,19 @@
 }
 
 /**
- * Returns true if the current site debugging settings are equal 
- * to the specified level: E_NOTICE, E_ALL, E_STRICT etc
+ * Returns true if the current site debugging settings are equal or above specified level.
  * eg use like this:
  *
- * 1)  debugging('a normal notice');
- * 2)  debugging('something really picky', E_STRICT);
- * 3)  if (debugging()) { echo "a bunch of commands could be here" } 
+ * 1)  debugging('a normal debug notice');
+ * 2)  debugging('something really picky', DEBUG_ALL);
+ * 3)  debugging('annoying debug message only for develpers', DEBUG_DEVELOPER);
+ * 4)  if (debugging()) { echo "a bunch of commands could be here" } 
  *
  * @param string $message a message to print
  * @param int $level the level at which this debugging statement should show
  * @return bool
  */
-function debugging($message='', $level=E_NOTICE) {
+function debugging($message='', $level=DEBUG_NORMAL) {
 
     global $CFG;
 
@@ -5370,5 +5370,13 @@
     return false;
 }
 
+/**
+ * Disable debug messages from debugging(), while keeping PHP error reporting level as is.
+ */
+function disable_debugging() {
+    global $CFG;
+    $CFG->debug = $CFG->debug | 0x80000000; // switch the sign bit in integer number ;-)
+}
+
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
 ?>
Index: lib/accesslib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/accesslib.php,v
retrieving revision 1.127
diff -u -r1.127 accesslib.php
--- lib/accesslib.php	23 Sep 2006 06:10:48 -0000	1.127
+++ lib/accesslib.php	23 Sep 2006 08:44:10 -0000
@@ -419,7 +419,7 @@
     global $USER, $CFG;
 
     if (isset($capabilities[$context->id][$capability])) {
-        debugging("Found $capability in context $context->id at level $context->contextlevel: ".$capabilities[$context->id][$capability], E_ALL);
+        debugging("Found $capability in context $context->id at level $context->contextlevel: ".$capabilities[$context->id][$capability], DEBUG_DEVELOPER);
         return ($capabilities[$context->id][$capability]);
     }
 
@@ -481,7 +481,7 @@
             error ('This is an unknown context!');
         return false;
     }
-    debugging("Found $capability recursively from context $context->id at level $context->contextlevel: $permission", E_ALL);
+    debugging("Found $capability recursively from context $context->id at level $context->contextlevel: $permission", DEBUG_DEVELOPER);
 
     return $permission;
 }
@@ -1361,7 +1361,7 @@
 function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $timeend=0, $hidden=0, $enrol='manual') {
     global $USER, $CFG;
 
-    debugging("Assign roleid $roleid userid $userid contextid $contextid", E_ALL);
+    debugging("Assign roleid $roleid userid $userid contextid $contextid", DEBUG_DEVELOPER);
 
 /// Do some data validation
 
@@ -2765,4 +2765,4 @@
                                   AND roleid = $role->id");
 }
 
-?>
+?>
\ No newline at end of file
Index: lib/adminlib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/adminlib.php,v
retrieving revision 1.54
diff -u -r1.54 adminlib.php
--- lib/adminlib.php	21 Sep 2006 22:34:45 -0000	1.54
+++ lib/adminlib.php	23 Sep 2006 08:44:13 -0000
@@ -2137,13 +2137,11 @@
         $name = 'debug';
         $visiblename = get_string('debug', 'admin');
         $description = get_string('configdebug', 'admin');
-        $choices = array( 0         => get_string('debugnone', 'admin'),
-                          E_ERROR   => get_string('debugerror', 'admin'),
-                          E_WARNING => get_string('debugwarning', 'admin'),
-                          E_PARSE   => get_string('debugparse', 'admin'),
-                          E_NOTICE  => get_string('debugnotice', 'admin'),
-                          E_ALL     => get_string('debugall', 'admin'),
-                          2048      => get_string('debugstrict', 'admin')   //  E_STRICT is php5 only
+        $choices = array( DEBUG_NONE      => get_string('debugnone', 'admin'),
+                          DEBUG_MINIMAL   => get_string('debugminimal', 'admin'),
+                          DEBUG_NORMAL    => get_string('debugnormal', 'admin'),
+                          DEBUG_ALL       => get_string('debugall', 'admin'), 
+                          DEBUG_DEVELOPER => get_string('debugdeveloper', 'admin') 
                         );
         parent::admin_setting_configselect($name, $visiblename, $description, '', $choices);
     }
@@ -2151,12 +2149,6 @@
     function get_setting() {
         global $CFG;
         if (isset($CFG->debug)) {
-            if ($CFG->debug == 7) {   // Old values
-                return 1;
-            }
-            if ($CFG->debug == 15) {  // Old values
-                return 16;
-            }
             return $CFG->debug;
         } else {
             return NULL;
Index: lib/setup.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/setup.php,v
retrieving revision 1.177
diff -u -r1.177 setup.php
--- lib/setup.php	20 Sep 2006 22:03:45 -0000	1.177
+++ lib/setup.php	23 Sep 2006 08:44:22 -0000
@@ -255,7 +255,7 @@
 
 /// Set error reporting back to normal
     if ($originaldatabasedebug == -1) {
-        $CFG->debug = E_PARSE;
+        $CFG->debug = DEBUG_MINIMAL;
     } else {
         $CFG->debug = $originaldatabasedebug;
     }
Index: mod/glossary/exportfile.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/glossary/exportfile.php,v
retrieving revision 1.6
diff -u -r1.6 exportfile.php
--- mod/glossary/exportfile.php	14 Aug 2006 05:55:44 -0000	1.6
+++ mod/glossary/exportfile.php	23 Sep 2006 08:44:28 -0000
@@ -3,6 +3,9 @@
     require_once("../../config.php");
     require_once("lib.php");
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $id = required_param('id', PARAM_INT);      // Course Module ID
 
     $l   = optional_param('l','', PARAM_ALPHANUM);
Index: rss/file.php
===================================================================
RCS file: /cvsroot/moodle/moodle/rss/file.php,v
retrieving revision 1.17
diff -u -r1.17 file.php
--- rss/file.php	6 Sep 2006 08:55:24 -0000	1.17
+++ rss/file.php	23 Sep 2006 08:44:28 -0000
@@ -21,6 +21,9 @@
 
     $lifetime = 3600;  // Seconds for files to remain in caches - 1 hour
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('file.php');
 
 
Index: user/pixgroup.php
===================================================================
RCS file: /cvsroot/moodle/moodle/user/pixgroup.php,v
retrieving revision 1.6
diff -u -r1.6 pixgroup.php
--- user/pixgroup.php	7 Mar 2005 12:10:22 -0000	1.6
+++ user/pixgroup.php	23 Sep 2006 08:44:28 -0000
@@ -8,6 +8,9 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('pixgroup.php');
 
     $args = explode('/', trim($relativepath, '/'));
Index: user/pix.php
===================================================================
RCS file: /cvsroot/moodle/moodle/user/pix.php,v
retrieving revision 1.14
diff -u -r1.14 pix.php
--- user/pix.php	7 Mar 2005 12:10:21 -0000	1.14
+++ user/pix.php	23 Sep 2006 08:44:28 -0000
@@ -8,6 +8,9 @@
     require_once('../config.php');
     require_once($CFG->libdir.'/filelib.php');
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('pix.php');
 
     $args = explode('/', trim($relativepath, '/'));
Index: file.php
===================================================================
RCS file: /cvsroot/moodle/moodle/file.php,v
retrieving revision 1.39
diff -u -r1.39 file.php
--- file.php	21 Sep 2006 06:38:27 -0000	1.39
+++ file.php	23 Sep 2006 08:44:04 -0000
@@ -15,10 +15,8 @@
         $lifetime = $CFG->filelifetime;
     }
 
-    // remove moodle specific debug messages by switching the sign bit in error level bitmask
-    if ($CFG->debug > 0) {
-        $CFG->debug = $CFG->debug | 0x80000000;
-    }
+    // disable moodle specific debug messages
+    disable_debugging();
 
     $relativepath = get_file_argument('file.php');
     $forcedownload = optional_param('forcedownload', 0, PARAM_BOOL);
Index: admin/index.php
===================================================================
RCS file: /cvsroot/moodle/moodle/admin/index.php,v
retrieving revision 1.236
diff -u -r1.236 index.php
--- admin/index.php	22 Sep 2006 11:09:15 -0000	1.236
+++ admin/index.php	23 Sep 2006 08:44:04 -0000
@@ -105,7 +105,7 @@
     if (! $maintables) {
     /// hide errors from headers in case debug enabled in config.php
         $origdebug = $CFG->debug;
-        $CFG->debug = 5;
+        $CFG->debug = DEBUG_MINIMAL;
         error_reporting($CFG->debug);
         if (empty($agreelicence)) {
             $strlicense = get_string("license");
@@ -208,7 +208,7 @@
 
             // hide errors from headers in case debug is enabled
             $origdebug = $CFG->debug;
-            $CFG->debug = 5;
+            $CFG->debug = DEBUG_MINIMAL;
             error_reporting($CFG->debug);
 
             // logout in case we are upgrading from pre 1.7 version - prevention of weird session problems
Index: filter/algebra/pix.php
===================================================================
RCS file: /cvsroot/moodle/moodle/filter/algebra/pix.php,v
retrieving revision 1.16
diff -u -r1.16 pix.php
--- filter/algebra/pix.php	18 Sep 2006 13:26:58 -0000	1.16
+++ filter/algebra/pix.php	23 Sep 2006 08:44:04 -0000
@@ -16,6 +16,9 @@
         }
     }
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     require_once($CFG->libdir.'/filelib.php');
 
     $CFG->texfilterdir     = 'filter/tex';
Index: enrol/ldap/enrol_ldap_sync.php
===================================================================
RCS file: /cvsroot/moodle/moodle/enrol/ldap/enrol_ldap_sync.php,v
retrieving revision 1.3
diff -u -r1.3 enrol_ldap_sync.php
--- enrol/ldap/enrol_ldap_sync.php	18 Sep 2006 13:24:47 -0000	1.3
+++ enrol/ldap/enrol_ldap_sync.php	23 Sep 2006 08:44:04 -0000
@@ -14,7 +14,7 @@
     require_once($CFG->dirroot . "/enrol/ldap/enrol.php");
 
     // ensure errors are well explained
-    $CFG->debug = E_NOTICE;
+    $CFG->debug = DEBUG_NORMAL;
 
     // update enrolments -- these handlers should autocreate courses if required
     $enrol = new enrolment_plugin_ldap();
Index: filter/tex/pix.php
===================================================================
RCS file: /cvsroot/moodle/moodle/filter/tex/pix.php,v
retrieving revision 1.25
diff -u -r1.25 pix.php
--- filter/tex/pix.php	18 Sep 2006 13:26:58 -0000	1.25
+++ filter/tex/pix.php	23 Sep 2006 08:44:04 -0000
@@ -16,6 +16,9 @@
         }
     }
 
+    // disable moodle specific debug messages
+    disable_debugging();
+
     require_once($CFG->libdir.'/filelib.php');
     require_once('defaultsettings.php' );
     require_once('latex.php');
Index: mod/quiz/quizfile.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/quizfile.php,v
retrieving revision 1.15
diff -u -r1.15 quizfile.php
--- mod/quiz/quizfile.php	31 Aug 2006 08:51:09 -0000	1.15
+++ mod/quiz/quizfile.php	23 Sep 2006 08:44:28 -0000
@@ -13,7 +13,10 @@
     } else {
         $lifetime = $CFG->filelifetime;
     }
-    
+
+    // disable moodle specific debug messages
+    disable_debugging();
+
     $relativepath = get_file_argument('quizfile.php');
     
     if (!$relativepath) {
