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