]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10894 - Make block add/remove and edit permissions more consistent
authortjhunt <tjhunt>
Fri, 17 Aug 2007 13:07:23 +0000 (13:07 +0000)
committertjhunt <tjhunt>
Fri, 17 Aug 2007 13:07:23 +0000 (13:07 +0000)
blocks/moodleblock.class.php

index 730348b7bab400a577ed4ae267efa5d1a5226afc..49d369cd8ac36079f69d1e99cc4c8d5c1c69943f 100644 (file)
@@ -361,20 +361,24 @@ class block_base {
         }
         $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
      
-         // place holder for roles button
-         $movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$blockcontext->id.'">' .
+        // place holder for roles button
+        $movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$blockcontext->id.'">' .
                         '<img src="'.$CFG->pixpath.'/i/roles.gif" alt="'.$this->str->assignroles.'" /></a>';
      
-        $movebuttons .= '<a class="icon hide" title="'. $title .'" href="'.$script.'&amp;blockaction=toggle">' .
-                        '<img src="'. $CFG->pixpath.$icon .'" alt="'.$title.'" /></a>';
+        if ($this->user_can_edit()) {
+            $movebuttons .= '<a class="icon hide" title="'. $title .'" href="'.$script.'&amp;blockaction=toggle">' .
+                            '<img src="'. $CFG->pixpath.$icon .'" alt="'.$title.'" /></a>';
+        }
 
         if ($options & BLOCK_CONFIGURE && $this->user_can_edit()) {
             $movebuttons .= '<a class="icon edit" title="'. $this->str->configure .'" href="'.$script.'&amp;blockaction=config">' .
                             '<img src="'. $CFG->pixpath .'/t/edit.gif" alt="'. $this->str->configure .'" /></a>';
         }
 
-        $movebuttons .= '<a class="icon delete" title="'. $this->str->delete .'" href="'.$script.'&amp;blockaction=delete">' .
-                        '<img src="'. $CFG->pixpath .'/t/delete.gif" alt="'. $this->str->delete .'" /></a>';
+        if ($this->user_can_addto($page)) {
+            $movebuttons .= '<a class="icon delete" title="'. $this->str->delete .'" href="'.$script.'&amp;blockaction=delete">' .
+                            '<img src="'. $CFG->pixpath .'/t/delete.gif" alt="'. $this->str->delete .'" /></a>';
+        }
 
         if ($options & BLOCK_MOVE_LEFT) {
             $movebuttons .= '<a class="icon left" title="'. $this->str->moveleft .'" href="'.$script.'&amp;blockaction=moveleft">' .