Zoom meeting introduction and universal EnterMeeting link - refs BT#17288

pull/3383/head
Sébastien Ducoulombier 5 years ago
parent ebe5387fa5
commit e099f58c47
  1. 28
      plugin/zoom/Entity/MeetingEntity.php
  2. 22
      plugin/zoom/global.php
  3. 10
      plugin/zoom/join_meeting.php
  4. 2
      plugin/zoom/lang/english.php
  5. 2
      plugin/zoom/lang/french.php
  6. 2
      plugin/zoom/lang/spanish.php
  7. 92
      plugin/zoom/lib/zoom_plugin.class.php
  8. 12
      plugin/zoom/view/meeting.tpl

@ -443,6 +443,34 @@ class MeetingEntity
return null;
}
/**
* Generates a short presentation of the meeting for the future participant.
* To be displayed above the "Enter meeting" link.
*
* @return string
*/
public function getIntroduction()
{
$introduction = sprintf('<h1>%s</h1>', $this->meetingInfoGet->topic);
if (!$this->isGlobalMeeting()) {
$introduction .= sprintf('<p>%s (%s)</p>', $this->formattedStartTime, $this->formattedDuration);
}
if ($this->user) {
$introduction .= sprintf('<p>%s</p>', $this->user->getFullname());
} elseif ($this->isCourseMeeting()) {
if (is_null($this->session)) {
$introduction .= sprintf('<p class="main">%s</p>', $this->course);
} else {
$introduction .= sprintf('<p class="main">%s (%s)</p>', $this->course, $this->session);
}
}
if (!empty($this->meetingInfoGet->agenda)) {
$introduction .= sprintf('<p>%s</p>', $this->meetingInfoGet->agenda);
}
return $introduction;
}
/**
* @throws Exception on unexpected start_time or duration
*/

@ -5,26 +5,8 @@ $course_plugin = 'zoom'; // needed in order to load the plugin lang variables
require_once __DIR__.'/config.php';
if (!api_user_is_login()) {
if (!ZoomPlugin::currentUserCanJoinGlobalMeeting()) {
api_not_allowed(true);
}
$plugin = ZoomPlugin::create();
Display::display_header($plugin->get_title());
try {
printf(
'<div class="embed-responsive embed-responsive-16by9">
<a class="embed-responsive-item" href="%s" target="_blank">%s</a>
</div>',
$plugin->getGlobalMeetingURL(),
get_lang('JoinGlobalVideoConference')
);
} catch (Exception $exception) {
Display::addFlash(
Display::return_message($exception->getMessage(), 'error')
);
}
Display::display_footer();
location('join_meeting.php?meetingId='.ZoomPlugin::create()->getGlobalMeeting()->getId());

@ -23,13 +23,11 @@ if (array_key_exists('meetingId', $_REQUEST)) {
if (is_null($meeting)) {
throw new Exception('Meeting not found');
}
// TODO introduce the meeting
printf(
'<div class="embed-responsive embed-responsive-16by9">
<a class="embed-responsive-item" href="%s" target="_blank">%s</a>
</div>',
$plugin->getUserMeetingURL($meeting),
get_lang('JoinMeetingAsMyself')
'%s<p><a href="%s" target="_blank">%s</a></p>',
$meeting->getIntroduction(),
$plugin->getStartOrJoinMeetingURL($meeting),
get_lang('EnterMeeting')
);
} catch (Exception $exception) {
Display::addFlash(

@ -79,6 +79,7 @@ $strings['Duration'] = "Duration";
$strings['DurationFormat'] = "%hh%I";
$strings['DurationInMinutes'] = "Duration (in minutes)";
$strings['EndDate'] = "End Date";
$strings['EnterMeeting'] = "Enter meeting";
$strings['Files'] = "Files";
$strings['Finished'] = "finished";
$strings['FileWasCopiedToCourse'] = "The file was copied to the course";
@ -88,7 +89,6 @@ $strings['GroupUsersWereRegistered'] = "Group members were registered";
$strings['InstantMeeting'] = "Instant meeting";
$strings['Join'] = "Join";
$strings['JoinGlobalVideoConference'] = "Join global conference";
$strings['JoinMeetingAsMyself'] = "Join meeting as myself";
$strings['JoinURLCopied'] = "Join URL copied";
$strings['JoinURLToSendToParticipants'] = "Join URL to send to participants";
$strings['LiveMeetings'] = "Live meetings";

@ -78,6 +78,7 @@ $strings['Duration'] = "Durée";
$strings['DurationFormat'] = "%hh%I";
$strings['DurationInMinutes'] = "Durée (en minutes)";
$strings['EndDate'] = "Date de fin";
$strings['EnterMeeting'] = "Entrer dans la conférence";
$strings['Files'] = "Fichiers";
$strings['Finished'] = "terminée";
$strings['FileWasCopiedToCourse'] = "Le fichier a été copié dans le cours";
@ -87,7 +88,6 @@ $strings['GroupUsersWereRegistered'] = "Les membres des groupes ont été inscri
$strings['InstantMeeting'] = "Conférence instantanée";
$strings['Join'] = "Rejoindre";
$strings['JoinGlobalVideoConference'] = "Rejoindre la conférence globale";
$strings['JoinMeetingAsMyself'] = "Rejoindre la conférence en tant que moi-même";
$strings['JoinURLCopied'] = "URL pour rejoindre copiée";
$strings['JoinURLToSendToParticipants'] = "URL pour assister à la conférence (à envoyer aux participants)";
$strings['LiveMeetings'] = "Conférences en cours";

@ -78,6 +78,7 @@ $strings['Duration'] = "Duración";
$strings['DurationFormat'] = "%hh%I";
$strings['DurationInMinutes'] = "Duración (en minutos)";
$strings['EndDate'] = "Fecha de fin";
$strings['EnterMeeting'] = "Ingresar la conferencia";
$strings['Files'] = "Archivos";
$strings['Finished'] = "terminada";
$strings['FileWasCopiedToCourse'] = "El archivo ha sido copiado en el curso";
@ -87,7 +88,6 @@ $strings['GroupUsersWereRegistered'] = "Miembros de los grupos han sido registra
$strings['InstantMeeting'] = "Conferencia instantánea";
$strings['Join'] = "Ingresar";
$strings['JoinGlobalVideoConference'] = "Ingresar la conrencia global";
$strings['JoinMeetingAsMyself'] = "Ingresar la conferencia como yo mismo";
$strings['JoinURLCopied'] = "URL para juntarse copiada";
$strings['JoinURLToSendToParticipants'] = "URL para asistir a la conferencia (para enviar a los participantes)";
$strings['LiveMeetings'] = "Conferencias activas";

@ -87,7 +87,7 @@ class ZoomPlugin extends Plugin
*/
public static function currentUserCanJoinGlobalMeeting()
{
return 'true' === api_get_plugin_setting('zoom', 'enableGlobalConference');
return 'true' === api_get_plugin_setting('zoom', 'enableGlobalConference') && api_user_is_login();
}
/**
@ -764,87 +764,65 @@ class ZoomPlugin extends Plugin
}
/**
* @throws OptimisticLockException
* Return the current global meeting (create it if needed).
*
* @throws Exception
*
* @return string
*/
public function getGlobalMeetingURL()
public function getGlobalMeeting()
{
if (!self::currentUserCanJoinGlobalMeeting()) {
throw new Exception('global meetings are not enabled');
}
$url = null;
foreach ($this->getMeetingRepository()->unfinishedGlobalMeetings() as $meeting) {
// Zoom does not allow for a new meeting to be started on first participant join.
// It requires the host to start the meeting first.
// Therefore we must make the global meeting creator the host, that is, redirect to start_url, not join_url
$meetingInfoGet = MeetingInfoGet::fromId($meeting->getMeetingInfoGet()->id);
if ($meeting->getMeetingInfoGet() != $meetingInfoGet) { // keep comparison operator (!=)
$meeting->setMeetingInfoGet($meetingInfoGet);
Database::getManager()->persist($meeting);
Database::getManager()->flush($meeting);
}
if ('waiting' === $meetingInfoGet->status) {
$url = $meeting->getMeetingInfoGet()->start_url;
break;
} elseif ('started' === $meetingInfoGet->status) {
if ('true' === $this->get('enableParticipantRegistration') && $meeting->requiresRegistration()) {
$user = api_get_user_entity(api_get_user_id());
/** @var RegistrantEntity $registrant */
$registrant = $meeting->getRegistrant($user);
if (is_null($registrant)) { // not registered yet
$registrant = $this->registerUser($meeting, $user);
}
$url = $registrant->getCreatedRegistration()->join_url;
break;
} else { // no registration possible, join anonymously
$url = $meetingInfoGet->join_url;
break;
}
} // else 'finished' - try next
}
if (is_null($url)) {
$url = $this->createGlobalMeeting()->getMeetingInfoGet()->start_url;
return $meeting;
}
return $url;
return $this->createGlobalMeeting();
}
/**
* Returns the URL to enter (start or join) a user meeting.
* Returns the URL to enter (start or join) a meeting or null if not possible to enter the meeting,
* The returned URL depends on the meeting current status (waiting, started or finished) and the current user.
*
* @param MeetingEntity $meeting
* @param bool $autoRegister
*
* @throws Exception
* @throws OptimisticLockException
*
* @return string
* @return string|null
*/
public function getUserMeetingURL($meeting, $autoRegister = false)
public function getStartOrJoinMeetingURL($meeting)
{
$url = null;
$host = $meeting->getUser();
$participant = api_get_user_entity(api_get_user_id());
if ($host === $participant) {
$url = $meeting->getMeetingInfoGet()->start_url;
} else {
if ('waiting' === $meeting->getMeetingInfoGet()->status) {
// Zoom does not allow for a new meeting to be started on first participant join.
// It requires the host to start the meeting first.
// Therefore for global meetings we must make the first participant the host
// that is use start_url rather than join_url.
// 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.
if ($meeting->isGlobalMeeting() && $this->get('enableGlobalConference')
|| $meeting->getUser() === api_get_user_entity(api_get_user_id())) {
return $meeting->getMeetingInfoGet()->start_url;
}
} elseif ('started' === $meeting->getMeetingInfoGet()->status) {
if ('true' === $this->get('enableParticipantRegistration') && $meeting->requiresRegistration()) {
// the participant must be registered
$participant = api_get_user_entity(api_get_user_id());
$registrant = $meeting->getRegistrant($participant);
if (is_null($registrant)) { // not registered yet
if (!$autoRegister) {
throw new Exception(get_lang('YouAreNotRegisteredToThisMeeting'));
}
$registrant = $this->registerUser($meeting, $participant);
if (!is_null($registrant)) {
// the participant is registered
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, $participant)->getCreatedRegistration()->join_url;
}
$url = $registrant->getCreatedRegistration()->join_url;
} else { // no registration possible, join anonymously
$url = $meeting->getMeetingInfoGet()->join_url;
} else {
// no registration possible, join anonymously
return $meeting->getMeetingInfoGet()->join_url;
}
}
return $url;
return null;
}
/**

@ -1,4 +1,13 @@
<p>{{ meeting.typeName }} {{ meeting.id }} ({{ meeting.meetingInfoGet.status }})</p>
<p>
{{ meeting.typeName }} {{ meeting.id }} ({{ meeting.meetingInfoGet.status }})
</p>
{% if meeting.meetingInfoGet.status != 'finished' %}
<p>
<a href="join_meeting.php?meetingId={{ meeting.id }}">
{{ 'EnterMeeting'|get_lang }}
</a>
</p>
{% endif %}
{% if isConferenceManager and meeting.status == 'waiting' %}
<p>
@ -75,4 +84,3 @@
{% endif %}
{% endif %}

Loading…
Cancel
Save