]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19676 Properly hiding blog_menu from block dropdown when blogs are disabled....
authornicolasconnault <nicolasconnault>
Tue, 15 Sep 2009 07:19:03 +0000 (07:19 +0000)
committernicolasconnault <nicolasconnault>
Tue, 15 Sep 2009 07:19:03 +0000 (07:19 +0000)
admin/settings/appearance.php
admin/settings/subsystems.php
blocks/blog_menu/block_blog_menu.php
lib/adminlib.php

index 78d962fe88aa040c5585c313ff723ca5fe9f9434..f2242a0632a8034bebf57b139c15f52d008bee3a 100644 (file)
@@ -52,7 +52,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     // blog
     $temp = new admin_settingpage('blog', get_string('blog','blog'));
     $temp->add(new admin_setting_configcheckbox('useblogassociations', get_string('useblogassociations', 'blog'), get_string('configuseblogassociations','blog'), 1));
-    $temp->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'),
+    $temp->add(new admin_setting_bloglevel('bloglevel', get_string('bloglevel', 'admin'), get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'),
                                                                                                                                               4 => get_string('siteblogs','blog'),
                                                                                                                                               1 => get_string('personalblogs','blog'),
                                                                                                                                               0 => get_string('disableblogs','blog'))));
index 33b2fd2ab6cb051971d16921b3d61f319900e722..d5dad0943fe5b053d11e932318088186b9f81b5d 100644 (file)
@@ -21,11 +21,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
 
     $optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', get_string('enablerssfeeds', 'admin'), get_string('configenablerssfeeds', 'admin'), 0));
 
-    $optionalsubsystems->add(new admin_setting_configselect('bloglevel', get_string('bloglevel', 'admin'),
+    $optionalsubsystems->add(new admin_setting_bloglevel('bloglevel', get_string('bloglevel', 'admin'),
                                 get_string('configbloglevel', 'admin'), 4, array(5 => get_string('worldblogs','blog'),
                                                                                  4 => get_string('siteblogs','blog'),
-                                                                                 3 => get_string('courseblogs','blog'),
-                                                                                 2 => get_string('groupblogs','blog'),
                                                                                  1 => get_string('personalblogs','blog'),
                                                                                  0 => get_string('disableblogs','blog'))));
 
index 1a8941aaf91af7acbd460eadea7c6649b7996843..1bd1c4c12f2ee19319b10f7344aef4381ab9d229 100755 (executable)
@@ -57,13 +57,13 @@ class block_blog_menu extends block_base {
         $context = $PAGE->get_context();
 
         if (empty($CFG->bloglevel)) {
-            $this->content->text = '';
+            $this->content->text = get_string('blogdisable', 'blog');
             return $this->content;
         }
 
         // don't display menu block if block is set at site level, and user is not logged in
         if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL && !(isloggedin() && !isguest())) {
-            $this->content->text = '';
+            $this->content->text = get_string('blogdisable', 'blog');
             return $this->content;
         }
 
index 0865e57309bb6a9fa970dc981100ee50739f3301..3c39dcd45f37d5ddbaab82161c3af41cd486cf18 100644 (file)
@@ -2748,6 +2748,30 @@ class admin_setting_sitesetselect extends admin_setting_configselect {
     }
 }
 
+/**
+ * Select for blog's bloglevel setting: if set to 0, will set blog_menu
+ * block to hidden.
+ *
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class admin_setting_bloglevel extends admin_setting_configselect {
+    /**
+     * Updates the database and save the setting
+     *
+     * @param string data
+     * @return string empty or error message
+     */
+    public function write_setting($data) {
+        global $DB;
+        if ($data['bloglevel'] == 0) {
+            $DB->set_field('block', 'visible', 0, array('name' => 'blog_menu'));
+        } else {
+            $DB->set_field('block', 'visible', 1, array('name' => 'blog_menu'));
+        }
+        return parent::write_setting($data);
+    }
+}
+
 /**
  * Special select - lists on the frontpage - hacky
  *