global $USER, $CFG;
if (isset($capabilities[$context->id][$capability])) {
- if ($CFG->debug > 15) {
- notify("Found $capability in context $context->id at level $context->aggregatelevel: ".$capabilities[$context->id][$capability], 'notifytiny');
- }
+ debugging("Found $capability in context $context->id at level $context->aggregatelevel: ".$capabilities[$context->id][$capability], E_ALL);
return ($capabilities[$context->id][$capability]);
}
error ('This is an unknown context!');
return false;
}
- if ($CFG->debug > 15) {
- notify("Found $capability recursively from context $context->id at level $context->aggregatelevel: $permission", 'notifytiny');
- }
+ debugging("Found $capability recursively from context $context->id at level $context->aggregatelevel: $permission", E_ALL);
return $permission;
}
/// If no level is supplied then return the current global context if there is one
if (empty($aggregatelevel)) {
if (empty($CONTEXT)) {
- if ($CFG->debug > 7) {
- notify("Error: get_context_instance() called without a context");
- }
+ debugging("Error: get_context_instance() called without a context");
} else {
return $CONTEXT;
}
function role_assign($roleid, $userid, $groupid, $contextid, $timestart=0, $timeend=0, $hidden=0, $enrol='manual') {
global $USER, $CFG;
- if ($CFG->debug > 7) {
- notify("Assign roleid $roleid userid $userid contextid $contextid", 'notifytiny');
- }
+ debugging("Assign roleid $roleid userid $userid contextid $contextid", E_ALL);
/// Do some data validation
$result = $db->Execute('INSERT INTO '. $CFG->prefix .'log (time, userid, course, ip, module, cmid, action, url, info)
VALUES (' . "'$timenow', '$userid', '$courseid', '$REMOTE_ADDR', '$module', '$cm', '$action', '$url', '$info')");
- if (!$result and ($CFG->debug > 7)) {
+ if (!$result and debugging()) {
echo '<p>Error: Could not insert a new entry to the Moodle log</p>'; // Don't throw an error
}
} else if ($expectmultiple) {
$limitfrom = 0;
$limitnum = 1;
- } else if (isset($CFG->debug) && $CFG->debug > 7) {
+ } 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
// impossible to know what's wrong.
$rs = $db->Execute($sql);
}
if (!$rs) {
- if (isset($CFG->debug) and $CFG->debug > 7) {
- notify($db->ErrorMsg() .'<br /><br />'. $sql);
- }
+ debugging($db->ErrorMsg() .'<br /><br />'. $sql);
if (!empty($CFG->dblogerror)) {
$debug=array_shift(debug_backtrace());
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql with limits ($limitfrom, $limitnum)");
$rs = $db->Execute($sql);
if (!$rs) {
- if (isset($CFG->debug) and $CFG->debug > 7) {
- notify($db->ErrorMsg() .'<br /><br />'. $sql);
- }
+ debugging($db->ErrorMsg() .'<br /><br />'. $sql);
if (!empty($CFG->dblogerror)) {
$debug=array_shift(debug_backtrace());
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $sql");
/// Run the SQL statement
if (!$rs = $db->Execute($insertSQL)) {
- if (isset($CFG->debug) and $CFG->debug > 7) {
- notify($db->ErrorMsg() .'<br /><br />'.$insertSQL);
- }
+ debugging($db->ErrorMsg() .'<br /><br />'.$insertSQL);
if (!empty($CFG->dblogerror)) {
$debug=array_shift(debug_backtrace());
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: $insertSQL");
if ($rs = $db->Execute('UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'')) {
return true;
} else {
- if (isset($CFG->debug) and $CFG->debug > 7) {
- notify($db->ErrorMsg() .'<br /><br />UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'');
- }
+ debugging($db->ErrorMsg() .'<br /><br />UPDATE '. $CFG->prefix . $table .' SET '. $update .' WHERE id = \''. $dataobject->id .'\'');
if (!empty($CFG->dblogerror)) {
$debug=array_shift(debug_backtrace());
error_log("SQL ".$db->ErrorMsg()." in {$debug['file']} on line {$debug['line']}. STATEMENT: UPDATE $CFG->prefix$table SET $update WHERE id = '$dataobject->id'");
} else {
$mail->IsSMTP(); // use SMTP directly
- if ($CFG->debug > 7) {
+ if (debugging()) {
echo '<pre>' . "\n";
$mail->SMTPDebug = true;
}
global $CFG;
+ if (empty($CFG->debug)) {
+ return false;
+ }
+
if ($CFG->debug >= $level) {
if ($message) {
- notify($message);
+ notify($message, 'notifytiny');
}
return true;
}
if ($object->get_type() !== $type) {
// Somehow somewhere someone made a mistake
- if ($CFG->debug > 7) {
- error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
- }
+ debugging('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')');
}
$object->init_quick($data);
}
if (!isset($mappings[$type])) {
- if ($CFG->debug > 7) {
- error('Page class mapping requested for unknown type: '.$type);
- }
+ debugging('Page class mapping requested for unknown type: '.$type);
}
if (empty($classname) && !class_exists($mappings[$type])) {
- if ($CFG->debug > 7) {
- error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
- }
+ debugging('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined');
}
return $mappings[$type];
define('MAGPIE_CACHE_ON', true); //might want to expose as an admin config option, but perhaps this is something that should truly just be on unless the code is tweaked
define('MAGPIE_CACHE_FRESH_ONLY', false); //should be exposed as an admin config option
define('MAGPIE_CACHE_AGE', $CFG->block_rss_timeout);
-if ($CFG->debug) {
- define('MAGPIE_DEBUG', $CFG->debug); // magpie, like moodle, takes an integer debug
-} else {
- define('MAGPIE_DEBUG', 0); // 0 is DEBUG off for magpie
-}
+define('MAGPIE_DEBUG', $CFG->debug); // magpie, like moodle, takes an integer debug
// defines for config var block_rss_client_submitters
define('SUBMITTERS_ALL_ACCOUNT_HOLDERS', 0);
/// Set error reporting back to normal
if ($originaldatabasedebug == -1) {
- $CFG->debug = 5;
+ $CFG->debug = E_PARSE;
} else {
$CFG->debug = $originaldatabasedebug;
}
if (match_referer($url)) {
return (object)$_POST;
} else {
- if ($CFG->debug > 10) {
- notice('The form did not come from this page! (referer = '. get_referer() .')');
- }
+ debugging('The form did not come from this page! (referer = '. get_referer() .')');
return false;
}
}
/// This makes sure that the header is never repeated twice on a page
if (defined('HEADER_PRINTED')) {
- if ($CFG->debug > 7) {
- notify('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
- }
+ debugging('print_header() was called more than once - this should not happen. Please check the code for this page closely. Note: error() and redirect() are now safe to call after print_header().');
return;
}
define('HEADER_PRINTED', 'true');
if (defined('MDL_PERFTOLOG')) {
error_log("PERF: " . $perf['txt']);
}
- if (defined('MDL_PERFTOFOOT') || $CFG->debug > 7 || $CFG->perfdebug > 7) {
+ if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $perf['html'];
}
}