Skip to content

Commit

Permalink
MDL-19676 Properly hiding blog_menu from block dropdown when blogs ar…
Browse files Browse the repository at this point in the history
…e disabled. Also showing "Blogs are disabled" in existing blog_menu blocks and removing old bloglevel options from subsystems settings
  • Loading branch information
nicolasconnault committed Sep 15, 2009
1 parent 0352a31 commit ca497f4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin/settings/appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
// 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'))));
Expand Down
4 changes: 1 addition & 3 deletions admin/settings/subsystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

$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'))));

Expand Down
4 changes: 2 additions & 2 deletions blocks/blog_menu/block_blog_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ function get_content() {
$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;
}

Expand Down
24 changes: 24 additions & 0 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2748,6 +2748,30 @@ public function write_setting($data) {
}
}

/**
* 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
*
Expand Down

0 comments on commit ca497f4

Please sign in to comment.