MDL-10107 Don't show messaging tab (and portfolio) when on user index page. Also fixed some notices.

This commit is contained in:
moodler 2008-07-28 07:17:34 +00:00
parent cf3ed6e42f
commit 1118434a2f
2 changed files with 14 additions and 10 deletions

View File

@ -44,13 +44,13 @@
require_login($course);
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);
if ($context->id != $frontpagectx->id) {
require_capability('moodle/course:viewparticipants', $context);
} else {
require_capability('moodle/site:viewparticipants', $sitecontext);
require_capability('moodle/site:viewparticipants', $systemcontext);
// override the default on frontpage
$roleid = optional_param('roleid', -1, PARAM_INT);
}
@ -66,7 +66,7 @@
// Otherwise they appear in every participant list
$canviewroles = get_roles_with_capability('moodle/course:view', CAP_ALLOW, $context);
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext);
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $systemcontext);
if ($context->id == $frontpagectx->id) {
//we want admins listed on frontpage too
@ -181,6 +181,7 @@
}
$currenttab = 'participants';
$user = $USER;
$userindexpage = true;
require_once($CFG->dirroot .'/user/tabs.php');
@ -204,7 +205,7 @@
foreach ($mycourses as $mycourse) {
$courselist[$mycourse->id] = format_string($mycourse->shortname);
}
if (has_capability('moodle/site:viewparticipants', $sitecontext)) {
if (has_capability('moodle/site:viewparticipants', $systemcontext)) {
unset($courselist[SITEID]);
$courselist = array(SITEID => format_string($SITE->shortname)) + $courselist;
}
@ -388,7 +389,7 @@
if ($usercontexts = get_parent_contexts($context)) {
$listofcontexts = '('.implode(',', $usercontexts).')';
} else {
$listofcontexts = '('.$sitecontext->id.')'; // must be site
$listofcontexts = '('.$systemcontext->id.')'; // must be site
}
if ($roleid > 0) {
$selectrole = " AND r.roleid = :roleid ";

View File

@ -239,19 +239,22 @@
}
}
if ($user->id == $USER->id) {
if (empty($userindexpage) && $user->id == $USER->id) {
/// Portfolio tab
require_once($CFG->libdir . '/portfoliolib.php');
if (portfolio_instances(true, false)) {
// @todo permissions check?
$toprow[] = new tabobject('portfolios', $CFG->wwwroot .'/user/portfolio.php', get_string('portfolios', 'portfolio'));
}
}
///added a new messaging tab
if (has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
$toprow[] = new tabobject('editmessage', $wwwroot.'/message/edit.php?id='.$user->id.'&course='.$course->id, get_string('editmymessage', 'message'));
/// Messaging tab
if (has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
$toprow[] = new tabobject('editmessage', $CFG->wwwroot.'/message/edit.php?id='.$user->id.'&course='.$course->id, get_string('editmymessage', 'message'));
}
}
/// Add second row to display if there is one
if (!empty($secondrow)) {