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']);
472 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
475 if (!$this->course_members->isSubscriber($id_data[
'usr_id']))
478 $this->course_members->addSubscriber($id_data[
'usr_id']);
480 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
483 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"]);
499 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
502 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id']))
505 $this->course_waiting_list->addToList($id_data[
'usr_id']);
507 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
510 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id']))
513 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
527 if($this->in_meta_data)
536 $this->log->write(
'CourseXMLParser: import_id = '.$this->course_obj->getImportId());
537 $this->course_obj->MDUpdateListener(
'General');
538 $this->course_obj->update();
539 $this->adv_md_handler->save();
543 $this->in_settings =
false;
547 $this->in_availability =
false;
551 $this->in_registration =
false;
555 $this->in_archive =
false;
559 if($this->in_availability)
561 $this->course_obj->setActivationStart(trim($this->cdata));
563 if($this->in_registration)
565 $this->course_obj->setSubscriptionStart(trim($this->cdata));
567 if($this->in_archive)
569 $this->course_obj->setArchiveStart(trim($this->cdata));
574 if($this->in_availability)
576 $this->course_obj->setActivationEnd(trim($this->cdata));
578 if($this->in_registration)
580 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
582 if($this->in_archive)
584 $this->course_obj->setArchiveEnd(trim($this->cdata));
589 $this->course_obj->setSyllabus(trim($this->cdata));
593 case 'ImportantInformation':
594 $this->course_obj->setImportantInformation(trim($this->cdata));
598 $this->course_obj->setContactName(trim($this->cdata));
601 case 'Responsibility':
602 $this->course_obj->setContactResponsibility(trim($this->cdata));
606 $this->course_obj->setContactPhone(trim($this->cdata));
610 $this->course_obj->setContactEmail(trim($this->cdata));
614 $this->course_obj->setContactConsultation(trim($this->cdata));
618 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
622 $this->in_meta_data =
false;
640 if($this->in_meta_data)
647 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
649 $this->cdata .= $a_data;
658 $fields = explode(
'_',$a_id);
660 if(!is_array($fields) or
661 $fields[0] !=
'il' or
662 !is_numeric($fields[1]) or
663 $fields[2] !=
'usr' or
664 !is_numeric($fields[3]))
670 return array(
'imported' =>
true,
676 return array(
'imported' =>
false,
678 'usr_id' => $fields[3]);