1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
4
|
|
|
|
5
|
|
|
namespace Chamilo\PluginBundle\Zoom; |
6
|
|
|
|
7
|
|
|
use Chamilo\PluginBundle\Zoom\API\BaseMeetingTrait; |
8
|
|
|
use Chamilo\PluginBundle\Zoom\API\WebinarSchema; |
9
|
|
|
use Chamilo\PluginBundle\Zoom\API\WebinarSettings; |
10
|
|
|
use DateInterval; |
11
|
|
|
use DateTime; |
12
|
|
|
use Doctrine\ORM\Mapping as ORM; |
13
|
|
|
use Exception; |
14
|
|
|
use ZoomPlugin; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @ORM\Entity() |
18
|
|
|
* @ORM\HasLifecycleCallbacks |
19
|
|
|
*/ |
20
|
|
|
class Webinar extends Meeting |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
* |
25
|
|
|
* @ORM\Column(name="webinar_schema_json", type="text", nullable=true) |
26
|
|
|
*/ |
27
|
|
|
protected $webinarSchemaJson; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var WebinarSchema |
31
|
|
|
*/ |
32
|
|
|
protected $webinarSchema; |
33
|
|
|
|
34
|
|
|
public function preFlush() |
35
|
|
|
{ |
36
|
|
|
if (null !== $this->webinarSchema) { |
37
|
|
|
$this->webinarSchemaJson = json_encode($this->webinarSchema); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function postLoad() |
42
|
|
|
{ |
43
|
|
|
if (null !== $this->webinarSchemaJson) { |
44
|
|
|
$this->webinarSchema = WebinarSchema::fromJson($this->webinarSchemaJson); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$this->initializeDisplayableProperties(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param WebinarSchema|BaseMeetingTrait $webinarSchema |
52
|
|
|
* |
53
|
|
|
* @throws Exception |
54
|
|
|
*/ |
55
|
|
|
public function setWebinarSchema(WebinarSchema $webinarSchema): Webinar |
56
|
|
|
{ |
57
|
|
|
if (null === $this->meetingId) { |
58
|
|
|
$this->meetingId = $webinarSchema->id; |
59
|
|
|
} elseif ($this->meetingId != $webinarSchema->id) { |
60
|
|
|
throw new Exception('the Meeting identifier differs from the MeetingInfoGet identifier'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$this->webinarSchema = $webinarSchema; |
64
|
|
|
|
65
|
|
|
$this->initializeDisplayableProperties(); |
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getWebinarSchema(): WebinarSchema |
71
|
|
|
{ |
72
|
|
|
return $this->webinarSchema; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function hasCloudAutoRecordingEnabled(): bool |
76
|
|
|
{ |
77
|
|
|
return $this->webinarSchema->settings->auto_recording !== ZoomPlugin::RECORDING_TYPE_NONE; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function requiresDateAndDuration(): bool |
81
|
|
|
{ |
82
|
|
|
return WebinarSchema::TYPE_WEBINAR == $this->webinarSchema->type; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function requiresRegistration(): bool |
86
|
|
|
{ |
87
|
|
|
return in_array( |
88
|
|
|
$this->webinarSchema->settings->approval_type, |
89
|
|
|
[ |
90
|
|
|
WebinarSettings::APPROVAL_TYPE_AUTOMATICALLY_APPROVE, |
91
|
|
|
WebinarSettings::APPROVAL_TYPE_MANUALLY_APPROVE, |
92
|
|
|
] |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function getTopic(): string |
97
|
|
|
{ |
98
|
|
|
return $this->webinarSchema->topic; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getAgenda(): ?string |
102
|
|
|
{ |
103
|
|
|
return $this->webinarSchema->agenda; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
protected function initializeDisplayableProperties() |
107
|
|
|
{ |
108
|
|
|
$zoomPlugin = ZoomPlugin::create(); |
109
|
|
|
|
110
|
|
|
$namedTypes = [ |
111
|
|
|
WebinarSchema::TYPE_WEBINAR => $zoomPlugin->get_lang('Webinar'), |
112
|
|
|
WebinarSchema::TYPE_RECURRING_NO_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithNoFixedTime'), |
113
|
|
|
WebinarSchema::TYPE_RECURRING_FIXED_TIME => $zoomPlugin->get_lang('RecurringWithFixedTime'), |
114
|
|
|
]; |
115
|
|
|
|
116
|
|
|
$this->typeName = $namedTypes[$this->webinarSchema->type]; |
117
|
|
|
|
118
|
|
|
if ($this->webinarSchema->start_time) { |
119
|
|
|
$this->startDateTime = new DateTime( |
120
|
|
|
$this->webinarSchema->start_time, |
121
|
|
|
new \DateTimeZone(api_get_timezone()) |
122
|
|
|
); |
123
|
|
|
$this->formattedStartTime = $this->startDateTime->format('Y-m-d H:i'); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
if ($this->webinarSchema->duration) { |
127
|
|
|
$now = new DateTime(); |
128
|
|
|
$later = new DateTime(); |
129
|
|
|
$later->add( |
130
|
|
|
new DateInterval('PT'.$this->webinarSchema->duration.'M') |
131
|
|
|
); |
132
|
|
|
$this->durationInterval = $now->diff($later); |
133
|
|
|
$this->formattedDuration = $this->durationInterval->format( |
134
|
|
|
$zoomPlugin->get_lang('DurationFormat') |
135
|
|
|
); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|