Plugin Zoom: fix translations, replace location with api_location

pull/3418/head
Julio Montoya 6 years ago
parent aaa19118c4
commit 93603fccfc
  1. 6
      main/inc/lib/api.lib.php
  2. 4
      main/inc/lib/userportal.lib.php
  3. 17
      plugin/zoom/Entity/MeetingEntity.php
  4. 3
      plugin/zoom/global.php
  5. 5
      plugin/zoom/join_meeting.php
  6. 53
      plugin/zoom/lib/zoom_plugin.class.php

@ -9577,10 +9577,10 @@ function api_number_format($number, $decimals = 0, $decimalSeparator = '.', $tho
/**
* Set location url with a exit break by default.
*
* @param $url
* @param bool $exit
* @param string $url
* @param bool $exit
*/
function location($url, $exit = true)
function api_location($url, $exit = true)
{
header('Location: '.$url);

@ -953,7 +953,9 @@ class IndexManager
}
if ('true' === api_get_plugin_setting('zoom', 'tool_enable')) {
foreach (ZoomPlugin::getProfileBlockItems() as $item) {
$zoomPlugin = new ZoomPlugin();
$blocks = $zoomPlugin->getProfileBlockItems();
foreach ($blocks as $item) {
$items[] = $item;
}
}

@ -475,17 +475,18 @@ class MeetingEntity
*/
private function initializeDisplayableProperties()
{
$zoomPlugin = new \ZoomPlugin();
$this->typeName = [
API\Meeting::TYPE_INSTANT => get_lang('InstantMeeting'),
API\Meeting::TYPE_SCHEDULED => get_lang('ScheduledMeeting'),
API\Meeting::TYPE_RECURRING_WITH_NO_FIXED_TIME => get_lang('RecurringWithNoFixedTime'),
API\Meeting::TYPE_RECURRING_WITH_FIXED_TIME => get_lang('RecurringWithFixedTime'),
API\Meeting::TYPE_INSTANT => $zoomPlugin->get_lang('InstantMeeting'),
API\Meeting::TYPE_SCHEDULED => $zoomPlugin->get_lang('ScheduledMeeting'),
API\Meeting::TYPE_RECURRING_WITH_NO_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithNoFixedTime'),
API\Meeting::TYPE_RECURRING_WITH_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithFixedTime'),
][$this->meetingInfoGet->type];
if (property_exists($this, 'status')) {
$this->statusName = [
'waiting' => get_lang('Waiting'),
'started' => get_lang('Started'),
'finished' => get_lang('Finished'),
'waiting' => $zoomPlugin->get_lang('Waiting'),
'started' => $zoomPlugin->get_lang('Started'),
'finished' => $zoomPlugin->get_lang('Finished'),
][$this->meetingInfoGet->status];
}
$this->startDateTime = null;
@ -502,7 +503,7 @@ class MeetingEntity
$later = new DateTime();
$later->add(new DateInterval('PT'.$this->meetingInfoGet->duration.'M'));
$this->durationInterval = $later->diff($now);
$this->formattedDuration = $this->durationInterval->format(get_lang('DurationFormat'));
$this->formattedDuration = $this->durationInterval->format($zoomPlugin->get_lang('DurationFormat'));
}
}
}

@ -1,4 +1,5 @@
<?php
/* For license terms, see /license.txt */
$course_plugin = 'zoom'; // needed in order to load the plugin lang variables
@ -9,4 +10,4 @@ if (!ZoomPlugin::currentUserCanJoinGlobalMeeting()) {
api_not_allowed(true);
}
location('join_meeting.php?meetingId='.ZoomPlugin::create()->getGlobalMeeting()->getId());
api_location('join_meeting.php?meetingId='.ZoomPlugin::create()->getGlobalMeeting()->getId());

@ -23,11 +23,12 @@ if (array_key_exists('meetingId', $_REQUEST)) {
if (is_null($meeting)) {
throw new Exception('Meeting not found');
}
printf(
'%s<p><a href="%s" target="_blank">%s</a></p>',
'%s<p><a href="%s" class="btn btn-primary" target="_blank">%s</a></p>',
$meeting->getIntroduction(),
$plugin->getStartOrJoinMeetingURL($meeting),
get_lang('EnterMeeting')
$plugin->get_lang('EnterMeeting')
);
} catch (Exception $exception) {
Display::addFlash(

@ -39,7 +39,7 @@ class ZoomPlugin extends Plugin
* {@inheritdoc}
* Initializes the API JWT client and the entity repositories.
*/
protected function __construct()
public function __construct()
{
parent::__construct(
'0.0.1',
@ -67,7 +67,6 @@ class ZoomPlugin extends Plugin
);
$this->isAdminPlugin = true;
$this->jwtClient = new JWTClient($this->get('apiKey'), $this->get('apiSecret'));
}
@ -98,8 +97,12 @@ class ZoomPlugin extends Plugin
{
$user = api_get_user_entity(api_get_user_id());
return !is_null($user)
&& 'true' === api_get_plugin_setting('zoom', 'enableGlobalConferencePerUser')
if (null === $user) {
return false;
}
return
'true' === api_get_plugin_setting('zoom', 'enableGlobalConferencePerUser')
&& in_array(
(api_is_platform_admin() ? PLATFORM_ADMIN : $user->getStatus()),
(array) api_get_plugin_setting('zoom', 'globalConferenceAllowRoles')
@ -110,13 +113,13 @@ class ZoomPlugin extends Plugin
/**
* @return array [ $title => $link ]
*/
public static function meetingsToWhichCurrentUserIsRegisteredComingSoon()
public function meetingsToWhichCurrentUserIsRegisteredComingSoon()
{
$items = [];
$linkTemplate = api_get_path(WEB_PLUGIN_PATH).'zoom/join_meeting.php?meetingId=%s';
foreach (self::getRegistrantRepository()->meetingsComingSoonRegistrationsForUser(
api_get_user_entity(api_get_user_id())
) as $registrant) {
$user = api_get_user_entity(api_get_user_id());
$meetings = self::getRegistrantRepository()->meetingsComingSoonRegistrationsForUser($user);
$items = [];
foreach ($meetings as $registrant) {
$meeting = $registrant->getMeeting();
$items[
sprintf(
@ -133,14 +136,14 @@ class ZoomPlugin extends Plugin
/**
* @return array
*/
public static function getProfileBlockItems()
public function getProfileBlockItems()
{
$elements = self::meetingsToWhichCurrentUserIsRegisteredComingSoon();
if (ZoomPlugin::currentUserCanJoinGlobalMeeting()) {
$elements[get_lang('JoinGlobalVideoConference')] = api_get_path(WEB_PLUGIN_PATH).'zoom/global.php';
$elements = $this->meetingsToWhichCurrentUserIsRegisteredComingSoon();
if (self::currentUserCanJoinGlobalMeeting()) {
$elements[$this->get_lang('JoinGlobalVideoConference')] = api_get_path(WEB_PLUGIN_PATH).'zoom/global.php';
}
if (ZoomPlugin::currentUserCanCreateUserMeeting()) {
$elements[get_lang('CreateUserVideoConference')] = api_get_path(WEB_PLUGIN_PATH).'zoom/user.php';
if (self::currentUserCanCreateUserMeeting()) {
$elements[$this->get_lang('CreateUserVideoConference')] = api_get_path(WEB_PLUGIN_PATH).'zoom/user.php';
}
$items = [];
foreach ($elements as $title => $link) {
@ -337,7 +340,7 @@ class ZoomPlugin extends Plugin
Display::addFlash(
Display::return_message(get_lang('MeetingDeleted'), 'confirm')
);
location($returnURL);
api_location($returnURL);
} catch (Exception $exception) {
Display::addFlash(
Display::return_message($exception->getMessage(), 'error')
@ -624,9 +627,9 @@ class ZoomPlugin extends Plugin
Display::return_message(get_lang('GroupUsersWereRegistered'))
);
}
location('meeting_from_start.php?meetingId='.$newMeeting->getId());
api_location('meeting_from_start.php?meetingId='.$newMeeting->getId());
} elseif (!is_null($user)) {
location('meeting_from_user.php?meetingId='.$newMeeting->getId());
api_location('meeting_from_user.php?meetingId='.$newMeeting->getId());
}
} catch (Exception $exception) {
Display::addFlash(
@ -694,15 +697,7 @@ class ZoomPlugin extends Plugin
$path = '/zoom_meeting_recording_file_'.$file->id.'.'.$file->file_type;
$docId = DocumentManager::addCloudLink($courseInfo, $path, $file->play_url, $name);
if (!$docId) {
throw new Exception(
get_lang(
DocumentManager::cloudLinkExists(
$courseInfo,
$path,
$file->play_url
) ? 'UrlAlreadyExists' : 'ErrorAddCloudLink'
)
);
throw new Exception(get_lang(DocumentManager::cloudLinkExists($courseInfo, $path, $file->play_url) ? 'UrlAlreadyExists' : 'ErrorAddCloudLink'));
}
}
@ -907,7 +902,7 @@ class ZoomPlugin extends Plugin
private function createGlobalMeeting()
{
$meetingInfoGet = MeetingInfoGet::fromTopicAndType(
get_lang('GlobalMeeting'),
$this->get_lang('GlobalMeeting'),
MeetingInfoGet::TYPE_SCHEDULED
);
$meetingInfoGet->start_time = (new DateTime())->format(DateTimeInterface::ISO8601);
@ -943,7 +938,7 @@ class ZoomPlugin extends Plugin
->setCourse($course)
->setSession($session)
);
location($meeting->getMeetingInfoGet()->start_url);
api_location($meeting->getMeetingInfoGet()->start_url);
}
/**

Loading…
Cancel
Save