From: skodak Date: Sun, 1 Oct 2006 19:55:47 +0000 (+0000) Subject: fixed MDL-6625 - can't switch courses X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=87a13824e13ebcfb97114289000ea336dbbdcf78;p=moodle.git fixed MDL-6625 - can't switch courses --- diff --git a/user/index.php b/user/index.php index 8eceb9de38..85319dcd17 100644 --- a/user/index.php +++ b/user/index.php @@ -36,6 +36,9 @@ error("Context ID is incorrect"); } } + // not needed anymore + unset($contextid); + unset($courseid); require_login($course->id); @@ -46,16 +49,16 @@ } } else { // no roles yet if (has_capability('moodle/user:assign', $context)) { - redirect($CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id); + redirect($CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id); } else { - error ('no participants found for this course'); + error ('no participants found for this course'); } } if (!has_capability('moodle/course:viewparticipants', $context) && !has_capability('moodle/site:viewparticipants', $context)) { print_error('nopermissions'); - } + } if (!$course->category) { if (!has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) { @@ -157,16 +160,16 @@ echo ''; print_string('mycourses'); echo ': '; - + $courselist = array(); foreach ($mycourses as $mycourse) { $courselist[$mycourse->id] = $mycourse->shortname; } - popup_form($CFG->wwwroot.'/user/index.php?contextid='.$context->id.'&roleid='.$roleid.'&sifirst=&silast=&id=', + popup_form($CFG->wwwroot.'/user/index.php?roleid='.$roleid.'&sifirst=&silast=&id=', $courselist, 'courseform',$course->id); echo ''; } - + if ($groupmode == VISIBLEGROUPS or ($groupmode and has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id)))) { if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) { echo ''; @@ -181,10 +184,10 @@ $lastaccess0exists = record_exists('user_lastaccess','courseid',$course->id,'timeaccess',0); $now = usergetmidnight(time()); $timeaccess = array(); - + // makes sense for this to go first. $timeoptions[0] = get_string('selectperiod'); - + // days for ($i = 1; $i < 7; $i++) { if (strtotime('-'.$i.' days',$now) >= $minlastaccess) { @@ -197,7 +200,7 @@ $timeoptions[strtotime('-'.$i.' weeks',$now)] = get_string('numweeks','moodle',$i); } } - // months + // months for ($i = 2; $i < 12; $i++) { if (strtotime('-'.$i.' months',$now) >= $minlastaccess) { $timeoptions[strtotime('-'.$i.' months',$now)] = get_string('nummonths','moodle',$i); @@ -207,11 +210,11 @@ if (strtotime('-1 year',$now) >= $minlastaccess) { $timeoptions[strtotime('-1 year',$now)] = get_string('lastyear'); } - + if (!empty($lastaccess0exists)) { $timeoptions[-1] = get_string('never'); - } - + } + if (count($timeoptions) > 1) { echo ''; echo get_string('usersnoaccesssince').': '; @@ -219,7 +222,7 @@ echo popup_form($baseurl.'&accesssince=',$timeoptions,'timeoptions',$accesssince,'','','',true); echo ''; } - + echo ''; echo get_string('userlist').': '; @@ -229,8 +232,8 @@ echo ''; if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id)))) { /// Display info about the group - if ($group = get_record('groups', 'id', $currentgroup)) { - if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) { + if ($group = get_record('groups', 'id', $currentgroup)) { + if (!empty($group->description) or (!empty($group->picture) and empty($group->hidepicture))) { echo '
'; print_group_picture($group, $course->id, true, false, false); echo ''; @@ -247,7 +250,7 @@ } } - + if ($roles = get_roles_used_in_context($context)) { foreach ($roles as $role) { $rolenames[$role->id] = strip_tags(format_string($role->name)); // Used in menus etc later on @@ -310,23 +313,23 @@ $listofcontexts = '('.implode(',', $usercontexts).')'; } else { $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); - $listofcontexts = '('.$sitecontext->id.')'; // must be site + $listofcontexts = '('.$sitecontext->id.')'; // must be site } if ($roleid) { $selectrole = " AND r.roleid = $roleid "; } else { $selectrole = " "; } - $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country, + $select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country, u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, ul.timeaccess AS lastaccess '; // s.lastaccess //$select .= $course->enrolperiod?', s.timeend ':''; $from = "FROM {$CFG->prefix}user u INNER JOIN {$CFG->prefix}role_assignments r on u.id=r.userid LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul on r.userid=ul.userid "; - $where = "WHERE (r.contextid = $context->id OR r.contextid in $listofcontexts) + $where = "WHERE (r.contextid = $context->id OR r.contextid in $listofcontexts) AND u.deleted = 0 $selectrole AND (ul.courseid = $course->id OR ul.courseid IS NULL) - AND u.username <> 'guest' "; + AND u.username <> 'guest' "; $where .= get_lastaccess_sql($accesssince); $wheresearch = ''; @@ -370,7 +373,7 @@ echo '
'; echo get_string('currentrole', 'role').': '; $rolenames = array(0 => get_string('all')) + $rolenames; - popup_form('index.php?contextid='.$context->id.'&sifirst=&silast=&roleid=', $rolenames, + popup_form('index.php?contextid='.$context->id.'&sifirst=&silast=&roleid=', $rolenames, 'rolesform', $roleid, ''); echo '
'; }