/// 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');
$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?)
* 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();
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
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
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 '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
$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');
}
/**
* 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
*/
print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav));
+ $showroles = 1;
$currenttab = 'notes';
require_once($CFG->dirroot .'/user/tabs.php');
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
}
}
- }
+ }
print_box_end();
$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,
$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'));
}
$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'));
}
}
/// 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,
}
/// 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)) {
$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'));
}
-
+
}
}
/// 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