Minor coding style fix - refs BT#17288

pull/3274/head
Sébastien Ducoulombier 6 years ago
parent 189ac597da
commit c184212739
  1. 2
      plugin/zoom/lib/API/CreatedRegistration.php
  2. 2
      plugin/zoom/lib/API/GlobalDialInNumber.php
  3. 22
      plugin/zoom/lib/API/Meeting.php
  4. 1
      plugin/zoom/lib/API/MeetingInfo.php
  5. 9
      plugin/zoom/lib/API/MeetingRegistrant.php
  6. 2
      plugin/zoom/lib/API/MeetingRegistrantList.php
  7. 2
      plugin/zoom/lib/API/MeetingSettings.php
  8. 2
      plugin/zoom/lib/API/RecordingFile.php
  9. 4
      plugin/zoom/lib/API/TrackingField.php
  10. 4
      plugin/zoom/lib/UserMeetingRegistrant.php
  11. 127
      plugin/zoom/lib/zoom_plugin.class.php

@ -28,7 +28,7 @@ class CreatedRegistration
public $topic;
/**
* @inheritDoc
* {@inheritdoc}
*/
protected function itemClass($propertyName)
{

@ -25,7 +25,7 @@ class GlobalDialInNumber
public $type;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -36,6 +36,17 @@ class Meeting
$this->settings = new MeetingSettings();
}
/**
* {@inheritdoc}
*/
public function itemClass($propertyName)
{
if ('tracking_fields' === $propertyName) {
return TrackingField::class;
}
throw new Exception("no such array property $propertyName");
}
/**
* Creates a Meeting instance from a topic.
*
@ -54,15 +65,4 @@ class Meeting
return $instance;
}
/**
* {@inheritdoc}
*/
public function itemClass($propertyName)
{
if ('tracking_fields' === $propertyName) {
return TrackingField::class;
}
throw new Exception("no such array property $propertyName");
}
}

@ -25,5 +25,4 @@ class MeetingInfo extends Meeting
/** @var object[] */
public $occurrences;
}

@ -70,20 +70,21 @@ class MeetingRegistrant
/**
* @param string $email
* @param string $first_name
* @param string $firstName
*
* @return MeetingRegistrant
*/
public static function fromEmailAndFirstName($email, $first_name)
public static function fromEmailAndFirstName($email, $firstName)
{
$instance = new static();
$instance->first_name = $first_name;
$instance->first_name = $firstName;
$instance->email = $email;
return $instance;
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -21,7 +21,7 @@ class MeetingRegistrantList
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -121,7 +121,7 @@ class MeetingSettings
}
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -72,7 +72,7 @@ class RecordingFile
public $recording_type;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -1,5 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\PluginBundle\Zoom\API;
@ -16,7 +16,7 @@ class TrackingField
public $value;
/**
* @inheritDoc
* {@inheritdoc}
*/
public function itemClass($propertyName)
{

@ -23,9 +23,9 @@ class UserMeetingRegistrant extends API\MeetingRegistrant
}
/**
* Creates a UserMeetingRegistrant instance from a user
* Creates a UserMeetingRegistrant instance from a user.
*
* @param User $user
* @param User $user
*
* @throws Exception
*

@ -121,9 +121,9 @@ class ZoomPlugin extends Plugin
/**
* @param $meetingId
*
* @return MeetingInstance[]
*
* @throws Exception
*
* @return MeetingInstance[]
*/
public function getEndedMeetingInstances($meetingId)
{
@ -304,65 +304,6 @@ class ZoomPlugin extends Plugin
return $this->jwtClient()->getParticipants($instanceUUID);
}
/**
* Caches and returns the JWT client instance, initialized with plugin settings.
*
* @return JWTClient object that provides means of communications with the Zoom servers
*/
protected function jwtClient()
{
static $jwtClient = null;
if (is_null($jwtClient)) {
$jwtClient = new JWTClient($this->get('apiKey'), $this->get('apiSecret'));
}
return $jwtClient;
}
/**
* Retrieves all meetings of a specific type and linked to current course and session.
*
* @param string $type MEETING_TYPE_LIVE, MEETING_TYPE_SCHEDULED or MEETING_TYPE_UPCOMING
*
* @throws Exception on API error
*
* @return CourseMeetingListItem[] matching meetings
*/
private function getMeetings($type)
{
$matchingMeetings = [];
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
foreach ($this->jwtClient()->getMeetings($type) as $meeting) {
$candidateMeeting = CourseMeetingListItem::fromMeetingListItem($meeting);
if ($candidateMeeting->matches($courseId, $sessionId)) {
$matchingMeetings[] = $candidateMeeting;
}
}
return $matchingMeetings;
}
/**
* Creates a meeting and returns it.
*
* @param CourseMeeting $meeting a meeting with at least a type and a topic
*
* @throws Exception describing the error (message and code)
*
* @return CourseMeetingInfoGet meeting
*/
private function createMeeting($meeting)
{
$meeting->settings->auto_recording = $this->get('enableCloudRecording')
? 'cloud'
: 'local';
$meeting->settings->registrants_email_notification = false;
$meeting->tagAgenda();
return CourseMeetingInfoGet::fromMeetingInfoGet($this->jwtClient()->createMeeting($meeting));
}
/**
* @param $meetingId
*
@ -376,11 +317,12 @@ class ZoomPlugin extends Plugin
foreach ($this->jwtClient()->getRegistrants($meetingId) as $registrant) {
$registrants[] = UserMeetingRegistrantListItem::fromMeetingRegistrantListItem($registrant);
}
return $registrants;
}
/**
* @param int $meetingId
* @param int $meetingId
* @param \Chamilo\UserBundle\Entity\User[] $users
*
* @throws Exception
@ -414,7 +356,7 @@ class ZoomPlugin extends Plugin
* Updates meeting registrants list. Adds the missing registrants and removes the extra.
*
* @param int $meetingId meeting identifier
* @param \Chamilo\UserBundle\Entity\User[] $users list of users to be registred
* @param \Chamilo\UserBundle\Entity\User[] $users list of users to be registred
*
* @throws Exception
*/
@ -462,4 +404,63 @@ class ZoomPlugin extends Plugin
{
$this->jwtClient()->deleteRecordings($instanceUUID);
}
/**
* Caches and returns the JWT client instance, initialized with plugin settings.
*
* @return JWTClient object that provides means of communications with the Zoom servers
*/
protected function jwtClient()
{
static $jwtClient = null;
if (is_null($jwtClient)) {
$jwtClient = new JWTClient($this->get('apiKey'), $this->get('apiSecret'));
}
return $jwtClient;
}
/**
* Retrieves all meetings of a specific type and linked to current course and session.
*
* @param string $type MEETING_TYPE_LIVE, MEETING_TYPE_SCHEDULED or MEETING_TYPE_UPCOMING
*
* @throws Exception on API error
*
* @return CourseMeetingListItem[] matching meetings
*/
private function getMeetings($type)
{
$matchingMeetings = [];
$courseId = api_get_course_int_id();
$sessionId = api_get_session_id();
foreach ($this->jwtClient()->getMeetings($type) as $meeting) {
$candidateMeeting = CourseMeetingListItem::fromMeetingListItem($meeting);
if ($candidateMeeting->matches($courseId, $sessionId)) {
$matchingMeetings[] = $candidateMeeting;
}
}
return $matchingMeetings;
}
/**
* Creates a meeting and returns it.
*
* @param CourseMeeting $meeting a meeting with at least a type and a topic
*
* @throws Exception describing the error (message and code)
*
* @return CourseMeetingInfoGet meeting
*/
private function createMeeting($meeting)
{
$meeting->settings->auto_recording = $this->get('enableCloudRecording')
? 'cloud'
: 'local';
$meeting->settings->registrants_email_notification = false;
$meeting->tagAgenda();
return CourseMeetingInfoGet::fromMeetingInfoGet($this->jwtClient()->createMeeting($meeting));
}
}

Loading…
Cancel
Save