diff --git a/plugin/zoom/Entity/MeetingEntity.php b/plugin/zoom/Entity/MeetingEntity.php index 591d95e4cf..2e8509c891 100644 --- a/plugin/zoom/Entity/MeetingEntity.php +++ b/plugin/zoom/Entity/MeetingEntity.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; } diff --git a/plugin/zoom/Entity/RecordingEntity.php b/plugin/zoom/Entity/RecordingEntity.php index 4f688da408..a933b3ece5 100644 --- a/plugin/zoom/Entity/RecordingEntity.php +++ b/plugin/zoom/Entity/RecordingEntity.php @@ -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'); } diff --git a/plugin/zoom/Entity/RegistrantEntity.php b/plugin/zoom/Entity/RegistrantEntity.php index 48bcf4b66b..1c95244095 100644 --- a/plugin/zoom/Entity/RegistrantEntity.php +++ b/plugin/zoom/Entity/RegistrantEntity.php @@ -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() diff --git a/plugin/zoom/join_meeting.php b/plugin/zoom/join_meeting.php index a3b2a5511f..9cae81d6e2 100644 --- a/plugin/zoom/join_meeting.php +++ b/plugin/zoom/join_meeting.php @@ -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') diff --git a/plugin/zoom/lib/API/Client.php b/plugin/zoom/lib/API/Client.php index 8dabe01f07..262cd072ea 100644 --- a/plugin/zoom/lib/API/Client.php +++ b/plugin/zoom/lib/API/Client.php @@ -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; + } } diff --git a/plugin/zoom/lib/API/MeetingInfoGet.php b/plugin/zoom/lib/API/MeetingInfoGet.php index abdfaea8fb..8998591b9d 100644 --- a/plugin/zoom/lib/API/MeetingInfoGet.php +++ b/plugin/zoom/lib/API/MeetingInfoGet.php @@ -34,7 +34,7 @@ class MeetingInfoGet extends MeetingInfo /** * Retrieves a meeting from its numeric identifier. * - * @param int $id + * @param int $id * * @throws Exception * diff --git a/plugin/zoom/lib/API/MeetingInstances.php b/plugin/zoom/lib/API/MeetingInstances.php index 133d82148b..4666ada4e2 100644 --- a/plugin/zoom/lib/API/MeetingInstances.php +++ b/plugin/zoom/lib/API/MeetingInstances.php @@ -30,7 +30,7 @@ class MeetingInstances /** * Retrieves a meeting's instances. * - * @param int $meetingId + * @param int $meetingId * * @throws Exception * diff --git a/plugin/zoom/lib/API/MeetingList.php b/plugin/zoom/lib/API/MeetingList.php index 449d275e52..e272636744 100644 --- a/plugin/zoom/lib/API/MeetingList.php +++ b/plugin/zoom/lib/API/MeetingList.php @@ -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 * diff --git a/plugin/zoom/lib/API/MeetingRegistrantList.php b/plugin/zoom/lib/API/MeetingRegistrantList.php index 515ca9437b..84d569b520 100644 --- a/plugin/zoom/lib/API/MeetingRegistrantList.php +++ b/plugin/zoom/lib/API/MeetingRegistrantList.php @@ -30,7 +30,7 @@ class MeetingRegistrantList /** * Retrieves all registrant for a meeting. * - * @param int $meetingId + * @param int $meetingId * * @throws Exception * diff --git a/plugin/zoom/lib/MeetingEntityRepository.php b/plugin/zoom/lib/MeetingEntityRepository.php index 791f7ffa9b..ccc9b62162 100644 --- a/plugin/zoom/lib/MeetingEntityRepository.php +++ b/plugin/zoom/lib/MeetingEntityRepository.php @@ -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[] diff --git a/plugin/zoom/lib/RecordingEntityRepository.php b/plugin/zoom/lib/RecordingEntityRepository.php index b6ec27834b..3d6d86aaef 100644 --- a/plugin/zoom/lib/RecordingEntityRepository.php +++ b/plugin/zoom/lib/RecordingEntityRepository.php @@ -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) diff --git a/plugin/zoom/lib/RegistrantEntityRepository.php b/plugin/zoom/lib/RegistrantEntityRepository.php index 3e868574d4..37f3e7d8bb 100644 --- a/plugin/zoom/lib/RegistrantEntityRepository.php +++ b/plugin/zoom/lib/RegistrantEntityRepository.php @@ -9,7 +9,8 @@ use DateTime; use Doctrine\ORM\EntityRepository; /** - * Class RegistrantEntityRepository + * Class RegistrantEntityRepository. + * * @package Chamilo\PluginBundle\Zoom */ class RegistrantEntityRepository extends EntityRepository diff --git a/plugin/zoom/lib/zoom_plugin.class.php b/plugin/zoom/lib/zoom_plugin.class.php index a9148dba1a..843a88e0aa 100755 --- a/plugin/zoom/lib/zoom_plugin.class.php +++ b/plugin/zoom/lib/zoom_plugin.class.php @@ -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 */