See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]
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 mod_bigbluebuttonbn\local\helpers; 18 19 use calendar_event; 20 use mod_bigbluebuttonbn\instance; 21 use mod_bigbluebuttonbn\logger; 22 use mod_bigbluebuttonbn\plugin; 23 use stdClass; 24 25 /** 26 * Utility class for all instance (module) routines helper. 27 * 28 * @package mod_bigbluebuttonbn 29 * @copyright 2021 onwards, Blindside Networks Inc 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 * @author Laurent David (laurent [at] call-learning [dt] fr) 32 */ 33 class mod_helper { 34 35 /** 36 * Runs any processes that must run before a bigbluebuttonbn insert/update. 37 * 38 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 39 **/ 40 public static function process_pre_save(stdClass $bigbluebuttonbn) { 41 self::process_pre_save_instance($bigbluebuttonbn); 42 self::process_pre_save_checkboxes($bigbluebuttonbn); 43 self::process_pre_save_common($bigbluebuttonbn); 44 $bigbluebuttonbn->participants = htmlspecialchars_decode($bigbluebuttonbn->participants, ENT_COMPAT); 45 } 46 47 /** 48 * Runs process for defining the instance (insert/update). 49 * 50 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 51 **/ 52 protected static function process_pre_save_instance(stdClass $bigbluebuttonbn): void { 53 $bigbluebuttonbn->timemodified = time(); 54 if ((integer) $bigbluebuttonbn->instance == 0) { 55 $bigbluebuttonbn->meetingid = 0; 56 $bigbluebuttonbn->timecreated = time(); 57 $bigbluebuttonbn->timemodified = 0; 58 // As it is a new activity, assign passwords. 59 $bigbluebuttonbn->moderatorpass = plugin::random_password(12); 60 $bigbluebuttonbn->viewerpass = plugin::random_password(12, $bigbluebuttonbn->moderatorpass); 61 } 62 } 63 64 /** 65 * Runs process for assigning default value to checkboxes. 66 * 67 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 68 **/ 69 protected static function process_pre_save_checkboxes($bigbluebuttonbn) { 70 if (!isset($bigbluebuttonbn->wait)) { 71 $bigbluebuttonbn->wait = 0; 72 } 73 if (!isset($bigbluebuttonbn->record)) { 74 $bigbluebuttonbn->record = 0; 75 } 76 if (!isset($bigbluebuttonbn->recordallfromstart)) { 77 $bigbluebuttonbn->recordallfromstart = 0; 78 } 79 if (!isset($bigbluebuttonbn->recordhidebutton)) { 80 $bigbluebuttonbn->recordhidebutton = 0; 81 } 82 if (!isset($bigbluebuttonbn->recordings_html)) { 83 $bigbluebuttonbn->recordings_html = 0; 84 } 85 if (!isset($bigbluebuttonbn->recordings_deleted)) { 86 $bigbluebuttonbn->recordings_deleted = 0; 87 } 88 if (!isset($bigbluebuttonbn->recordings_imported)) { 89 $bigbluebuttonbn->recordings_imported = 0; 90 } 91 if (!isset($bigbluebuttonbn->recordings_preview)) { 92 $bigbluebuttonbn->recordings_preview = 0; 93 } 94 if (!isset($bigbluebuttonbn->muteonstart)) { 95 $bigbluebuttonbn->muteonstart = 0; 96 } 97 if (!isset($bigbluebuttonbn->disablecam)) { 98 $bigbluebuttonbn->disablecam = 0; 99 } 100 if (!isset($bigbluebuttonbn->disablemic)) { 101 $bigbluebuttonbn->disablemic = 0; 102 } 103 if (!isset($bigbluebuttonbn->disableprivatechat)) { 104 $bigbluebuttonbn->disableprivatechat = 0; 105 } 106 if (!isset($bigbluebuttonbn->disablepublicchat)) { 107 $bigbluebuttonbn->disablepublicchat = 0; 108 } 109 if (!isset($bigbluebuttonbn->disablenote)) { 110 $bigbluebuttonbn->disablenote = 0; 111 } 112 if (!isset($bigbluebuttonbn->hideuserlist)) { 113 $bigbluebuttonbn->hideuserlist = 0; 114 } 115 if (!isset($bigbluebuttonbn->lockedlayout)) { 116 $bigbluebuttonbn->lockedlayout = 0; 117 } 118 } 119 120 /** 121 * Runs process for wipping common settings when 'recordings only'. 122 * 123 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 124 **/ 125 protected static function process_pre_save_common(stdClass $bigbluebuttonbn): void { 126 // Make sure common settings are removed when 'recordings only'. 127 if ($bigbluebuttonbn->type == instance::TYPE_RECORDING_ONLY) { 128 $bigbluebuttonbn->groupmode = 0; 129 $bigbluebuttonbn->groupingid = 0; 130 } 131 } 132 133 /** 134 * Runs any processes that must be run after a bigbluebuttonbn insert/update. 135 * 136 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 137 **/ 138 public static function process_post_save(stdClass $bigbluebuttonbn): void { 139 self::process_post_save_event($bigbluebuttonbn); 140 self::process_post_save_completion($bigbluebuttonbn); 141 } 142 143 /** 144 * Generates an event after a bigbluebuttonbn insert/update. 145 * 146 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 147 **/ 148 protected static function process_post_save_event(stdClass $bigbluebuttonbn): void { 149 global $CFG, $DB; 150 151 require_once($CFG->dirroot . '/calendar/lib.php'); 152 $eventid = $DB->get_field('event', 'id', [ 153 'modulename' => 'bigbluebuttonbn', 154 'instance' => $bigbluebuttonbn->id, 155 'eventtype' => logger::EVENT_MEETING_START 156 ]); 157 158 // Delete the event from calendar when/if openingtime is NOT set. 159 if (!isset($bigbluebuttonbn->openingtime) || !$bigbluebuttonbn->openingtime) { 160 if ($eventid) { 161 $calendarevent = calendar_event::load($eventid); 162 $calendarevent->delete(); 163 } 164 return; 165 } 166 167 // Add event to the calendar as openingtime is set. 168 $event = (object) [ 169 'eventtype' => logger::EVENT_MEETING_START, 170 'type' => CALENDAR_EVENT_TYPE_ACTION, 171 'name' => get_string('calendarstarts', 'bigbluebuttonbn', $bigbluebuttonbn->name), 172 'description' => format_module_intro('bigbluebuttonbn', $bigbluebuttonbn, $bigbluebuttonbn->coursemodule, false), 173 'format' => FORMAT_HTML, 174 'courseid' => $bigbluebuttonbn->course, 175 'groupid' => 0, 176 'userid' => 0, 177 'modulename' => 'bigbluebuttonbn', 178 'instance' => $bigbluebuttonbn->id, 179 'timestart' => $bigbluebuttonbn->openingtime, 180 'timeduration' => 0, 181 'timesort' => $bigbluebuttonbn->openingtime, 182 'visible' => instance_is_visible('bigbluebuttonbn', $bigbluebuttonbn), 183 'priority' => null, 184 ]; 185 186 // Update the event in calendar when/if eventid was found. 187 if ($eventid) { 188 $event->id = $eventid; 189 $calendarevent = calendar_event::load($eventid); 190 $calendarevent->update($event); 191 return; 192 } 193 calendar_event::create($event); 194 } 195 196 /** 197 * Generates an event after a bigbluebuttonbn activity is completed. 198 * 199 * @param stdClass $bigbluebuttonbn BigBlueButtonBN form data 200 **/ 201 protected static function process_post_save_completion(stdClass $bigbluebuttonbn): void { 202 if (empty($bigbluebuttonbn->completionexpected)) { 203 return; 204 } 205 \core_completion\api::update_completion_date_event( 206 $bigbluebuttonbn->coursemodule, 207 'bigbluebuttonbn', 208 $bigbluebuttonbn->id, 209 $bigbluebuttonbn->completionexpected 210 ); 211 } 212 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body