1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace core_adminpresets\local\setting; 18 19 /** 20 * Select setting for blog's bloglevel setting. 21 * 22 * @package core_adminpresets 23 * @copyright 2021 Pimenko <support@pimenko.com><pimenko.com> 24 * @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David MonllaĆ³ <david.monllao@urv.cat> code 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 class adminpresets_admin_setting_bloglevel extends adminpresets_admin_setting_configselect { 28 29 /** 30 * Extended to change the block visibility. 31 * 32 * @param bool $name Setting name to store. 33 * @param mixed $value Setting value to store. 34 * @return int|false config_log inserted id or false whenever the value has not been saved. 35 */ 36 public function save_value($name = false, $value = null) { 37 global $DB; 38 39 if (!$id = parent::save_value($name, $value)) { 40 return false; 41 } 42 43 // Object values if no arguments. 44 if ($value === null) { 45 $value = $this->value; 46 } 47 48 // Pasted from admin_setting_bloglevel (can't use write_config). 49 if ($value == 0) { 50 $DB->set_field('block', 'visible', 0, ['name' => 'blog_menu']); 51 } else { 52 $DB->set_field('block', 'visible', 1, ['name' => 'blog_menu']); 53 } 54 55 return $id; 56 } 57 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body