Minor - Plugin zoom - refactor code

pull/3425/head
Julio Montoya 5 years ago
parent 97ce9951ca
commit 30a84559c2
  1. 2
      plugin/zoom/join_meeting.php
  2. 2
      plugin/zoom/lang/english.php
  3. 2
      plugin/zoom/lang/french.php
  4. 2
      plugin/zoom/lang/spanish.php
  5. 9
      plugin/zoom/lib/MeetingEntityRepository.php
  6. 29
      plugin/zoom/lib/ZoomPlugin.php

@ -31,7 +31,7 @@ try {
if (!empty($startJoinURL)) { if (!empty($startJoinURL)) {
echo Display::url($plugin->get_lang('EnterMeeting'), $startJoinURL, ['class' => 'btn btn-primary']); echo Display::url($plugin->get_lang('EnterMeeting'), $startJoinURL, ['class' => 'btn btn-primary']);
} else { } else {
echo Display::return_message($plugin->get_lang('ConferenceNotStarted'), 'warning'); //echo Display::return_message($plugin->get_lang('ConferenceNotStarted'), 'warning');
} }
if ($plugin->userIsConferenceManager($meeting)) { if ($plugin->userIsConferenceManager($meeting)) {

@ -111,7 +111,7 @@ $strings['RegisterTheseGroupMembers'] = "Register these group members";
$strings['ScheduleAMeeting'] = "Schedule a meeting"; $strings['ScheduleAMeeting'] = "Schedule a meeting";
$strings['ScheduledMeeting'] = "Scheduled meeting"; $strings['ScheduledMeeting'] = "Scheduled meeting";
$strings['ScheduledMeetings'] = "Scheduled Meetings"; $strings['ScheduledMeetings'] = "Scheduled Meetings";
$strings['ScheduleTheMeeting'] = "Schedule the meeting"; $strings['ScheduleAMeeting'] = "Schedule a meeting";
$strings['SearchMeeting'] = "Search meeting"; $strings['SearchMeeting'] = "Search meeting";
$strings['Session'] = "Session"; $strings['Session'] = "Session";
$strings['StartDate'] = "Start Date"; $strings['StartDate'] = "Start Date";

@ -109,7 +109,7 @@ $strings['RegisterTheseGroupMembers'] = "Inscrire les membres de ces groupes";
$strings['ScheduleAMeeting'] = "Programmer une conférence"; $strings['ScheduleAMeeting'] = "Programmer une conférence";
$strings['ScheduledMeeting'] = "Conférence programmée"; $strings['ScheduledMeeting'] = "Conférence programmée";
$strings['ScheduledMeetings'] = "Conférences programmées"; $strings['ScheduledMeetings'] = "Conférences programmées";
$strings['ScheduleTheMeeting'] = "Programmer la conférence"; $strings['ScheduleAMeeting'] = "Programmer une conférence";
$strings['SearchMeeting'] = "Rechercher une conférence"; $strings['SearchMeeting'] = "Rechercher une conférence";
$strings['Session'] = "Session"; $strings['Session'] = "Session";
$strings['StartDate'] = "Date de début"; $strings['StartDate'] = "Date de début";

@ -109,7 +109,7 @@ $strings['RegisterTheseGroupMembers'] = "Inscribir los miembros de estos grupos"
$strings['ScheduleAMeeting'] = "Programar una conferencia"; $strings['ScheduleAMeeting'] = "Programar una conferencia";
$strings['ScheduledMeeting'] = "Conferencia programada"; $strings['ScheduledMeeting'] = "Conferencia programada";
$strings['ScheduledMeetings'] = "Conferencias programadas"; $strings['ScheduledMeetings'] = "Conferencias programadas";
$strings['ScheduleTheMeeting'] = "Programar la conferencia"; $strings['ScheduleAMeeting'] = "Programar una conferencia";
$strings['SearchMeeting'] = "Buscar una conferencia"; $strings['SearchMeeting'] = "Buscar una conferencia";
$strings['Session'] = "Sesión"; $strings['Session'] = "Sesión";
$strings['StartDate'] = "Fecha de inicio"; $strings['StartDate'] = "Fecha de inicio";

@ -80,7 +80,7 @@ class MeetingEntityRepository extends EntityRepository
Criteria::create()->where( Criteria::create()->where(
Criteria::expr()->andX( Criteria::expr()->andX(
Criteria::expr()->eq('course', null), Criteria::expr()->eq('course', null),
is_null($user) null === $user
? Criteria::expr()->neq('user', null) ? Criteria::expr()->neq('user', null)
: Criteria::expr()->eq('user', $user) : Criteria::expr()->eq('user', $user)
) )
@ -105,16 +105,15 @@ class MeetingEntityRepository extends EntityRepository
/** /**
* @param DateTime $start * @param DateTime $start
* @param DateTime $end * @param DateTime $end
* @param User|null $user * @param User $user
* *
* @return ArrayCollection|Collection|MeetingEntity[] * @return ArrayCollection|Collection|MeetingEntity[]
*/ */
public function periodUserMeetings($start, $end, $user = null) public function periodUserMeetings($start, $end, $user)
{ {
return $this->userMeetings($user)->filter( return $this->userMeetings($user)->filter(
function ($meeting) use ($start, $end) { function ($meeting) use ($start, $end) {
return $meeting->startDateTime >= $start return $meeting->startDateTime >= $start && $meeting->startDateTime <= $end;
&& $meeting->startDateTime <= $end;
} }
); );
} }

@ -597,7 +597,7 @@ class ZoomPlugin extends Plugin
public function getScheduleMeetingForm($user, $course = null, $session = null) public function getScheduleMeetingForm($user, $course = null, $session = null)
{ {
$form = new FormValidator('scheduleMeetingForm'); $form = new FormValidator('scheduleMeetingForm');
$form->addHeader($this->get_lang('ScheduleTheMeeting')); $form->addHeader($this->get_lang('ScheduleAMeeting'));
$startTimeDatePicker = $form->addDateTimePicker('startTime', get_lang('StartTime')); $startTimeDatePicker = $form->addDateTimePicker('startTime', get_lang('StartTime'));
$form->setRequired($startTimeDatePicker); $form->setRequired($startTimeDatePicker);
@ -856,8 +856,14 @@ class ZoomPlugin extends Plugin
{ {
$status = $meeting->getMeetingInfoGet()->status; $status = $meeting->getMeetingInfoGet()->status;
$currentUser = api_get_user_entity(api_get_user_id()); $currentUser = api_get_user_entity(api_get_user_id());
$isGlobal = 'true' === $this->get('enableGlobalConference') && $meeting->isGlobalMeeting();
switch ($status) { switch ($status) {
case 'ended':
if ($currentUser === $meeting->getUser()) {
return $meeting->getMeetingInfoGet()->start_url;
}
break;
case 'waiting': case 'waiting':
// Zoom does not allow for a new meeting to be started on first participant join. // Zoom does not allow for a new meeting to be started on first participant join.
// It requires the host to start the meeting first. // It requires the host to start the meeting first.
@ -865,25 +871,28 @@ class ZoomPlugin extends Plugin
// that is use start_url rather than join_url. // that is use start_url rather than join_url.
// the participant will not be registered and will appear as the Zoom user account owner. // the participant will not be registered and will appear as the Zoom user account owner.
// For course and user meetings, only the host can start the meeting. // For course and user meetings, only the host can start the meeting.
if ( if ($isGlobal || $currentUser === $meeting->getUser()) {
($meeting->isGlobalMeeting() && $this->get('enableGlobalConference')) ||
$currentUser === $meeting->getUser()
) {
return $meeting->getMeetingInfoGet()->start_url; return $meeting->getMeetingInfoGet()->start_url;
} }
break; break;
case 'started': case 'started':
if ('true' === $this->get('enableParticipantRegistration') && $meeting->requiresRegistration()) { if ($currentUser === $meeting->getUser()) {
return $meeting->getMeetingInfoGet()->join_url;
}
// the participant is not registered, he can join only the global meeting (automatic registration)
if ($isGlobal) {
return $this->registerUser($meeting, $currentUser)->getCreatedRegistration()->join_url;
}
if ('true' === $this->get('enableParticipantRegistration')) {
//if ('true' === $this->get('enableParticipantRegistration') && $meeting->requiresRegistration()) {
// the participant must be registered // the participant must be registered
$registrant = $meeting->getRegistrant($currentUser); $registrant = $meeting->getRegistrant($currentUser);
if (null !== $registrant) { if (null !== $registrant) {
// the participant is registered // the participant is registered
return $registrant->getCreatedRegistration()->join_url; return $registrant->getCreatedRegistration()->join_url;
} }
// the participant is not registered, he can join only the global meeting (automatic registration)
if ($meeting->isGlobalMeeting() && $this->get('enableGlobalConference')) {
return $this->registerUser($meeting, $currentUser)->getCreatedRegistration()->join_url;
}
} }
break; break;
} }

Loading…
Cancel
Save