19 declare(strict_types=0);
32 private int $mode = self::MODE_EXPORT;
61 $this->log = $DIC->logger()->crs();
62 $this->setting = $DIC->settings();
63 $this->course_obj = $a_course_obj;
68 $this->course_members_array = array_flip($this->course_members->getParticipants());
71 public function setMode(
int $a_mode): void
73 $this->mode = $a_mode;
86 $this->sax_controller->setHandlers($a_xml_parser);
87 $this->sax_controller->setDefaultElementHandler($this);
88 $this->sax_controller->setElementHandler(
97 public function handlerBeginTag($a_xml_parser,
string $a_name, array $a_attribs): void
103 if (strlen($a_attribs[
'importId'] ??
'')) {
104 $this->log->write(
"CourseXMLParser: importId = " . $a_attribs[
'importId']);
105 $this->course_obj->setImportId($a_attribs[
'importId']);
108 if (strlen($a_attribs[
'showMembers'] ??
'')) {
109 $this->course_obj->setShowMembers(
110 $a_attribs[
'showMembers'] ==
'Yes' 116 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
117 if ($id_data[
'local'] or $id_data[
'imported']) {
124 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
125 if ($id_data[
'local'] or $id_data[
'imported']) {
132 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
133 if ($id_data[
'local'] or $id_data[
'imported']) {
140 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
141 if ($id_data[
'local'] or $id_data[
'imported']) {
148 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
149 if ($id_data[
'local'] or $id_data[
'imported']) {
156 if ($id_data = $this->
__parseId($a_attribs[
'id'] ??
'')) {
157 if ($id_data[
'local'] or $id_data[
'imported']) {
158 $this->course_obj->setOwner((
int) ($id_data[
'usr_id'] ?? 0));
159 $this->course_obj->updateOwner();
167 $this->in_availability =
true;
171 if ($this->in_availability) {
172 $this->course_obj->setOfflineStatus(
true);
173 } elseif ($this->in_registration) {
180 if ($this->in_availability) {
181 $this->course_obj->setOfflineStatus(
false);
182 } elseif ($this->in_registration) {
187 case 'TemporarilyAvailable':
188 if ($this->in_availability) {
189 $this->course_obj->setOfflineStatus(
false);
190 } elseif ($this->in_registration) {
211 case 'Responsibility':
218 $this->in_registration =
true;
220 switch ($a_attribs[
'registrationType'] ??
'') {
234 $this->course_obj->setSubscriptionMaxMembers((
int) ($a_attribs[
'maxMembers'] ?? 0));
235 $this->course_obj->enableSubscriptionMembershipLimitation($this->course_obj->getSubscriptionMaxMembers() > 0);
236 $this->course_obj->enableWaitingList(($a_attribs[
'waitingList'] ??
null) ==
'Yes' ?
true :
false);
243 $this->course_obj->setOrderType(
252 case 'ContainerSetting':
253 $this->current_container_setting = ($a_attribs[
'id'] ??
'');
257 $this->in_period =
true;
258 $this->in_period_with_time = (bool) ($a_attribs[
'withTime'] ??
false);
261 case 'WaitingListAutoFill':
262 case 'CancellationEnd':
264 case 'StatusDetermination':
265 case 'MailToMembersType':
269 if (array_key_exists(
'status', $a_attribs)) {
270 $this->course_obj->setAutoNotification((
bool) $a_attribs[
'status']);
275 $this->course_obj->setEnableCourseMap((
bool) $a_attribs[
'enabled'] ??
false);
276 $this->course_obj->setLatitude((
string) $a_attribs[
'latitude'] ??
'');
277 $this->course_obj->setLongitude((
string) $a_attribs[
'longitude'] ??
'');
278 $this->course_obj->setLocationZoom((
int) $a_attribs[
'location_zoom'] ?? 0);
281 case 'TutorialSupportBlock':
282 if (isset($a_attribs[
'active'])) {
283 $this->course_obj->setTutorialSupportBlockSettingValue((
int) $a_attribs[
'active']);
288 if (isset($a_attribs[
'active'])) {
289 $this->course_obj->enableSessionLimit((
bool) $a_attribs[
'active']);
291 if (isset($a_attribs[
'previous'])) {
292 $this->course_obj->setNumberOfPreviousSessions((
int) $a_attribs[
'previous']);
294 if (isset($a_attribs[
'next'])) {
295 $this->course_obj->setNumberOfNextSessions((
int) $a_attribs[
'next']);
303 $fields = explode(
'_', $a_id);
305 if (!is_array($fields) or
306 $fields[0] !=
'il' or
307 !is_numeric($fields[1]) or
308 $fields[2] !=
'usr' or
309 !is_numeric($fields[3])) {
313 return array(
'imported' =>
true,
319 return array(
'imported' =>
false,
321 'usr_id' => (
int) $fields[3]
330 private function handleAdmin(array $a_attribs, array $id_data): void
332 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
334 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
337 if (isset($a_attribs[
'notification']) && $a_attribs[
'notification'] ==
'Yes') {
338 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
340 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
341 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
343 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
345 $this->course_members->updateContact($id_data[
'usr_id'],
true);
347 $this->course_members_array[$id_data[
'usr_id']] =
"added";
350 if (isset($a_attribs[
'notification']) && $a_attribs[
'notification'] ==
'Yes') {
351 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
353 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
354 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
356 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
357 $this->course_members->updateContact($id_data[
'usr_id'],
true);
358 } elseif (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'No') {
359 $this->course_members->updateContact($id_data[
'usr_id'],
false);
361 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
363 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id'])) {
365 $this->course_members->delete($id_data[
'usr_id']);
369 private function handleTutor(array $a_attribs, array $id_data): void
371 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
373 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
376 if (isset($a_attribs[
'notification']) && $a_attribs[
'notification'] ==
'Yes') {
377 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
379 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
380 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
382 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
384 $this->course_members->updateContact($id_data[
'usr_id'],
true);
386 $this->course_members_array[$id_data[
'usr_id']] =
"added";
388 if (isset($a_attribs[
'notification']) && $a_attribs[
'notification'] ==
'Yes') {
389 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
391 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
392 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
394 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
395 $this->course_members->updateContact($id_data[
'usr_id'],
true);
396 } elseif (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'No') {
397 $this->course_members->updateContact($id_data[
'usr_id'],
false);
399 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
401 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id'])) {
403 $this->course_members->delete($id_data[
'usr_id']);
412 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
414 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
417 if (isset($a_attribs[
'blocked']) && $a_attribs[
'blocked'] ==
'Yes') {
418 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
420 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
421 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
423 $this->course_members_array[$id_data[
'usr_id']] =
"added";
426 if (isset($a_attribs[
'blocked']) && $a_attribs[
'blocked'] ==
'Yes') {
427 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
429 if (isset($a_attribs[
'passed']) && $a_attribs[
'passed'] ==
'Yes') {
430 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
433 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id'])) {
435 $this->course_members->delete($id_data[
'usr_id']);
444 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
446 if (!$this->course_members->isSubscriber($id_data[
'usr_id'])) {
448 $this->course_members->addSubscriber($id_data[
'usr_id']);
450 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'], (
int) ($a_attribs[
'subscriptionTime'] ?? 0));
451 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id'])) {
453 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
462 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
464 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id'])) {
466 $this->course_waiting_list->addToList($id_data[
'usr_id']);
468 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'], (
int) ($a_attribs[
'subscriptionTime'] ?? 0));
469 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id'])) {
471 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
485 $this->log->write(
'CourseXMLParser: import_id = ' . $this->course_obj->getImportId());
487 $this->course_obj->readContainerSettings();
490 if ($transl->getDefaultTitle() !==
"") {
491 $this->course_obj->setTitle($transl->getDefaultTitle());
493 if ($transl->getDefaultDescription() !==
"") {
494 $this->course_obj->setDescription($transl->getDefaultDescription());
496 $this->course_obj->getObjectProperties()->storePropertyTranslations(
499 $this->course_obj->update();
503 $this->course_obj->setTitle(trim($this->cdata));
504 $this->translations = $this->translations->
withDefaultTitle(trim($this->cdata));
508 $this->course_obj->setDescription(trim($this->cdata));
509 $this->translations = $this->translations->withDefaultDescription(trim($this->cdata));
516 $this->in_availability =
false;
520 $this->in_registration =
false;
524 if ($this->in_availability) {
525 $this->course_obj->setActivationStart((
int) trim($this->cdata));
527 if ($this->in_registration) {
528 $this->course_obj->setSubscriptionStart((
int) trim($this->cdata));
530 if ($this->in_period) {
531 if ((
int) $this->cdata) {
532 if ($this->in_period_with_time) {
533 $this->period_start = new \ilDateTime((
int) $this->cdata,
IL_CAL_UNIX);
535 $this->period_start = new \ilDate((
int) $this->cdata,
IL_CAL_UNIX);
542 if ($this->in_availability) {
543 $this->course_obj->setActivationEnd((
int) trim($this->cdata));
545 if ($this->in_registration) {
546 $this->course_obj->setSubscriptionEnd((
int) trim($this->cdata));
548 if ($this->in_period) {
549 if ((
int) $this->cdata) {
550 if ($this->in_period_with_time) {
551 $this->period_end = new \ilDateTime((
int) $this->cdata,
IL_CAL_UNIX);
553 $this->period_end = new \ilDate((
int) $this->cdata,
IL_CAL_UNIX);
560 $this->course_obj->setSyllabus(trim($this->cdata));
564 $this->course_obj->setTargetGroup(trim($this->cdata));
567 case 'ImportantInformation':
568 $this->course_obj->setImportantInformation(trim($this->cdata));
572 $this->course_obj->setViewMode((
int) trim($this->cdata));
576 $this->course_obj->setContactName(trim($this->cdata));
579 case 'Responsibility':
580 $this->course_obj->setContactResponsibility(trim($this->cdata));
584 $this->course_obj->setContactPhone(trim($this->cdata));
588 $this->course_obj->setContactEmail(trim($this->cdata));
592 $this->course_obj->setContactConsultation(trim($this->cdata));
596 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
599 case 'ContainerSetting':
600 if ($this->current_container_setting) {
602 $this->course_obj->getId(),
610 $this->in_period =
false;
612 $this->course_obj->setCoursePeriod($this->period_start, $this->period_end);
614 $this->log->warning(
'invalid course period given');
618 case 'WaitingListAutoFill':
619 $this->course_obj->setWaitingListAutoFill((
bool) $this->cdata);
622 case 'CancellationEnd':
623 if ((
int) $this->cdata) {
624 $this->course_obj->setCancellationEnd(
new ilDate((
int) $this->cdata,
IL_CAL_UNIX));
629 if ((
int) $this->cdata) {
630 $this->course_obj->setSubscriptionMinMembers((
int) $this->cdata);
635 $this->course_obj->setTimingMode((
int) $this->cdata);
638 case 'StatusDetermination':
639 $this->course_obj->setStatusDetermination((
int) $this->cdata);
642 case 'MailToMembersType':
643 $this->course_obj->setMailToMembersType((
int) $this->cdata);
653 if ($a_data !=
"\n") {
655 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
657 $this->cdata .= $a_data;
664 foreach ($attribs as $k => $v) {
trimAndStrip(string $input)
static _writeImportId(int $obj_id, string $import_id)
write import id to db (static)
handlerBeginTag($a_xml_parser, string $a_name, array $a_attribs)
const IL_CRS_SUBSCRIPTION_DIRECT
const IL_CRS_SUBSCRIPTION_DEACTIVATED
handleWaitingList(array $a_attribs, array $id_data)
attach or detach members from waitinglist
handleAdmin(array $a_attribs, array $id_data)
attach or detach admin from course member
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
Class handles translation mode for an object.
ilCourseWaitingList $course_waiting_list
setHandlers($a_xml_parser)
array $course_members_array
static _importContainerSortingSettings(array $attibs, int $obj_id)
sorting import for all container objects
handleSubscriber(array $a_attribs, array $id_data)
attach or detach members from subscribers
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 IL_CRS_SUBSCRIPTION_PASSWORD
const IL_CRS_SUBSCRIPTION_LIMITED
static _getInstanceByObjId(int $a_obj_id)
withDefaultTitle(string $title)
ilSaxController $sax_controller
bool $in_period_with_time
ilAdvancedMDValueParser $adv_md_handler
string $current_container_setting
handlerEndTag($a_xml_parser, string $a_name)
handleTutor(array $a_attribs, array $id_data)
static _writeContainerSetting(int $a_id, string $a_keyword, string $a_value)
const IL_CRS_SUBSCRIPTION_UNLIMITED
Translations $translations
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)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__construct(Container $dic, ilPlugin $plugin)
const IL_CRS_SUBSCRIPTION_CONFIRMATION
handleMember(array $a_attribs, array $id_data)
attach or detach user/member/admin from course member
trimAndStripAttribs(array $attribs)
ilCourseParticipants $course_members
__construct(ilObjCourse $a_course_obj, string $a_xml_file='')
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(int $a_obj_id)
handlerCharacterData($a_xml_parser, string $a_data)
Character data handler.
static _lookupLogin(int $a_user_id)