]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12373 - More instances of links to the participants list being shown in the navig...
authortjhunt <tjhunt>
Thu, 10 Jan 2008 10:58:16 +0000 (10:58 +0000)
committertjhunt <tjhunt>
Thu, 10 Jan 2008 10:58:16 +0000 (10:58 +0000)
I have not copied and pasted the same code into lots of different places. That sucks. We really need to refactor this into a function that builds the navigation up to, and including the user's name. However, I don't have time now. A list of the places touched by this bug (MDL-12373) will at least give a complete list of places that such a refactoring would have to touch.

admin/roles/assign.php
admin/roles/override.php
course/user.php
mod/forum/user.php
notes/add.php
notes/delete.php
notes/edit.php
notes/edit_form.php
notes/index.php

index 537231a0f5d367288a2c97205fbd4a1bb73f89f6..2e46637536f83e7bd09f4fae294f96bb5ba66a51 100755 (executable)
         /// course header
         $navlinks = array();
         if ($courseid != SITEID) {
-            $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
+            if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
+                $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&amp;course=$courseid", 'type' => 'misc');
             $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
             $navigation = build_navigation($navlinks);
index 4432d6c426d827f369d6be6092676d7055843396..4a76aeb5a938dc86ddf5d42c2eeb17a359008169 100755 (executable)
         $navlinks = array();
         /// course header
         if ($course->id != SITEID) {
-            $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');
+            if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
+                $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&amp;course=$courseid", 'type' => 'misc');
             $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
             $navigation = build_navigation($navlinks);
index e10fa7f7294979e7b075524bc9f01832f2c49884..320284abfaa1d7779612c475e741a2589b3d0b30 100644 (file)
@@ -45,7 +45,7 @@
 
     $navlinks = array();
 
-    if ($course->id != SITEID) {
+    if ($course->id != SITEID && has_capability('moodle/course:viewparticipants', $coursecontext)) {
         $navlinks[] = array('name' => $strparticipants, 'link' => "../user/index.php?id=$course->id", 'type' => 'misc');
     }
 
index 39b537a53efd90e491cc29f50c80b29411f18529..29547316316d243351bb540de637fedb134fbe7f 100644 (file)
@@ -40,7 +40,9 @@
     $fullname        = fullname($user, has_capability('moodle/site:viewfullnames', $syscontext));
 
     $navlinks = array();
-    $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'core');
+    if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id)) || has_capability('moodle/site:viewparticipants', $syscontext)) {
+        $navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'core');
+    }
     $navlinks[] = array('name' => $fullname, 'link' => "$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id", 'type' => 'title');
     $navlinks[] = array('name' => $strforumposts, 'link' => '', 'type' => 'title');
     $navlinks[] = array('name' => $strmode, 'link' => '', 'type' => 'title');
index 28d5647a640f8f5fa9f7026bc487e2b29e4c339d..58b5cf44a30fff3ddd7999cbead7d0ad0197012a 100644 (file)
@@ -31,7 +31,7 @@
     require_once('edit_form.php');
 
 /// create form
-    $noteform = new note_edit_form(null, $extradata);
+    $noteform = new note_edit_form();
 
 /// if form was cancelled then return to the previous notes list
     if ($noteform->is_cancelled()) {
@@ -69,7 +69,9 @@
 
 /// output HTML
     $nav = array();
-    $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    if (has_capability('moodle/course:viewparticipants', $context) || has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
+        $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    }
     $nav[] = array('name' => fullname($user), 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id. '&amp;course=' . $course->id, 'type' => 'misc');
     $nav[] = array('name' => get_string('notes', 'notes'), 'link' => $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user=' . $user->id, 'type' => 'misc');
     $nav[] = array('name' => $strnotes, 'link' => '', 'type' => 'activity');
index 0ffe0ec7fc8d9905daf97af48a7ea065240dd6f6..dc17409b3ccaf8fae2db5a4cdde28f262d62c7a4 100644 (file)
@@ -15,6 +15,12 @@ if (!$note = note_load($noteid)) {
 if (!$course = get_record('course', 'id', $note->courseid)) {
     error('Incorrect course id found');
 }
+
+// locate user information
+    if (!$user = get_record('user', 'id', $note->userid)) {
+        error('Incorrect user id found');
+    }
+
 // require login to access notes
 require_login($course->id);
 
@@ -42,8 +48,13 @@ if (data_submitted() && confirm_sesskey()) {
     $optionsno = array('course'=>$course->id, 'user'=>$note->userid);
 
 // output HTML
-    $crumbs = array(array('name' => $strnotes, 'link' => '', 'type' => 'activity'));
-    print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($crumbs));
+    if (has_capability('moodle/course:viewparticipants', $context) || has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
+        $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    }
+    $nav[] = array('name' => fullname($user), 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id. '&amp;course=' . $course->id, 'type' => 'misc');
+    $nav[] = array('name' => get_string('notes', 'notes'), 'link' => $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user=' . $user->id, 'type' => 'misc');
+    $nav[] = array('name' => get_string('delete'), 'link' => '', 'type' => 'activity');
+    print_header($course->shortname . ': ' . $strnotes, $course->fullname, build_navigation($nav));
     notice_yesno(get_string('deleteconfirm', 'notes'), 'delete.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
     echo '<br />';
     note_print($note, NOTES_SHOW_BODY | NOTES_SHOW_HEAD);
index ba2238a0317527a88cc9509968df85a2bda11964..bf6f36f3714be3722ca0b306864f813dee4c0c52 100644 (file)
@@ -36,7 +36,7 @@
 /// get option values for the user select
 
 /// create form
-    $noteform = new note_edit_form(null);
+    $noteform = new note_edit_form();
 
 /// if form was cancelled then return to the notes list of the note
     if ($noteform->is_cancelled()) {
@@ -72,7 +72,9 @@
 
 /// output HTML
     $nav = array();
-    $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    if (has_capability('moodle/course:viewparticipants', $context) || has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
+        $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    }
     $nav[] = array('name' => fullname($user), 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id. '&amp;course=' . $course->id, 'type' => 'misc');
     $nav[] = array('name' => get_string('notes', 'notes'), 'link' => $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&amp;user=' . $user->id, 'type' => 'misc');
     $nav[] = array('name' => $strnotes, 'link' => '', 'type' => 'activity');
index ef39288f2e92380644d9f5d6a6c8fb95b1c77478..0eddb1366b5bd01867c3069888ad8798c5a65c60 100644 (file)
@@ -13,7 +13,6 @@ class note_edit_form extends moodleform {
         $mform->addElement('textarea', 'content', $strcontent, array('rows'=>15, 'cols'=>40));
         $mform->setType('content', PARAM_RAW);
         $mform->addRule('content', get_string('nocontent', 'notes'), 'required', null, 'client');
-        $mform->setHelpButton('content', 'writing');
 
         $mform->addElement('select', 'publishstate', $strpublishstate, note_get_state_names());
         $mform->setDefault('publishstate', NOTES_STATE_PUBLIC);
index e563e94c998c8a1d838b87f7c00fa98a40c26d14..3c2832c21a24be6aa2fabd93d4b3ce042968618f 100644 (file)
 
 
 /// output HTML
-
+    if ($course->id == SITEID) {
+        $coursecontext = get_context_instance(CONTEXT_SYSTEM);   // SYSTEM context
+    } else {
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);   // Course context
+    }
+    $systemcontext = get_context_instance(CONTEXT_SYSTEM);   // SYSTEM context
+    
     $strnotes = get_string('notes', 'notes');
     $nav = array();
-    $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
+        $nav[] = array('name' => get_string('participants'), 'link' => $CFG->wwwroot . '/user/index.php?id=' . $course->id, 'type' => 'misc');
+    }
     if ($userid) {
         $nav[] = array('name' => fullname($user), 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id. '&amp;course=' . $course->id, 'type' => 'misc');
     }