// 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))) {
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;
if ($modname) {
$joins[] = "l.module = :modname";
- $params['modname'] = $modname;
+ $params['modname'] = $modname;
}
if ('site_errors' === $modid) {
}
}
-
+
/// Getting all members of a group.
if ($groupid and !$user) {
if ($gusers = groups_get_members($groupid)) {
if (empty($logs['logs'])) {
$logs['logs'] = array();
}
-
+
$row = 1;
foreach ($logs['logs'] as $log) {
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')) {
}
}
}
-
+
$totalcount = $logs['totalcount'];
$count=0;
$ldcache = array();
$row = 1;
foreach ($logs['logs'] as $log) {
-
+
$log->info = $log->coursename;
$row = ($row + 1) % 2;
}
}
- //Filter log->info
+ //Filter log->info
$log->info = format_string($log->info);
$log->url = strip_tags(urldecode($log->url)); // Some XSS protection
$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");
}
}
* 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!)
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();
/// 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)) {
static $resources = false;
static $activities = false;
- if ($resources === false) {
+ if ($resources === false) {
$resources = array();
$activities = array();
$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';
}
// update cached global COURSE too ;-)
if ($course->id == $COURSE->id) {
- $COURSE->modinfo = $modinfo;
+ $COURSE->modinfo = $modinfo;
}
}
$rs->close();
$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'));
}
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);
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');
$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 {
$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.'&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.'&course='.SITEID.'">'
- . $fullname . '</a>';
+ . $fullname . '</a>';
}
}
}
echo "</li></ul>";
}
}
-
+
require_once("$CFG->dirroot/enrol/enrol.class.php");
$enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);
}
// 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%");
$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;
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
foreach ($grade_items as $grade_item) {
$grade_item->delete('moddelete');
}
-
+
}
return $DB->delete_records('course_modules', array('id'=>$cm->id));
}
' alt="'.$str->movedown.'" /></a>'."\n";
}
} else {
- $move = '';
+ $move = '';
}
$leftright = '';
$rightarrow = 'right.gif';
$leftarrow = 'left.gif';
}
-
+
if ($indent > 0) {
$leftright .= '<a class="editing_moveleft" title="'.$str->moveleft.'" href="'.$path.'/mod.php?id='.$mod->id.
'&indent=-1&sesskey='.$sesskey.$section.'"><img'.
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>';
function course_allowed_module($course,$mod) {
global $DB;
-
+
if (empty($course->restrictmodules)) {
return true;
}
if (empty($modid)) {
return false;
}
-
+
return $DB->record_exists('course_allowed_modules', array('course'=>$course->id, 'module'=>$modid));
}
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;
}
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
add_to_log(SITEID, 'course', 'new', 'view.php?id='.$course->id, $data->fullname.' (ID '.$course->id.')');
return $course;
- }
+ }
return false; // error
}
// 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;