19 declare(strict_types=1);
74 $this->
user = $DIC->user();
75 $this->rbacreview = $DIC->rbac()->review();
79 $this->group_obj = $group;
80 $this->log = $DIC->logger()->grp();
86 $this->group_obj->getId(),
87 $this->group_obj->getId(),
88 $this->group_obj->getType()
98 $this->parent[] = $a_id;
102 array_pop($this->parent);
107 return $this->parent[count($this->parent) - 1];
116 $this->sax_controller->setHandlers($a_xml_parser);
117 $this->sax_controller->setDefaultElementHandler($this);
120 $this->group_obj->getId()
123 $this->sax_controller->setElementHandler(
124 $this->advanced_md_value_parser,
136 parent::startParsing();
139 $status = is_object($this->group_obj) ? $this->group_obj->getRefId() :
false;
141 $status = is_object($this->group_obj) ? $this->group_obj->update() :
false;
143 $this->after_parsing_status = $status;
147 $identifier_ids = $general->getIdentifierIds();
148 if (!isset($identifier_ids[0])) {
151 $identifier = $general->getIdentifier($identifier_ids[0]);
152 $identifier->setEntry(
155 $identifier->update();
168 public function handlerBeginTag($a_xml_parser,
string $a_name, array $a_attribs): void
176 if ($this->lom_parsing_active) {
177 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
183 $this->lom_parsing_active =
true;
184 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
190 $this->group_data[
"admin"] = array();
191 $this->group_data[
"member"] = array();
193 $this->group_data[
"type"] = $a_attribs[
"type"];
194 $this->group_data[
"id"] = $a_attribs[
"id"];
202 $this->group_data[
"owner"] = $a_attribs[
"id"];
206 $this->group_data[
'registration_type'] = $a_attribs[
'type'];
207 $this->group_data[
'waiting_list_enabled'] = $a_attribs[
'waitingList'] ==
'Yes' ? true :
false;
211 $this->in_period =
true;
212 $this->group_data[
'period_with_time'] = $a_attribs[
'withTime'];
216 $this->group_data[
'max_members_enabled'] = $a_attribs[
'enabled'] ==
'Yes' ? true :
false;
220 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Attach") {
221 $this->group_data[
"admin"][
"attach"][] = $a_attribs[
"id"];
222 } elseif (isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Detach") {
223 $this->group_data[
"admin"][
"detach"][] = $a_attribs[
"id"];
226 if (isset($a_attribs[
'notification']) and $a_attribs[
'notification'] ==
'Yes') {
227 $this->group_data[
'notifications'][] = $a_attribs[
'id'];
233 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Attach") {
234 $GLOBALS[
'DIC']->logger()->grp()->debug(
'New member with id ' . $a_attribs[
'id']);
235 $this->group_data[
"member"][
"attach"][] = $a_attribs[
"id"];
236 } elseif (isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
"Detach") {
237 $GLOBALS[
'DIC']->logger()->grp()->debug(
'Deprecated member with id ' . $a_attribs[
'id']);
238 $this->group_data[
"member"][
"detach"][] = $a_attribs[
"id"];
243 case 'ContainerSetting':
244 $this->current_container_setting = $a_attribs[
'id'];
249 if ($this->group_imported) {
252 $this->sort = $a_attribs;
258 if (isset($a_attribs[
'active'])) {
259 $this->group_data[
'session_limit'] = (bool) $a_attribs[
'active'];
261 if (isset($a_attribs[
'previous'])) {
262 $this->group_data[
'session_previous'] = (
int) $a_attribs[
'previous'];
264 if (isset($a_attribs[
'next'])) {
265 $this->group_data[
'session_next'] = (
int) $a_attribs[
'next'];
270 $this->group_data[
'map_enabled'] = (bool) $a_attribs[
'enabled'] ??
false;
271 $this->group_data[
'map_latitude'] = (string) $a_attribs[
'latitude'] ??
'';
272 $this->group_data[
'map_longitude'] = (string) $a_attribs[
'longitude'] ??
'';
273 $this->group_data[
'map_location_zoom'] = (
int) $a_attribs[
'location_zoom'] ?? 0;
276 case 'RegistrationAccessCode':
277 $this->group_data[
'registration_code_enabled'] = (bool) $a_attribs[
'enabled'] ??
false;
278 $this->group_data[
'registration_code'] = (string) $a_attribs[
'code'] ??
'';
281 case 'WaitingListAutoFill':
282 case 'CancellationEnd':
284 case 'mailMembersType':
291 $this->cdata = $this->
trimAndStrip((
string) $this->cdata);
293 if ($this->lom_parsing_active) {
294 parent::handlerEndTag($a_xml_parser, $a_name);
299 $this->lom_parsing_active =
false;
300 parent::handlerEndTag($a_xml_parser, $a_name);
305 $this->group_data[
"title"] = trim($this->cdata);
309 $this->group_data[
"description"] = trim($this->cdata);
313 $this->group_data[
'information'] = trim($this->cdata);
317 $this->group_data[
'password'] = trim($this->cdata);
321 $this->group_data[
'max_members'] = trim($this->cdata);
325 $this->group_data[
'expiration_end'] = trim($this->cdata);
329 if ($this->in_period) {
330 $this->group_data[
'period_start'] = trim($this->cdata);
332 $this->group_data[
'expiration_start'] = trim($this->cdata);
337 if ($this->in_period) {
338 $this->group_data[
'period_end'] = trim($this->cdata);
340 $this->group_data[
'expiration_end'] = trim($this->cdata);
345 $this->in_period =
false;
352 case 'ContainerSetting':
353 if ($this->current_container_setting) {
355 $this->group_obj->getId(),
362 case 'WaitingListAutoFill':
363 $this->group_data[
'auto_wait'] = trim($this->cdata);
366 case 'CancellationEnd':
367 if ((
int) $this->cdata) {
373 if ((
int) $this->cdata) {
374 $this->group_data[
'min_members'] = (
int) $this->cdata;
380 $this->group_data[
'show_members'] = (
int) $this->cdata;
384 case 'admissionNotification':
386 $this->group_data[
'auto_notification'] = (bool) $this->cdata;
390 case 'mailMembersType':
391 $this->group_data[
'mail_members_type'] = (
int) $this->cdata;
395 $this->group_data[
'view_mode'] = (
int) $this->cdata;
408 if ($this->lom_parsing_active) {
409 parent::handlerCharacterData($a_xml_parser, $a_data);
412 $a_data = str_replace(
"<",
"<", $a_data);
413 $a_data = str_replace(
">",
">", $a_data);
415 if (!empty($a_data)) {
416 $this->cdata .= $a_data;
422 if ($this->group_imported) {
426 $this->group_obj->setImportId($this->group_data[
"id"] ??
'');
427 $this->group_obj->setTitle($this->group_data[
"title"] ??
'');
428 $this->group_obj->setDescription($this->group_data[
"description"] ??
'');
429 $this->group_obj->setInformation((
string) $this->group_data[
'information']);
431 if (isset($this->group_data[
'period_start']) && isset($this->group_data[
'period_end'])) {
433 if ($this->group_data[
'period_with_time'] ??
false) {
434 $this->group_obj->setPeriod(
439 $this->group_obj->setPeriod(
445 $this->log->warning(
'Ignoring invalid group period settings: ');
446 $this->log->warning(
'Period start: ' . $this->group_data[
'period_start']);
447 $this->log->warning(
'Period end: ' . $this->group_data[
'period_end']);
451 $ownerChanged =
false;
452 if (isset($this->group_data[
"owner"])) {
453 $owner = $this->group_data[
"owner"];
454 if (!is_numeric($owner)) {
457 if (is_numeric($owner) && $owner > 0) {
458 $this->group_obj->setOwner((
int) $owner);
459 $ownerChanged =
true;
467 $this->group_obj->createReference();
469 $this->group_obj->setPermissions($this->
getParentId());
471 array_key_exists(
'type', $this->group_data) &&
472 $this->group_data[
'type'] ==
'closed' 474 $this->group_obj->updateGroupType(
480 array_key_exists(
'type', $this->group_data) &&
481 $this->group_data[
'type'] ==
'closed' 483 $this->group_obj->updateGroupType(
487 array_key_exists(
'type', $this->group_data) &&
488 $this->group_data[
'type'] ==
'open' 490 $this->group_obj->updateGroupType(
496 switch ($this->group_data[
'registration_type'] ??
'') {
517 $this->group_obj->setRegistrationType($flag);
520 $registration_end = null;
521 if ($this->group_data[
'expiration_end'] ??
false) {
525 $registration_start = null;
526 if ($this->group_data[
'expiration_start'] ??
false) {
533 $this->group_obj->enableUnlimitedRegistration(
false);
534 $this->group_obj->setRegistrationStart($registration_start);
535 $this->group_obj->setRegistrationEnd($registration_end);
537 $this->group_obj->enableUnlimitedRegistration(
true);
539 $this->group_obj->setPassword($this->group_data[
'password'] ??
'');
540 $this->group_obj->enableMembershipLimitation((
bool) ($this->group_data[
'max_members_enabled'] ??
false));
541 $this->group_obj->setMaxMembers((
int) ($this->group_data[
'max_members'] ?? 0));
542 $this->group_obj->enableWaitingList((
bool) ($this->group_data[
'waiting_list_enabled'] ??
false));
543 $this->group_obj->setWaitingListAutoFill((
bool) ($this->group_data[
'auto_wait'] ??
false));
544 $this->group_obj->setCancellationEnd($this->group_data[
'cancel_end'] ?? null);
545 $this->group_obj->setMinMembers((
int) ($this->group_data[
'min_members'] ?? 0));
546 $this->group_obj->setShowMembers((
bool) ($this->group_data[
'show_members'] ??
false));
547 $this->group_obj->setAutoNotification((
bool) (($this->group_data[
'auto_notification'] ??
false)));
548 $this->group_obj->setMailToMembersType((
int) ($this->group_data[
'mail_members_type'] ?? 0));
549 $this->group_obj->enableRegistrationAccessCode((
bool) ($this->group_data[
'registration_code_enabled'] ??
false));
550 $this->group_obj->setRegistrationAccessCode((
string) ($this->group_data[
'registration_code'] ??
''));
551 if (isset($this->group_data[
'view_mode'])) {
552 $this->group_obj->setViewMode((
int) $this->group_data[
'view_mode']);
554 if (isset($this->group_data[
'session_limit'])) {
555 $this->group_obj->enableSessionLimit((
bool) $this->group_data[
'session_limit']);
557 if (isset($this->group_data[
'session_previous'])) {
558 $this->group_obj->setNumberOfPreviousSessions((
int) $this->group_data[
'session_previous']);
560 if (isset($this->group_data[
'session_next'])) {
561 $this->group_obj->setNumberOfNextSessions((
int) $this->group_data[
'session_next']);
564 $this->group_obj->setEnableGroupMap((
bool) ($this->group_data[
'map_enabled'] ??
false));
565 $this->group_obj->setLatitude((
string) ($this->group_data[
'map_latitude'] ??
''));
566 $this->group_obj->setLongitude((
string) ($this->group_data[
'map_longitude'] ??
''));
567 $this->group_obj->setLocationZoom((
int) ($this->group_data[
'map_location_zoom'] ?? 0));
573 $this->group_obj->readContainerSettings();
574 $this->group_obj->update();
585 $this->group_imported =
true;
594 $this->participants->updateNotification($this->
user->getId(), (bool) $this->
settings->get(
'mail_grp_admin_notification',
"1"));
597 if (isset($this->group_data[
"admin"][
"attach"]) && count($this->group_data[
"admin"][
"attach"])) {
598 foreach ($this->group_data[
"admin"][
"attach"] as $user) {
599 if ($id_data = $this->
parseId($user)) {
600 if ($id_data[
'local'] or $id_data[
'imported']) {
602 if (isset($this->group_data[
'notifications']) && in_array($user, (array) $this->group_data[
'notifications'])) {
603 $this->participants->updateNotification($id_data[
'usr_id'],
true);
610 if (isset($this->group_data[
"admin"][
"detach"]) && count($this->group_data[
"admin"][
"detach"])) {
611 foreach ($this->group_data[
"admin"][
"detach"] as $user) {
612 if ($id_data = $this->
parseId($user)) {
613 if ($id_data[
'local'] or $id_data[
'imported']) {
614 if ($this->participants->isAssigned($id_data[
'usr_id'])) {
615 $this->participants->delete($id_data[
'usr_id']);
622 if (isset($this->group_data[
"member"][
"attach"]) && count($this->group_data[
"member"][
"attach"])) {
623 foreach ($this->group_data[
"member"][
"attach"] as $user) {
624 if ($id_data = $this->
parseId($user)) {
625 if ($id_data[
'local'] or $id_data[
'imported']) {
632 if (isset($this->group_data[
"member"][
"detach"]) && count($this->group_data[
"member"][
"detach"])) {
633 foreach ($this->group_data[
"member"][
"detach"] as $user) {
634 if ($id_data = $this->
parseId($user)) {
635 if ($id_data[
'local'] or $id_data[
'imported']) {
636 if ($this->participants->isAssigned($id_data[
'usr_id'])) {
637 $this->participants->delete($id_data[
'usr_id']);
647 $fields = explode(
'_', $a_id);
649 if (!is_array($fields) or
650 $fields[0] !=
'il' or
651 !is_numeric($fields[1]) or
652 $fields[2] !=
'usr' or
653 !is_numeric($fields[3])) {
657 return array(
'imported' =>
true,
662 if (strlen($user[
'login'])) {
663 return array(
'imported' =>
false,
665 'usr_id' => (
int) $fields[3]);
668 $this->log->warning(
'Parsing id failed: ' . $a_id);
const GRP_REGISTRATION_DEACTIVATED
trimAndStrip(string $input)
handlerCharacterData($a_xml_parser, string $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trimAndStripAttribs(array $attribs)
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
const GRP_REGISTRATION_PASSWORD
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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
Interface definition for sax subset parsers.
Controller class for sax element handlers.
static _getImportedUserId(string $i2_id)
ilSaxController $sax_controller
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
__construct(Container $dic, ilPlugin $plugin)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
setHandlers($a_xml_parser)
initContainerSorting(array $a_attribs, int $a_group_id)
setXMLContent(string $a_xml_content)