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. 29
      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. 9
      plugin/zoom/lib/MeetingEntityRepository.php
  7. 5
      plugin/zoom/lib/RecordingEntityRepository.php
  8. 3
      plugin/zoom/lib/RegistrantEntityRepository.php
  9. 44
      plugin/zoom/lib/zoom_plugin.class.php

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

@ -13,6 +13,7 @@ use Exception;
/** /**
* Class RecordingEntity. * Class RecordingEntity.
*
* @package Chamilo\PluginBundle\Zoom * @package Chamilo\PluginBundle\Zoom
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\RecordingEntityRepository") * @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\RecordingEntityRepository")
* @ORM\Table( * @ORM\Table(
@ -25,6 +26,18 @@ use Exception;
*/ */
class RecordingEntity class RecordingEntity
{ {
/** @var DateTime */
public $startDateTime;
/** @var string */
public $formattedStartTime;
/** @var DateInterval */
public $durationInterval;
/** @var string */
public $formattedDuration;
/** /**
* @var string * @var string
* @ORM\Column(type="string") * @ORM\Column(type="string")
@ -51,18 +64,6 @@ class RecordingEntity
/** @var RecordingMeeting */ /** @var RecordingMeeting */
private $recordingMeeting; private $recordingMeeting;
/** @var DateTime */
public $startDateTime;
/** @var string */
public $formattedStartTime;
/** @var DateInterval */
public $durationInterval;
/** @var string */
public $formattedDuration;
/** /**
* @param $name * @param $name
* *
@ -96,9 +97,9 @@ class RecordingEntity
} }
/** /**
* @return RecordingMeeting
*
* @throws Exception * @throws Exception
*
* @return RecordingMeeting
*/ */
public function getRecordingMeeting() public function getRecordingMeeting()
{ {

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

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

@ -28,16 +28,6 @@ abstract class Client
return self::$instance; 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. * 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) * @return string response body (not json-decoded)
*/ */
abstract public function send($httpMethod, $relativePath, $parameters = [], $requestBody = null); abstract public function send($httpMethod, $relativePath, $parameters = [], $requestBody = null);
/**
* Registers an initialized Client.
*
* @param Client $instance
*/
protected static function register($instance)
{
self::$instance = $instance;
}
} }

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

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

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

@ -35,7 +35,7 @@ class ZoomPlugin extends Plugin
/** /**
* ZoomPlugin constructor. * ZoomPlugin constructor.
* @inheritDoc * {@inheritdoc}
* Initializes the API JWT client and the entity repositories. * Initializes the API JWT client and the entity repositories.
*/ */
protected function __construct() protected function __construct()
@ -95,13 +95,14 @@ class ZoomPlugin extends Plugin
public static function currentUserCanCreateUserMeeting() public static function currentUserCanCreateUserMeeting()
{ {
$user = api_get_user_entity(api_get_user_id()); $user = api_get_user_entity(api_get_user_id());
return (!is_null($user)
return !is_null($user)
&& 'true' === api_get_plugin_setting('zoom', 'enableGlobalConferencePerUser') && 'true' === api_get_plugin_setting('zoom', 'enableGlobalConferencePerUser')
&& in_array( && in_array(
(api_is_platform_admin() ? PLATFORM_ADMIN : $user->getStatus()), (api_is_platform_admin() ? PLATFORM_ADMIN : $user->getStatus()),
(array) api_get_plugin_setting('zoom', 'globalConferenceAllowRoles') (array) api_get_plugin_setting('zoom', 'globalConferenceAllowRoles')
) )
); ;
} }
/** /**
@ -179,7 +180,6 @@ class ZoomPlugin extends Plugin
return Database::getManager()->getRepository(RegistrantEntity::class); return Database::getManager()->getRepository(RegistrantEntity::class);
} }
/** /**
* Creates this plugin's related tables in the internal database. * Creates this plugin's related tables in the internal database.
* Installs course fields in all courses. * Installs course fields in all courses.
@ -198,7 +198,7 @@ class ZoomPlugin extends Plugin
/** /**
* Drops this plugins' related tables from the internal database. * Drops this plugins' related tables from the internal database.
* Uninstalls course fields in all courses() * Uninstalls course fields in all courses().
*/ */
public function uninstall() public function uninstall()
{ {
@ -263,9 +263,9 @@ class ZoomPlugin extends Plugin
* *
* @param MeetingEntity $meetingEntity the meeting * @param MeetingEntity $meetingEntity the meeting
* *
* @return FormValidator
* @throws Exception * @throws Exception
* *
* @return FormValidator
*/ */
public function getEditMeetingForm($meetingEntity) public function getEditMeetingForm($meetingEntity)
{ {
@ -324,9 +324,9 @@ class ZoomPlugin extends Plugin
* @param MeetingEntity $meetingEntity * @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 * @throws Exception
* *
* @return FormValidator
*/ */
public function getDeleteMeetingForm($meetingEntity, $returnURL) public function getDeleteMeetingForm($meetingEntity, $returnURL)
{ {
@ -356,9 +356,9 @@ class ZoomPlugin extends Plugin
* *
* @param MeetingEntity $meetingEntity * @param MeetingEntity $meetingEntity
* *
* @return FormValidator
* @throws Exception * @throws Exception
* *
* @return FormValidator
*/ */
public function getRegisterParticipantForm($meetingEntity) public function getRegisterParticipantForm($meetingEntity)
{ {
@ -693,15 +693,7 @@ class ZoomPlugin extends Plugin
$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); $docId = DocumentManager::addCloudLink($courseInfo, $path, $file->play_url, $name);
if (!$docId) { if (!$docId) {
throw new Exception( throw new Exception(get_lang(DocumentManager::cloudLinkExists($courseInfo, $path, $file->play_url) ? 'UrlAlreadyExists' : 'ErrorAddCloudLink'));
get_lang(
DocumentManager::cloudLinkExists(
$courseInfo,
$path,
$file->play_url
) ? 'UrlAlreadyExists' : 'ErrorAddCloudLink'
)
);
} }
} }
@ -859,9 +851,6 @@ class ZoomPlugin extends Plugin
} }
/** /**
* @param DateTime $startDate
* @param DateTime $endDate
*
* @throws OptimisticLockException * @throws OptimisticLockException
* @throws Exception * @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 * @param MeetingEntity $meeting a new, unsaved meeting with at least a type and a topic
* *
* @return MeetingEntity
* @throws Exception * @throws Exception
* *
* @return MeetingEntity
*/ */
private function createMeetingFromMeetingEntity($meeting) private function createMeetingFromMeetingEntity($meeting)
{ {
@ -918,9 +907,9 @@ class ZoomPlugin extends Plugin
} }
/** /**
* @return MeetingEntity
*
* @throws Exception * @throws Exception
*
* @return MeetingEntity
*/ */
private function createGlobalMeeting() private function createGlobalMeeting()
{ {
@ -977,8 +966,9 @@ class ZoomPlugin extends Plugin
* @param string $agenda ordre du jour * @param string $agenda ordre du jour
* @param string $password meeting password * @param string $password meeting password
* *
* @return MeetingEntity meeting
* @throws Exception * @throws Exception
*
* @return MeetingEntity meeting
*/ */
private function scheduleMeeting($user, $course, $session, $startTime, $duration, $topic, $agenda, $password) 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') $meetingInfoGet->settings->approval_type = $this->get('enableParticipantRegistration')
? MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE ? MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE
: MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED; : MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED;
return $this->createMeetingFromMeetingEntity( return $this->createMeetingFromMeetingEntity(
(new MeetingEntity()) (new MeetingEntity())
->setMeetingInfoGet($meetingInfoGet) ->setMeetingInfoGet($meetingInfoGet)
@ -1004,10 +995,10 @@ class ZoomPlugin extends Plugin
* @param User $user * @param User $user
* @param bool $andFlush * @param bool $andFlush
* *
* @return RegistrantEntity
*
* @throws OptimisticLockException * @throws OptimisticLockException
* @throws Exception * @throws Exception
*
* @return RegistrantEntity
*/ */
private function registerUser($meetingEntity, $user, $andFlush = true) private function registerUser($meetingEntity, $user, $andFlush = true)
{ {
@ -1028,6 +1019,7 @@ class ZoomPlugin extends Plugin
if ($andFlush) { if ($andFlush) {
Database::getManager()->flush($registrantEntity); Database::getManager()->flush($registrantEntity);
} }
return $registrantEntity; return $registrantEntity;
} }

Loading…
Cancel
Save