From: moodler Date: Mon, 28 Jul 2008 07:17:34 +0000 (+0000) Subject: MDL-10107 Don't show messaging tab (and portfolio) when on user index page. Also... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1118434a2fccad77ee034af174d02c80ef064d5f;p=moodle.git MDL-10107 Don't show messaging tab (and portfolio) when on user index page. Also fixed some notices. --- diff --git a/user/index.php b/user/index.php index e6a69f36d4..19058654d3 100644 --- a/user/index.php +++ b/user/index.php @@ -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 "; diff --git a/user/tabs.php b/user/tabs.php index 9d405914bb..293e308ad5 100644 --- a/user/tabs.php +++ b/user/tabs.php @@ -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)) {