mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-26859 automatically enable and disable blog related blocks when bloglevel changed
This commit is contained in:
parent
56babbcb76
commit
d9e0b80ffb
1 changed files with 12 additions and 3 deletions
|
@ -2971,11 +2971,20 @@ class admin_setting_bloglevel extends admin_setting_configselect {
|
||||||
* @return string empty or error message
|
* @return string empty or error message
|
||||||
*/
|
*/
|
||||||
public function write_setting($data) {
|
public function write_setting($data) {
|
||||||
global $DB;
|
global $DB, $CFG;
|
||||||
if ($data['bloglevel'] == 0) {
|
if ($data['bloglevel'] == 0) {
|
||||||
$DB->set_field('block', 'visible', 0, array('name' => 'blog_menu'));
|
$blogblocks = $DB->get_records_select('block', "name LIKE 'blog_%' AND visible = 1");
|
||||||
|
foreach ($blogblocks as $block) {
|
||||||
|
$DB->set_field('block', 'visible', 0, array('id' => $block->id));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$DB->set_field('block', 'visible', 1, array('name' => 'blog_menu'));
|
// reenable all blocks only when switching from disabled blogs
|
||||||
|
if (isset($CFG->bloglevel) and $CFG->bloglevel == 0) {
|
||||||
|
$blogblocks = $DB->get_records_select('block', "name LIKE 'blog_%' AND visible = 0");
|
||||||
|
foreach ($blogblocks as $block) {
|
||||||
|
$DB->set_field('block', 'visible', 1, array('id' => $block->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return parent::write_setting($data);
|
return parent::write_setting($data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue