diff --git a/plugin/zoom/lib/ZoomPlugin.php b/plugin/zoom/lib/ZoomPlugin.php index 617e7ca268..8c1eab8290 100644 --- a/plugin/zoom/lib/ZoomPlugin.php +++ b/plugin/zoom/lib/ZoomPlugin.php @@ -357,28 +357,43 @@ class ZoomPlugin extends Plugin */ public function getDeleteMeetingForm($meetingEntity, $returnURL) { - $form = new FormValidator('delete', 'post', $_SERVER['REQUEST_URI']); + $form = new FormValidator('delete', 'post', Security::remove_XSS($_SERVER['REQUEST_URI'])); $form->addButtonDelete($this->get_lang('DeleteMeeting')); if ($form->validate()) { - try { - $meetingEntity->getMeetingInfoGet()->delete(); - Database::getManager()->remove($meetingEntity); - Database::getManager()->flush(); - - Display::addFlash( - Display::return_message($this->get_lang('MeetingDeleted'), 'confirm') - ); - api_location($returnURL); - } catch (Exception $exception) { - Display::addFlash( - Display::return_message($exception->getMessage(), 'error') - ); - } + $this->deleteMeeting($meetingEntity, $returnURL); } return $form; } + /** + * @param MeetingEntity $meetingEntity + * @param string $returnURL + * + * @return false + */ + public function deleteMeeting($meetingEntity, $returnURL) + { + if (null === $meetingEntity) { + return false; + } + + try { + $meetingEntity->getMeetingInfoGet()->delete(); + Database::getManager()->remove($meetingEntity); + Database::getManager()->flush(); + + Display::addFlash( + Display::return_message($this->get_lang('MeetingDeleted'), 'confirm') + ); + api_location($returnURL); + } catch (Exception $exception) { + Display::addFlash( + Display::return_message($exception->getMessage(), 'error') + ); + } + } + /** * Generates a registrant list update form listing course and session users. * Updates the list on validation. @@ -589,7 +604,7 @@ class ZoomPlugin extends Plugin $form->setRequired($durationNumeric); // $passwordText = $form->addText('password', get_lang('Password'), false, ['maxlength' => '10']); - if (!is_null($course)) { + if (null !== $course) { $registrationOptions = [ 'RegisterAllCourseUsers' => $this->get_lang('RegisterAllCourseUsers'), ]; diff --git a/plugin/zoom/start.php b/plugin/zoom/start.php index af99f727d0..dbd2c36586 100755 --- a/plugin/zoom/start.php +++ b/plugin/zoom/start.php @@ -22,8 +22,17 @@ $tool_name = $plugin->get_lang('ZoomVideoConferences'); $tpl = new Template($tool_name); $course = api_get_course_entity(); $session = api_get_session_entity(); +$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; if ($plugin->userIsCourseConferenceManager($course)) { + switch ($action) { + case 'delete': + $meeting = $plugin->getMeetingRepository()->find($_REQUEST['meetingId']); + $plugin->deleteMeeting($meeting, api_get_self().'?'.api_get_cidreq()); + + break; + } + $user = api_get_user_entity(api_get_user_id()); // user can create a new meeting $tpl->assign( diff --git a/plugin/zoom/view/start.tpl b/plugin/zoom/view/start.tpl index 7931eddf69..9eff6f4882 100644 --- a/plugin/zoom/view/start.tpl +++ b/plugin/zoom/view/start.tpl @@ -30,7 +30,14 @@ - {{ 'Details'|get_lang }} + {{ 'Edit'|get_lang }} + + + + {{ 'Delete'|get_lang }}