diff --git a/admin/roles/assign.php b/admin/roles/assign.php index 8088733a069..f428bdbed27 100755 --- a/admin/roles/assign.php +++ b/admin/roles/assign.php @@ -129,7 +129,6 @@ /// course header $navlinks = array(); if ($courseid != SITEID) { - $navlinks[] = array('name' => $course->shortname, 'link' => "$CFG->wwwroot/course/view.php?id=$course->id", 'type' => 'course'); $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc'); $navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc'); $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc'); @@ -301,8 +300,8 @@ $selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') "; $select .= $selectsql; - } else { - $selectsql = ""; + } else { + $selectsql = ""; } if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?) @@ -320,9 +319,9 @@ * 3) get_recordset_sql() is more efficient * * * ************************************************************************/ - + if ($possibleroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context)) { - + $doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM)); $validroleids = array(); @@ -339,7 +338,7 @@ if ($validroleids) { $roleids = '('.implode(',', $validroleids).')'; - + $select = " SELECT u.id, u.firstname, u.lastname, u.email"; $countselect = "SELECT COUNT(u.id)"; $from = " FROM {$CFG->prefix}user u @@ -353,25 +352,25 @@ FROM {$CFG->prefix}role_assignments r, {$CFG->prefix}user u WHERE r.contextid = $contextid - AND u.id = r.userid + AND u.id = r.userid AND r.roleid = $roleid $selectsql)"; - - $availableusers = get_recordset_sql($select . $from . $where . $selectsql . $excsql); + + $availableusers = get_recordset_sql($select . $from . $where . $selectsql . $excsql); } - + $usercount = count_records_sql($countselect . $from . $where) - count($contextusers); } - } else { - + } else { + /************************************************************************ * * * context level is above or equal course context level * * in this case we pull out all users matching search criteria (if any) * * * ************************************************************************/ - + /// MDL-11111 do not include user already assigned this role in this context as available users /// so that the number of available users is right and we save time looping later $availableusers = get_recordset_sql('SELECT id, firstname, lastname, email @@ -382,12 +381,12 @@ FROM '.$CFG->prefix.'role_assignments r, '.$CFG->prefix.'user u WHERE r.contextid = '.$contextid.' - AND u.id = r.userid + AND u.id = r.userid AND r.roleid = '.$roleid.' '.$selectsql.') ORDER BY lastname ASC, firstname ASC'); $usercount = count_records_select('user', $select) - count($contextusers); - + } echo '
'.$strcurrentcontext.': '.print_context_name($context).'
'; diff --git a/course/user.php b/course/user.php index 4c270b1dc82..63d9432f7a9 100644 --- a/course/user.php +++ b/course/user.php @@ -43,6 +43,8 @@ $fullname = fullname($user, true); $navlinks = array(); + $navlinks[] = array('name' => $course->shortname, 'link' => "course/view.php?id=$course->id", 'type' => 'misc'); + if ($course->id != SITEID) { $navlinks[] = array('name' => $strparticipants, 'link' => "../user/index.php?id=$course->id", 'type' => 'misc'); } diff --git a/notes/index.php b/notes/index.php index d20f4a72e84..e563e94c998 100644 --- a/notes/index.php +++ b/notes/index.php @@ -2,7 +2,7 @@ /** * file index.php - * index page to view notes. + * index page to view notes. * if a course id is specified then the entries from that course are shown * if a user id is specified only notes related to that user are shown */ @@ -59,6 +59,7 @@ print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav)); + $showroles = 1; $currenttab = 'notes'; require_once($CFG->dirroot .'/user/tabs.php'); @@ -96,7 +97,7 @@ note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0); } } - } + } print_box_end(); diff --git a/user/tabs.php b/user/tabs.php index 814a6fff55f..4990e582975 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -32,7 +32,7 @@ $site = get_site(); print_heading(format_string($site->fullname)); - + if ($CFG->bloglevel >= 4) { if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) { $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.SITEID, @@ -54,7 +54,7 @@ $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect, get_string('participants')); - + if ($CFG->bloglevel >= 3) { $toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&filterselect='.$filterselect, get_string('blogs','blog')); } @@ -76,7 +76,7 @@ $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$filterselect, get_string('participants')); - + $toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=group&filterselect='.$filterselect, get_string('blogs','blog')); } @@ -139,7 +139,7 @@ } /// Everyone can see posts for this user - + /// add logic to see course read posts permission if (has_capability('moodle/user:readuserposts', $personalcontext) || has_capability('mod/forum:viewdiscussion', get_context_instance(CONTEXT_COURSE, $course->id))) { $toprow[] = new tabobject('forumposts', $CFG->wwwroot.'/mod/forum/user.php?id='.$user->id.'&course='.$course->id, @@ -176,10 +176,10 @@ } /// Current user must be teacher of the course or the course allows user to view their reports - + //print_object($course); //print_object($user); - + // add in logic to check course read report if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext) || ($course->showreports and $USER->id == $user->id) || has_capability('moodle/user:viewuseractivitiesreport', $coursecontext)) { @@ -203,12 +203,12 @@ $secondrow[] = new tabobject('stats',$CFG->wwwroot.'/course/user.php?id='.$course->id. '&user='.$user->id.'&mode=stats',get_string('stats')); } - + if ($course->showgrades) { $secondrow[] = new tabobject('grade', $CFG->wwwroot.'/course/user.php?id='.$course->id. '&user='.$user->id.'&mode=grade', get_string('grade')); } - + } } @@ -218,25 +218,25 @@ /// this needs permission checkings - + if (!empty($showroles) and !empty($user)) { // this variable controls whether this roles is showed, or not, so only user/view page should set this flag $usercontext = get_context_instance(CONTEXT_USER, $user->id); if (has_capability('moodle/role:assign',$usercontext)) { $toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id ,get_string('roles')); - + if (in_array($currenttab, array('assign', 'override'))) { $inactive = array('roles'); $activetwo = array('roles'); - + $secondrow = array(); $secondrow[] = new tabobject('assign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id ,get_string('assignroles', 'role')); $secondrow[] = new tabobject('override', $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$usercontext->id.'&userid='.$user->id.'&courseid='.$course->id ,get_string('overrideroles', 'role')); - + } - } + } } /// Add second row to display if there is one