19 declare(strict_types=1);
67 $this->
user = $DIC->user();
68 $this->rbacreview = $DIC->rbac()->review();
72 $this->group_obj = $group;
73 $this->log = $DIC->logger()->grp();
82 $this->parent[] = $a_id;
86 array_pop($this->parent);
91 return $this->parent[count($this->parent) - 1];
100 $this->sax_controller->setHandlers($a_xml_parser);
101 $this->sax_controller->setDefaultElementHandler($this);
104 $this->group_obj->getId()
107 $this->sax_controller->setElementHandler(
108 $this->advanced_md_value_parser,
120 parent::startParsing();
123 $status = is_object($this->group_obj) ? $this->group_obj->getRefId() :
false;
125 $status = is_object($this->group_obj) ? $this->group_obj->update() :
false;
127 $this->after_parsing_status = $status;
140 public function handlerBeginTag($a_xml_parser,
string $a_name, array $a_attribs): void
150 $this->group_data[
"admin"] = array();
151 $this->group_data[
"member"] = array();
153 $this->group_data[
"type"] = $a_attribs[
"type"];
154 $this->group_data[
"id"] = $a_attribs[
"id"];
162 $this->group_data[
"owner"] = $a_attribs[
"id"];
166 $this->group_data[
'registration_type'] = $a_attribs[
'type'];
167 $this->group_data[
'waiting_list_enabled'] = $a_attribs[
'waitingList'] ==
'Yes' ? true :
false;
171 $this->in_period =
true;
172 $this->group_data[
'period_with_time'] = $a_attribs[
'withTime'];
176 $this->group_data[
'max_members_enabled'] = $a_attribs[
'enabled'] ==
'Yes' ? true :
false;
180 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Attach") {
181 $this->group_data[
"admin"][
"attach"][] = $a_attribs[
"id"];
182 } elseif (isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Detach") {
183 $this->group_data[
"admin"][
"detach"][] = $a_attribs[
"id"];
186 if (isset($a_attribs[
'notification']) and $a_attribs[
'notification'] ==
'Yes') {
187 $this->group_data[
'notifications'][] = $a_attribs[
'id'];
193 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Attach") {
194 $GLOBALS[
'DIC']->logger()->grp()->debug(
'New member with id ' . $a_attribs[
'id']);
195 $this->group_data[
"member"][
"attach"][] = $a_attribs[
"id"];
196 } elseif (isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Detach") {
197 $GLOBALS[
'DIC']->logger()->grp()->debug(
'Deprecated member with id ' . $a_attribs[
'id']);
198 $this->group_data[
"member"][
"detach"][] = $a_attribs[
"id"];
203 case 'ContainerSetting':
204 $this->current_container_setting = $a_attribs[
'id'];
209 if ($this->group_imported) {
212 $this->
sort = $a_attribs;
218 if (isset($a_attribs[
'active'])) {
219 $this->group_data[
'session_limit'] = (bool) $a_attribs[
'active'];
221 if (isset($a_attribs[
'previous'])) {
222 $this->group_data[
'session_previous'] = (
int) $a_attribs[
'previous'];
224 if (isset($a_attribs[
'next'])) {
225 $this->group_data[
'session_next'] = (
int) $a_attribs[
'next'];
230 $this->group_data[
'map_enabled'] = (bool) $a_attribs[
'enabled'] ??
false;
231 $this->group_data[
'map_latitude'] = (string) $a_attribs[
'latitude'] ??
'';
232 $this->group_data[
'map_longitude'] = (string) $a_attribs[
'longitude'] ??
'';
233 $this->group_data[
'map_location_zoom'] = (
int) $a_attribs[
'location_zoom'] ?? 0;
236 case 'RegistrationAccessCode':
237 $this->group_data[
'registration_code_enabled'] = (bool) $a_attribs[
'enabled'] ??
false;
238 $this->group_data[
'registration_code'] = (string) $a_attribs[
'code'] ??
'';
241 case 'WaitingListAutoFill':
242 case 'CancellationEnd':
244 case 'mailMembersType':
255 $this->group_data[
"title"] = trim($this->cdata);
259 $this->group_data[
"description"] = trim($this->cdata);
263 $this->group_data[
'information'] = trim($this->cdata);
267 $this->group_data[
'password'] = trim($this->cdata);
271 $this->group_data[
'max_members'] = trim($this->cdata);
275 $this->group_data[
'expiration_end'] = trim($this->cdata);
279 if ($this->in_period) {
280 $this->group_data[
'period_start'] = trim($this->cdata);
282 $this->group_data[
'expiration_start'] = trim($this->cdata);
287 if ($this->in_period) {
288 $this->group_data[
'period_end'] = trim($this->cdata);
290 $this->group_data[
'expiration_end'] = trim($this->cdata);
295 $this->in_period =
false;
302 case 'ContainerSetting':
303 if ($this->current_container_setting) {
305 $this->group_obj->getId(),
312 case 'WaitingListAutoFill':
313 $this->group_data[
'auto_wait'] = trim($this->cdata);
316 case 'CancellationEnd':
317 if ((
int) $this->cdata) {
323 if ((
int) $this->cdata) {
324 $this->group_data[
'min_members'] = (
int) $this->cdata;
330 $this->group_data[
'show_members'] = (
int) $this->cdata;
334 case 'admissionNotification':
336 $this->group_data[
'auto_notification'] = (bool) $this->cdata;
340 case 'mailMembersType':
341 $this->group_data[
'mail_members_type'] = (
int) $this->cdata;
345 $this->group_data[
'view_mode'] = (
int) $this->cdata;
357 $a_name = str_replace(
"<",
"<", $a_name);
358 $a_name = str_replace(
">",
">", $a_name);
360 if (!empty($a_name)) {
361 $this->cdata .= $a_name;
367 if ($this->group_imported) {
371 $this->group_obj->setImportId($this->group_data[
"id"] ??
'');
372 $this->group_obj->setTitle($this->group_data[
"title"] ??
'');
373 $this->group_obj->setDescription($this->group_data[
"description"] ??
'');
374 $this->group_obj->setInformation((
string) $this->group_data[
'information']);
376 if (isset($this->group_data[
'period_start']) && isset($this->group_data[
'period_end'])) {
378 if ($this->group_data[
'period_with_time'] ??
false) {
379 $this->group_obj->setPeriod(
384 $this->group_obj->setPeriod(
390 $this->log->warning(
'Ignoring invalid group period settings: ');
391 $this->log->warning(
'Period start: ' . $this->group_data[
'period_start']);
392 $this->log->warning(
'Period end: ' . $this->group_data[
'period_end']);
396 $ownerChanged =
false;
397 if (isset($this->group_data[
"owner"])) {
398 $owner = $this->group_data[
"owner"];
399 if (!is_numeric($owner)) {
402 if (is_numeric($owner) && $owner > 0) {
403 $this->group_obj->setOwner((
int) $owner);
404 $ownerChanged =
true;
412 $this->group_obj->createReference();
414 $this->group_obj->setPermissions($this->
getParentId());
416 array_key_exists(
'type', $this->group_data) &&
417 $this->group_data[
'type'] ==
'closed' 419 $this->group_obj->updateGroupType(
425 array_key_exists(
'type', $this->group_data) &&
426 $this->group_data[
'type'] ==
'closed' 428 $this->group_obj->updateGroupType(
432 array_key_exists(
'type', $this->group_data) &&
433 $this->group_data[
'type'] ==
'open' 435 $this->group_obj->updateGroupType(
441 switch ($this->group_data[
'registration_type'] ??
'') {
462 $this->group_obj->setRegistrationType($flag);
465 $registration_end =
null;
466 if ($this->group_data[
'expiration_end'] ??
false) {
470 $registration_start =
null;
471 if ($this->group_data[
'expiration_start'] ??
false) {
478 $this->group_obj->enableUnlimitedRegistration(
false);
479 $this->group_obj->setRegistrationStart($registration_start);
480 $this->group_obj->setRegistrationEnd($registration_end);
482 $this->group_obj->enableUnlimitedRegistration(
true);
484 $this->group_obj->setPassword($this->group_data[
'password'] ??
'');
485 $this->group_obj->enableMembershipLimitation((
bool) ($this->group_data[
'max_members_enabled'] ??
false));
486 $this->group_obj->setMaxMembers((
int) ($this->group_data[
'max_members'] ?? 0));
487 $this->group_obj->enableWaitingList((
bool) ($this->group_data[
'waiting_list_enabled'] ??
false));
488 $this->group_obj->setWaitingListAutoFill((
bool) ($this->group_data[
'auto_wait'] ??
false));
489 $this->group_obj->setCancellationEnd($this->group_data[
'cancel_end'] ??
null);
490 $this->group_obj->setMinMembers((
int) ($this->group_data[
'min_members'] ?? 0));
491 $this->group_obj->setShowMembers((
bool) ($this->group_data[
'show_members'] ??
false));
492 $this->group_obj->setAutoNotification((
bool) (($this->group_data[
'auto_notification'] ??
false)));
493 $this->group_obj->setMailToMembersType((
int) ($this->group_data[
'mail_members_type'] ?? 0));
494 $this->group_obj->enableRegistrationAccessCode((
bool) ($this->group_data[
'registration_code_enabled'] ??
false));
495 $this->group_obj->setRegistrationAccessCode((
string) ($this->group_data[
'registration_code'] ??
''));
496 if (isset($this->group_data[
'view_mode'])) {
497 $this->group_obj->setViewMode((
int) $this->group_data[
'view_mode']);
499 if (isset($this->group_data[
'session_limit'])) {
500 $this->group_obj->enableSessionLimit((
bool) $this->group_data[
'session_limit']);
502 if (isset($this->group_data[
'session_previous'])) {
503 $this->group_obj->setNumberOfPreviousSessions((
int) $this->group_data[
'session_previous']);
505 if (isset($this->group_data[
'session_next'])) {
506 $this->group_obj->setNumberOfNextSessions((
int) $this->group_data[
'session_next']);
509 $this->group_obj->setEnableGroupMap((
bool) ($this->group_data[
'map_enabled'] ??
false));
510 $this->group_obj->setLatitude((
string) ($this->group_data[
'map_latitude'] ??
''));
511 $this->group_obj->setLongitude((
string) ($this->group_data[
'map_longitude'] ??
''));
512 $this->group_obj->setLocationZoom((
int) ($this->group_data[
'map_location_zoom'] ?? 0));
518 $this->group_obj->readContainerSettings();
519 $this->group_obj->update();
530 $this->group_imported =
true;
539 $this->participants->updateNotification($this->
user->getId(), (bool) $this->
settings->get(
'mail_grp_admin_notification',
"1"));
542 if (isset($this->group_data[
"admin"][
"attach"]) && count($this->group_data[
"admin"][
"attach"])) {
543 foreach ($this->group_data[
"admin"][
"attach"] as $user) {
544 if ($id_data = $this->
parseId($user)) {
545 if ($id_data[
'local'] or $id_data[
'imported']) {
547 if (isset($this->group_data[
'notifications']) && in_array($user, (array) $this->group_data[
'notifications'])) {
548 $this->participants->updateNotification($id_data[
'usr_id'],
true);
555 if (isset($this->group_data[
"admin"][
"detach"]) && count($this->group_data[
"admin"][
"detach"])) {
556 foreach ($this->group_data[
"admin"][
"detach"] as $user) {
557 if ($id_data = $this->
parseId($user)) {
558 if ($id_data[
'local'] or $id_data[
'imported']) {
559 if ($this->participants->isAssigned($id_data[
'usr_id'])) {
560 $this->participants->delete($id_data[
'usr_id']);
567 if (isset($this->group_data[
"member"][
"attach"]) && count($this->group_data[
"member"][
"attach"])) {
568 foreach ($this->group_data[
"member"][
"attach"] as $user) {
569 if ($id_data = $this->
parseId($user)) {
570 if ($id_data[
'local'] or $id_data[
'imported']) {
577 if (isset($this->group_data[
"member"][
"detach"]) && count($this->group_data[
"member"][
"detach"])) {
578 foreach ($this->group_data[
"member"][
"detach"] as $user) {
579 if ($id_data = $this->
parseId($user)) {
580 if ($id_data[
'local'] or $id_data[
'imported']) {
581 if ($this->participants->isAssigned($id_data[
'usr_id'])) {
582 $this->participants->delete($id_data[
'usr_id']);
592 $fields = explode(
'_', $a_id);
593 $usr_id = (
int) $fields[3];
595 if (!is_array($fields) or
596 $fields[0] !=
'il' or
597 !is_numeric($fields[1]) or
598 $fields[2] !=
'usr' or
599 !is_numeric($usr_id)) {
603 return array(
'imported' =>
true,
608 if (strlen($user[
'login'])) {
609 return array(
'imported' =>
false,
611 'usr_id' => $usr_id);
614 $this->log->warning(
'Parsing id failed: ' . $a_id);
632 foreach ($attribs as $k => $v) {
const GRP_REGISTRATION_DEACTIVATED
handlerCharacterData($a_xml_parser, string $a_name)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static _lookupName(int $a_user_id)
lookup user name
static _importContainerSortingSettings(array $attibs, int $obj_id)
sorting import for all container objects
const GRP_REGISTRATION_REQUEST
sort()
description: > Example for rendering a Sort Glyph.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const GRP_REGISTRATION_PASSWORD
handlerEndTag($a_xml_parser, string $a_name)
End element handler.
ilGroupParticipants $participants
const GRP_REGISTRATION_DIRECT
ilAdvancedMDValueParser $advanced_md_value_parser
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
add(int $a_usr_id, int $a_role)
__construct(ilObjGroup $group, string $a_xml, int $a_parent_id)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
string $current_container_setting
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getImportedUserId(string $i2_id)
ilSaxController $sax_controller
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
trimAndStripAttribs(array $attribs)
trimAndStrip(string $input)
setHandlers($a_xml_parser)
initContainerSorting(array $a_attribs, int $a_group_id)
setXMLContent(string $a_xml_content)