From e0306ef96382f67c74198e7f86984cf9bd7ba47d Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 4 Aug 2020 14:06:04 +0200 Subject: [PATCH] Minor - Plugin: zoom refactor format code BT#17288 --- plugin/zoom/Entity/RegistrantEntity.php | 2 +- plugin/zoom/lib/ZoomPlugin.php | 19 ++++++++++++++----- plugin/zoom/meeting.php | 4 ++-- plugin/zoom/start.php | 7 ++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/plugin/zoom/Entity/RegistrantEntity.php b/plugin/zoom/Entity/RegistrantEntity.php index c43985e20d..fd339e0151 100644 --- a/plugin/zoom/Entity/RegistrantEntity.php +++ b/plugin/zoom/Entity/RegistrantEntity.php @@ -166,7 +166,7 @@ class RegistrantEntity ); } - public function joinUrl() + public function getJoinUrl() { if (!$this->createdRegistration) { return ''; diff --git a/plugin/zoom/lib/ZoomPlugin.php b/plugin/zoom/lib/ZoomPlugin.php index ed16b7b13e..6c5d36af73 100644 --- a/plugin/zoom/lib/ZoomPlugin.php +++ b/plugin/zoom/lib/ZoomPlugin.php @@ -783,16 +783,21 @@ class ZoomPlugin extends Plugin } /** - * @param Course $course * * @return bool whether the logged-in user can manage conferences in this context, that is either * the current course or session coach, the platform admin or the current course admin */ - public function userIsCourseConferenceManager($course) + public function userIsCourseConferenceManager() { - return api_is_coach() - || api_is_platform_admin() - || api_get_course_id() && api_is_course_admin(); + if (api_is_coach() || api_is_platform_admin()) { + return true; + } + + if (api_get_course_id() && api_is_course_admin()) { + return true; + } + + return false; } /** @@ -959,6 +964,10 @@ class ZoomPlugin extends Plugin return $this->registerUser($meeting, $currentUser)->getCreatedRegistration()->join_url; } + if ($meeting->isCourseMeeting() && $this->userIsCourseConferenceManager()) { + return $meeting->getMeetingInfoGet()->start_url; + } + if ('true' === $this->get('enableParticipantRegistration')) { //if ('true' === $this->get('enableParticipantRegistration') && $meeting->requiresRegistration()) { // the participant must be registered diff --git a/plugin/zoom/meeting.php b/plugin/zoom/meeting.php index fe0236ec5a..cf4b9eea32 100755 --- a/plugin/zoom/meeting.php +++ b/plugin/zoom/meeting.php @@ -64,8 +64,8 @@ if ($plugin->userIsConferenceManager($meeting)) { $userId = api_get_user_id(); try { foreach ($meeting->getRegistrants() as $registrant) { - if ($registrant->userId == $userId) { - $tpl->assign('currentUserJoinURL', $registrant->join_url); + if ($registrant->getUser()->getId() == $userId) { + $tpl->assign('currentUserJoinURL', $registrant->getJoinUrl()); break; } } diff --git a/plugin/zoom/start.php b/plugin/zoom/start.php index 983e32c60e..d6d4caeeeb 100755 --- a/plugin/zoom/start.php +++ b/plugin/zoom/start.php @@ -22,12 +22,13 @@ $course = api_get_course_entity(); $session = api_get_session_entity(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; -if ($plugin->userIsCourseConferenceManager($course)) { +if ($plugin->userIsCourseConferenceManager()) { switch ($action) { case 'delete': $meeting = $plugin->getMeetingRepository()->findOneBy(['meetingId' => $_REQUEST['meetingId']]); - $plugin->deleteMeeting($meeting, api_get_self().'?'.api_get_cidreq()); - + if ($meeting->isCourseMeeting()) { + $plugin->deleteMeeting($meeting, api_get_self().'?'.api_get_cidreq()); + } break; }