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 /** 18 * Class to display collection select for the refresh interval. 19 * 20 * @package core_calendar 21 * @copyright 2021 Huong Nguyen <huongnv13@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_calendar\output; 26 27 use core\output\inplace_editable; 28 29 class refreshintervalcollection extends inplace_editable { 30 31 /** 32 * Constructor. 33 * 34 * @param \stdClass $subscription Subscription object 35 */ 36 public function __construct(\stdClass $subscription) { 37 $collection = calendar_get_pollinterval_choices(); 38 parent::__construct('core_calendar', 'refreshinterval', $subscription->id, true, null, $subscription->pollinterval, null, 39 get_string('pollinterval', 'calendar')); 40 $this->set_type_select($collection); 41 } 42 43 public static function update(int $subscriptionid, int $pollinterval) { 44 if (calendar_can_edit_subscription($subscriptionid)) { 45 $subscription = calendar_get_subscription($subscriptionid); 46 $subscription->pollinterval = $pollinterval; 47 calendar_update_subscription($subscription); 48 $tmpl = new self($subscription); 49 return $tmpl; 50 } else { 51 throw new \moodle_exception('nopermissions', 'error', '', get_string('managesubscriptions', 'calendar')); 52 } 53 } 54 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body