Skip to content

Commit

Permalink
MDL-11379 and MDL-11380 fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Sep 21, 2007
1 parent 6421ee7 commit 2f6c662
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 30 deletions.
29 changes: 14 additions & 15 deletions admin/roles/assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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?)
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 '<div style="text-align:center">'.$strcurrentcontext.': '.print_context_name($context).'<br/>';
Expand Down
2 changes: 2 additions & 0 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
5 changes: 3 additions & 2 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -96,7 +97,7 @@
note_print_notes($header, $addid, $view, $c->id, $userid, NOTES_STATE_PUBLIC, 0);
}
}
}
}

print_box_end();

Expand Down
26 changes: 13 additions & 13 deletions user/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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&amp;filterselect='.$filterselect, get_string('blogs','blog'));
}
Expand All @@ -76,7 +76,7 @@
$toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$filterselect,
get_string('participants'));


$toprow[] = new tabobject('blogs', $CFG->wwwroot.'/blog/index.php?filtertype=group&amp;filterselect='.$filterselect, get_string('blogs','blog'));
}

Expand Down Expand Up @@ -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.'&amp;course='.$course->id,
Expand Down Expand Up @@ -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)) {

Expand All @@ -203,12 +203,12 @@
$secondrow[] = new tabobject('stats',$CFG->wwwroot.'/course/user.php?id='.$course->id.
'&amp;user='.$user->id.'&amp;mode=stats',get_string('stats'));
}

if ($course->showgrades) {
$secondrow[] = new tabobject('grade', $CFG->wwwroot.'/course/user.php?id='.$course->id.
'&amp;user='.$user->id.'&amp;mode=grade', get_string('grade'));
}

}

}
Expand All @@ -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.'&amp;userid='.$user->id.'&amp;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.'&amp;userid='.$user->id.'&amp;courseid='.$course->id
,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
,get_string('overrideroles', 'role'));

}
}
}
}
/// Add second row to display if there is one

Expand Down

0 comments on commit 2f6c662

Please sign in to comment.