MDL-14679 Fixed a typo from Petr, which caused fatal error in course lib

This commit is contained in:
nicolasconnault
2008-06-04 06:38:03 +00:00
parent 8a318fa81a
commit 238c0dd9c1
+76 -76
View File
@@ -62,11 +62,11 @@ function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.tim
// and so the next 86400 seconds worth of logs are printed.
/// Setup for group handling.
// TODO: I don't understand group/context/etc. enough to be able to do
// TODO: I don't understand group/context/etc. enough to be able to do
// something interesting with it here
// What is the context of a remote course?
/// If the group mode is separate, and this user does not have editing privileges,
/// then only the user's group can be viewed.
//if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
@@ -106,7 +106,7 @@ function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.tim
if ('site_errors' === $modid) {
$where .= " AND ( l.action='error' OR l.action='infected' )";
} else if ($modid) {
//TODO: This assumes that modids are the same across sites... probably
//TODO: This assumes that modids are the same across sites... probably
//not true
$where .= " AND l.cmid = :modid";
$params['modid'] = $modid;
@@ -174,7 +174,7 @@ function build_logs_array($course, $user=0, $date=0, $order="l.time ASC", $limit
if ($modname) {
$joins[] = "l.module = :modname";
$params['modname'] = $modname;
$params['modname'] = $modname;
}
if ('site_errors' === $modid) {
@@ -196,7 +196,7 @@ function build_logs_array($course, $user=0, $date=0, $order="l.time ASC", $limit
}
}
/// Getting all members of a group.
if ($groupid and !$user) {
if ($gusers = groups_get_members($groupid)) {
@@ -284,7 +284,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
if (empty($logs['logs'])) {
$logs['logs'] = array();
}
$row = 1;
foreach ($logs['logs'] as $log) {
@@ -355,16 +355,16 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
$url="", $modname="", $modid=0, $modaction="", $groupid=0) {
global $CFG, $DB;
if (!$logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page*$perpage, $perpage,
$modname, $modid, $modaction, $groupid)) {
notify("No logs found!");
print_footer($course);
exit;
}
if ($course->id == SITEID) {
$courses[0] = '';
if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) {
@@ -373,7 +373,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
}
}
}
$totalcount = $logs['totalcount'];
$count=0;
$ldcache = array();
@@ -407,7 +407,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
$row = 1;
foreach ($logs['logs'] as $log) {
$log->info = $log->coursename;
$row = ($row + 1) % 2;
@@ -426,7 +426,7 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
}
}
//Filter log->info
//Filter log->info
$log->info = format_string($log->info);
$log->url = strip_tags(urldecode($log->url)); // Some XSS protection
@@ -955,7 +955,7 @@ function print_recent_activity($course) {
$content = $print_recent_activity($course, $viewfullnames, $timestart) || $content;
}
} else {
debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
}
}
@@ -1179,7 +1179,7 @@ function &get_fast_modinfo(&$course, $userid=0) {
* Returns a number of useful structures for course displays
*/
function get_all_mods($courseid, &$mods, &$modnames, &$modnamesplural, &$modnamesused) {
global $DB;
global $DB;
$mods = array(); // course modules indexed by id
$modnames = array(); // all course module names (except resource!)
@@ -1236,7 +1236,7 @@ function course_set_display($courseid, $display=0) {
if (empty($USER->id) or $USER->username == 'guest') {
//do not store settings in db for guests
} else if ($DB->record_exists("course_display", "userid", $USER->id, array("course"=>$courseid))) {
} else if ($DB->record_exists("course_display", array("userid" => $USER->id, "course"=>$courseid))) {
$DB->set_field("course_display", "display", $display, array("userid"=>$USER->id, "course"=>$courseid));
} else {
$record = new object();
@@ -1310,7 +1310,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
/// Casting $course->modinfo to string prevents one notice when the field is null
$modinfo = get_fast_modinfo($course);
//Acccessibility: replace table with list <ul>, but don't output empty list.
if (!empty($section->sequence)) {
@@ -1480,7 +1480,7 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
static $resources = false;
static $activities = false;
if ($resources === false) {
if ($resources === false) {
$resources = array();
$activities = array();
@@ -1565,7 +1565,7 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
$DB->set_field('course', 'modinfo', null, $courseselect);
// update cached global COURSE too ;-)
if ($courseid == $COURSE->id) {
$COURSE->modinfo = null;
$COURSE->modinfo = null;
}
// reset the fast modinfo cache
$reset = 'reset';
@@ -1588,7 +1588,7 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
}
// update cached global COURSE too ;-)
if ($course->id == $COURSE->id) {
$COURSE->modinfo = $modinfo;
$COURSE->modinfo = $modinfo;
}
}
$rs->close();
@@ -1835,18 +1835,18 @@ function print_courses($category) {
$categories = get_child_categories(0); // Parent = 0 ie top-level categories only
if (is_array($categories) && count($categories) == 1) {
$category = array_shift($categories);
$courses = get_courses_wmanagers($category->id,
'c.sortorder ASC',
$courses = get_courses_wmanagers($category->id,
'c.sortorder ASC',
array('password','summary','currency'));
} else {
$courses = get_courses_wmanagers('all',
'c.sortorder ASC',
$courses = get_courses_wmanagers('all',
'c.sortorder ASC',
array('password','summary','currency'));
}
unset($categories);
} else {
$courses = get_courses_wmanagers($category->id,
'c.sortorder ASC',
$courses = get_courses_wmanagers($category->id,
'c.sortorder ASC',
array('password','summary','currency'));
}
@@ -1890,10 +1890,10 @@ function print_course($course) {
echo '<div class="info">';
echo '<div class="name"><a title="'.get_string('entercourse').'"'.
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
format_string($course->fullname).'</a></div>';
format_string($course->fullname).'</a></div>';
/// first find all roles that are supposed to be displayed
if (!empty($CFG->coursemanager)) {
$managerroles = split(',', $CFG->coursemanager);
$canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
@@ -1902,7 +1902,7 @@ function print_course($course) {
if (count($course->managers)) {
$rusers = $course->managers;
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
/// Rename some of the role names if needed
if (isset($context)) {
$aliasnames = $DB->get_records('role_names', array('contextid'=>$context->id), '', 'roleid,contextid,name');
@@ -1919,7 +1919,7 @@ function print_course($course) {
$usersshown[] = $ra->user->id;
if ($ra->hidden == 0 || $canseehidden) {
$fullname = fullname($ra->user, $canviewfullnames);
$fullname = fullname($ra->user, $canviewfullnames);
if ($ra->hidden == 1) {
$status = " <img src=\"{$CFG->pixpath}/t/show.gif\" title=\"".get_string('userhashiddenassignments', 'role')."\" alt=\"".get_string('hiddenassign')."\" class=\"hide-show-image\"/>";
} else {
@@ -1930,22 +1930,22 @@ function print_course($course) {
$ra->rolename = $aliasnames[$ra->roleid]->name;
}
$namesarray[] = format_string($ra->rolename)
$namesarray[] = format_string($ra->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$ra->user->id.'&amp;course='.SITEID.'">'
. $fullname . '</a>' . $status;
. $fullname . '</a>' . $status;
}
}
}
} else {
$rusers = get_role_users($managerroles, $context,
$rusers = get_role_users($managerroles, $context,
true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
if (is_array($rusers) && count($rusers)) {
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
foreach ($rusers as $teacher) {
$fullname = fullname($teacher, $canviewfullnames);
$namesarray[] = format_string($teacher->rolename)
$fullname = fullname($teacher, $canviewfullnames);
$namesarray[] = format_string($teacher->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&amp;course='.SITEID.'">'
. $fullname . '</a>';
. $fullname . '</a>';
}
}
}
@@ -1956,7 +1956,7 @@ function print_course($course) {
echo "</li></ul>";
}
}
require_once("$CFG->dirroot/enrol/enrol.class.php");
$enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);
@@ -2005,7 +2005,7 @@ function print_my_moodle() {
}
// MNET
if (!empty($rcourses)) {
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
foreach ($rcourses as $course) {
print_remote_course($course, "100%");
@@ -2095,8 +2095,8 @@ function print_remote_course($course, $width="100%") {
$linkcss.' href="'.$url.'">'
. format_string($course->fullname) .'</a><br />'
. format_string($course->hostname) . ' : '
. format_string($course->cat_name) . ' : '
. format_string($course->shortname). '</div>';
. format_string($course->cat_name) . ' : '
. format_string($course->shortname). '</div>';
echo '</div><div class="summary">';
$options = NULL;
$options->noclean = true;
@@ -2220,7 +2220,7 @@ function set_coursemodule_groupmembersonly($id, $groupmembersonly) {
function set_coursemodule_idnumber($id, $idnumber) {
global $DB;
return $DB->set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));
return $DB->set_field("course_modules", "idnumber", $idnumber, array("id"=>$id));
}
/**
* $prevstateoverrides = true will set the visibility of the course module
@@ -2284,7 +2284,7 @@ function delete_course_module($id) {
foreach ($grade_items as $grade_item) {
$grade_item->delete('moddelete');
}
}
return $DB->delete_records('course_modules', array('id'=>$cm->id));
}
@@ -2502,7 +2502,7 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
' alt="'.$str->movedown.'" /></a>'."\n";
}
} else {
$move = '';
$move = '';
}
$leftright = '';
@@ -2515,7 +2515,7 @@ function make_editing_buttons($mod, $absolute=false, $moveselect=true, $indent=-
$rightarrow = 'right.gif';
$leftarrow = 'left.gif';
}
if ($indent > 0) {
$leftright .= '<a class="editing_moveleft" title="'.$str->moveleft.'" href="'.$path.'/mod.php?id='.$mod->id.
'&amp;indent=-1&amp;sesskey='.$sesskey.$section.'"><img'.
@@ -2645,12 +2645,12 @@ function print_grouping_settings($form, $course=NULL) {
echo '<tr valign="top">';
echo '<td align="right"><b>'.get_string('grouping', 'group').':</b></td>';
echo '<td align="left">';
$groupingid = isset($cm->groupingid) ? $cm->groupingid : 0;
choose_from_menu($groupings, 'groupingid', $groupingid, get_string('none'), '', 0, false);
echo '</td></tr>';
$checked = empty($cm->groupmembersonly) ? '':'checked="checked"';
echo '<tr valign="top">';
echo '<td align="right"><b>'.get_string('groupmembersonly', 'group').':</b></td>';
@@ -2725,7 +2725,7 @@ function update_restricted_mods($course, $mods) {
function course_allowed_module($course,$mod) {
global $DB;
if (empty($course->restrictmodules)) {
return true;
}
@@ -2744,7 +2744,7 @@ function course_allowed_module($course,$mod) {
if (empty($modid)) {
return false;
}
return $DB->record_exists('course_allowed_modules', array('course'=>$course->id, 'module'=>$modid));
}
@@ -2761,7 +2761,7 @@ function category_delete_full($category, $showfeedback=true) {
if ($children = $DB->get_records('course_categories', array('parent'=>$category->id), 'sortorder ASC')) {
foreach ($children as $childcat) {
if (!category_delete_full($childcat, $showfeedback)) {
notify("Error deleting category $childcat->name");
notify("Error deleting category $childcat->name");
return false;
}
}
@@ -2770,17 +2770,17 @@ function category_delete_full($category, $showfeedback=true) {
if ($courses = $DB->get_records('course', array('category'=>$category->id), 'sortorder ASC')) {
foreach ($courses as $course) {
if (!delete_course($course->id, false)) {
notify("Error deleting course $course->shortname");
notify("Error deleting course $course->shortname");
return false;
}
notify(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
notify(get_string('coursedeleted', '', $course->shortname), 'notifysuccess');
}
}
// now delete anything that may depend on course category context
grade_course_category_delete($category->id, 0, $showfeedback);
if (!question_delete_course_category($category, 0, $showfeedback)) {
notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
return false;
}
@@ -2790,7 +2790,7 @@ function category_delete_full($category, $showfeedback=true) {
events_trigger('category_deleted', $category);
notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
return true;
}
@@ -2813,7 +2813,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) {
if ($children = $DB->get_records('course_categories', array('parent'=>$category->id), 'sortorder ASC')) {
foreach ($children as $childcat) {
if (!move_category($childcat, $newparentcat)) {
notify("Error moving category $childcat->name");
notify("Error moving category $childcat->name");
return false;
}
}
@@ -2821,16 +2821,16 @@ function category_delete_move($category, $newparentid, $showfeedback=true) {
if ($courses = $DB->get_records('course', array('category'=>$category->id), 'sortorder ASC', 'id')) {
if (!move_courses(array_keys($courses), $newparentid)) {
notify("Error moving courses");
notify("Error moving courses");
return false;
}
notify(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess');
notify(get_string('coursesmovedout', '', format_string($category->name)), 'notifysuccess');
}
// now delete anything that may depend on course category context
grade_course_category_delete($category->id, $newparentid, $showfeedback);
if (!question_delete_course_category($category, $newparentcat, $showfeedback)) {
notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
notify(get_string('errordeletingquestionsfromcategory', 'question', $category), 'notifysuccess');
return false;
}
@@ -2840,7 +2840,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) {
events_trigger('category_deleted', $category);
notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
notify(get_string('coursecategorydeleted', '', format_string($category->name)), 'notifysuccess');
return true;
}
@@ -2923,10 +2923,10 @@ function move_category ($category, $newparentcat) {
context_moved($context, $newparent);
// The most effective thing would be to find the common parent,
// The most effective thing would be to find the common parent,
// until then, do it sitewide...
fix_course_sortorder();
return true;
}
@@ -3017,7 +3017,7 @@ function create_course($data) {
add_to_log(SITEID, 'course', 'new', 'view.php?id='.$course->id, $data->fullname.' (ID '.$course->id.')');
return $course;
}
}
return false; // error
}
@@ -3077,37 +3077,37 @@ function update_course($data) {
// put custom role names into db
$context = get_context_instance(CONTEXT_COURSE, $course->id);
foreach ($data as $dname => $dvalue) {
// is this the right param?
$dvalue = clean_param($dvalue, PARAM_NOTAGS);
if (!strstr($dname, 'role_')) {
continue;
}
}
$dt = explode('_', $dname);
$roleid = $dt[1];
// make up our mind whether we want to delete, update or insert
if (empty($dvalue)) {
$DB->delete_records('role_names', array('contextid'=>$context->id, 'roleid'=>$roleid));
} else if ($t = $DB->get_record('role_names', array('contextid'=>$context->id, 'roleid'=>$roleid))) {
$t->name = $dvalue;
$DB->update_record('role_names', $t);
$DB->update_record('role_names', $t);
} else {
$t->contextid = $context->id;
$t->roleid = $roleid;
$t->name = $dvalue;
$DB->insert_record('role_names', $t);
$DB->insert_record('role_names', $t);
}
}
return true;