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'])
185 $this->in_settings =
true;
188 $this->in_availability =
true;
192 if($this->in_availability)
196 elseif($this->in_registration)
204 if($this->in_availability)
208 elseif($this->in_registration)
214 case 'TemporarilyAvailable':
215 if($this->in_availability)
219 elseif($this->in_registration)
238 case 'Responsibility':
245 $this->in_registration =
true;
247 switch($a_attribs[
'registrationType'])
261 $this->course_obj->setSubscriptionMaxMembers((
int) $a_attribs[
'maxMembers']);
262 $this->course_obj->setSubscriptionNotify($a_attribs[
'notification'] ==
'Yes' ?
true :
false);
263 $this->course_obj->enableWaitingList($a_attribs[
'waitingList'] ==
'Yes' ?
true :
false);
267 switch($a_attribs[
'type'])
285 $this->in_archive =
true;
286 switch($a_attribs[
'Access'])
294 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
298 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
309 $this->in_meta_data =
true;
326 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
329 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
332 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_MEMBER);
333 if($a_attribs[
'blocked'] ==
'Yes')
335 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
337 if($a_attribs[
'passed'] ==
'Yes')
339 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
341 $this->course_members_array[$id_data[
'usr_id']] =
"added";
346 if($a_attribs[
'blocked'] ==
'Yes')
348 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
350 if($a_attribs[
'passed'] ==
'Yes')
352 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
356 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id']))
359 $this->course_members->delete($id_data[
'usr_id']);
376 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
379 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
382 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_ADMIN);
383 if($a_attribs[
'notification'] ==
'Yes')
385 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
387 if($a_attribs[
'passed'] ==
'Yes')
389 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
391 $this->course_members_array[$id_data[
'usr_id']] =
"added";
396 if($a_attribs[
'notification'] ==
'Yes')
398 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
400 if($a_attribs[
'passed'] ==
'Yes')
402 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
404 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
407 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id']))
410 $this->course_members->delete($id_data[
'usr_id']);
424 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
427 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
430 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_TUTOR);
431 if($a_attribs[
'notification'] ==
'Yes')
433 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
435 if($a_attribs[
'passed'] ==
'Yes')
437 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
439 $this->course_members_array[$id_data[
'usr_id']] =
"added";
443 if($a_attribs[
'notification'] ==
'Yes')
445 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
447 if($a_attribs[
'passed'] ==
'Yes')
449 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
451 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
454 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id']))
457 $this->course_members->delete($id_data[
'usr_id']);
471 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
474 if (!$this->course_members->isSubscriber($id_data[
'usr_id']))
477 $this->course_members->addSubscriber($id_data[
'usr_id']);
479 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
482 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id']))
485 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
498 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
501 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id']))
504 $this->course_waiting_list->addToList($id_data[
'usr_id']);
506 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
509 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id']))
512 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
526 if($this->in_meta_data)
535 $this->log->write(
'CourseXMLParser: import_id = '.$this->course_obj->getImportId());
536 $this->course_obj->MDUpdateListener(
'General');
537 $this->course_obj->update();
538 $this->adv_md_handler->save();
542 $this->in_settings =
false;
546 $this->in_availability =
false;
550 $this->in_registration =
false;
554 $this->in_archive =
false;
558 if($this->in_availability)
560 $this->course_obj->setActivationStart(trim($this->cdata));
562 if($this->in_registration)
564 $this->course_obj->setSubscriptionStart(trim($this->cdata));
566 if($this->in_archive)
568 $this->course_obj->setArchiveStart(trim($this->cdata));
573 if($this->in_availability)
575 $this->course_obj->setActivationEnd(trim($this->cdata));
577 if($this->in_registration)
579 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
581 if($this->in_archive)
583 $this->course_obj->setArchiveEnd(trim($this->cdata));
588 $this->course_obj->setSyllabus(trim($this->cdata));
592 case 'ImportantInformation':
593 $this->course_obj->setImportantInformation(trim($this->cdata));
597 $this->course_obj->setContactName(trim($this->cdata));
600 case 'Responsibility':
601 $this->course_obj->setContactResponsibility(trim($this->cdata));
605 $this->course_obj->setContactPhone(trim($this->cdata));
609 $this->course_obj->setContactEmail(trim($this->cdata));
613 $this->course_obj->setContactConsultation(trim($this->cdata));
617 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
621 $this->in_meta_data =
false;
639 if($this->in_meta_data)
646 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
648 $this->cdata .= $a_data;
657 $fields = explode(
'_',$a_id);
659 if(!is_array($fields) or
660 $fields[0] !=
'il' or
661 !is_numeric($fields[1]) or
662 $fields[2] !=
'usr' or
663 !is_numeric($fields[3]))
669 return array(
'imported' =>
true,
675 return array(
'imported' =>
false,
677 'usr_id' => $fields[3]);