MDL-11379 and MDL-11380 fixed

This commit is contained in:
nicolasconnault 2007-09-21 07:52:52 +00:00
parent 6421ee7191
commit 2f6c662f41
4 changed files with 32 additions and 30 deletions

View file

@ -129,7 +129,6 @@
/// course header /// course header
$navlinks = array(); $navlinks = array();
if ($courseid != SITEID) { 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' => $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' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$userid&course=$courseid", 'type' => 'misc');
$navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc'); $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
@ -301,8 +300,8 @@
$selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') "; $selectsql = " AND ($FULLNAME $LIKE '%$searchtext%' OR email $LIKE '%$searchtext%') ";
$select .= $selectsql; $select .= $selectsql;
} else { } else {
$selectsql = ""; $selectsql = "";
} }
if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?) if ($context->contextlevel > CONTEXT_COURSE) { // mod or block (or group?)
@ -320,9 +319,9 @@
* 3) get_recordset_sql() is more efficient * * 3) get_recordset_sql() is more efficient *
* * * *
************************************************************************/ ************************************************************************/
if ($possibleroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context)) { 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)); $doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM));
$validroleids = array(); $validroleids = array();
@ -339,7 +338,7 @@
if ($validroleids) { if ($validroleids) {
$roleids = '('.implode(',', $validroleids).')'; $roleids = '('.implode(',', $validroleids).')';
$select = " SELECT u.id, u.firstname, u.lastname, u.email"; $select = " SELECT u.id, u.firstname, u.lastname, u.email";
$countselect = "SELECT COUNT(u.id)"; $countselect = "SELECT COUNT(u.id)";
$from = " FROM {$CFG->prefix}user u $from = " FROM {$CFG->prefix}user u
@ -353,25 +352,25 @@
FROM {$CFG->prefix}role_assignments r, FROM {$CFG->prefix}role_assignments r,
{$CFG->prefix}user u {$CFG->prefix}user u
WHERE r.contextid = $contextid WHERE r.contextid = $contextid
AND u.id = r.userid AND u.id = r.userid
AND r.roleid = $roleid AND r.roleid = $roleid
$selectsql)"; $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); $usercount = count_records_sql($countselect . $from . $where) - count($contextusers);
} }
} else { } else {
/************************************************************************ /************************************************************************
* * * *
* context level is above or equal course context level * * context level is above or equal course context level *
* in this case we pull out all users matching search criteria (if any) * * 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 /// 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 /// so that the number of available users is right and we save time looping later
$availableusers = get_recordset_sql('SELECT id, firstname, lastname, email $availableusers = get_recordset_sql('SELECT id, firstname, lastname, email
@ -382,12 +381,12 @@
FROM '.$CFG->prefix.'role_assignments r, FROM '.$CFG->prefix.'role_assignments r,
'.$CFG->prefix.'user u '.$CFG->prefix.'user u
WHERE r.contextid = '.$contextid.' WHERE r.contextid = '.$contextid.'
AND u.id = r.userid AND u.id = r.userid
AND r.roleid = '.$roleid.' AND r.roleid = '.$roleid.'
'.$selectsql.') '.$selectsql.')
ORDER BY lastname ASC, firstname ASC'); ORDER BY lastname ASC, firstname ASC');
$usercount = count_records_select('user', $select) - count($contextusers); $usercount = count_records_select('user', $select) - count($contextusers);
} }
echo '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>'; echo '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';

View file

@ -43,6 +43,8 @@
$fullname = fullname($user, true); $fullname = fullname($user, true);
$navlinks = array(); $navlinks = array();
$navlinks[] = array('name' => $course->shortname, 'link' => "course/view.php?id=$course->id", 'type' => 'misc');
if ($course->id != SITEID) { if ($course->id != SITEID) {
$navlinks[] = array('name' => $strparticipants, 'link' => "../user/index.php?id=$course->id", 'type' => 'misc'); $navlinks[] = array('name' => $strparticipants, 'link' => "../user/index.php?id=$course->id", 'type' => 'misc');
} }

View file

@ -2,7 +2,7 @@
/** /**
* file index.php * 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 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 * 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)); print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav));
$showroles = 1;
$currenttab = 'notes'; $currenttab = 'notes';
require_once($CFG->dirroot .'/user/tabs.php'); require_once($CFG->dirroot .'/user/tabs.php');
@ -96,7 +97,7 @@
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0); note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
} }
} }
} }
print_box_end(); print_box_end();

View file

@ -32,7 +32,7 @@
$site = get_site(); $site = get_site();
print_heading(format_string($site->fullname)); print_heading(format_string($site->fullname));
if ($CFG->bloglevel >= 4) { if ($CFG->bloglevel >= 4) {
if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) { if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
$toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.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, $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$filterselect,
get_string('participants')); get_string('participants'));
if ($CFG->bloglevel >= 3) { if ($CFG->bloglevel >= 3) {
$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&amp;filterselect='.$filterselect, get_string('blogs','blog')); $toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=course&amp;filterselect='.$filterselect, get_string('blogs','blog'));
} }
@ -76,7 +76,7 @@
$toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect, $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect,
get_string('participants')); get_string('participants'));
$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=group&amp;filterselect='.$filterselect, get_string('blogs','blog')); $toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=group&amp;filterselect='.$filterselect, get_string('blogs','blog'));
} }
@ -139,7 +139,7 @@
} }
/// Everyone can see posts for this user /// Everyone can see posts for this user
/// add logic to see course read posts permission /// 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))) { 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.'&amp;course='.$course->id, $toprow[] = new tabobject('forumposts', $CFG->wwwroot.'/mod/forum/user.php?id='.$user->id.'&amp;course='.$course->id,
@ -176,10 +176,10 @@
} }
/// Current user must be teacher of the course or the course allows user to view their reports /// Current user must be teacher of the course or the course allows user to view their reports
//print_object($course); //print_object($course);
//print_object($user); //print_object($user);
// add in logic to check course read report // 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)) { 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. $secondrow[] = new tabobject('stats',$CFG->wwwroot.'/course/user.php?id='.$course->id.
'&amp;user='.$user->id.'&amp;mode=stats',get_string('stats')); '&amp;user='.$user->id.'&amp;mode=stats',get_string('stats'));
} }
if ($course->showgrades) { if ($course->showgrades) {
$secondrow[] = new tabobject('grade', $CFG->wwwroot.'/course/user.php?id='.$course->id. $secondrow[] = new tabobject('grade', $CFG->wwwroot.'/course/user.php?id='.$course->id.
'&amp;user='.$user->id.'&amp;mode=grade', get_string('grade')); '&amp;user='.$user->id.'&amp;mode=grade', get_string('grade'));
} }
} }
} }
@ -218,25 +218,25 @@
/// this needs permission checkings /// 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 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); $usercontext = get_context_instance(CONTEXT_USER, $user->id);
if (has_capability('moodle/role:assign',$usercontext)) { if (has_capability('moodle/role:assign',$usercontext)) {
$toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id $toprow[] = new tabobject('roles', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id
,get_string('roles')); ,get_string('roles'));
if (in_array($currenttab, array('assign', 'override'))) { if (in_array($currenttab, array('assign', 'override'))) {
$inactive = array('roles'); $inactive = array('roles');
$activetwo = array('roles'); $activetwo = array('roles');
$secondrow = array(); $secondrow = array();
$secondrow[] = new tabobject('assign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id $secondrow[] = new tabobject('assign', $CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id
,get_string('assignroles', 'role')); ,get_string('assignroles', 'role'));
$secondrow[] = new tabobject('override', $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id $secondrow[] = new tabobject('override', $CFG->wwwroot.'/'.$CFG->admin.'/roles/override.php?contextid='.$usercontext->id.'&amp;userid='.$user->id.'&amp;courseid='.$course->id
,get_string('overrideroles', 'role')); ,get_string('overrideroles', 'role'));
} }
} }
} }
/// Add second row to display if there is one /// Add second row to display if there is one