25 include_once(
"Services/MetaData/classes/class.ilMDSaxParser.php");
26 include_once(
"Services/MetaData/classes/class.ilMD.php");
27 include_once(
'Services/Utilities/interfaces/interface.ilSaxSubsetParser.php');
28 include_once(
'Services/Utilities/classes/class.ilSaxController.php');
29 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
30 include_once
'Modules/Course/classes/class.ilCourseWaitingList.php';
31 include_once
'Modules/Course/classes/class.ilCourseConstants.php';
79 $this->log = $DIC->logger()->crs();
81 $this->course_obj = $a_course_obj;
85 $this->course_members_array = array_flip($this->course_members->getParticipants());
87 $this->md_obj =
new ilMD($this->course_obj->getId(), 0,
'crs');
101 $this->sax_controller->setHandlers($a_xml_parser);
102 $this->sax_controller->setDefaultElementHandler($this);
104 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValueParser.php');
105 $this->sax_controller->setElementHandler(
124 if ($this->in_meta_data) {
125 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
132 if (strlen($a_attribs[
'importId'])) {
133 $this->log->write(
"CourseXMLParser: importId = " . $a_attribs[
'importId']);
134 $this->course_obj->setImportId($a_attribs[
'importId']);
137 if (strlen($a_attribs[
'showMembers'])) {
138 $this->course_obj->setShowMembers(
139 $a_attribs[
'showMembers'] ==
'Yes' ?
true :
false 145 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
146 if ($id_data[
'local'] or $id_data[
'imported']) {
153 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
154 if ($id_data[
'local'] or $id_data[
'imported']) {
161 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
162 if ($id_data[
'local'] or $id_data[
'imported']) {
169 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
170 if ($id_data[
'local'] or $id_data[
'imported']) {
177 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
178 if ($id_data[
'local'] or $id_data[
'imported']) {
185 if ($id_data = $this->
__parseId($a_attribs[
'id'])) {
186 if ($id_data[
'local'] or $id_data[
'imported']) {
187 $this->course_obj->setOwner($id_data[
'usr_id']);
188 $this->course_obj->updateOwner();
195 $this->in_settings =
true;
198 $this->in_availability =
true;
202 if ($this->in_availability) {
203 $this->course_obj->setOfflineStatus(
true);
204 } elseif ($this->in_registration) {
211 if ($this->in_availability) {
212 $this->course_obj->setOfflineStatus(
false);
213 } elseif ($this->in_registration) {
218 case 'TemporarilyAvailable':
219 if ($this->in_availability) {
220 $this->course_obj->setOfflineStatus(
false);
221 } elseif ($this->in_registration) {
242 case 'Responsibility':
249 $this->in_registration =
true;
251 switch ($a_attribs[
'registrationType']) {
265 $this->course_obj->setSubscriptionMaxMembers((
int) $a_attribs[
'maxMembers']);
266 $this->course_obj->enableSubscriptionMembershipLimitation($this->course_obj->getSubscriptionMaxMembers() > 0);
267 $this->course_obj->setSubscriptionNotify($a_attribs[
'notification'] ==
'Yes' ?
true :
false);
268 $this->course_obj->enableWaitingList($a_attribs[
'waitingList'] ==
'Yes' ?
true :
false);
272 include_once
'./Services/Container/classes/class.ilContainerSortingSettings.php';
276 $this->course_obj->setOrderType(
286 $this->in_meta_data =
true;
287 parent::handlerBeginTag($a_xml_parser, $a_name, $a_attribs);
290 case 'ContainerSetting':
291 $this->current_container_setting = $a_attribs[
'id'];
295 $this->in_period =
true;
296 $this->in_period_with_time = $a_attribs[
'withTime'];
299 case 'WaitingListAutoFill':
300 case 'CancellationEnd':
302 case 'StatusDetermination':
303 case 'MailToMembersType':
307 if (array_key_exists(
'status', $a_attribs)) {
308 $this->course_obj->setAutoNotification((
bool) $a_attribs[
'status']);
313 $this->course_obj->setEnableCourseMap((
bool) $a_attribs[
'enabled'] ??
false);
314 $this->course_obj->setLatitude((
string) $a_attribs[
'latitude'] ??
'');
315 $this->course_obj->setLongitude((
string) $a_attribs[
'longitude'] ??
'');
316 $this->course_obj->setLocationZoom((
int) $a_attribs[
'location_zoom'] ?? 0);
320 if (isset($a_attribs[
'active'])) {
321 $this->course_obj->enableSessionLimit((
bool) $a_attribs[
'active']);
323 if (isset($a_attribs[
'previous'])) {
324 $this->course_obj->setNumberOfPreviousSessions((
int) $a_attribs[
'previous']);
326 if (isset($a_attribs[
'next'])) {
327 $this->course_obj->setNumberOfNextSessions((
int) $a_attribs[
'next']);
343 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
345 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
347 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_MEMBER);
348 if ($a_attribs[
'blocked'] ==
'Yes') {
349 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
351 if ($a_attribs[
'passed'] ==
'Yes') {
352 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
354 $this->course_members_array[$id_data[
'usr_id']] =
"added";
357 if ($a_attribs[
'blocked'] ==
'Yes') {
358 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
360 if ($a_attribs[
'passed'] ==
'Yes') {
361 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
364 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id'])) {
366 $this->course_members->delete($id_data[
'usr_id']);
382 $rbacadmin = $DIC[
'rbacadmin'];
384 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
386 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
388 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_ADMIN);
389 if ($a_attribs[
'notification'] ==
'Yes') {
390 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
392 if ($a_attribs[
'passed'] ==
'Yes') {
393 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
395 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
397 $this->course_members->updateContact($id_data[
'usr_id'],
true);
399 $this->course_members_array[$id_data[
'usr_id']] =
"added";
402 if ($a_attribs[
'notification'] ==
'Yes') {
403 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
405 if ($a_attribs[
'passed'] ==
'Yes') {
406 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
408 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
409 $this->course_members->updateContact($id_data[
'usr_id'],
true);
410 } elseif (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'No') {
411 $this->course_members->updateContact($id_data[
'usr_id'],
false);
413 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
415 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id'])) {
417 $this->course_members->delete($id_data[
'usr_id']);
431 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
433 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array)) {
435 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_TUTOR);
436 if ($a_attribs[
'notification'] ==
'Yes') {
437 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
439 if ($a_attribs[
'passed'] ==
'Yes') {
440 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
442 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
444 $this->course_members->updateContact($id_data[
'usr_id'],
true);
446 $this->course_members_array[$id_data[
'usr_id']] =
"added";
448 if ($a_attribs[
'notification'] ==
'Yes') {
449 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
451 if ($a_attribs[
'passed'] ==
'Yes') {
452 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
454 if (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'Yes') {
455 $this->course_members->updateContact($id_data[
'usr_id'],
true);
456 } elseif (isset($a_attribs[
'contact']) && $a_attribs[
'contact'] ==
'No') {
457 $this->course_members->updateContact($id_data[
'usr_id'],
false);
459 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
461 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id'])) {
463 $this->course_members->delete($id_data[
'usr_id']);
477 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
479 if (!$this->course_members->isSubscriber($id_data[
'usr_id'])) {
481 $this->course_members->addSubscriber($id_data[
'usr_id']);
483 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'], $a_attribs[
'subscriptionTime']);
484 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id'])) {
486 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
498 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach') {
500 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id'])) {
502 $this->course_waiting_list->addToList($id_data[
'usr_id']);
504 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'], $a_attribs[
'subscriptionTime']);
505 } elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id'])) {
507 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
520 $this->cdata = $this->
trimAndStrip((
string) $this->cdata);
521 if ($this->in_meta_data) {
522 parent::handlerEndTag($a_xml_parser, $a_name);
528 $this->log->write(
'CourseXMLParser: import_id = ' . $this->course_obj->getImportId());
533 $this->course_obj->readContainerSettings();
534 $this->course_obj->MDUpdateListener(
'General');
535 $this->course_obj->update();
536 $this->adv_md_handler->save();
540 $this->in_settings =
false;
544 $this->in_availability =
false;
548 $this->in_registration =
false;
553 if ($this->in_availability) {
554 $this->course_obj->setActivationStart(trim($this->cdata));
556 if ($this->in_registration) {
557 $this->course_obj->setSubscriptionStart(trim($this->cdata));
559 if ($this->in_period) {
560 if ((
int) $this->cdata) {
561 if ($this->in_period_with_time) {
562 $this->period_start = new \ilDateTime((
int) $this->cdata,
IL_CAL_UNIX);
564 $this->period_start = new \ilDate((
int) $this->cdata,
IL_CAL_UNIX);
571 if ($this->in_availability) {
572 $this->course_obj->setActivationEnd(trim($this->cdata));
574 if ($this->in_registration) {
575 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
577 if ($this->in_period) {
578 if ((
int) $this->cdata) {
579 if ($this->in_period_with_time) {
580 $this->period_end = new \ilDateTime((
int) $this->cdata,
IL_CAL_UNIX);
582 $this->period_end = new \ilDate((
int) $this->cdata,
IL_CAL_UNIX);
589 $this->course_obj->setSyllabus(trim($this->cdata));
593 $this->course_obj->setTargetGroup(trim($this->cdata));
596 case 'ImportantInformation':
597 $this->course_obj->setImportantInformation(trim($this->cdata));
601 $this->course_obj->setViewMode(trim($this->cdata));
605 $this->course_obj->setContactName(trim($this->cdata));
608 case 'Responsibility':
609 $this->course_obj->setContactResponsibility(trim($this->cdata));
613 $this->course_obj->setContactPhone(trim($this->cdata));
617 $this->course_obj->setContactEmail(trim($this->cdata));
621 $this->course_obj->setContactConsultation(trim($this->cdata));
625 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
629 $this->in_meta_data =
false;
630 parent::handlerEndTag($a_xml_parser, $a_name);
633 case 'ContainerSetting':
634 if ($this->current_container_setting) {
636 $this->course_obj->getId(),
644 $this->in_period =
false;
646 $this->course_obj->setCoursePeriod($this->period_start, $this->period_end);
648 $this->log->warning(
'invalid course period given');
652 case 'WaitingListAutoFill':
653 $this->course_obj->setWaitingListAutoFill($this->cdata);
656 case 'CancellationEnd':
657 if ((
int) $this->cdata) {
658 $this->course_obj->setCancellationEnd(
new ilDate((
int) $this->cdata,
IL_CAL_UNIX));
663 if ((
int) $this->cdata) {
664 $this->course_obj->setSubscriptionMinMembers((
int) $this->cdata);
669 $this->course_obj->setViewMode((
int) $this->cdata);
673 $this->course_obj->setTimingMode((
int) $this->cdata);
676 case 'StatusDetermination':
677 $this->course_obj->setStatusDetermination((
int) $this->cdata);
680 case 'MailToMembersType':
681 $this->course_obj->setMailToMembersType((
int) $this->cdata);
698 if ($this->in_meta_data) {
699 parent::handlerCharacterData($a_xml_parser, $a_data);
701 if ($a_data !=
"\n") {
703 $a_data = preg_replace(
"/\t+/",
" ", $a_data);
705 $this->cdata .= $a_data;
716 $fields = explode(
'_', $a_id);
718 if (!is_array($fields) or
719 $fields[0] !=
'il' or
720 !is_numeric($fields[1]) or
721 $fields[2] !=
'usr' or
722 !is_numeric($fields[3])) {
726 return array(
'imported' =>
true,
731 return array(
'imported' =>
false,
733 'usr_id' => $fields[3]);
static _lookupLogin($a_user_id)
lookup login
__construct($a_course_obj, $a_xml_file='')
Constructor.
const IL_CRS_SUBSCRIPTION_LIMITED
trimAndStrip(string $input)
static _importContainerSortingSettings($attibs, $obj_id)
sorting import for all container objects
handleMember($a_attribs, $id_data)
attach or detach user/member/admin from course member
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
trimAndStripAttribs(array $attribs)
setHandlers($a_xml_parser)
set event handlers
handleAdmin($a_attribs, $id_data)
attach or detach admin from course member
$current_container_setting
const IL_CRS_SUBSCRIPTION_CONFIRMATION
handleWaitingList($a_attribs, $id_data)
attach or detach members from waitinglist
static _getImportedUserId($i2_id)
handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
handler for begin of element
handlerEndTag($a_xml_parser, $a_name)
handler for end of element
const IL_CRS_SUBSCRIPTION_PASSWORD
const IL_CRS_SUBSCRIPTION_UNLIMITED
handleTutor($a_attribs, $id_data)
attach or detach admin from course member
const IL_CRS_ADMIN
Base class for course and group participants.
Interface definition for sax subset parsers.
Controller class for sax element handlers.
__construct(Container $dic, ilPlugin $plugin)
static _writeImportId($a_obj_id, $a_import_id)
write import id to db (static)
static _writeContainerSetting($a_id, $a_keyword, $a_value)
const IL_CRS_SUBSCRIPTION_DIRECT
static getInstanceByObjId($a_obj_id)
Get singleton instance.
handlerCharacterData($a_xml_parser, $a_data)
handler for character data
handleSubscriber($a_attribs, $id_data)
attach or detach members from subscribers
const IL_CRS_SUBSCRIPTION_DEACTIVATED