]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10107 Don't show messaging tab (and portfolio) when on user index page. Also...
authormoodler <moodler>
Mon, 28 Jul 2008 07:17:34 +0000 (07:17 +0000)
committermoodler <moodler>
Mon, 28 Jul 2008 07:17:34 +0000 (07:17 +0000)
user/index.php
user/tabs.php

index e6a69f36d4922d5efc4818cf3254dab70a26ea81..19058654d385082514f7d1af6814cdff08104563 100644 (file)
 
     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
     }
     $currenttab = 'participants';
     $user = $USER;
+    $userindexpage = true;
 
     require_once($CFG->dirroot .'/user/tabs.php');
 
         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;
         }
     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 ";
index 9d405914bb1004231b92e45f96eb27b12b9ed68c..293e308ad5c5a4bc616e81e0ca550f39f9e10c65 100644 (file)
         }
     }
 
-    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.'&amp;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.'&amp;course='.$course->id, get_string('editmymessage', 'message'));
+        }
     }
 
+
 /// Add second row to display if there is one
 
     if (!empty($secondrow)) {