]> git.mjollnir.org Git - moodle.git/commitdiff
change participants of frontpage course to display all users, if current user has...
authortoyomoyo <toyomoyo>
Tue, 2 Oct 2007 03:37:30 +0000 (03:37 +0000)
committertoyomoyo <toyomoyo>
Tue, 2 Oct 2007 03:37:30 +0000 (03:37 +0000)
blocks/participants/block_participants.php
lib/db/access.php
user/index.php
user/tabs.php
version.php

index 16670424d44b2c0a20c67920d5323974367822bd..f6ecc93e763eafdb8ef8294e0420c1610d793b9d 100644 (file)
@@ -19,22 +19,29 @@ class block_participants extends block_list {
         if (empty($this->instance->pageid)) {
             return '';
         }
-
+        
+        $this->content = new object();
+        $this->content->items = array();
+        $this->content->icons = array();
+        $this->content->footer = '';
+        
         if (!$currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid)) {
             $this->content = '';
             return $this->content;
         }
-
-        if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
-            $this->content = '';
-            return $this->content;
+        
+        if ($this->instance->pageid == SITEID) {
+            if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
+                $this->content = '';
+                return $this->content;
+            }
+        } else {
+            if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
+                $this->content = '';
+                return $this->content;
+            }
         }
 
-        $this->content = new object();
-        $this->content->items = array();
-        $this->content->icons = array();
-        $this->content->footer = '';
-
         $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
                                   $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
         $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
index 77d13f7b3c029c92dc33e92fabd5d7664e1b097c..870d2e82dea1d839bd6d17031c2fcaf6179f11e9 100644 (file)
@@ -597,6 +597,15 @@ $moodle_capabilities = array(
             'admin' => CAP_ALLOW
         )
     ),
+    
+    'moodle/site:viewparticipants' => array(
+
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'legacy' => array(
+            'admin' => CAP_ALLOW
+        )
+    ),
 
     'moodle/course:viewscales' => array(
 
index be147f3d77fcaf282f48058a78b1e99ff9a6e9da..f76090231dd7dff96c2bbd431297ac99c8617dce 100644 (file)
     require_login($course);
 
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+    $frontpagectx = get_context_instance(CONTEXT_COURSE, SITEID);
 
-    if (!has_capability('moodle/course:viewparticipants', $context)) {
-        print_error('nopermissions');
+    if ($context->id != $frontpagectx->id) {
+        if (!has_capability('moodle/course:viewparticipants', $context)) {
+            print_error('nopermissions');
+        }     
+    } else {
+        if (!has_capability('moodle/site:viewparticipants', $sitecontext)) {
+            print_error('nopermissions');
+        }
     }
 
+    /// front page course is different
     $rolenames = array();
     $avoidroles = array();
 
@@ -74,8 +82,9 @@
         }
     }
 
-    // no roles to display yet?
-    if (empty($rolenames)) {
+    // no roles to display yet? 
+    // frontpage course is an exception, on the front page course we should display all users
+    if (empty($rolenames) && $context->id != $frontpagectx->id) {
         if (has_capability('moodle/role:assign', $context)) {
             redirect($CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id);
         } else {
         }
     }
 
-
     /// Define a table showing a list of users in the current role selection
 
     $tablecolumns = array('userpic', 'fullname');
     } else {
         $selectrole = " ";
     }
-    $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
+    
+    if ($context->id != $frontpagectx->id) {
+        $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
                       u.email, u.city, u.country, u.picture,
                       u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
                       COALESCE(ul.timeaccess, 0) AS lastaccess,
                       r.hidden,
                       ctx.id AS ctxid, ctx.path AS ctxpath,
+                      ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel ';    
+        $select .= $course->enrolperiod?', r.timeend ':'';
+    } else {
+        $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
+                      u.email, u.city, u.country, u.picture,
+                      u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
+                      u.lastaccess,
+                      ctx.id AS ctxid, ctx.path AS ctxpath,
                       ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel ';
+     
+    }
 
-    $select .= $course->enrolperiod?', r.timeend ':'';
-
-    $from   = "FROM {$CFG->prefix}user u
-               LEFT OUTER JOIN {$CFG->prefix}context ctx
-                 ON (u.id=ctx.instanceid AND ctx.contextlevel = ".CONTEXT_USER.")
-               JOIN {$CFG->prefix}role_assignments r
-                 ON u.id=r.userid
-               LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul
-                 ON (r.userid=ul.userid and ul.courseid = $course->id) ";
-
+    if ($context->id != $frontpagectx->id) {
+        $from   = "FROM {$CFG->prefix}user u
+                LEFT OUTER JOIN {$CFG->prefix}context ctx
+                    ON (u.id=ctx.instanceid AND ctx.contextlevel = ".CONTEXT_USER.")
+                JOIN {$CFG->prefix}role_assignments r
+                    ON u.id=r.userid
+                LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul
+                    ON (r.userid=ul.userid and ul.courseid = $course->id) ";
+    } else {
+        $from = "FROM {$CFG->prefix}user u
+                LEFT OUTER JOIN {$CFG->prefix}context ctx
+                    ON (u.id=ctx.instanceid AND ctx.contextlevel = ".CONTEXT_USER.") ";               
+     
+    }
+    
     $hiddensql = has_capability('moodle/role:viewhiddenassigns', $context)? '':' AND r.hidden = 0 ';
 
     // exclude users with roles we are avoiding
     // join on 2 conditions
     // otherwise we run into the problem of having records in ul table, but not relevant course
     // and user record is not pulled out
-    $where  = "WHERE (r.contextid = $context->id OR r.contextid in $listofcontexts)
-        AND u.deleted = 0 $selectrole
-        AND (ul.courseid = $course->id OR ul.courseid IS NULL)
-        AND u.username != 'guest'
-        $adminroles
-        $hiddensql ";
-        $where .= get_lastaccess_sql($accesssince);
-
+    
+    if ($context->id != $frontpagectx->id) {
+        $where  = "WHERE (r.contextid = $context->id OR r.contextid in $listofcontexts)
+            AND u.deleted = 0 $selectrole
+            AND (ul.courseid = $course->id OR ul.courseid IS NULL)
+            AND u.username != 'guest'
+            $adminroles
+            $hiddensql ";
+            $where .= get_lastaccess_sql($accesssince);
+    } else {
+        $where = "WHERE u.deleted = 0
+            AND u.username != 'guest'";
+            $where .= get_lastaccess_sql($accesssince); 
+    }
     $wheresearch = '';
 
     if (!empty($search)) {
         if (has_capability('moodle/site:readallmessages', $context) && !empty($CFG->messaging)) {
             $displaylist['messageselect.php'] = get_string('messageselectadd');
         }
-        if (has_capability('moodle/notes:manage', $context)) {
+        if (has_capability('moodle/notes:manage', $context) && $context->id != $frontpagectx->id) {
             $displaylist['addnote.php'] = get_string('addnewnote', 'notes');
             $displaylist['groupaddnote.php'] = get_string('groupaddnewnote', 'notes');
         }
-        $displaylist['extendenrol.php'] = get_string('extendenrol');
-        $displaylist['groupextendenrol.php'] = get_string('groupextendenrol');
+        
+        if ($context->id != $frontpagectx->id) {
+            $displaylist['extendenrol.php'] = get_string('extendenrol');
+            $displaylist['groupextendenrol.php'] = get_string('groupextendenrol');
+        }
 
         helpbutton("participantswithselectedusers", get_string("withselectedusers"));
         choose_from_menu ($displaylist, "formaction", "", get_string("withselectedusers"), "if(checksubmit(this.form))this.form.submit();", "");
index 4990e582975f10d23feecf855741aef8159cac33..1822b19e3cfd608e6479a1e25d3cb6941b4acdb8 100644 (file)
@@ -34,7 +34,7 @@
         print_heading(format_string($site->fullname));
 
         if ($CFG->bloglevel >= 4) {
-            if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
+            if (has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
                 $toprow[] = new tabobject('participants', $CFG->wwwroot.'/user/index.php?id='.SITEID,
                     get_string('participants'));
             }
index 4452f3f579928d580652fe026b74f1f19d11231c..9fda03bfe75d76fb60b27557c0a54a3b95b9104b 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-    $version = 2007092806;  // YYYYMMDD = date
+    $version = 2007092807;  // YYYYMMDD = date
                             //       XY = increments within a single day
 
     $release = '1.9 Beta +';   // Human-friendly version name