]> git.mjollnir.org Git - moodle.git/commitdiff
DOn't show "Add" links if you can't use them
authormoodler <moodler>
Tue, 12 Sep 2006 08:28:36 +0000 (08:28 +0000)
committermoodler <moodler>
Tue, 12 Sep 2006 08:28:36 +0000 (08:28 +0000)
blocks/calendar_upcoming/block_calendar_upcoming.php

index b69b932329ef6b1180c865b2e4ce26029533f32c..f0e1566b80fe71042c7d8dc849103ad3f4d29118 100644 (file)
@@ -31,10 +31,13 @@ class block_calendar_upcoming extends block_base {
             $this->content->footer = '<br /><a href="'.$CFG->wwwroot.
                                      '/calendar/view.php?view=upcoming&amp;course='.$courseshown.'">'.
                                       get_string('gotocalendar', 'calendar').'</a>...';
-            $this->content->footer .= '<br /><a href="'.$CFG->wwwroot.
-                                      '/calendar/event.php?action=new&amp;course='.$courseshown.'">'.
-                                       get_string('newevent', 'calendar').'</a>...';
-            
+            $context = get_context_instance(CONTEXT_COURSE, $courseshown);
+            if (has_capability('moodle/calendar:manageentries', $context) ||
+                has_capability('moodle/calendar:manageownentries', $context)) {
+                $this->content->footer .= '<br /><a href="'.$CFG->wwwroot.
+                                          '/calendar/event.php?action=new&amp;course='.$courseshown.'">'.
+                                           get_string('newevent', 'calendar').'</a>...';
+            } 
             if ($courseshown == SITEID) {
                 // Being displayed at site level. This will cause the filter to fall back to auto-detecting
                 // the list of courses it will be grabbing events from.