| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?PHP //$Id: upgradelogs.php,v 1.10 2007/04/30 17:08:41 skodak Exp $ 2 3 require_once ('../config.php'); 4 require_once($CFG->libdir.'/adminlib.php'); 5 6 admin_externalpage_setup('upgradelogs'); 7 8 $confirm = optional_param('confirm', 0, PARAM_BOOL); 9 10 if ($CFG->version < 2004013101) { 11 error("This script does not work with this old version of Moodle"); 12 } 13 14 if (!$site = get_site()) { 15 redirect("index.php"); 16 } 17 18 /// Turn off time limits, sometimes upgrades can be slow. 19 20 @set_time_limit(0); 21 @ob_implicit_flush(true); 22 while(@ob_end_flush()); 23 24 25 /// Print header 26 27 $strupgradinglogs = get_string("upgradinglogs", "admin"); 28 admin_externalpage_print_header(); 29 print_heading($strupgradinglogs); 30 31 if (!data_submitted() or empty($confirm) or !confirm_sesskey()) { 32 $optionsyes = array('confirm'=>'1', 'sesskey'=>sesskey()); 33 notice_yesno(get_string('upgradeforumreadinfo', 'admin'), 34 'upgradelogs.php', 'index.php', $optionsyes, NULL, 'post', 'get'); 35 admin_externalpage_print_footer(); 36 exit; 37 } 38 39 40 /// Try and extract as many cmids as possible from the existing logs 41 42 if ($coursemodules = get_records_sql("SELECT cm.*, m.name 43 FROM {$CFG->prefix}course_modules cm, 44 {$CFG->prefix}modules m 45 WHERE cm.module = m.id")) { 46 $cmcount = count($coursemodules); 47 $count = 0; 48 $starttime = time(); 49 $sleeptime = 0; 50 51 $LIKE = sql_ilike(); 52 53 if ($cmcount > 10) { 54 print_simple_box('This process may take a very long time ... please be patient and let it finish.', 55 'center', '', '#ffcccc'); 56 $sleeptime = 1; 57 } 58 foreach ($coursemodules as $cm) { 59 60 switch ($cm->name) { 61 case "forum": 62 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 63 WHERE module = '$cm->name' AND url = 'view.php?id=$cm->id'", false); 64 65 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 66 WHERE module = '$cm->name' AND url = 'view.php?f=$cm->instance'", false); 67 68 if ($discussions = get_records("forum_discussions", "forum", $cm->instance)) { 69 foreach ($discussions as $discussion) { 70 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 71 WHERE module = '$cm->name' AND url $LIKE 'discuss.php?d=$discussion->id%'", false); 72 } 73 } 74 break; 75 76 case "glossary": 77 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 78 WHERE module = '$cm->name' AND url $LIKE 'view.php?id=$cm->id%'", false); 79 break; 80 81 case "quiz": 82 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 83 WHERE module = '$cm->name' AND url = 'view.php?id=$cm->id'", false); 84 break; 85 86 case "assignment": 87 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 88 WHERE module = '$cm->name' AND url = 'view.php?id=$cm->id'", false); 89 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 90 WHERE module = '$cm->name' AND url = 'view.php?a=$cm->instance'", false); 91 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 92 WHERE module = '$cm->name' AND url = 'submissions.php?id=$cm->instance'", false); 93 break; 94 95 case "journal": 96 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 97 WHERE module = '$cm->name' AND url = 'report.php?id=$cm->id'", false); 98 99 execute_sql("UPDATE {$CFG->prefix}log SET cmid = '$cm->id' 100 WHERE module = '$cm->name' AND url = 'view.php?id=$cm->id'", false); 101 break; 102 103 } 104 105 $count++; 106 $elapsedtime = time() - $starttime; 107 $projectedtime = (int)(((float)$cmcount / (float)$count) * $elapsedtime) - $elapsedtime; 108 109 if ($cmcount > 10) { 110 notify("Processed $count of $cmcount coursemodules. Estimated completion: ".format_time($projectedtime)); 111 flush(); 112 sleep($sleeptime); // To help reduce database load 113 } 114 } 115 } 116 117 delete_records("config", "name", "upgrade", "value", "logs"); 118 119 notify('Log upgrading was successful!', 'notifysuccess'); 120 121 print_continue('index.php'); 122 123 admin_externalpage_print_footer(); 124 125 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |