From fdb1cf2cc124483f57b4dd7a72415cb78226c0ce Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 18 Sep 2006 09:13:04 +0000 Subject: [PATCH] FIxed to use the new debugging function --- mod/assignment/restorelib.php | 2 +- mod/chat/restorelib.php | 2 +- mod/choice/restorelib.php | 2 +- mod/data/rate.php | 2 -- mod/data/rsslib.php | 10 ++----- mod/forum/rate.php | 1 - mod/forum/restorelib.php | 4 +-- mod/forum/rsslib.php | 33 +++++---------------- mod/glossary/restorelib.php | 4 +-- mod/glossary/rsslib.php | 32 +++++--------------- mod/hotpot/db/update_to_v2.php | 6 ++-- mod/label/restorelib.php | 2 +- mod/lesson/edit.php | 6 ++-- mod/lesson/restorelib.php | 2 +- mod/quiz/restorelib.php | 4 +-- mod/resource/restorelib.php | 2 +- mod/resource/type/ims/deploy.php | 12 ++++---- mod/resource/type/ims/repository_deploy.php | 12 ++++---- mod/survey/restorelib.php | 2 +- mod/wiki/restorelib.php | 4 +-- mod/workshop/restorelib.php | 2 +- 21 files changed, 50 insertions(+), 96 deletions(-) diff --git a/mod/assignment/restorelib.php b/mod/assignment/restorelib.php index a60f324926..21562219e9 100644 --- a/mod/assignment/restorelib.php +++ b/mod/assignment/restorelib.php @@ -338,7 +338,7 @@ //Update record $assignment->description = addslashes($result); $status = update_record("assignment",$assignment); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/chat/restorelib.php b/mod/chat/restorelib.php index 40669b0a87..6e95d28b8b 100644 --- a/mod/chat/restorelib.php +++ b/mod/chat/restorelib.php @@ -231,7 +231,7 @@ //Update record $chat->intro = addslashes($result); $status = update_record("chat",$chat); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index c9be13e200..92bd5fa5b7 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -363,7 +363,7 @@ function choice_options_restore_mods($choiceid,$info,$restore) { //Update record $choice->text = addslashes($result); $status = update_record("choice",$choice); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/data/rate.php b/mod/data/rate.php index 306e6431a0..618ef77c87 100755 --- a/mod/data/rate.php +++ b/mod/data/rate.php @@ -14,8 +14,6 @@ error("Guests are not allowed to rate posts.", $_SERVER["HTTP_REFERER"]); } - $CFG->debug = 0; /// Temporarily - $returntoview = false; if (($data = data_submitted($CFG->wwwroot.'/mod/data/view.php')) and confirm_sesskey()) { diff --git a/mod/data/rsslib.php b/mod/data/rsslib.php index 9a94dac74e..f8d2f174c4 100644 --- a/mod/data/rsslib.php +++ b/mod/data/rsslib.php @@ -13,17 +13,11 @@ // Check CFG->enablerssfeeds. if (empty($CFG->enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (admin variables)"; - } + debugging("DISABLED (admin variables)"); } // Check CFG->data_enablerssfeeds. else if (empty($CFG->data_enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (module configuration)"; - } + debugging("DISABLED (module configuration)"); } // It's working so we start... else { diff --git a/mod/forum/rate.php b/mod/forum/rate.php index 1fcf1058c1..96a93e4569 100644 --- a/mod/forum/rate.php +++ b/mod/forum/rate.php @@ -27,7 +27,6 @@ require_login($course->id); - $CFG->debug = 0; /// Temporarily $returntoview = false; if (!$data = data_submitted("$CFG->wwwroot/mod/forum/discuss.php")) { // form submitted diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index c37309c4a9..c43b7b9ef9 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -1134,7 +1134,7 @@ //Update record $post->message = addslashes($result); $status = update_record("forum_posts",$post); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } @@ -1168,7 +1168,7 @@ //Update record $forum->intro = addslashes($result); $status = update_record("forum",$forum); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/forum/rsslib.php b/mod/forum/rsslib.php index a4021cb914..01dd46f443 100644 --- a/mod/forum/rsslib.php +++ b/mod/forum/rsslib.php @@ -12,16 +12,10 @@ //Check CFG->enablerssfeeds if (empty($CFG->enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (admin variables)"; - } + debugging('DISABLED (admin variables)'); //Check CFG->forum_enablerssfeeds } else if (empty($CFG->forum_enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (module configuration)"; - } + debugging('DISABLED (module configuration)'); //It's working so we start... } else { //Iterate over all forums @@ -50,25 +44,20 @@ mtrace("Updating RSS feed for ".format_string($forum->name,true).", ID: $forum->id"); - //Some debug... - if ($CFG->debug > 7) { - echo "ID: $forum->id->"; - } //Get the XML contents $result = forum_rss_feed($forum); //Save the XML contents to file if (!empty($result)) { $status = rss_save_file("forum",$forum,$result); } - //Some debug... - if ($CFG->debug > 7) { + if (debugging()) { if (empty($result)) { - echo "(empty) "; + echo "ID: $forum->id-> (empty) "; } else { if (!empty($status)) { - echo "OK "; + echo "ID: $forum->id-> OK "; } else { - echo "FAIL "; + echo "ID: $forum->id-> FAIL "; } } } @@ -100,16 +89,10 @@ //Check CFG->enablerssfeeds if (empty($CFG->enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (admin variables)"; - } + debugging("DISABLED (admin variables)"); //Check CFG->forum_enablerssfeeds } else if (empty($CFG->forum_enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (module configuration)"; - } + debugging("DISABLED (module configuration)"); //It's working so we start... } else { //Check the forum has rss activated diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index d234e5c57a..d6ccd0ab49 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -632,7 +632,7 @@ //Update record $entry->definition = addslashes($result); $status = update_record("glossary_entries",$entry); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } @@ -666,7 +666,7 @@ //Update record $glossary->intro = addslashes($result); $status = update_record("glossary",$glossary); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/glossary/rsslib.php b/mod/glossary/rsslib.php index bbef639556..4143db6e59 100644 --- a/mod/glossary/rsslib.php +++ b/mod/glossary/rsslib.php @@ -12,16 +12,10 @@ //Check CFG->enablerssfeeds if (empty($CFG->enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (admin variables)"; - } + debugging("DISABLED (admin variables)"); //Check CFG->glossary_enablerssfeeds } else if (empty($CFG->glossary_enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (module configuration)"; - } + debugging("DISABLED (module configuration)"); //It's working so we start... } else { //Iterate over all glossaries @@ -50,10 +44,6 @@ mtrace("Updating RSS feed for ".format_string($glossary->name,true).", ID: $glossary->id"); - //Some debug... - if ($CFG->debug > 7) { - echo "ID: $glossary->id->"; - } //Get the XML contents $result = glossary_rss_feed($glossary); //Save the XML contents to file @@ -61,14 +51,14 @@ $status = rss_save_file("glossary",$glossary,$result); } //Some debug... - if ($CFG->debug > 7) { + if (debugging()) { if (empty($result)) { - echo "(empty) "; + echo "ID: $glossary->id-> (empty) "; } else { if (!empty($status)) { - echo "OK "; + echo "ID: $glossary->id-> OK "; } else { - echo "FAIL "; + echo "ID: $glossary->id-> FAIL "; } } } @@ -100,16 +90,10 @@ //Check CFG->enablerssfeeds if (empty($CFG->enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (admin variables)"; - } + debugging("DISABLED (admin variables)"); //Check CFG->glossary_enablerssfeeds } else if (empty($CFG->glossary_enablerssfeeds)) { - //Some debug... - if ($CFG->debug > 7) { - echo "DISABLED (module configuration)"; - } + debugging("DISABLED (module configuration)"); //It's working so we start... } else { //Check the glossary has rss activated diff --git a/mod/hotpot/db/update_to_v2.php b/mod/hotpot/db/update_to_v2.php index 5ef0ca3240..ad9a283df4 100644 --- a/mod/hotpot/db/update_to_v2.php +++ b/mod/hotpot/db/update_to_v2.php @@ -1076,7 +1076,7 @@ function hotpot_db_object_exists($table, $field='', $feedback=false) { // restore SQL message echo setting $db->debug = $debug; // report error if required - if (empty($rs) && isset($CFG->debug) and $CFG->debug > 7) { + if (empty($rs) && debugging()) { notify($db->ErrorMsg()."

$sql"); } return ($rs && $rs->RecordCount()>0); @@ -1336,9 +1336,7 @@ function hotpot_db_update_record($table, $record, $forcenull=false) { $rs = $db->Execute($sql); if (empty($rs)) { $ok = false; - if (isset($CFG->debug) and $CFG->debug > 7) { - notify($db->ErrorMsg()."

$sql"); - } + debugging($db->ErrorMsg()."

$sql"); } } } diff --git a/mod/label/restorelib.php b/mod/label/restorelib.php index 9b3aa6f6a4..ab6259955e 100644 --- a/mod/label/restorelib.php +++ b/mod/label/restorelib.php @@ -81,7 +81,7 @@ //Update record $label->content = addslashes($result); $status = update_record("label", $label); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php index e704f48ed3..eabad28a90 100644 --- a/mod/lesson/edit.php +++ b/mod/lesson/edit.php @@ -272,9 +272,7 @@ if ($page->prevpageid != $prevpageid) { // fix it set_field("lesson_pages", "prevpageid", $prevpageid, "id", $page->id); - if ($CFG->debug) { - echo "

***prevpageid of page $page->id set to $prevpageid***"; - } + debugging("

***prevpageid of page $page->id set to $prevpageid***"); } if (count($pages) == 1) { @@ -290,4 +288,4 @@ } print_footer($course); -?> \ No newline at end of file +?> diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index c96b5308e9..0b418f8431 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -801,7 +801,7 @@ //Update record $page->contents = addslashes($result); $status = update_record("lesson_pages",$page); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '


'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index fb44a86661..9a133b9386 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -556,7 +556,7 @@ //Update record $quiz->intro = addslashes($result); $status = update_record("quiz",$quiz); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } @@ -845,4 +845,4 @@ return implode(',', $questionids); } -?> \ No newline at end of file +?> diff --git a/mod/resource/restorelib.php b/mod/resource/restorelib.php index 2d5cd21d8f..115a449ed5 100644 --- a/mod/resource/restorelib.php +++ b/mod/resource/restorelib.php @@ -200,7 +200,7 @@ $resource->summary = addslashes($result2); $resource->reference = addslashes($result3); $status = update_record("resource",$resource); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content1).'
changed to
'.s($result1).'

'; echo '

'.s($content2).'
changed to
'.s($result2).'

'; diff --git a/mod/resource/type/ims/deploy.php b/mod/resource/type/ims/deploy.php index f394786509..9371bcaa25 100644 --- a/mod/resource/type/ims/deploy.php +++ b/mod/resource/type/ims/deploy.php @@ -277,14 +277,14 @@ /// Get the default organization $default_organization = $data['@']['default']; - if ($CFG->debug > 7) print_object('default_organization: '.$default_organization); + debugging('default_organization: '.$default_organization); /// Iterate (reverse) over organizations until we find the default one if (empty($data['#']['organization'])) { /// Verify exists return false; } $count_organizations = count($data['#']['organization']); - if ($CFG->debug > 7) print_object('count_organizations: '.$count_organizations); + debugging('count_organizations: '.$count_organizations); $current_organization = $count_organizations - 1; while ($current_organization >= 0) { @@ -297,7 +297,7 @@ } /// At this point we MUST have the final organization - if ($CFG->debug > 7) print_object('final organization: '.$organization['#']['title'][0]['#']); + debugging('final organization: '.$organization['#']['title'][0]['#']); if (empty($organization)) { return false; //Error, no organization found } @@ -323,7 +323,7 @@ /// Iterate over items from start to end $count_items = count($items); - if ($CFG->debug > 7) print_object('level '.$level.'-count_items: '.$count_items); + debugging('level '.$level.'-count_items: '.$count_items); $current_item = 0; while ($current_item < $count_items) { @@ -341,7 +341,7 @@ !empty($obj_item->identifier)) { /// Add to itemmap $itemmap[$id] = $obj_item; - if ($CFG->debug > 7) print_object('level '.$level.'-id '.$id.'-parent '.$parent.'-'.$obj_item->title); + debugging('level '.$level.'-id '.$id.'-parent '.$parent.'-'.$obj_item->title); /// Counters go up $id++; /// Check for subitems recursively @@ -377,7 +377,7 @@ return false; } $count_resources = count($data); - if ($CFG->debug > 7) print_object('count_resources: '.$count_resources); + debugging('count_resources: '.$count_resources); $current_resource = 0; while ($current_resource < $count_resources) { diff --git a/mod/resource/type/ims/repository_deploy.php b/mod/resource/type/ims/repository_deploy.php index 56a9d7db96..0e5599c41b 100644 --- a/mod/resource/type/ims/repository_deploy.php +++ b/mod/resource/type/ims/repository_deploy.php @@ -265,14 +265,14 @@ /// Get the default organization $default_organization = $data['@']['default']; - if ($CFG->debug > 7) print_object('default_organization: '.$default_organization); + debugging('default_organization: '.$default_organization); /// Iterate (reverse) over organizations until we find the default one if (empty($data['#']['organization'])) { /// Verify exists return false; } $count_organizations = count($data['#']['organization']); - if ($CFG->debug > 7) print_object('count_organizations: '.$count_organizations); + debugging('count_organizations: '.$count_organizations); $current_organization = $count_organizations - 1; while ($current_organization >= 0) { @@ -285,7 +285,7 @@ } /// At this point we MUST have the final organization - if ($CFG->debug > 7) print_object('final organization: '.$organization['#']['title'][0]['#']); + debugging('final organization: '.$organization['#']['title'][0]['#']); if (empty($organization)) { return false; //Error, no organization found } @@ -311,7 +311,7 @@ /// Iterate over items from start to end $count_items = count($items); - if ($CFG->debug > 7) print_object('level '.$level.'-count_items: '.$count_items); + debugging('level '.$level.'-count_items: '.$count_items); $current_item = 0; while ($current_item < $count_items) { @@ -329,7 +329,7 @@ !empty($obj_item->identifier)) { /// Add to itemmap $itemmap[$id] = $obj_item; - if ($CFG->debug > 7) print_object('level '.$level.'-id '.$id.'-parent '.$parent.'-'.$obj_item->title); + debugging('level '.$level.'-id '.$id.'-parent '.$parent.'-'.$obj_item->title); /// Counters go up $id++; /// Check for subitems recursively @@ -365,7 +365,7 @@ return false; } $count_resources = count($data); - if ($CFG->debug > 7) print_object('count_resources: '.$count_resources); + debugging('count_resources: '.$count_resources); $current_resource = 0; while ($current_resource < $count_resources) { diff --git a/mod/survey/restorelib.php b/mod/survey/restorelib.php index 53c658518b..90525d53d7 100644 --- a/mod/survey/restorelib.php +++ b/mod/survey/restorelib.php @@ -286,7 +286,7 @@ //Update record $survey->intro = addslashes($result); $status = update_record("survey",$survey); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/wiki/restorelib.php b/mod/wiki/restorelib.php index 3e9c753d73..71224176a1 100644 --- a/mod/wiki/restorelib.php +++ b/mod/wiki/restorelib.php @@ -376,7 +376,7 @@ //Update record $page->content = addslashes($result); $status = update_record("wiki_pages",$page); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } @@ -410,7 +410,7 @@ //Update record $wiki->summary = addslashes($result); $status = update_record("wiki",$wiki); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } diff --git a/mod/workshop/restorelib.php b/mod/workshop/restorelib.php index 1258529fb8..f8670e392e 100644 --- a/mod/workshop/restorelib.php +++ b/mod/workshop/restorelib.php @@ -790,7 +790,7 @@ //Update record $workshop->description = addslashes($result); $status = update_record("workshop",$workshop); - if ($CFG->debug>7) { + if (debugging()) { if (!defined('RESTORE_SILENTLY')) { echo '

'.s($content).'
changed to
'.s($result).'

'; } -- 2.39.5