|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Soheilrt\AdobeConnectClient\Client\Entities; |
|
4
|
|
|
|
|
5
|
|
|
use DomainException; |
|
6
|
|
|
use Soheilrt\AdobeConnectClient\Client\Contracts\ArrayableInterface; |
|
7
|
|
|
use Soheilrt\AdobeConnectClient\Client\Helpers\StringCaseTransform as SCT; |
|
8
|
|
|
use Soheilrt\AdobeConnectClient\Client\Helpers\ValueTransform as VT; |
|
9
|
|
|
use Soheilrt\AdobeConnectClient\Client\Traits\Fillable; |
|
10
|
|
|
use Soheilrt\AdobeConnectClient\Client\Traits\PropertyCaller; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Adobe Connect Principal. |
|
14
|
|
|
* |
|
15
|
|
|
* See {@link https://helpx.adobe.com/adobe-connect/webservices/common-xml-elements-attributes.html#type} |
|
16
|
|
|
* |
|
17
|
|
|
* @property int|string|mixed $name |
|
18
|
|
|
* @property int|string|mixed $display_uid |
|
19
|
|
|
* @property int|string|mixed $principal_id |
|
20
|
|
|
* @property int|string|mixed $training_group_id |
|
21
|
|
|
* @property int|string|mixed $account_id |
|
22
|
|
|
* @property string|mixed $login |
|
23
|
|
|
* @property string|mixed $type See {@link https://helpx.adobe.com/adobe-connect/webservices/common-xml-elements-attributes.html#type} |
|
24
|
|
|
* @property string|mixed $permission_id @see Permission::PRINCIPAL_* constants |
|
25
|
|
|
* @property string|mixed $description The new group’s description. Use only when creating a new group. |
|
26
|
|
|
* @property string|mixed $email Only for user |
|
27
|
|
|
* @property string|mixed $first_name Only for user |
|
28
|
|
|
* @property string|mixed $last_name Only for user |
|
29
|
|
|
* @property string|mixed $password Only on create a user |
|
30
|
|
|
* @property bool|string|mixed $is_primary |
|
31
|
|
|
* @property bool|string|mixed $has_children On create: If the principal is a group, use true. If the principal is a user, use false. |
|
32
|
|
|
* @property bool|string|mixed $is_ecommerece |
|
33
|
|
|
* @property bool|string|mixed $is_hidden |
|
34
|
|
|
* @property bool|string|mixed $disabled |
|
35
|
|
|
* @property bool|string|mixed $send_email only on create a user |
|
36
|
|
|
* @property bool|string|mixed $is_member only on create a user . Indicates if the user is a member of the group (@see \AdobeConnectClient\Commands\PrincipalList) |
|
37
|
|
|
* |
|
38
|
|
|
* |
|
39
|
|
|
* @method Principal setDisplayId($value) |
|
40
|
|
|
* @method Principal setPrincipalId($value) |
|
41
|
|
|
* @method Principal setTrainingGroupId($value) |
|
42
|
|
|
* @method Principal setAccountId($value) |
|
43
|
|
|
* @method Principal setLogin($value) |
|
44
|
|
|
* @method Principal setPermissionId($value) @see Permission::PRINCIPAL_* constants |
|
45
|
|
|
* @method Principal setDescription($value) The new group’s description. Use only when creating a new group. |
|
46
|
|
|
* @method Principal setEmail($value) Only for user |
|
47
|
|
|
* @method Principal setPassword($value) Only on create a user |
|
48
|
|
|
* @method Principal setIsEcommerece($value) |
|
49
|
|
|
* |
|
50
|
|
|
* @method int|string|mixed getName() |
|
51
|
|
|
* @method int|string|mixed getDisplayUid() |
|
52
|
|
|
* @method int|string|mixed getPrincipalId() |
|
53
|
|
|
* @method int|string|mixed getTrainingGroupId() |
|
54
|
|
|
* @method int|string|mixed getAccountId() |
|
55
|
|
|
* @method string|mixed|null getLogin() |
|
56
|
|
|
* @method string|mixed|null getType() See { |
|
57
|
|
|
* @link https://helpx.adobe.com/adobe-connect/webservices/common-xml-elements-attributes.html#type} |
|
58
|
|
|
* @method string|mixed|null getPermissionId() @see Permission::PRINCIPAL_* constants |
|
59
|
|
|
* @method string|mixed|null getDescription() The new group’s description. Use only when creating a new group. |
|
60
|
|
|
* @method string|mixed|null getEmail() Only for user |
|
61
|
|
|
* @method string|mixed|null getFirstName() Only for user |
|
62
|
|
|
* @method string|mixed|null getLastName() Only for user |
|
63
|
|
|
* @method string|mixed|null getPassword() Only on create a user |
|
64
|
|
|
* @method bool|string|mixed|null getIsPrimary() |
|
65
|
|
|
* @method bool|string|mixed|null getHasChildren() On create: If the principal is a group, use true. If the principal is a user, use false. |
|
66
|
|
|
* @method bool|string|mixed|null getIsEcommerece() |
|
67
|
|
|
* @method bool|string|mixed|null getIsHidden() |
|
68
|
|
|
* @method bool|string|mixed|null getDisabled() |
|
69
|
|
|
* @method bool|string|mixed|null getSendEmail() only on create a user |
|
70
|
|
|
* @method bool|string|mixed|null getIsMember() only on create a user . Indicates if the user is a member of the group (@see \AdobeConnectClient\Commands\PrincipalList) |
|
71
|
|
|
* |
|
72
|
|
|
* @todo Maybe a factory for the differents types? |
|
73
|
|
|
*/ |
|
74
|
|
|
class Principal implements ArrayableInterface |
|
75
|
|
|
{ |
|
76
|
|
|
use PropertyCaller, Fillable; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* The built-in group Administrators, for Adobe Connect server Administrators. |
|
80
|
|
|
* |
|
81
|
|
|
* @var string |
|
82
|
|
|
*/ |
|
83
|
|
|
public const TYPE_ADMINS = 'admins'; |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* The built-in group Administrators, for Adobe Connect server Administrators. |
|
87
|
|
|
* |
|
88
|
|
|
* @var string |
|
89
|
|
|
*/ |
|
90
|
|
|
public const TYPE_ADMINS_LIMITED = 'admins-limited'; |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* The built-in group Authors, for authors. |
|
94
|
|
|
* |
|
95
|
|
|
* @var string |
|
96
|
|
|
*/ |
|
97
|
|
|
public const TYPE_AUTHORS = 'authors'; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* The built-in group Training Managers, for training managers. |
|
101
|
|
|
* |
|
102
|
|
|
* @var string |
|
103
|
|
|
*/ |
|
104
|
|
|
public const TYPE_COURSE_ADMINS = 'course-admins'; |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* The built-in group Event Managers, for anyone who can create an Adobe Connect meeting. |
|
108
|
|
|
* |
|
109
|
|
|
* @var string |
|
110
|
|
|
*/ |
|
111
|
|
|
public const TYPE_EVENT_ADMINS = 'event-admins'; |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* The Event Supper Admins |
|
115
|
|
|
* |
|
116
|
|
|
* @var string |
|
117
|
|
|
*/ |
|
118
|
|
|
public const TYPE_EVENT_SUPER_ADMINS = 'event-super-admins'; |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Virtual Classroom admins |
|
122
|
|
|
* |
|
123
|
|
|
* @var string |
|
124
|
|
|
*/ |
|
125
|
|
|
public const TYPE_NAMED_VIRTUAL_CLASSROM_ADMINS = 'named-vc-admins'; |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* The group of users invited to an event. |
|
129
|
|
|
* |
|
130
|
|
|
* @var string |
|
131
|
|
|
*/ |
|
132
|
|
|
public const TYPE_EVENT_GROUP = 'event-group'; |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* All Adobe Connect users. |
|
136
|
|
|
* |
|
137
|
|
|
* @var string |
|
138
|
|
|
*/ |
|
139
|
|
|
public const TYPE_EVERYONE = 'everyone'; |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* A group authenticated from an external network. |
|
143
|
|
|
* |
|
144
|
|
|
* @var string |
|
145
|
|
|
*/ |
|
146
|
|
|
public const TYPE_EXTERNAL_GROUP = 'external-group'; |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* A user authenticated from an external network. |
|
150
|
|
|
* |
|
151
|
|
|
* @var string |
|
152
|
|
|
*/ |
|
153
|
|
|
public const TYPE_EXTERNAL_USER = 'external-user'; |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* A group that a user or Administrator creates. |
|
157
|
|
|
* |
|
158
|
|
|
* @var string |
|
159
|
|
|
*/ |
|
160
|
|
|
public const TYPE_GROUP = 'group'; |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* A non-registered user who enters an Adobe Connect meeting room. |
|
164
|
|
|
* |
|
165
|
|
|
* @var string |
|
166
|
|
|
*/ |
|
167
|
|
|
public const TYPE_GUEST = 'guest'; |
|
168
|
|
|
|
|
169
|
|
|
/** |
|
170
|
|
|
* The built-in group learners, for users who take courses. |
|
171
|
|
|
* |
|
172
|
|
|
* @var string |
|
173
|
|
|
*/ |
|
174
|
|
|
public const TYPE_LEARNERS = 'learners'; |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* The built-in group Meeting Hosts, for Adobe Connect meeting hosts. |
|
178
|
|
|
* |
|
179
|
|
|
* @var string |
|
180
|
|
|
*/ |
|
181
|
|
|
public const TYPE_LIVE_ADMINS = 'live-admins'; |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* The built-in group Seminar Hosts, for seminar hosts. |
|
185
|
|
|
* |
|
186
|
|
|
* @var string |
|
187
|
|
|
*/ |
|
188
|
|
|
public const TYPE_SEMINAR_ADMINS = 'seminar-admins'; |
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* A registered user on the server. |
|
192
|
|
|
* |
|
193
|
|
|
* @var string |
|
194
|
|
|
*/ |
|
195
|
|
|
public const TYPE_USER = 'user'; |
|
196
|
|
|
|
|
197
|
|
|
/** |
|
198
|
|
|
* Returns a new Principal instance. |
|
199
|
|
|
* |
|
200
|
|
|
* @return Principal |
|
201
|
|
|
*/ |
|
202
|
|
|
public static function instance(): Principal |
|
203
|
|
|
{ |
|
204
|
|
|
return new static(); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
/** |
|
208
|
|
|
* Retrieves all not null attributes in an associative array. |
|
209
|
|
|
* |
|
210
|
|
|
* @return string[] [string => string] |
|
211
|
|
|
* |
|
212
|
|
|
* @todo Returns fields for all types |
|
213
|
|
|
*/ |
|
214
|
|
|
public function toArray(): array |
|
215
|
|
|
{ |
|
216
|
|
|
$parameters = []; |
|
217
|
|
|
|
|
218
|
|
|
switch ($this->type) { |
|
219
|
|
|
case self::TYPE_USER: |
|
220
|
|
|
$fields = $this->fieldsForUser(); |
|
221
|
|
|
break; |
|
222
|
|
|
|
|
223
|
|
|
case self::TYPE_GROUP: |
|
224
|
|
|
$fields = $this->fieldsForGroup(); |
|
225
|
|
|
break; |
|
226
|
|
|
|
|
227
|
|
|
default: |
|
228
|
|
|
$fields = []; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
foreach ($fields as $field) { |
|
232
|
|
|
$value = $this->$field; |
|
233
|
|
|
|
|
234
|
|
|
if (isset($value)) { |
|
235
|
|
|
$parameters[SCT::toHyphen($field)] = VT::toString($value); |
|
236
|
|
|
} |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
return $parameters; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* The fields for create/update a User. |
|
244
|
|
|
* |
|
245
|
|
|
* @return string[] |
|
246
|
|
|
*/ |
|
247
|
|
|
protected function fieldsForUser(): array |
|
248
|
|
|
{ |
|
249
|
|
|
return [ |
|
250
|
|
|
'hasChildren', |
|
251
|
|
|
'principalId', |
|
252
|
|
|
'firstName', |
|
253
|
|
|
'lastName', |
|
254
|
|
|
'login', |
|
255
|
|
|
'password', |
|
256
|
|
|
'email', |
|
257
|
|
|
'sendEmail', |
|
258
|
|
|
'type', |
|
259
|
|
|
]; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* The fields for create/update a Group. |
|
264
|
|
|
* |
|
265
|
|
|
* @return string[] |
|
266
|
|
|
*/ |
|
267
|
|
|
protected function fieldsForGroup(): array |
|
268
|
|
|
{ |
|
269
|
|
|
return [ |
|
270
|
|
|
'hasChildren', |
|
271
|
|
|
'principalId', |
|
272
|
|
|
'name', |
|
273
|
|
|
'description', |
|
274
|
|
|
'type', |
|
275
|
|
|
]; |
|
276
|
|
|
} |
|
277
|
|
|
|
|
278
|
|
|
/** |
|
279
|
|
|
* @param string $name |
|
280
|
|
|
* |
|
281
|
|
|
* @return Principal |
|
282
|
|
|
*/ |
|
283
|
|
|
public function setName($name): Principal |
|
284
|
|
|
{ |
|
285
|
|
|
$this->attributes['name'] = (string) $name; |
|
286
|
|
|
$this->fixNameByType(); |
|
287
|
|
|
|
|
288
|
|
|
return $this; |
|
289
|
|
|
} |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* Fix the name or firstName and lastName. |
|
293
|
|
|
* |
|
294
|
|
|
* The user type has firstName and lastName, but some actions from Adobe Connect returns the |
|
295
|
|
|
* Principal user type with name, so we need fix it. |
|
296
|
|
|
*/ |
|
297
|
|
|
protected function fixNameByType(): void |
|
298
|
|
|
{ |
|
299
|
|
|
if ( |
|
300
|
|
|
$this->type === self::TYPE_GROUP && |
|
301
|
|
|
!isset($this->attributes['name']) && |
|
302
|
|
|
isset($this->attributes['firstName'], $this->attributes['lastName']) |
|
303
|
|
|
) { |
|
304
|
|
|
$this->attributes['name'] = $this->attributes['firstName'] . ' ' . $this->attributes['lastName']; |
|
305
|
|
|
return; |
|
306
|
|
|
} |
|
307
|
|
|
|
|
308
|
|
|
if ( |
|
309
|
|
|
$this->type === self::TYPE_USER && |
|
310
|
|
|
empty($this->attributes['firstName']) && |
|
311
|
|
|
empty($this->attributes['lastName']) && |
|
312
|
|
|
isset($this->attributes['name']) |
|
313
|
|
|
) { |
|
314
|
|
|
$names = explode(' ', $this->name, 2); |
|
315
|
|
|
|
|
316
|
|
|
if (count($names) !== 2) { |
|
317
|
|
|
$this->first_name = $names[0]; |
|
318
|
|
|
|
|
319
|
|
|
return; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
[$this->attributes['firstName'], $this->attributes['lastName']] = $names; |
|
323
|
|
|
} |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
/** |
|
327
|
|
|
* @param bool $isPrimary |
|
328
|
|
|
* |
|
329
|
|
|
* @return Principal |
|
330
|
|
|
*/ |
|
331
|
|
|
public function setIsPrimary($isPrimary): Principal |
|
332
|
|
|
{ |
|
333
|
|
|
$this->attributes['isPrimary'] = VT::toBool($isPrimary); |
|
334
|
|
|
|
|
335
|
|
|
return $this; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
/** |
|
339
|
|
|
* Set the Principal type. |
|
340
|
|
|
* |
|
341
|
|
|
* More info about types see {@link https://helpx.adobe.com/adobe-connect/webservices/common-xml-elements-attributes.html#type} |
|
342
|
|
|
* |
|
343
|
|
|
* @param string $type |
|
344
|
|
|
* |
|
345
|
|
|
* @throws DomainException |
|
346
|
|
|
* |
|
347
|
|
|
* @return Principal |
|
348
|
|
|
*/ |
|
349
|
|
|
public function setType($type): Principal |
|
350
|
|
|
{ |
|
351
|
|
|
$this->attributes['type'] = (string) $type; |
|
352
|
|
|
|
|
353
|
|
|
if (!in_array( |
|
354
|
|
|
$this->attributes['type'], |
|
355
|
|
|
[ |
|
356
|
|
|
self::TYPE_ADMINS, |
|
357
|
|
|
self::TYPE_ADMINS_LIMITED, |
|
358
|
|
|
self::TYPE_AUTHORS, |
|
359
|
|
|
self::TYPE_COURSE_ADMINS, |
|
360
|
|
|
self::TYPE_EVENT_ADMINS, |
|
361
|
|
|
self::TYPE_EVENT_SUPER_ADMINS, |
|
362
|
|
|
self::TYPE_NAMED_VIRTUAL_CLASSROM_ADMINS, |
|
363
|
|
|
self::TYPE_EVENT_GROUP, |
|
364
|
|
|
self::TYPE_EVERYONE, |
|
365
|
|
|
self::TYPE_EXTERNAL_GROUP, |
|
366
|
|
|
self::TYPE_EXTERNAL_USER, |
|
367
|
|
|
self::TYPE_GROUP, |
|
368
|
|
|
self::TYPE_GUEST, |
|
369
|
|
|
self::TYPE_LEARNERS, |
|
370
|
|
|
self::TYPE_LIVE_ADMINS, |
|
371
|
|
|
self::TYPE_SEMINAR_ADMINS, |
|
372
|
|
|
self::TYPE_USER, |
|
373
|
|
|
] |
|
374
|
|
|
)) { |
|
375
|
|
|
throw new DomainException("{$type} isn't a valid Principal Type"); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
$this->fixNameByType(); |
|
379
|
|
|
|
|
380
|
|
|
return $this; |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
/** |
|
384
|
|
|
* @param bool $hasChildren |
|
385
|
|
|
* |
|
386
|
|
|
* @return Principal |
|
387
|
|
|
*/ |
|
388
|
|
|
public function setHasChildren($hasChildren): Principal |
|
389
|
|
|
{ |
|
390
|
|
|
$this->attributes['hasChildren'] = VT::toBool($hasChildren); |
|
391
|
|
|
|
|
392
|
|
|
return $this; |
|
393
|
|
|
} |
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* @param bool $isEcommerce |
|
397
|
|
|
* |
|
398
|
|
|
* @return Principal |
|
399
|
|
|
*/ |
|
400
|
|
|
public function setIsEcommerce($isEcommerce): Principal |
|
401
|
|
|
{ |
|
402
|
|
|
$this->attributes['isEcommerce'] = VT::toBool($isEcommerce); |
|
403
|
|
|
|
|
404
|
|
|
return $this; |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* @param bool $isHidden |
|
409
|
|
|
* |
|
410
|
|
|
* @return Principal |
|
411
|
|
|
*/ |
|
412
|
|
|
public function setIsHidden($isHidden): Principal |
|
413
|
|
|
{ |
|
414
|
|
|
$this->attributes['isHidden'] = VT::toBool($isHidden); |
|
415
|
|
|
|
|
416
|
|
|
return $this; |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
|
|
/** |
|
420
|
|
|
* @param bool $disabled |
|
421
|
|
|
* |
|
422
|
|
|
* @return Principal |
|
423
|
|
|
*/ |
|
424
|
|
|
public function setDisabled($disabled): Principal |
|
425
|
|
|
{ |
|
426
|
|
|
$this->attributes['disabled'] = VT::toBool($disabled); |
|
427
|
|
|
|
|
428
|
|
|
return $this; |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
/** |
|
432
|
|
|
* @param string $firstName |
|
433
|
|
|
* |
|
434
|
|
|
* @return Principal |
|
435
|
|
|
*/ |
|
436
|
|
|
public function setFirstName($firstName): Principal |
|
437
|
|
|
{ |
|
438
|
|
|
$this->attributes['firstName'] = (string) $firstName; |
|
439
|
|
|
$this->fixNameByType(); |
|
440
|
|
|
|
|
441
|
|
|
return $this; |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
/** |
|
445
|
|
|
* @param string $lastName |
|
446
|
|
|
* |
|
447
|
|
|
* @return Principal |
|
448
|
|
|
*/ |
|
449
|
|
|
public function setLastName($lastName): Principal |
|
450
|
|
|
{ |
|
451
|
|
|
$this->attributes['lastName'] = (string) $lastName; |
|
452
|
|
|
$this->fixNameByType(); |
|
453
|
|
|
|
|
454
|
|
|
return $this; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
/** |
|
458
|
|
|
* @param bool $sendEmail |
|
459
|
|
|
* |
|
460
|
|
|
* @return Principal |
|
461
|
|
|
*/ |
|
462
|
|
|
public function setSendEmail($sendEmail): Principal |
|
463
|
|
|
{ |
|
464
|
|
|
$this->attributes['sendEmail'] = VT::toBool($sendEmail); |
|
465
|
|
|
|
|
466
|
|
|
return $this; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
/** |
|
470
|
|
|
* @param bool $isMember |
|
471
|
|
|
* |
|
472
|
|
|
* @return Principal |
|
473
|
|
|
*/ |
|
474
|
|
|
public function setIsMember($isMember): Principal |
|
475
|
|
|
{ |
|
476
|
|
|
$this->attributes['isMember'] = VT::toBool($isMember); |
|
477
|
|
|
|
|
478
|
|
|
return $this; |
|
479
|
|
|
} |
|
480
|
|
|
} |
|
481
|
|
|
|