diff --git a/backup/moodle2/restore_zoom_stepslib.php b/backup/moodle2/restore_zoom_stepslib.php index 1f4d61f4..8997bc47 100755 --- a/backup/moodle2/restore_zoom_stepslib.php +++ b/backup/moodle2/restore_zoom_stepslib.php @@ -29,6 +29,7 @@ require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use moodle_exception; use restore_path_element; /** diff --git a/classes/analytics/indicator/activity_base.php b/classes/analytics/indicator/activity_base.php index d055266f..c41614f2 100644 --- a/classes/analytics/indicator/activity_base.php +++ b/classes/analytics/indicator/activity_base.php @@ -24,10 +24,12 @@ namespace mod_zoom\analytics\indicator; +use core_analytics\local\indicator\community_of_inquiry_activity; + /** * Activity base class. */ -abstract class activity_base extends \core_analytics\local\indicator\community_of_inquiry_activity { +abstract class activity_base extends community_of_inquiry_activity { /** * Grading not implemented. * diff --git a/classes/analytics/indicator/cognitive_depth.php b/classes/analytics/indicator/cognitive_depth.php index 88c3f69a..e265e1d1 100644 --- a/classes/analytics/indicator/cognitive_depth.php +++ b/classes/analytics/indicator/cognitive_depth.php @@ -24,6 +24,9 @@ namespace mod_zoom\analytics\indicator; +use cm_info; +use lang_string; + /** * Cognitive depth indicator - zoom. */ @@ -33,8 +36,8 @@ class cognitive_depth extends activity_base { * * @return object */ - public static function get_name(): \lang_string { - return new \lang_string('indicator:cognitivedepth', 'mod_zoom'); + public static function get_name(): lang_string { + return new lang_string('indicator:cognitivedepth', 'mod_zoom'); } /** @@ -53,7 +56,7 @@ public function get_indicator_type() { * * @return integer */ - public function get_cognitive_depth_level(\cm_info $cm) { + public function get_cognitive_depth_level(cm_info $cm) { return self::COGNITIVE_LEVEL_1; } } diff --git a/classes/analytics/indicator/social_breadth.php b/classes/analytics/indicator/social_breadth.php index 2cf3ac87..5bb8a948 100644 --- a/classes/analytics/indicator/social_breadth.php +++ b/classes/analytics/indicator/social_breadth.php @@ -24,6 +24,9 @@ namespace mod_zoom\analytics\indicator; +use cm_info; +use lang_string; + /** * Social breadth indicator. */ @@ -35,8 +38,8 @@ class social_breadth extends activity_base { * * @return object */ - public static function get_name(): \lang_string { - return new \lang_string('indicator:socialbreadth', 'mod_zoom'); + public static function get_name(): lang_string { + return new lang_string('indicator:socialbreadth', 'mod_zoom'); } /** @@ -55,7 +58,7 @@ public function get_indicator_type() { * * @return integer */ - public function get_social_breadth_level(\cm_info $cm) { + public function get_social_breadth_level(cm_info $cm) { return self::SOCIAL_LEVEL_2; } } diff --git a/classes/api_limit_exception.php b/classes/api_limit_exception.php index e04d04f5..d3297b71 100644 --- a/classes/api_limit_exception.php +++ b/classes/api_limit_exception.php @@ -24,6 +24,8 @@ namespace mod_zoom; +use stdClass; + /** * Exceeded daily API limit. */ @@ -43,7 +45,7 @@ class api_limit_exception extends webservice_exception { public function __construct($response, $errorcode, $retryafter) { $this->retryafter = $retryafter; - $a = new \stdClass(); + $a = new stdClass(); $a->response = $response; parent::__construct( $response, diff --git a/classes/event/join_meeting_button_clicked.php b/classes/event/join_meeting_button_clicked.php index 73c8d6dd..bda3a1a6 100644 --- a/classes/event/join_meeting_button_clicked.php +++ b/classes/event/join_meeting_button_clicked.php @@ -24,6 +24,9 @@ namespace mod_zoom\event; +use coding_exception; +use moodle_url; + /** * Records when a join meeting button is clicked. */ @@ -44,9 +47,9 @@ protected function validate_data() { $fieldstovalidate = ['cmid' => "integer", 'meetingid' => "integer", 'userishost' => "boolean"]; foreach ($fieldstovalidate as $field => $shouldbe) { if (is_null($this->other[$field])) { - throw new \coding_exception("The $field value must be set in other."); + throw new coding_exception("The $field value must be set in other."); } else if (gettype($this->other[$field]) != $shouldbe) { - throw new \coding_exception("The $field value must be an $shouldbe."); + throw new coding_exception("The $field value must be an $shouldbe."); } } } @@ -76,6 +79,6 @@ public function get_description() { * @return moodle_url */ public function get_url() { - return new \moodle_url('/mod/zoom/view.php', ['id' => $this->other['cmid']]); + return new moodle_url('/mod/zoom/view.php', ['id' => $this->other['cmid']]); } } diff --git a/classes/invitation.php b/classes/invitation.php index a784c2eb..d6bd9c36 100644 --- a/classes/invitation.php +++ b/classes/invitation.php @@ -25,6 +25,10 @@ namespace mod_zoom; +use coding_exception; +use context_module; +use moodle_exception; + /** * Invitation class. */ @@ -81,11 +85,11 @@ public function get_display_string(int $coursemoduleid, int $userid = null) { } // Check user capabilities, and remove parts of the invitation they don't have permission to view. - if (!has_capability('mod/zoom:viewjoinurl', \context_module::instance($coursemoduleid), $userid)) { + if (!has_capability('mod/zoom:viewjoinurl', context_module::instance($coursemoduleid), $userid)) { $displaystring = $this->remove_element($displaystring, 'joinurl'); } - if (!has_capability('mod/zoom:viewdialin', \context_module::instance($coursemoduleid), $userid)) { + if (!has_capability('mod/zoom:viewdialin', context_module::instance($coursemoduleid), $userid)) { $displaystring = $this->remove_element($displaystring, 'onetapmobile'); $displaystring = $this->remove_element($displaystring, 'dialin'); $displaystring = $this->remove_element($displaystring, 'sip'); @@ -94,7 +98,7 @@ public function get_display_string(int $coursemoduleid, int $userid = null) { // Fix the formatting of the onetapmobile section if it exists. $displaystring = $this->add_paragraph_break_above_element($displaystring, 'onetapmobile'); } - } catch (\moodle_exception $e) { + } catch (moodle_exception $e) { // If the regex parsing fails, log a debugging message and return the whole invitation. debugging($e->getMessage(), DEBUG_DEVELOPER); return $this->invitation; @@ -120,7 +124,7 @@ private function remove_element(string $invitation, string $element): string { $configregex = $this->get_config_invitation_regex(); if (!array_key_exists($element, $configregex)) { - throw new \coding_exception('Cannot remove element: ' . $element + throw new coding_exception('Cannot remove element: ' . $element . '. See mod/zoom/classes/invitation.php:get_default_invitation_regex for valid elements.'); } @@ -134,7 +138,7 @@ private function remove_element(string $invitation, string $element): string { // If invitation is null, an error occurred in preg_replace. if ($invitation === null) { - throw new \moodle_exception( + throw new moodle_exception( 'invitationmodificationfailed', 'mod_zoom', $PAGE->url, diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index dafb19f0..0796c31d 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -25,20 +25,31 @@ namespace mod_zoom\privacy; +use context; +use context_module; +use core_privacy\local\metadata\collection; +use core_privacy\local\metadata\provider as metadata_provider; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\approved_userlist; +use core_privacy\local\request\contextlist; +use core_privacy\local\request\core_userlist_provider; +use core_privacy\local\request\helper; +use core_privacy\local\request\plugin\provider as request_plugin_provider; +use core_privacy\local\request\transform; +use core_privacy\local\request\userlist; +use core_privacy\local\request\writer; + /** * Ad hoc task that performs the actions for approved data privacy requests. */ -class provider implements - \core_privacy\local\request\core_userlist_provider, - \core_privacy\local\metadata\provider, - \core_privacy\local\request\plugin\provider { +class provider implements core_userlist_provider, metadata_provider, request_plugin_provider { /** * Returns meta data about this system. * * @param collection $coll The collection to add metadata to. * @return collection The array of metadata */ - public static function get_metadata(\core_privacy\local\metadata\collection $coll): \core_privacy\local\metadata\collection { + public static function get_metadata(collection $coll): collection { // Add all user data fields to the collection. $coll->add_database_table('zoom_meeting_participants', [ @@ -76,10 +87,10 @@ public static function get_metadata(\core_privacy\local\metadata\collection $col * @param int $userid The user to search. * @return contextlist $contextlist The list of contexts used in this plugin. */ - public static function get_contexts_for_userid(int $userid): \core_privacy\local\request\contextlist { + public static function get_contexts_for_userid(int $userid): contextlist { // Query the database for context IDs give a specific user ID and return these to the user. - $contextlist = new \core_privacy\local\request\contextlist(); + $contextlist = new contextlist(); $sql = 'SELECT c.id FROM {context} c @@ -110,10 +121,10 @@ public static function get_contexts_for_userid(int $userid): \core_privacy\local * * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination. */ - public static function get_users_in_context(\core_privacy\local\request\userlist $userlist) { + public static function get_users_in_context(userlist $userlist) { $context = $userlist->get_context(); - if (!($context instanceof \context_module)) { + if (!($context instanceof context_module)) { return; } @@ -159,7 +170,7 @@ public static function get_users_in_context(\core_privacy\local\request\userlist * @param approved_contextlist $contextlist The approved contexts to export information for. * @link http://tandl.churchward.ca/2018/06/implementing-moodles-privacy-api-in.html */ - public static function export_user_data(\core_privacy\local\request\approved_contextlist $contextlist) { + public static function export_user_data(approved_contextlist $contextlist) { global $DB; if (empty($contextlist->count())) { @@ -197,20 +208,20 @@ public static function export_user_data(\core_privacy\local\request\approved_con $participantinstances = $DB->get_recordset_sql($sql, $params); foreach ($participantinstances as $participantinstance) { - $context = \context_module::instance($participantinstance->cmid); - $contextdata = \core_privacy\local\request\helper::get_context_data($context, $user); + $context = context_module::instance($participantinstance->cmid); + $contextdata = helper::get_context_data($context, $user); $instancedata = [ 'topic' => $participantinstance->topic, 'participant_name' => $participantinstance->name, 'user_email' => $participantinstance->user_email, - 'join_time' => \core_privacy\local\request\transform::datetime($participantinstance->join_time), - 'leave_time' => \core_privacy\local\request\transform::datetime($participantinstance->leave_time), + 'join_time' => transform::datetime($participantinstance->join_time), + 'leave_time' => transform::datetime($participantinstance->leave_time), 'duration' => $participantinstance->duration, ]; $contextdata = (object) array_merge((array) $contextdata, $instancedata); - \core_privacy\local\request\writer::with_context($context)->export_data([], $contextdata); + writer::with_context($context)->export_data([], $contextdata); } $participantinstances->close(); @@ -240,18 +251,18 @@ public static function export_user_data(\core_privacy\local\request\approved_con $recordingviewinstances = $DB->get_recordset_sql($sql, $params); foreach ($recordingviewinstances as $recordingviewinstance) { - $context = \context_module::instance($recordingviewinstance->cmid); - $contextdata = \core_privacy\local\request\helper::get_context_data($context, $user); + $context = context_module::instance($recordingviewinstance->cmid); + $contextdata = helper::get_context_data($context, $user); $instancedata = [ 'recording_name' => $recordingviewinstance->name, 'userid' => $recordingviewinstance->userid, 'viewed' => $recordingviewinstance->viewed, - 'timemodified' => \core_privacy\local\request\transform::datetime($recordingviewinstance->timemodified), + 'timemodified' => transform::datetime($recordingviewinstance->timemodified), ]; $contextdata = (object) array_merge((array) $contextdata, $instancedata); - \core_privacy\local\request\writer::with_context($context)->export_data([], $contextdata); + writer::with_context($context)->export_data([], $contextdata); } $recordingviewinstances->close(); @@ -262,10 +273,10 @@ public static function export_user_data(\core_privacy\local\request\approved_con * * @param context $context Context to delete data from. */ - public static function delete_data_for_all_users_in_context(\context $context) { + public static function delete_data_for_all_users_in_context(context $context) { global $DB; - if (!($context instanceof \context_module)) { + if (!($context instanceof context_module)) { return; } @@ -299,7 +310,7 @@ public static function delete_data_for_all_users_in_context(\context $context) { * * @param approved_contextlist $contextlist The approved contexts and user information to delete information for. */ - public static function delete_data_for_user(\core_privacy\local\request\approved_contextlist $contextlist) { + public static function delete_data_for_user(approved_contextlist $contextlist) { global $DB; if (empty($contextlist->count())) { @@ -309,7 +320,7 @@ public static function delete_data_for_user(\core_privacy\local\request\approved $user = $contextlist->get_user(); foreach ($contextlist->get_contexts() as $context) { - if (!($context instanceof \context_module)) { + if (!($context instanceof context_module)) { continue; } @@ -337,11 +348,11 @@ public static function delete_data_for_user(\core_privacy\local\request\approved * * @param approved_userlist $userlist The approved context and user information to delete information for. */ - public static function delete_data_for_users(\core_privacy\local\request\approved_userlist $userlist) { + public static function delete_data_for_users(approved_userlist $userlist) { global $DB; $context = $userlist->get_context(); - if (!($context instanceof \context_module)) { + if (!($context instanceof context_module)) { return; } diff --git a/classes/retry_failed_exception.php b/classes/retry_failed_exception.php index 654f2ea5..fec676de 100644 --- a/classes/retry_failed_exception.php +++ b/classes/retry_failed_exception.php @@ -24,6 +24,8 @@ namespace mod_zoom; +use stdClass; + /** * Couldn't succeed within the allowed number of retries. */ @@ -34,7 +36,7 @@ class retry_failed_exception extends webservice_exception { * @param int $errorcode Web service response error code */ public function __construct($response, $errorcode) { - $a = new \stdClass(); + $a = new stdClass(); $a->response = $response; $a->maxretries = webservice::MAX_RETRIES; parent::__construct($response, $errorcode, 'zoomerr_maxretries', 'mod_zoom', '', $a); diff --git a/classes/search/activity.php b/classes/search/activity.php index 5a43a87a..a97c0c8d 100644 --- a/classes/search/activity.php +++ b/classes/search/activity.php @@ -24,10 +24,12 @@ namespace mod_zoom\search; +use core_search\base_activity; + /** * Search area for mod_zoom activities. */ -class activity extends \core_search\base_activity { +class activity extends base_activity { /** * Returns true if this area uses file indexing. * diff --git a/classes/task/delete_meeting_recordings.php b/classes/task/delete_meeting_recordings.php index 5a8ac1ea..e1756a12 100644 --- a/classes/task/delete_meeting_recordings.php +++ b/classes/task/delete_meeting_recordings.php @@ -29,10 +29,13 @@ require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use core\task\scheduled_task; +use moodle_exception; + /** * Scheduled task to delete meeting recordings from Moodle. */ -class delete_meeting_recordings extends \core\task\scheduled_task { +class delete_meeting_recordings extends scheduled_task { /** * Returns name of task. * @@ -52,7 +55,7 @@ public function execute() { try { $service = zoom_webservice(); - } catch (\moodle_exception $exception) { + } catch (moodle_exception $exception) { mtrace('Skipping task - ', $exception->getMessage()); return; } diff --git a/classes/task/get_meeting_recordings.php b/classes/task/get_meeting_recordings.php index 57474b14..97457569 100644 --- a/classes/task/get_meeting_recordings.php +++ b/classes/task/get_meeting_recordings.php @@ -29,10 +29,14 @@ require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use core\task\scheduled_task; +use moodle_exception; +use stdClass; + /** * Scheduled task to get the meeting recordings. */ -class get_meeting_recordings extends \core\task\scheduled_task { +class get_meeting_recordings extends scheduled_task { /** * Returns name of task. * @@ -52,7 +56,7 @@ public function execute() { try { $service = zoom_webservice(); - } catch (\moodle_exception $exception) { + } catch (moodle_exception $exception) { mtrace('Skipping task - ', $exception->getMessage()); return; } @@ -131,7 +135,7 @@ public function execute() { $recordingtype = $recording->recordingtype; $recordingtypestring = $recordingtypestrings[$recordingtype]; - $record = new \stdClass(); + $record = new stdClass(); $record->zoomid = $zoom->id; $record->meetinguuid = $recording->meetinguuid; $record->zoomrecordingid = $recordingid; diff --git a/classes/task/get_meeting_reports.php b/classes/task/get_meeting_reports.php index e83296d1..1ba53d1e 100644 --- a/classes/task/get_meeting_reports.php +++ b/classes/task/get_meeting_reports.php @@ -29,10 +29,19 @@ require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use context_course; +use core\task\scheduled_task; +use dml_exception; +use mod_zoom\not_found_exception; +use mod_zoom\retry_failed_exception; +use mod_zoom\webservice_exception; +use moodle_exception; +use stdClass; + /** * Scheduled task to get the meeting participants for each . */ -class get_meeting_reports extends \core\task\scheduled_task { +class get_meeting_reports extends scheduled_task { /** * Percentage in which we want similar_text to reach before we consider * using its results. @@ -77,7 +86,7 @@ private function cmp($a, $b) { public function execute($paramstart = null, $paramend = null, $hostuuids = null) { try { $this->service = zoom_webservice(); - } catch (\moodle_exception $exception) { + } catch (moodle_exception $exception) { mtrace('Skipping task - ', $exception->getMessage()); return; } @@ -289,7 +298,7 @@ public function format_participant($participant, $detailsid, $names, $emails) { */ public function get_enrollments($courseid) { // Loop through each user to generate name->uids mapping. - $coursecontext = \context_course::instance($courseid); + $coursecontext = context_course::instance($courseid); $enrolled = get_enrolled_users($coursecontext); $names = []; $emails = []; @@ -345,12 +354,12 @@ public function get_meetings_via_reports($start, $end, $hostuuids) { $this->debugmsg('Getting meetings for host uuid ' . $activehostsuuid); try { $usersmeetings = $this->service->get_user_report($activehostsuuid, $start, $end); - } catch (\mod_zoom\not_found_exception $e) { + } catch (not_found_exception $e) { // Zoom API returned user not found for a user it said had, // meetings. Have to skip user. $this->debugmsg("Skipping $activehostsuuid because user does not exist on Zoom"); continue; - } catch (\mod_zoom\retry_failed_exception $e) { + } catch (retry_failed_exception $e) { // Hit API limit, so cannot continue. mtrace($e->response . ': ' . $e->zoomerrorcode); return; @@ -504,10 +513,10 @@ public function process_meeting_reports($meeting) { try { $participants = $this->service->get_meeting_participants($meeting->uuid, $zoomrecord->webinar); - } catch (\mod_zoom\not_found_exception $e) { + } catch (not_found_exception $e) { mtrace(sprintf('Warning: Cannot find meeting %s|%s; skipping', $meeting->meeting_id, $meeting->uuid)); return true; // Not really a show stopping error. - } catch (\mod_zoom\webservice_exception $e) { + } catch (webservice_exception $e) { mtrace($e->response . ': ' . $e->zoomerrorcode); return false; } @@ -542,7 +551,7 @@ public function process_meeting_reports($meeting) { } $transaction->allow_commit(); - } catch (\dml_exception $exception) { + } catch (dml_exception $exception) { $transaction->rollback($exception); mtrace('ERROR: Cannot insert zoom_meeting_participants: ' . $exception->getMessage()); return false; @@ -561,7 +570,7 @@ public function process_meeting_reports($meeting) { * @return object Normalized meeting object */ public function normalize_meeting($meeting) { - $normalizedmeeting = new \stdClass(); + $normalizedmeeting = new stdClass(); // Returned meeting object will not be using Zoom's id, because it is a // primary key in our own tables. diff --git a/classes/task/update_meetings.php b/classes/task/update_meetings.php index ecdcf573..dca6b188 100644 --- a/classes/task/update_meetings.php +++ b/classes/task/update_meetings.php @@ -31,10 +31,15 @@ require_once($CFG->dirroot . '/mod/zoom/lib.php'); require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use core\task\scheduled_task; +use mod_zoom\not_found_exception; +use moodle_exception; +use moodle_url; + /** * Scheduled task to sychronize meeting data. */ -class update_meetings extends \core\task\scheduled_task { +class update_meetings extends scheduled_task { /** * Returns name of task. * @@ -54,7 +59,7 @@ public function execute() { try { $service = zoom_webservice(); - } catch (\moodle_exception $exception) { + } catch (moodle_exception $exception) { mtrace('Skipping task - ', $exception->getMessage()); return; } @@ -72,7 +77,7 @@ public function execute() { mtrace('Processing next Zoom meeting activity ...'); mtrace(' Zoom meeting ID: ' . $zoom->meeting_id); mtrace(' Zoom meeting title: ' . $zoom->name); - $zoomactivityurl = new \moodle_url('/mod/zoom/view.php', ['n' => $zoom->id]); + $zoomactivityurl = new moodle_url('/mod/zoom/view.php', ['n' => $zoom->id]); mtrace(' Zoom meeting activity URL: ' . $zoomactivityurl->out()); mtrace(' Moodle course ID: ' . $zoom->course); @@ -80,14 +85,14 @@ public function execute() { try { $response = $service->get_meeting_webinar_info($zoom->meeting_id, $zoom->webinar); $gotinfo = true; - } catch (\mod_zoom\not_found_exception $error) { + } catch (not_found_exception $error) { $zoom->exists_on_zoom = ZOOM_MEETING_EXPIRED; $DB->update_record('zoom', $zoom); // Show trace message. mtrace(' => Marked Zoom meeting activity for Zoom meeting ID ' . $zoom->meeting_id . ' as not existing anymore on Zoom'); - } catch (\moodle_exception $error) { + } catch (moodle_exception $error) { // Show trace message. mtrace(' !! Error updating Zoom meeting activity for Zoom meeting ID ' . $zoom->meeting_id . ': ' . $error); } diff --git a/classes/task/update_tracking_fields.php b/classes/task/update_tracking_fields.php index 1bc08cca..8484297b 100644 --- a/classes/task/update_tracking_fields.php +++ b/classes/task/update_tracking_fields.php @@ -29,10 +29,13 @@ require_once($CFG->dirroot . '/mod/zoom/lib.php'); require_once($CFG->dirroot . '/mod/zoom/locallib.php'); +use core\task\scheduled_task; +use moodle_exception; + /** * Scheduled task to sychronize tracking field data. */ -class update_tracking_fields extends \core\task\scheduled_task { +class update_tracking_fields extends scheduled_task { /** * Returns name of task. * @@ -50,7 +53,7 @@ public function get_name() { public function execute() { try { zoom_webservice(); - } catch (\moodle_exception $exception) { + } catch (moodle_exception $exception) { mtrace('Skipping task - ', $exception->getMessage()); return; } diff --git a/classes/webservice.php b/classes/webservice.php index 35257c45..645dbc13 100644 --- a/classes/webservice.php +++ b/classes/webservice.php @@ -29,6 +29,9 @@ require_once($CFG->dirroot . '/mod/zoom/locallib.php'); require_once($CFG->libdir . '/filelib.php'); +use cache; +use core_user; +use curl; use moodle_exception; use stdClass; @@ -205,7 +208,7 @@ protected function get_curl_object() { } // Create $curl, which implicitly uses the proxy settings from $CFG. - $curl = new \curl(); + $curl = new curl(); if (!empty($proxyhost)) { // Restore the stored global proxy settings from above. @@ -430,7 +433,7 @@ private function paid_user_limit_reached() { foreach ($userslist as $user) { if ($user->type != ZOOM_USER_TYPE_BASIC) { // Count the user if we're including all users or if the user is on this instance. - if (!$this->instanceusers || \core_user::get_user_by_email($user->email)) { + if (!$this->instanceusers || core_user::get_user_by_email($user->email)) { $numusers++; if ($numusers >= $this->numlicenses) { return true; @@ -453,7 +456,7 @@ private function get_least_recently_active_paid_user_id() { foreach ($userslist as $user) { if ($user->type != ZOOM_USER_TYPE_BASIC && isset($user->last_login_time)) { // Count the user if we're including all users or if the user is on this instance. - if (!$this->instanceusers || \core_user::get_user_by_email($user->email)) { + if (!$this->instanceusers || core_user::get_user_by_email($user->email)) { $usertimes[$user->id] = strtotime($user->last_login_time); } } @@ -1076,7 +1079,7 @@ public function get_user_recordings($userid, $from, $to) { * @return string access token */ protected function get_access_token() { - $cache = \cache::make('mod_zoom', 'oauth'); + $cache = cache::make('mod_zoom', 'oauth'); $token = $cache->get('accesstoken'); $expires = $cache->get('expires'); if (empty($token) || empty($expires) || time() >= $expires) { diff --git a/classes/webservice_exception.php b/classes/webservice_exception.php index 1b12d22d..7e7ea4b1 100644 --- a/classes/webservice_exception.php +++ b/classes/webservice_exception.php @@ -24,10 +24,12 @@ namespace mod_zoom; +use moodle_exception; + /** * Webservice exception class. */ -class webservice_exception extends \moodle_exception { +class webservice_exception extends moodle_exception { /** * Web service response. * @var string diff --git a/tests/mod_zoom_invitation_test.php b/tests/mod_zoom_invitation_test.php index 477e3482..26f23dc0 100644 --- a/tests/mod_zoom_invitation_test.php +++ b/tests/mod_zoom_invitation_test.php @@ -58,7 +58,7 @@ public function test_display_message_when_user_has_all_capabilities(): void { $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -121,7 +121,7 @@ public function test_display_message_when_user_has_viewjoinurl_capability(): voi $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); assign_capability('mod/zoom:viewjoinurl', CAP_ALLOW, $role, context_system::instance()->id); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -149,7 +149,7 @@ public function test_display_message_when_user_has_viewdialin_capability(): void $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); assign_capability('mod/zoom:viewdialin', CAP_ALLOW, $role, context_system::instance()); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -205,7 +205,7 @@ public function test_display_message_when_user_has_no_capabilities(): void { $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -230,7 +230,7 @@ public function test_display_message_when_a_regex_pattern_is_empty(): void { role_assign($role, $user->id, context_course::instance($course->id)); // Set mock zoom activity URL for page as exception messages expect it. $PAGE->set_url(new moodle_url('/mod/zoom/view.php?id=123')); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingNotCalled(); @@ -251,7 +251,7 @@ public function test_display_message_when_a_regex_pattern_is_invalid(): void { role_assign($role, $user->id, context_course::instance($course->id)); // Set mock zoom activity URL for page as exception messages expect it. $PAGE->set_url(new moodle_url('/mod/zoom/view.php?id=123')); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingCalled('Error in regex for zoom invitation element: "joinurl" with pattern: "~".'); @@ -269,7 +269,7 @@ public function test_display_message_when_a_regex_pattern_is_finds_no_match(): v $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $this->assertDebuggingCalled('No match found in zoom invitation for element: "joinurl" with pattern: "/nomatch/mi".'); @@ -284,7 +284,7 @@ public function test_display_message_has_invite_removed_if_setting_enabled(): vo set_config('invitationremoveinvite', '1', 'zoom'); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid); $expectedmessage = "Topic: Zoom Meeting\r\n" @@ -342,7 +342,7 @@ public function test_display_message_does_not_have_invite_removed_if_setting_dis set_config('invitationremoveinvite', '0', 'zoom'); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -404,7 +404,7 @@ public function test_display_message_has_icallink_removed_if_setting_enabled(): $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); // Test a scheduled meeting. - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -455,7 +455,7 @@ public function test_display_message_has_icallink_removed_if_setting_enabled(): $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with no fixed time. - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_recurringnofixed() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -506,7 +506,7 @@ public function test_display_message_has_icallink_removed_if_setting_enabled(): $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with fixed time. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); + $message = (new invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" . "\r\n" . "Topic: Zoom Meeting\r\n" @@ -577,7 +577,7 @@ public function test_display_message_does_not_have_icallink_removed_if_setting_d $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); // Test a scheduled meeting. - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -628,7 +628,7 @@ public function test_display_message_does_not_have_icallink_removed_if_setting_d $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with no fixed time. - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_recurringnofixed() ))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" @@ -679,7 +679,7 @@ public function test_display_message_does_not_have_icallink_removed_if_setting_d $this->assertEquals($expectedmessage, $message); // Test a recurring meeting with fixed time. - $message = (new \mod_zoom\invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); + $message = (new invitation($this->get_mock_invitation_message_recurringfixed()))->get_display_string($zoom->cmid); $expectedmessage = "Organization is inviting you to a scheduled Zoom meeting.\r\n" . "\r\n" . "Topic: Zoom Meeting\r\n" @@ -743,7 +743,7 @@ public function test_display_message_when_instantiated_with_null_zoom_meeting_in $this->setAdminUser(); $course = $this->getDataGenerator()->create_course(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); - $message = (new \mod_zoom\invitation(null))->get_display_string($zoom->cmid); + $message = (new invitation(null))->get_display_string($zoom->cmid); $this->assertNull($message); } @@ -759,7 +759,7 @@ public function test_display_message_when_user_has_no_capabilities_with_regex_di $role = $this->getDataGenerator()->create_role(); $zoom = $this->getDataGenerator()->create_module('zoom', ['course' => $course]); role_assign($role, $user->id, context_course::instance($course->id)); - $message = (new \mod_zoom\invitation( + $message = (new invitation( $this->get_mock_invitation_message_scheduledmeeting() ))->get_display_string($zoom->cmid, $user->id); $expectedmessage = $this->get_mock_invitation_message_scheduledmeeting(); diff --git a/tests/privacy/mod_zoom_provider_test.php b/tests/privacy/mod_zoom_provider_test.php index 08d79dd7..de12490a 100644 --- a/tests/privacy/mod_zoom_provider_test.php +++ b/tests/privacy/mod_zoom_provider_test.php @@ -23,6 +23,7 @@ use core_privacy\local\request\deletion_criteria; use core_privacy\local\request\userlist; use core_privacy\local\request\writer; +use core_privacy\tests\provider_testcase; use mod_zoom\privacy\provider; /** @@ -34,7 +35,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @coversDefaultClass \mod_zoom\privacy\provider */ -class mod_zoom_provider_test extends \core_privacy\tests\provider_testcase { +class mod_zoom_provider_test extends provider_testcase { /** @var object The zoom instance object. */ protected $zoominstance;