Minor code style fixes (FlintCI) - refs BT#17288

pull/3383/head
Sébastien Ducoulombier 5 years ago
parent eb80bfdd9c
commit 9ca1c03ff3
  1. 46
      plugin/zoom/Entity/MeetingEntity.php
  2. 31
      plugin/zoom/Entity/RecordingEntity.php
  3. 20
      plugin/zoom/Entity/RegistrantEntity.php
  4. 1
      plugin/zoom/join_meeting.php
  5. 20
      plugin/zoom/lib/API/Client.php
  6. 2
      plugin/zoom/lib/API/MeetingInfoGet.php
  7. 2
      plugin/zoom/lib/API/MeetingInstances.php
  8. 2
      plugin/zoom/lib/API/MeetingList.php
  9. 2
      plugin/zoom/lib/API/MeetingRegistrantList.php
  10. 15
      plugin/zoom/lib/MeetingEntityRepository.php
  11. 5
      plugin/zoom/lib/RecordingEntityRepository.php
  12. 3
      plugin/zoom/lib/RegistrantEntityRepository.php
  13. 104
      plugin/zoom/lib/zoom_plugin.class.php

@ -21,6 +21,7 @@ use Exception;
/**
* Class MeetingEntity.
*
* @package Chamilo\PluginBundle\Zoom
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\MeetingEntityRepository")
* @ORM\Table(
@ -35,6 +36,24 @@ use Exception;
*/
class MeetingEntity
{
/** @var string meeting type name */
public $typeName;
/** @var DateTime meeting start time as a DateTime instance */
public $startDateTime;
/** @var string meeting formatted start time */
public $formattedStartTime;
/** @var DateInterval meeting duration as a DateInterval instance */
public $durationInterval;
/** @var string meeting formatted duration */
public $formattedDuration;
/** @var string */
public $statusName;
/**
* @var int the remote zoom meeting identifier
* @ORM\Column(type="bigint")
@ -106,27 +125,6 @@ class MeetingEntity
*/
private $recordings;
// Displayable properties
/** @var string meeting type name */
public $typeName;
/** @var DateTime meeting start time as a DateTime instance */
public $startDateTime;
/** @var string meeting formatted start time */
public $formattedStartTime;
/** @var DateInterval meeting duration as a DateInterval instance */
public $durationInterval;
/** @var string meeting formatted duration */
public $formattedDuration;
/** @var string */
public $statusName;
public function __construct()
{
$this->registrants = new ArrayCollection();
@ -207,6 +205,7 @@ class MeetingEntity
/**
* @ORM\PostUpdate
*
* @throws Exception
*/
public function postUpdate()
@ -406,7 +405,7 @@ class MeetingEntity
*
* @return bool
*/
public function hasRegisteredUser(User $user)
public function hasRegisteredUser($user)
{
return $this->getRegistrants()->exists(
function (RegistrantEntity $registrantEntity) use (&$user) {
@ -420,13 +419,14 @@ class MeetingEntity
*
* @return RegistrantEntity|null
*/
public function getRegistrant(User $user)
public function getRegistrant($user)
{
foreach ($this->getRegistrants() as $registrant) {
if ($registrant->getUser() === $user) {
return $registrant;
}
}
return null;
}

@ -13,6 +13,7 @@ use Exception;
/**
* Class RecordingEntity.
*
* @package Chamilo\PluginBundle\Zoom
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\RecordingEntityRepository")
* @ORM\Table(
@ -25,6 +26,18 @@ use Exception;
*/
class RecordingEntity
{
/** @var DateTime */
public $startDateTime;
/** @var string */
public $formattedStartTime;
/** @var DateInterval */
public $durationInterval;
/** @var string */
public $formattedDuration;
/**
* @var string
* @ORM\Column(type="string")
@ -51,18 +64,6 @@ class RecordingEntity
/** @var RecordingMeeting */
private $recordingMeeting;
/** @var DateTime */
public $startDateTime;
/** @var string */
public $formattedStartTime;
/** @var DateInterval */
public $durationInterval;
/** @var string */
public $formattedDuration;
/**
* @param $name
*
@ -96,9 +97,9 @@ class RecordingEntity
}
/**
* @return RecordingMeeting
*
* @throws Exception
*
* @return RecordingMeeting
*/
public function getRecordingMeeting()
{
@ -134,7 +135,7 @@ class RecordingEntity
}
if (is_null($this->meeting)) {
$this->meeting = Database::getManager()->getRepository(MeetingEntity::class)->find($recordingMeeting->id);
// $this->meeting remains null when the remote RecordingMeeting refers to a deleted meeting
// $this->meeting remains null when the remote RecordingMeeting refers to a deleted meeting
} elseif ($this->meeting->getId() != $recordingMeeting->id) {
throw new Exception('The RecordingEntity meeting id differs from the RecordingMeeting meeting id');
}

@ -12,6 +12,7 @@ use Exception;
/**
* Class RegistrantEntity.
*
* @package Chamilo\PluginBundle\Zoom
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\RegistrantEntityRepository")
* @ORM\Table(
@ -25,6 +26,9 @@ use Exception;
*/
class RegistrantEntity
{
/** @var string */
public $fullName;
/**
* @var string
* @ORM\Column(type="string")
@ -78,9 +82,6 @@ class RegistrantEntity
/** @var MeetingRegistrantListItem */
private $meetingRegistrantListItem;
/** @var string */
public $fullName;
/**
* @return string
*/
@ -106,9 +107,9 @@ class RegistrantEntity
}
/**
* @return MeetingRegistrantListItem
*
* @throws Exception
*
* @return MeetingRegistrantListItem
*/
public function getMeetingRegistrantListItem()
{
@ -116,9 +117,9 @@ class RegistrantEntity
}
/**
* @return CreatedRegistration
*
* @throws Exception
*
* @return CreatedRegistration
*/
public function getCreatedRegistration()
{
@ -126,9 +127,9 @@ class RegistrantEntity
}
/**
* @return MeetingRegistrant
*
* @throws Exception
*
* @return MeetingRegistrant
*/
public function getMeetingRegistrant()
{
@ -214,6 +215,7 @@ class RegistrantEntity
/**
* @ORM\PostLoad
*
* @throws Exception
*/
public function postLoad()

@ -31,7 +31,6 @@ if (array_key_exists('meetingId', $_REQUEST)) {
$plugin->getUserMeetingURL($meeting),
get_lang('JoinMeetingAsMyself')
);
} catch (Exception $exception) {
Display::addFlash(
Display::return_message($exception->getMessage(), 'error')

@ -28,16 +28,6 @@ abstract class Client
return self::$instance;
}
/**
* Registers an initialized Client.
*
* @param Client $instance
*/
protected static function register($instance)
{
self::$instance = $instance;
}
/**
* Sends a Zoom API-compliant HTTP request and retrieves the response.
*
@ -54,4 +44,14 @@ abstract class Client
* @return string response body (not json-decoded)
*/
abstract public function send($httpMethod, $relativePath, $parameters = [], $requestBody = null);
/**
* Registers an initialized Client.
*
* @param Client $instance
*/
protected static function register($instance)
{
self::$instance = $instance;
}
}

@ -34,7 +34,7 @@ class MeetingInfoGet extends MeetingInfo
/**
* Retrieves a meeting from its numeric identifier.
*
* @param int $id
* @param int $id
*
* @throws Exception
*

@ -30,7 +30,7 @@ class MeetingInstances
/**
* Retrieves a meeting's instances.
*
* @param int $meetingId
* @param int $meetingId
*
* @throws Exception
*

@ -35,7 +35,7 @@ class MeetingList
/**
* Retrieves all meetings of a type.
*
* @param int $type TYPE_SCHEDULED, TYPE_LIVE or TYPE_UPCOMING
* @param int $type TYPE_SCHEDULED, TYPE_LIVE or TYPE_UPCOMING
*
* @throws Exception
*

@ -30,7 +30,7 @@ class MeetingRegistrantList
/**
* Retrieves all registrant for a meeting.
*
* @param int $meetingId
* @param int $meetingId
*
* @throws Exception
*

@ -13,7 +13,8 @@ use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityRepository;
/**
* Class MeetingEntityRepository
* Class MeetingEntityRepository.
*
* @package Chamilo\PluginBundle\Zoom
*/
class MeetingEntityRepository extends EntityRepository
@ -36,6 +37,7 @@ class MeetingEntityRepository extends EntityRepository
$matching[] = $candidate;
}
}
return $matching;
}
@ -70,6 +72,7 @@ class MeetingEntityRepository extends EntityRepository
* Returns either a user's meetings or all user meetings.
*
* @param User|null $user
*
* @return ArrayCollection|Collection|MeetingEntity[]
*/
public function userMeetings($user = null)
@ -88,6 +91,7 @@ class MeetingEntityRepository extends EntityRepository
/**
* @param User|null $user
*
* @return ArrayCollection|Collection|MeetingEntity[]
*/
public function unfinishedUserMeetings($user = null)
@ -100,9 +104,10 @@ class MeetingEntityRepository extends EntityRepository
}
/**
* @param DateTime $start
* @param DateTime $end
* @param DateTime $start
* @param DateTime $end
* @param User|null $user
*
* @return ArrayCollection|Collection|MeetingEntity[]
*/
public function periodUserMeetings($start, $end, $user = null)
@ -115,12 +120,10 @@ class MeetingEntityRepository extends EntityRepository
);
}
/**
* Returns either a course's meetings or all course meetings.
*
* @param Course|null $course
* @param Course|null $course
* @param Session|null $session
*
* @return ArrayCollection|Collection|MeetingEntity[]

@ -11,7 +11,8 @@ use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityRepository;
/**
* Class RecordingEntityRepository
* Class RecordingEntityRepository.
*
* @package Chamilo\PluginBundle\Zoom
*/
class RecordingEntityRepository extends EntityRepository
@ -26,6 +27,7 @@ class RecordingEntityRepository extends EntityRepository
$matching[] = $candidate;
}
}
return $matching;
}
@ -33,6 +35,7 @@ class RecordingEntityRepository extends EntityRepository
* Returns a user's meeting recordings.
*
* @param User $user
*
* @return ArrayCollection|Collection|RecordingEntity[]
*/
public function userRecordings($user)

@ -9,7 +9,8 @@ use DateTime;
use Doctrine\ORM\EntityRepository;
/**
* Class RegistrantEntityRepository
* Class RegistrantEntityRepository.
*
* @package Chamilo\PluginBundle\Zoom
*/
class RegistrantEntityRepository extends EntityRepository

@ -35,7 +35,7 @@ class ZoomPlugin extends Plugin
/**
* ZoomPlugin constructor.
* @inheritDoc
* {@inheritdoc}
* Initializes the API JWT client and the entity repositories.
*/
protected function __construct()
@ -95,13 +95,14 @@ class ZoomPlugin extends Plugin
public static function currentUserCanCreateUserMeeting()
{
$user = api_get_user_entity(api_get_user_id());
return (!is_null($user)
return !is_null($user)
&& 'true' === api_get_plugin_setting('zoom', 'enableGlobalConferencePerUser')
&& in_array(
(api_is_platform_admin() ? PLATFORM_ADMIN : $user->getStatus()),
(array)api_get_plugin_setting('zoom', 'globalConferenceAllowRoles')
(array) api_get_plugin_setting('zoom', 'globalConferenceAllowRoles')
)
);
;
}
/**
@ -134,7 +135,7 @@ class ZoomPlugin extends Plugin
{
$elements = self::meetingsToWhichCurrentUserIsRegisteredComingSoon();
if (ZoomPlugin::currentUserCanJoinGlobalMeeting()) {
$elements[get_lang('JoinGlobalVideoConference')] = api_get_path(WEB_PLUGIN_PATH) . 'zoom/global.php';
$elements[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';
@ -179,7 +180,6 @@ class ZoomPlugin extends Plugin
return Database::getManager()->getRepository(RegistrantEntity::class);
}
/**
* Creates this plugin's related tables in the internal database.
* Installs course fields in all courses.
@ -198,7 +198,7 @@ class ZoomPlugin extends Plugin
/**
* Drops this plugins' related tables from the internal database.
* Uninstalls course fields in all courses()
* Uninstalls course fields in all courses().
*/
public function uninstall()
{
@ -263,9 +263,9 @@ class ZoomPlugin extends Plugin
*
* @param MeetingEntity $meetingEntity the meeting
*
* @return FormValidator
* @throws Exception
*
* @return FormValidator
*/
public function getEditMeetingForm($meetingEntity)
{
@ -287,7 +287,7 @@ class ZoomPlugin extends Plugin
DateTimeInterface::ISO8601
);
$meetingInfoGet->timezone = date_default_timezone_get();
$meetingInfoGet->duration = (int)$form->getSubmitValue('duration');
$meetingInfoGet->duration = (int) $form->getSubmitValue('duration');
}
$meetingInfoGet->topic = $form->getSubmitValue('topic');
$meetingInfoGet->agenda = $form->getSubmitValue('agenda');
@ -322,11 +322,11 @@ class ZoomPlugin extends Plugin
* Generates a meeting delete form and deletes the meeting on validation.
*
* @param MeetingEntity $meetingEntity
* @param string $returnURL where to redirect to on successful deletion
* @param string $returnURL where to redirect to on successful deletion
*
* @return FormValidator
* @throws Exception
*
* @return FormValidator
*/
public function getDeleteMeetingForm($meetingEntity, $returnURL)
{
@ -356,9 +356,9 @@ class ZoomPlugin extends Plugin
*
* @param MeetingEntity $meetingEntity
*
* @return FormValidator
* @throws Exception
*
* @return FormValidator
*/
public function getRegisterParticipantForm($meetingEntity)
{
@ -535,8 +535,8 @@ class ZoomPlugin extends Plugin
* Generates a form to schedule a meeting.
* On validation, creates it and redirects to its page.
*
* @param User|null $user
* @param Course|null $course
* @param User|null $user
* @param Course|null $course
* @param Session|null $session
*
* @throws Exception
@ -676,7 +676,7 @@ class ZoomPlugin extends Plugin
*
* @param MeetingEntity $meeting
* @param RecordingFile $file
* @param string $name
* @param string $name
*
* @throws Exception
*/
@ -690,18 +690,10 @@ class ZoomPlugin extends Plugin
if (empty($courseInfo)) {
throw new Exception('This meeting is not linked to a valid course');
}
$path = '/zoom_meeting_recording_file_' . $file->id . '.' . $file->file_type;
$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'));
}
}
@ -710,7 +702,7 @@ class ZoomPlugin extends Plugin
*
* @param MeetingEntity $meeting
* @param RecordingFile $file
* @param string $name
* @param string $name
*
* @throws Exception
*/
@ -730,7 +722,7 @@ class ZoomPlugin extends Plugin
}
$curl = curl_init($file->getFullDownloadURL($this->jwtClient->token));
if (false === $curl) {
throw new Exception('Could not init curl: ' . curl_error($curl));
throw new Exception('Could not init curl: '.curl_error($curl));
}
if (!curl_setopt_array(
$curl,
@ -741,10 +733,10 @@ class ZoomPlugin extends Plugin
CURLOPT_TIMEOUT => 120,
]
)) {
throw new Exception("Could not set curl options: " . curl_error($curl));
throw new Exception("Could not set curl options: ".curl_error($curl));
}
if (false === curl_exec($curl)) {
throw new Exception("curl_exec failed: " . curl_error($curl));
throw new Exception("curl_exec failed: ".curl_error($curl));
}
$newPath = handle_uploaded_document(
$courseInfo,
@ -756,7 +748,7 @@ class ZoomPlugin extends Plugin
'type' => $file->file_type,
],
'/',
api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document',
api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document',
api_get_user_id(),
0,
null,
@ -826,7 +818,7 @@ class ZoomPlugin extends Plugin
* Returns the URL to enter (start or join) a user meeting.
*
* @param MeetingEntity $meeting
* @param bool $autoRegister
* @param bool $autoRegister
*
* @throws Exception
* @throws OptimisticLockException
@ -859,9 +851,6 @@ class ZoomPlugin extends Plugin
}
/**
* @param DateTime $startDate
* @param DateTime $endDate
*
* @throws OptimisticLockException
* @throws Exception
*/
@ -900,9 +889,9 @@ class ZoomPlugin extends Plugin
*
* @param MeetingEntity $meeting a new, unsaved meeting with at least a type and a topic
*
* @return MeetingEntity
* @throws Exception
*
* @return MeetingEntity
*/
private function createMeetingFromMeetingEntity($meeting)
{
@ -918,9 +907,9 @@ class ZoomPlugin extends Plugin
}
/**
* @return MeetingEntity
*
* @throws Exception
*
* @return MeetingEntity
*/
private function createGlobalMeeting()
{
@ -945,9 +934,9 @@ class ZoomPlugin extends Plugin
/**
* Starts a new instant meeting and redirects to its start url.
*
* @param string $topic
* @param User|null $user
* @param Course|null $course
* @param string $topic
* @param User|null $user
* @param Course|null $course
* @param Session|null $session
*
* @throws Exception
@ -968,17 +957,18 @@ class ZoomPlugin extends Plugin
* Schedules a meeting and returns it.
* set $course, $session and $user to null in order to create a global meeting.
*
* @param User|null $user the current user, for a course meeting or a user meeting
* @param Course|null $course the course, for a course meeting
* @param Session|null $session the session, for a course meeting
* @param DateTime $startTime meeting local start date-time (configure local timezone on your Zoom account)
* @param int $duration in minutes
* @param string $topic short title of the meeting, required
* @param string $agenda ordre du jour
* @param string $password meeting password
* @param User|null $user the current user, for a course meeting or a user meeting
* @param Course|null $course the course, for a course meeting
* @param Session|null $session the session, for a course meeting
* @param DateTime $startTime meeting local start date-time (configure local timezone on your Zoom account)
* @param int $duration in minutes
* @param string $topic short title of the meeting, required
* @param string $agenda ordre du jour
* @param string $password meeting password
*
* @return MeetingEntity meeting
* @throws Exception
*
* @return MeetingEntity meeting
*/
private function scheduleMeeting($user, $course, $session, $startTime, $duration, $topic, $agenda, $password)
{
@ -990,6 +980,7 @@ class ZoomPlugin extends Plugin
$meetingInfoGet->settings->approval_type = $this->get('enableParticipantRegistration')
? MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE
: MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED;
return $this->createMeetingFromMeetingEntity(
(new MeetingEntity())
->setMeetingInfoGet($meetingInfoGet)
@ -1001,13 +992,13 @@ class ZoomPlugin extends Plugin
/**
* @param MeetingEntity $meetingEntity
* @param User $user
* @param bool $andFlush
*
* @return RegistrantEntity
* @param User $user
* @param bool $andFlush
*
* @throws OptimisticLockException
* @throws Exception
*
* @return RegistrantEntity
*/
private function registerUser($meetingEntity, $user, $andFlush = true)
{
@ -1028,6 +1019,7 @@ class ZoomPlugin extends Plugin
if ($andFlush) {
Database::getManager()->flush($registrantEntity);
}
return $registrantEntity;
}
@ -1035,7 +1027,7 @@ class ZoomPlugin extends Plugin
* Register users to a meeting.
*
* @param MeetingEntity $meetingEntity
* @param User[] $users
* @param User[] $users
*
* @throws OptimisticLockException
*
@ -1071,7 +1063,7 @@ class ZoomPlugin extends Plugin
/**
* Removes registrants from a meeting.
*
* @param MeetingEntity $meetingEntity
* @param MeetingEntity $meetingEntity
* @param RegistrantEntity[] $registrants
*
* @throws Exception
@ -1093,7 +1085,7 @@ class ZoomPlugin extends Plugin
* Updates meeting registrants list. Adds the missing registrants and removes the extra.
*
* @param MeetingEntity $meetingEntity
* @param User[] $users list of users to be registered
* @param User[] $users list of users to be registered
*
* @throws Exception
*/

Loading…
Cancel
Save