upgrade
This commit is contained in:
706
plugin/zoom/Entity/Meeting.php
Normal file
706
plugin/zoom/Entity/Meeting.php
Normal file
@@ -0,0 +1,706 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use Chamilo\CoreBundle\Entity\Course;
|
||||
use Chamilo\CoreBundle\Entity\CourseRelUser;
|
||||
use Chamilo\CoreBundle\Entity\Session;
|
||||
use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser;
|
||||
use Chamilo\CoreBundle\Entity\SysAnnouncement;
|
||||
use Chamilo\CourseBundle\Entity\CGroupInfo;
|
||||
use Chamilo\PluginBundle\Zoom\API\BaseMeetingTrait;
|
||||
use Chamilo\PluginBundle\Zoom\API\MeetingInfoGet;
|
||||
use Chamilo\PluginBundle\Zoom\API\MeetingListItem;
|
||||
use Chamilo\PluginBundle\Zoom\API\MeetingSettings;
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
use Database;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class Meeting.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\MeetingRepository")
|
||||
* @ORM\Table(
|
||||
* name="plugin_zoom_meeting",
|
||||
* indexes={
|
||||
* @ORM\Index(name="user_id_index", columns={"user_id"}),
|
||||
* @ORM\Index(name="course_id_index", columns={"course_id"}),
|
||||
* @ORM\Index(name="session_id_index", columns={"session_id"})
|
||||
* }
|
||||
* )
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
* @ORM\InheritanceType("SINGLE_TABLE")
|
||||
* @ORM\DiscriminatorColumn(name="type", type="string")
|
||||
* @ORM\DiscriminatorMap({"meeting" = "Chamilo\PluginBundle\Zoom\Meeting", "webinar" = "Chamilo\PluginBundle\Zoom\Webinar"})
|
||||
*/
|
||||
class Meeting
|
||||
{
|
||||
/** @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
|
||||
* @ORM\Column(type="integer", name="id")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue()
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var int the remote zoom meeting identifier
|
||||
* @ORM\Column(name="meeting_id", type="string")
|
||||
*/
|
||||
protected $meetingId;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var Course
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
|
||||
* @ORM\JoinColumn(name="course_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $course;
|
||||
|
||||
/**
|
||||
* @var CGroupInfo
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CGroupInfo")
|
||||
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=true)
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
* @var Session
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
|
||||
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true)
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="meeting_list_item_json", nullable=true)
|
||||
*/
|
||||
protected $meetingListItemJson;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="meeting_info_get_json", nullable=true)
|
||||
*/
|
||||
protected $meetingInfoGetJson;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
* @ORM\Column(type="boolean", name="sign_attendance")
|
||||
*/
|
||||
protected $signAttendance;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="text", name="reason_to_sign_attendance", nullable=true)
|
||||
*/
|
||||
protected $reasonToSignAttendance;
|
||||
|
||||
/** @var MeetingListItem */
|
||||
protected $meetingListItem;
|
||||
|
||||
/** @var MeetingInfoGet */
|
||||
protected $meetingInfoGet;
|
||||
|
||||
/**
|
||||
* @var MeetingActivity[]|ArrayCollection
|
||||
* @ORM\OrderBy({"createdAt" = "DESC"})
|
||||
* @ORM\OneToMany(targetEntity="MeetingActivity", mappedBy="meeting", cascade={"persist", "remove"})
|
||||
*/
|
||||
protected $activities;
|
||||
|
||||
/**
|
||||
* @var Registrant[]|ArrayCollection
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Registrant", mappedBy="meeting", cascade={"persist", "remove"})
|
||||
*/
|
||||
protected $registrants;
|
||||
|
||||
/**
|
||||
* @var Recording[]|ArrayCollection
|
||||
*
|
||||
* @ORM\OneToMany(targetEntity="Recording", mappedBy="meeting", cascade={"persist"}, orphanRemoval=true)
|
||||
*/
|
||||
protected $recordings;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*
|
||||
* @ORM\Column(type="string", name="account_email", nullable=true)
|
||||
*/
|
||||
protected $accountEmail;
|
||||
|
||||
/**
|
||||
* @var SysAnnouncement|null
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\SysAnnouncement")
|
||||
* @ORM\JoinColumn(name="sys_announcement_id", referencedColumnName="id", onDelete="SET NULL")
|
||||
*/
|
||||
protected $sysAnnouncement;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->registrants = new ArrayCollection();
|
||||
$this->recordings = new ArrayCollection();
|
||||
$this->activities = new ArrayCollection();
|
||||
$this->signAttendance = false;
|
||||
$this->sysAnnouncement = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('Meeting %d', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMeetingId()
|
||||
{
|
||||
return $this->meetingId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $meetingId
|
||||
*
|
||||
* @return Meeting
|
||||
*/
|
||||
public function setMeetingId($meetingId)
|
||||
{
|
||||
$this->meetingId = $meetingId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Course
|
||||
*/
|
||||
public function getCourse()
|
||||
{
|
||||
return $this->course;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Registrant[]|ArrayCollection
|
||||
*/
|
||||
public function getRegistrants()
|
||||
{
|
||||
return $this->registrants->filter(function (Registrant $registrant) {
|
||||
return !$registrant instanceof Presenter;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection<int, Presenter>
|
||||
*/
|
||||
public function getPresenters(): ArrayCollection
|
||||
{
|
||||
return $this->registrants->filter(function (Registrant $registrant) {
|
||||
return $registrant instanceof Presenter;
|
||||
});
|
||||
}
|
||||
|
||||
public function hasUserAsPresenter(User $user): bool
|
||||
{
|
||||
$presenters = $this->getPresenters();
|
||||
|
||||
$criteria = Criteria::create();
|
||||
$criteria->where(
|
||||
Criteria::expr()->eq('user', $user)
|
||||
);
|
||||
|
||||
return $presenters->matching($criteria)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Recording[]|ArrayCollection
|
||||
*/
|
||||
public function getRecordings()
|
||||
{
|
||||
return $this->recordings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeetingActivity[]|ArrayCollection
|
||||
*/
|
||||
public function getActivities()
|
||||
{
|
||||
return $this->activities;
|
||||
}
|
||||
|
||||
public function addActivity(MeetingActivity $activity)
|
||||
{
|
||||
$activity->setMeeting($this);
|
||||
$this->activities[] = $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MeetingActivity[]|ArrayCollection $activities
|
||||
*
|
||||
* @return Meeting
|
||||
*/
|
||||
public function setActivities($activities)
|
||||
{
|
||||
$this->activities = $activities;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostLoad
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function postLoad()
|
||||
{
|
||||
if (null !== $this->meetingListItemJson) {
|
||||
$this->meetingListItem = MeetingListItem::fromJson($this->meetingListItemJson);
|
||||
}
|
||||
if (null !== $this->meetingInfoGetJson) {
|
||||
$this->meetingInfoGet = MeetingInfoGet::fromJson($this->meetingInfoGetJson);
|
||||
}
|
||||
$this->initializeDisplayableProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostUpdate
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function postUpdate()
|
||||
{
|
||||
$this->initializeDisplayableProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreFlush
|
||||
*/
|
||||
public function preFlush()
|
||||
{
|
||||
if (null !== $this->meetingListItem) {
|
||||
$this->meetingListItemJson = json_encode($this->meetingListItem);
|
||||
}
|
||||
if (null !== $this->meetingInfoGet) {
|
||||
$this->meetingInfoGetJson = json_encode($this->meetingInfoGet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeetingListItem
|
||||
*/
|
||||
public function getMeetingListItem()
|
||||
{
|
||||
return $this->meetingListItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MeetingInfoGet
|
||||
*/
|
||||
public function getMeetingInfoGet()
|
||||
{
|
||||
return $this->meetingInfoGet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Course $course
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCourse($course)
|
||||
{
|
||||
$this->course = $course;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Session $session
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSession($session)
|
||||
{
|
||||
$this->session = $session;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CGroupInfo
|
||||
*/
|
||||
public function getGroup()
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CGroupInfo $group
|
||||
*
|
||||
* @return Meeting
|
||||
*/
|
||||
public function setGroup($group)
|
||||
{
|
||||
$this->group = $group;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MeetingListItem $meetingListItem
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Meeting
|
||||
*/
|
||||
public function setMeetingListItem($meetingListItem)
|
||||
{
|
||||
if (null === $this->meetingId) {
|
||||
$this->meetingId = $meetingListItem->id;
|
||||
} elseif ($this->meetingId != $meetingListItem->id) {
|
||||
throw new Exception('the Meeting identifier differs from the MeetingListItem identifier');
|
||||
}
|
||||
$this->meetingListItem = $meetingListItem;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MeetingInfoGet|BaseMeetingTrait $meetingInfoGet
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Meeting
|
||||
*/
|
||||
public function setMeetingInfoGet($meetingInfoGet)
|
||||
{
|
||||
if (null === $this->meetingId) {
|
||||
$this->meetingId = $meetingInfoGet->id;
|
||||
} elseif ($this->meetingId != $meetingInfoGet->id) {
|
||||
throw new Exception('the Meeting identifier differs from the MeetingInfoGet identifier');
|
||||
}
|
||||
$this->meetingInfoGet = $meetingInfoGet;
|
||||
$this->initializeDisplayableProperties();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCourseMeeting()
|
||||
{
|
||||
return null !== $this->course;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCourseGroupMeeting()
|
||||
{
|
||||
return null !== $this->course && null !== $this->group;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isUserMeeting()
|
||||
{
|
||||
return null !== $this->user && null === $this->course;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isGlobalMeeting()
|
||||
{
|
||||
return null === $this->user && null === $this->course;
|
||||
}
|
||||
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->meetingInfoGet->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the list of users that can register into this meeting.
|
||||
* Zoom requires an email address, therefore users without an email address are excluded from the list.
|
||||
*
|
||||
* @return User[] the list of users
|
||||
*/
|
||||
public function getRegistrableUsers()
|
||||
{
|
||||
$users = [];
|
||||
if (!$this->isCourseMeeting()) {
|
||||
$criteria = ['active' => true];
|
||||
$users = Database::getManager()->getRepository('ChamiloUserBundle:User')->findBy($criteria);
|
||||
} elseif (null === $this->session) {
|
||||
if (null !== $this->course) {
|
||||
/** @var CourseRelUser $courseRelUser */
|
||||
foreach ($this->course->getUsers() as $courseRelUser) {
|
||||
$users[] = $courseRelUser->getUser();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (null !== $this->course) {
|
||||
$subscriptions = $this->session->getUserCourseSubscriptionsByStatus($this->course, Session::STUDENT);
|
||||
if ($subscriptions) {
|
||||
/** @var SessionRelCourseRelUser $sessionCourseUser */
|
||||
foreach ($subscriptions as $sessionCourseUser) {
|
||||
$users[] = $sessionCourseUser->getUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$activeUsersWithEmail = [];
|
||||
foreach ($users as $user) {
|
||||
if ($user->isActive() && !empty($user->getEmail())) {
|
||||
$activeUsersWithEmail[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $activeUsersWithEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function requiresDateAndDuration()
|
||||
{
|
||||
return MeetingInfoGet::TYPE_SCHEDULED === $this->meetingInfoGet->type
|
||||
|| MeetingInfoGet::TYPE_RECURRING_WITH_FIXED_TIME === $this->meetingInfoGet->type;
|
||||
}
|
||||
|
||||
public function requiresRegistration(): bool
|
||||
{
|
||||
return true; //MeetingSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE === $this->meetingInfoGet->settings->approval_type;
|
||||
/*return
|
||||
MeetingSettings::APPROVAL_TYPE_NO_REGISTRATION_REQUIRED != $this->meetingInfoGet->settings->approval_type;*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCloudAutoRecordingEnabled()
|
||||
{
|
||||
return \ZoomPlugin::RECORDING_TYPE_NONE !== $this->meetingInfoGet->settings->auto_recording;
|
||||
}
|
||||
|
||||
public function getRegistrantByUser(User $user): ?Registrant
|
||||
{
|
||||
$criteria = Criteria::create()
|
||||
->where(
|
||||
Criteria::expr()->eq('user', $user)
|
||||
)
|
||||
;
|
||||
|
||||
return $this->registrants->matching($criteria)->first() ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a short presentation of the meeting for the future participant.
|
||||
* To be displayed above the "Enter meeting" link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIntroduction()
|
||||
{
|
||||
$introduction = sprintf('<h1>%s</h1>', $this->getTopic()).PHP_EOL;
|
||||
if (!$this->isGlobalMeeting()) {
|
||||
if (!empty($this->formattedStartTime)) {
|
||||
$introduction .= $this->formattedStartTime;
|
||||
if (!empty($this->formattedDuration)) {
|
||||
$introduction .= ' ('.$this->formattedDuration.')';
|
||||
}
|
||||
$introduction .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
if ($this->user) {
|
||||
$introduction .= sprintf('<p>%s</p>', $this->user->getFullname()).PHP_EOL;
|
||||
} elseif ($this->isCourseMeeting()) {
|
||||
if (null === $this->session) {
|
||||
$introduction .= sprintf('<p class="main">%s</p>', $this->course).PHP_EOL;
|
||||
} else {
|
||||
$introduction .= sprintf('<p class="main">%s (%s)</p>', $this->course, $this->session).PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->getAgenda())) {
|
||||
$introduction .= sprintf('<p>%s</p>', $this->getAgenda()).PHP_EOL;
|
||||
}
|
||||
|
||||
return $introduction;
|
||||
}
|
||||
|
||||
public function isSignAttendance(): bool
|
||||
{
|
||||
return $this->signAttendance;
|
||||
}
|
||||
|
||||
public function setSignAttendance(bool $signAttendance): Meeting
|
||||
{
|
||||
$this->signAttendance = $signAttendance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAccountEmail(): ?string
|
||||
{
|
||||
return $this->accountEmail;
|
||||
}
|
||||
|
||||
public function setAccountEmail(?string $accountEmail): self
|
||||
{
|
||||
$this->accountEmail = $accountEmail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReasonToSignAttendance(): ?string
|
||||
{
|
||||
return $this->reasonToSignAttendance;
|
||||
}
|
||||
|
||||
public function setReasonToSignAttendance(string $reasonToSignAttendance): Meeting
|
||||
{
|
||||
$this->reasonToSignAttendance = $reasonToSignAttendance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTopic(): string
|
||||
{
|
||||
return $this->meetingInfoGet->topic;
|
||||
}
|
||||
|
||||
public function getAgenda(): ?string
|
||||
{
|
||||
return $this->meetingInfoGet->agenda;
|
||||
}
|
||||
|
||||
public function getSysAnnouncement(): ?SysAnnouncement
|
||||
{
|
||||
return $this->sysAnnouncement;
|
||||
}
|
||||
|
||||
public function setSysAnnouncement(?SysAnnouncement $sysAnnouncement): Meeting
|
||||
{
|
||||
$this->sysAnnouncement = $sysAnnouncement;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception on unexpected start_time or duration
|
||||
*/
|
||||
protected function initializeDisplayableProperties()
|
||||
{
|
||||
$zoomPlugin = new \ZoomPlugin();
|
||||
|
||||
$typeList = [
|
||||
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->typeName = $typeList[$this->meetingInfoGet->type];
|
||||
|
||||
if (property_exists($this, 'status')) {
|
||||
$statusList = [
|
||||
'waiting' => $zoomPlugin->get_lang('Waiting'),
|
||||
'started' => $zoomPlugin->get_lang('Started'),
|
||||
'finished' => $zoomPlugin->get_lang('Finished'),
|
||||
];
|
||||
$this->statusName = $statusList[$this->meetingInfoGet->status];
|
||||
}
|
||||
$this->startDateTime = null;
|
||||
$this->formattedStartTime = '';
|
||||
$this->durationInterval = null;
|
||||
$this->formattedDuration = '';
|
||||
if (!empty($this->meetingInfoGet->start_time)) {
|
||||
$this->startDateTime = new DateTime($this->meetingInfoGet->start_time);
|
||||
$this->startDateTime->setTimezone(new DateTimeZone(api_get_timezone()));
|
||||
$this->formattedStartTime = $this->startDateTime->format('Y-m-d H:i');
|
||||
}
|
||||
|
||||
if (!empty($this->meetingInfoGet->duration)) {
|
||||
$now = new DateTime();
|
||||
$later = new DateTime();
|
||||
$later->add(new DateInterval('PT'.$this->meetingInfoGet->duration.'M'));
|
||||
$this->durationInterval = $now->diff($later);
|
||||
$this->formattedDuration = $this->durationInterval->format($zoomPlugin->get_lang('DurationFormat'));
|
||||
}
|
||||
}
|
||||
}
|
||||
208
plugin/zoom/Entity/MeetingActivity.php
Normal file
208
plugin/zoom/Entity/MeetingActivity.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Class Meeting.
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="plugin_zoom_meeting_activity")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class MeetingActivity
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue()
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var Meeting
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Meeting", inversedBy="activities")
|
||||
* @ORM\JoinColumn(name="meeting_id")
|
||||
*/
|
||||
protected $meeting;
|
||||
|
||||
/**
|
||||
* @var Meeting
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", name="name", length=255, nullable=false)
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string", name="type", length=255, nullable=false)
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="text", name="event", nullable=true)
|
||||
*/
|
||||
protected $event;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="created_at", type="datetime", nullable=false)
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('Activity %d', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Meeting
|
||||
*/
|
||||
public function getMeeting()
|
||||
{
|
||||
return $this->meeting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Meeting $meeting
|
||||
*
|
||||
* @return MeetingActivity
|
||||
*/
|
||||
public function setMeeting($meeting)
|
||||
{
|
||||
$this->meeting = $meeting;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return MeetingActivity
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return MeetingActivity
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEvent()
|
||||
{
|
||||
return $this->event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Meeting
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Meeting $user
|
||||
*
|
||||
* @return MeetingActivity
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEventDecoded()
|
||||
{
|
||||
if (!empty($this->event)) {
|
||||
return json_decode($this->event);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $event
|
||||
*
|
||||
* @return MeetingActivity
|
||||
*/
|
||||
public function setEvent($event)
|
||||
{
|
||||
$this->event = $event;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
38
plugin/zoom/Entity/Presenter.php
Normal file
38
plugin/zoom/Entity/Presenter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
class Presenter extends Registrant
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('Presenter %d', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostLoad()
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function postLoad()
|
||||
{
|
||||
parent::postLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreFlush()
|
||||
*/
|
||||
public function preFlush()
|
||||
{
|
||||
parent::preFlush();
|
||||
}
|
||||
}
|
||||
193
plugin/zoom/Entity/Recording.php
Normal file
193
plugin/zoom/Entity/Recording.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use Chamilo\PluginBundle\Zoom\API\RecordingMeeting;
|
||||
use Database;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class RecordingEntity.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chamilo\PluginBundle\Zoom\RecordingRepository")
|
||||
* @ORM\Table(
|
||||
* name="plugin_zoom_recording",
|
||||
* indexes={
|
||||
* @ORM\Index(name="meeting_id_index", columns={"meeting_id"}),
|
||||
* }
|
||||
* )
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Recording
|
||||
{
|
||||
/** @var DateTime */
|
||||
public $startDateTime;
|
||||
|
||||
/** @var string */
|
||||
public $formattedStartTime;
|
||||
|
||||
/** @var DateInterval */
|
||||
public $durationInterval;
|
||||
|
||||
/** @var string */
|
||||
public $formattedDuration;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue()
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $uuid;
|
||||
|
||||
/**
|
||||
* @var Meeting
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity="Meeting", inversedBy="recordings")
|
||||
* @ORM\JoinColumn(name="meeting_id")
|
||||
*/
|
||||
protected $meeting;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(type="text", name="recording_meeting_json", nullable=true)
|
||||
*/
|
||||
protected $recordingMeetingJson;
|
||||
|
||||
/** @var RecordingMeeting */
|
||||
protected $recordingMeeting;
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$object = $this->getRecordingMeeting();
|
||||
if (property_exists($object, $name)) {
|
||||
return $object->$name;
|
||||
}
|
||||
throw new Exception(sprintf('%s does not know property %s', $this, $name));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('Recording %d', $this->uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Meeting
|
||||
*/
|
||||
public function getMeeting()
|
||||
{
|
||||
return $this->meeting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return RecordingMeeting
|
||||
*/
|
||||
public function getRecordingMeeting()
|
||||
{
|
||||
return $this->recordingMeeting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Meeting $meeting
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMeeting($meeting)
|
||||
{
|
||||
$this->meeting = $meeting;
|
||||
$this->meeting->getRecordings()->add($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecordingMeeting $recordingMeeting
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Recording
|
||||
*/
|
||||
public function setRecordingMeeting($recordingMeeting)
|
||||
{
|
||||
if (null === $this->uuid) {
|
||||
$this->uuid = $recordingMeeting->uuid;
|
||||
} elseif ($this->uuid !== $recordingMeeting->uuid) {
|
||||
throw new Exception('the RecordingEntity identifier differs from the RecordingMeeting identifier');
|
||||
}
|
||||
if (null === $this->meeting) {
|
||||
$this->meeting = Database::getManager()->getRepository(Meeting::class)->find($recordingMeeting->id);
|
||||
} elseif ($this->meeting->getMeetingId() != $recordingMeeting->id) {
|
||||
// $this->meeting remains null when the remote RecordingMeeting refers to a deleted meeting.
|
||||
throw new Exception('The RecordingEntity meeting id differs from the RecordingMeeting meeting id');
|
||||
}
|
||||
$this->recordingMeeting = $recordingMeeting;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostLoad
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function postLoad()
|
||||
{
|
||||
if (null !== $this->recordingMeetingJson) {
|
||||
$this->recordingMeeting = RecordingMeeting::fromJson($this->recordingMeetingJson);
|
||||
}
|
||||
$this->initializeExtraProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreFlush
|
||||
*/
|
||||
public function preFlush()
|
||||
{
|
||||
if (null !== $this->recordingMeeting) {
|
||||
$this->recordingMeetingJson = json_encode($this->recordingMeeting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function initializeExtraProperties()
|
||||
{
|
||||
$this->startDateTime = new DateTime($this->recordingMeeting->start_time);
|
||||
$this->startDateTime->setTimezone(new DateTimeZone(api_get_timezone()));
|
||||
$this->formattedStartTime = $this->startDateTime->format('Y-m-d H:i');
|
||||
|
||||
$now = new DateTime();
|
||||
$later = new DateTime();
|
||||
$later->add(new DateInterval('PT'.$this->recordingMeeting->duration.'M'));
|
||||
$this->durationInterval = $later->diff($now);
|
||||
$this->formattedDuration = $this->durationInterval->format(get_lang('DurationFormat'));
|
||||
}
|
||||
}
|
||||
283
plugin/zoom/Entity/Registrant.php
Normal file
283
plugin/zoom/Entity/Registrant.php
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use Chamilo\PluginBundle\Zoom\API\CreatedRegistration;
|
||||
use Chamilo\PluginBundle\Zoom\API\MeetingRegistrant;
|
||||
use Chamilo\PluginBundle\Zoom\API\MeetingRegistrantListItem;
|
||||
use Chamilo\UserBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Class RegistrantEntity.
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="RegistrantRepository")
|
||||
* @ORM\Table(
|
||||
* name="plugin_zoom_registrant",
|
||||
* indexes={
|
||||
* @ORM\Index(name="user_id_index", columns={"user_id"}),
|
||||
* @ORM\Index(name="meeting_id_index", columns={"meeting_id"}),
|
||||
* }
|
||||
* )
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
* @ORM\InheritanceType("SINGLE_TABLE")
|
||||
* @ORM\DiscriminatorColumn(name="type", type="string")
|
||||
* @ORM\DiscriminatorMap({"registrant" = "Chamilo\PluginBundle\Zoom\Registrant", "presenter" = "Chamilo\PluginBundle\Zoom\Presenter"})
|
||||
*/
|
||||
class Registrant
|
||||
{
|
||||
/** @var string */
|
||||
public $fullName;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer", name="id")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var Meeting
|
||||
* @ORM\ManyToOne(targetEntity="Meeting", inversedBy="registrants")
|
||||
* @ORM\JoinColumn(name="meeting_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $meeting;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="created_registration_json", nullable=true)
|
||||
*/
|
||||
protected $createdRegistrationJson;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="meeting_registrant_list_item_json", nullable=true)
|
||||
*/
|
||||
protected $meetingRegistrantListItemJson;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="text", name="meeting_registrant_json", nullable=true)
|
||||
*/
|
||||
protected $meetingRegistrantJson;
|
||||
|
||||
/**
|
||||
* @var Signature|null
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="Chamilo\PluginBundle\Zoom\Signature", mappedBy="registrant", orphanRemoval=true)
|
||||
*/
|
||||
protected $signature;
|
||||
|
||||
/** @var CreatedRegistration */
|
||||
protected $createdRegistration;
|
||||
|
||||
/** @var MeetingRegistrant */
|
||||
protected $meetingRegistrant;
|
||||
|
||||
/** @var MeetingRegistrantListItem */
|
||||
protected $meetingRegistrantListItem;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('Registrant %d', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Meeting
|
||||
*/
|
||||
public function getMeeting()
|
||||
{
|
||||
return $this->meeting;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Meeting $meeting
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMeeting($meeting)
|
||||
{
|
||||
$this->meeting = $meeting;
|
||||
$this->meeting->getRegistrants()->add($this);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUser($user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return MeetingRegistrantListItem
|
||||
*/
|
||||
public function getMeetingRegistrantListItem()
|
||||
{
|
||||
return $this->meetingRegistrantListItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MeetingRegistrantListItem $meetingRegistrantListItem
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMeetingRegistrantListItem($meetingRegistrantListItem)
|
||||
{
|
||||
if (!is_null($this->meeting) && $this->meeting->getId() != $meetingRegistrantListItem->id) {
|
||||
throw new Exception('RegistrantEntity meeting id differs from MeetingRegistrantListItem id');
|
||||
}
|
||||
$this->meetingRegistrantListItem = $meetingRegistrantListItem;
|
||||
$this->computeFullName();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function computeFullName()
|
||||
{
|
||||
$this->fullName = api_get_person_name(
|
||||
$this->meetingRegistrant->first_name,
|
||||
$this->meetingRegistrant->last_name
|
||||
);
|
||||
}
|
||||
|
||||
public function getJoinUrl()
|
||||
{
|
||||
if (!$this->createdRegistration) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->createdRegistration->join_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return CreatedRegistration
|
||||
*/
|
||||
public function getCreatedRegistration()
|
||||
{
|
||||
return $this->createdRegistration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CreatedRegistration $createdRegistration
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedRegistration($createdRegistration)
|
||||
{
|
||||
if (null === $this->id) {
|
||||
$this->id = $createdRegistration->registrant_id;
|
||||
} elseif ($this->id != $createdRegistration->registrant_id) {
|
||||
throw new Exception('RegistrantEntity id differs from CreatedRegistration identifier');
|
||||
}
|
||||
$this->createdRegistration = $createdRegistration;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
* @return MeetingRegistrant
|
||||
*/
|
||||
public function getMeetingRegistrant()
|
||||
{
|
||||
return $this->meetingRegistrant;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setMeetingRegistrant(API\RegistrantSchema $meetingRegistrant): Registrant
|
||||
{
|
||||
$this->meetingRegistrant = $meetingRegistrant;
|
||||
$this->computeFullName();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostLoad
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function postLoad()
|
||||
{
|
||||
if (null !== $this->meetingRegistrantJson) {
|
||||
$this->meetingRegistrant = MeetingRegistrant::fromJson($this->meetingRegistrantJson);
|
||||
}
|
||||
if (null !== $this->createdRegistrationJson) {
|
||||
$this->createdRegistration = CreatedRegistration::fromJson($this->createdRegistrationJson);
|
||||
}
|
||||
if (null !== $this->meetingRegistrantListItemJson) {
|
||||
$this->meetingRegistrantListItem = MeetingRegistrantListItem::fromJson(
|
||||
$this->meetingRegistrantListItemJson
|
||||
);
|
||||
}
|
||||
$this->computeFullName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreFlush
|
||||
*/
|
||||
public function preFlush()
|
||||
{
|
||||
if (null !== $this->meetingRegistrant) {
|
||||
$this->meetingRegistrantJson = json_encode($this->meetingRegistrant);
|
||||
}
|
||||
if (null !== $this->createdRegistration) {
|
||||
$this->createdRegistrationJson = json_encode($this->createdRegistration);
|
||||
}
|
||||
if (null !== $this->meetingRegistrantListItem) {
|
||||
$this->meetingRegistrantListItemJson = json_encode($this->meetingRegistrantListItem);
|
||||
}
|
||||
}
|
||||
|
||||
public function setSignature(Signature $signature): void
|
||||
{
|
||||
$this->signature = $signature;
|
||||
|
||||
$signature->setRegistrant($this);
|
||||
}
|
||||
|
||||
public function getSignature(): ?Signature
|
||||
{
|
||||
return $this->signature;
|
||||
}
|
||||
}
|
||||
84
plugin/zoom/Entity/Signature.php
Normal file
84
plugin/zoom/Entity/Signature.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="plugin_zoom_signature")
|
||||
*/
|
||||
class Signature
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
/**
|
||||
* @var Registrant
|
||||
*
|
||||
* @ORM\OneToOne(targetEntity="Chamilo\PluginBundle\Zoom\Registrant", inversedBy="signature")
|
||||
* @ORM\JoinColumn(name="registrant_id", referencedColumnName="id")
|
||||
*/
|
||||
private $registrant;
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="signature", type="text")
|
||||
*/
|
||||
private $file;
|
||||
/**
|
||||
* @var DateTime
|
||||
*
|
||||
* @ORM\Column(name="registered_at", type="datetime")
|
||||
*/
|
||||
private $registeredAt;
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getRegistrant(): Registrant
|
||||
{
|
||||
return $this->registrant;
|
||||
}
|
||||
|
||||
public function setRegistrant(Registrant $registrant): Signature
|
||||
{
|
||||
$this->registrant = $registrant;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFile(): string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function setFile(string $file): Signature
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRegisteredAt(): DateTime
|
||||
{
|
||||
return $this->registeredAt;
|
||||
}
|
||||
|
||||
public function setRegisteredAt(DateTime $registeredAt): Signature
|
||||
{
|
||||
$this->registeredAt = $registeredAt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
138
plugin/zoom/Entity/Webinar.php
Normal file
138
plugin/zoom/Entity/Webinar.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
namespace Chamilo\PluginBundle\Zoom;
|
||||
|
||||
use Chamilo\PluginBundle\Zoom\API\BaseMeetingTrait;
|
||||
use Chamilo\PluginBundle\Zoom\API\WebinarSchema;
|
||||
use Chamilo\PluginBundle\Zoom\API\WebinarSettings;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Exception;
|
||||
use ZoomPlugin;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Webinar extends Meeting
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="webinar_schema_json", type="text", nullable=true)
|
||||
*/
|
||||
protected $webinarSchemaJson;
|
||||
|
||||
/**
|
||||
* @var WebinarSchema
|
||||
*/
|
||||
protected $webinarSchema;
|
||||
|
||||
public function preFlush()
|
||||
{
|
||||
if (null !== $this->webinarSchema) {
|
||||
$this->webinarSchemaJson = json_encode($this->webinarSchema);
|
||||
}
|
||||
}
|
||||
|
||||
public function postLoad()
|
||||
{
|
||||
if (null !== $this->webinarSchemaJson) {
|
||||
$this->webinarSchema = WebinarSchema::fromJson($this->webinarSchemaJson);
|
||||
}
|
||||
|
||||
$this->initializeDisplayableProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WebinarSchema|BaseMeetingTrait $webinarSchema
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setWebinarSchema(WebinarSchema $webinarSchema): Webinar
|
||||
{
|
||||
if (null === $this->meetingId) {
|
||||
$this->meetingId = $webinarSchema->id;
|
||||
} elseif ($this->meetingId != $webinarSchema->id) {
|
||||
throw new Exception('the Meeting identifier differs from the MeetingInfoGet identifier');
|
||||
}
|
||||
|
||||
$this->webinarSchema = $webinarSchema;
|
||||
|
||||
$this->initializeDisplayableProperties();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWebinarSchema(): WebinarSchema
|
||||
{
|
||||
return $this->webinarSchema;
|
||||
}
|
||||
|
||||
public function hasCloudAutoRecordingEnabled(): bool
|
||||
{
|
||||
return $this->webinarSchema->settings->auto_recording !== ZoomPlugin::RECORDING_TYPE_NONE;
|
||||
}
|
||||
|
||||
public function requiresDateAndDuration(): bool
|
||||
{
|
||||
return WebinarSchema::TYPE_WEBINAR == $this->webinarSchema->type;
|
||||
}
|
||||
|
||||
public function requiresRegistration(): bool
|
||||
{
|
||||
return in_array(
|
||||
$this->webinarSchema->settings->approval_type,
|
||||
[
|
||||
WebinarSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE,
|
||||
WebinarSettings::APPROVAL_TYPE_MANUALLY_APPROVE,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function getTopic(): string
|
||||
{
|
||||
return $this->webinarSchema->topic;
|
||||
}
|
||||
|
||||
public function getAgenda(): ?string
|
||||
{
|
||||
return $this->webinarSchema->agenda;
|
||||
}
|
||||
|
||||
protected function initializeDisplayableProperties()
|
||||
{
|
||||
$zoomPlugin = ZoomPlugin::create();
|
||||
|
||||
$namedTypes = [
|
||||
WebinarSchema::TYPE_WEBINAR => $zoomPlugin->get_lang('Webinar'),
|
||||
WebinarSchema::TYPE_RECURRING_NO_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithNoFixedTime'),
|
||||
WebinarSchema::TYPE_RECURRING_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithFixedTime'),
|
||||
];
|
||||
|
||||
$this->typeName = $namedTypes[$this->webinarSchema->type];
|
||||
|
||||
if ($this->webinarSchema->start_time) {
|
||||
$this->startDateTime = new DateTime(
|
||||
$this->webinarSchema->start_time,
|
||||
new \DateTimeZone(api_get_timezone())
|
||||
);
|
||||
$this->formattedStartTime = $this->startDateTime->format('Y-m-d H:i');
|
||||
}
|
||||
|
||||
if ($this->webinarSchema->duration) {
|
||||
$now = new DateTime();
|
||||
$later = new DateTime();
|
||||
$later->add(
|
||||
new DateInterval('PT'.$this->webinarSchema->duration.'M')
|
||||
);
|
||||
$this->durationInterval = $now->diff($later);
|
||||
$this->formattedDuration = $this->durationInterval->format(
|
||||
$zoomPlugin->get_lang('DurationFormat')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user