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';
67 $this->course_obj = $a_course_obj;
71 $this->course_members_array = array_flip($this->course_members->getParticipants());
73 $this->md_obj =
new ilMD($this->course_obj->getId(),0,
'crs');
87 $this->sax_controller->setHandlers($a_xml_parser);
88 $this->sax_controller->setDefaultElementHandler($this);
90 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValueParser.php');
91 $this->sax_controller->setElementHandler(
108 if($this->in_meta_data)
118 if(strlen($a_attribs[
'importId']))
120 $this->log->write(
"CourseXMLParser: importId = ".$a_attribs[
'importId']);
121 $this->course_obj->setImportId($a_attribs[
'importId']);
124 if(strlen($a_attribs[
'showMembers']))
126 $this->course_obj->setShowMembers(
127 $a_attribs[
'showMembers'] ==
'Yes' ?
true :
false
133 if($id_data = $this->
__parseId($a_attribs[
'id']))
135 if($id_data[
'local'] or $id_data[
'imported'])
143 if($id_data = $this->
__parseId($a_attribs[
'id']))
145 if($id_data[
'local'] or $id_data[
'imported'])
154 if($id_data = $this->
__parseId($a_attribs[
'id']))
156 if($id_data[
'local'] or $id_data[
'imported'])
164 if($id_data = $this->
__parseId($a_attribs[
'id']))
166 if($id_data[
'local'] or $id_data[
'imported'])
174 if($id_data = $this->
__parseId($a_attribs[
'id']))
176 if($id_data[
'local'] or $id_data[
'imported'])
184 if($id_data = $this->
__parseId($a_attribs[
'id']))
186 if($id_data[
'local'] or $id_data[
'imported'])
188 $this->course_obj->setOwner($id_data[
'usr_id']);
189 $this->course_obj->updateOwner();
196 $this->in_settings =
true;
199 $this->in_availability =
true;
203 if($this->in_availability)
207 elseif($this->in_registration)
215 if($this->in_availability)
217 $this->course_obj->setOfflineStatus(
false);
220 elseif($this->in_registration)
226 case 'TemporarilyAvailable':
227 if($this->in_availability)
229 $this->course_obj->setOfflineStatus(
false);
232 elseif($this->in_registration)
251 case 'Responsibility':
258 $this->in_registration =
true;
260 switch($a_attribs[
'registrationType'])
275 $this->course_obj->setSubscriptionMaxMembers((
int) $a_attribs[
'maxMembers']);
276 $this->course_obj->enableSubscriptionMembershipLimitation($this->course_obj->getSubscriptionMaxMembers() > 0);
277 $this->course_obj->setSubscriptionNotify($a_attribs[
'notification'] ==
'Yes' ?
true :
false);
278 $this->course_obj->enableWaitingList($a_attribs[
'waitingList'] ==
'Yes' ?
true :
false);
282 switch($a_attribs[
'type'])
300 $this->in_archive =
true;
301 switch($a_attribs[
'Access'])
309 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
313 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
324 $this->in_meta_data =
true;
341 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
344 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')
350 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
352 if($a_attribs[
'passed'] ==
'Yes')
354 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
356 $this->course_members_array[$id_data[
'usr_id']] =
"added";
361 if($a_attribs[
'blocked'] ==
'Yes')
363 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
365 if($a_attribs[
'passed'] ==
'Yes')
367 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
371 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id']))
374 $this->course_members->delete($id_data[
'usr_id']);
391 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
394 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
397 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_ADMIN);
398 if($a_attribs[
'notification'] ==
'Yes')
400 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
402 if($a_attribs[
'passed'] ==
'Yes')
404 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
406 $this->course_members_array[$id_data[
'usr_id']] =
"added";
411 if($a_attribs[
'notification'] ==
'Yes')
413 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
415 if($a_attribs[
'passed'] ==
'Yes')
417 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
419 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
422 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id']))
425 $this->course_members->delete($id_data[
'usr_id']);
439 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
442 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
445 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_TUTOR);
446 if($a_attribs[
'notification'] ==
'Yes')
448 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
450 if($a_attribs[
'passed'] ==
'Yes')
452 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
454 $this->course_members_array[$id_data[
'usr_id']] =
"added";
458 if($a_attribs[
'notification'] ==
'Yes')
460 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
462 if($a_attribs[
'passed'] ==
'Yes')
464 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
466 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
469 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id']))
472 $this->course_members->delete($id_data[
'usr_id']);
487 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
490 if (!$this->course_members->isSubscriber($id_data[
'usr_id']))
493 $this->course_members->addSubscriber($id_data[
'usr_id']);
495 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
498 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id']))
501 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
514 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
517 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id']))
520 $this->course_waiting_list->addToList($id_data[
'usr_id']);
522 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
525 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id']))
528 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
542 if($this->in_meta_data)
551 $this->log->write(
'CourseXMLParser: import_id = '.$this->course_obj->getImportId());
552 $this->course_obj->MDUpdateListener(
'General');
553 $this->course_obj->update();
554 $this->adv_md_handler->save();
558 $this->in_settings =
false;
562 $this->in_availability =
false;
566 $this->in_registration =
false;
570 $this->in_archive =
false;
574 if($this->in_availability)
576 $this->course_obj->setActivationStart(trim($this->cdata));
578 if($this->in_registration)
580 $this->course_obj->setSubscriptionStart(trim($this->cdata));
582 if($this->in_archive)
584 $this->course_obj->setArchiveStart(trim($this->cdata));
589 if($this->in_availability)
591 $this->course_obj->setActivationEnd(trim($this->cdata));
593 if($this->in_registration)
595 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
597 if($this->in_archive)
599 $this->course_obj->setArchiveEnd(trim($this->cdata));
604 $this->course_obj->setSyllabus(trim($this->cdata));
608 case 'ImportantInformation':
609 $this->course_obj->setImportantInformation(trim($this->cdata));
613 $this->course_obj->setContactName(trim($this->cdata));
616 case 'Responsibility':
617 $this->course_obj->setContactResponsibility(trim($this->cdata));
621 $this->course_obj->setContactPhone(trim($this->cdata));
625 $this->course_obj->setContactEmail(trim($this->cdata));
629 $this->course_obj->setContactConsultation(trim($this->cdata));
633 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
637 $this->in_meta_data =
false;
655 if($this->in_meta_data)
662 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
664 $this->cdata .= $a_data;
673 $fields = explode(
'_',$a_id);
675 if(!is_array($fields) or
676 $fields[0] !=
'il' or
677 !is_numeric($fields[1]) or
678 $fields[2] !=
'usr' or
679 !is_numeric($fields[3]))
685 return array(
'imported' =>
true,
691 return array(
'imported' =>
false,
693 'usr_id' => $fields[3]);