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';
69 $this->course_obj = $a_course_obj;
73 $this->course_members_array = array_flip($this->course_members->getParticipants());
75 $this->md_obj =
new ilMD($this->course_obj->getId(),0,
'crs');
89 $this->sax_controller->setHandlers($a_xml_parser);
90 $this->sax_controller->setDefaultElementHandler($this);
92 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValueParser.php');
93 $this->sax_controller->setElementHandler(
110 if($this->in_meta_data)
120 if(strlen($a_attribs[
'importId']))
122 $this->log->write(
"CourseXMLParser: importId = ".$a_attribs[
'importId']);
123 $this->course_obj->setImportId($a_attribs[
'importId']);
126 if(strlen($a_attribs[
'showMembers']))
128 $this->course_obj->setShowMembers(
129 $a_attribs[
'showMembers'] ==
'Yes' ?
true :
false
135 if($id_data = $this->
__parseId($a_attribs[
'id']))
137 if($id_data[
'local'] or $id_data[
'imported'])
145 if($id_data = $this->
__parseId($a_attribs[
'id']))
147 if($id_data[
'local'] or $id_data[
'imported'])
156 if($id_data = $this->
__parseId($a_attribs[
'id']))
158 if($id_data[
'local'] or $id_data[
'imported'])
166 if($id_data = $this->
__parseId($a_attribs[
'id']))
168 if($id_data[
'local'] or $id_data[
'imported'])
176 if($id_data = $this->
__parseId($a_attribs[
'id']))
178 if($id_data[
'local'] or $id_data[
'imported'])
186 if($id_data = $this->
__parseId($a_attribs[
'id']))
188 if($id_data[
'local'] or $id_data[
'imported'])
190 $this->course_obj->setOwner($id_data[
'usr_id']);
191 $this->course_obj->updateOwner();
198 $this->in_settings =
true;
201 $this->in_availability =
true;
205 if($this->in_availability)
209 elseif($this->in_registration)
217 if($this->in_availability)
219 $this->course_obj->setOfflineStatus(
false);
222 elseif($this->in_registration)
228 case 'TemporarilyAvailable':
229 if($this->in_availability)
231 $this->course_obj->setOfflineStatus(
false);
234 elseif($this->in_registration)
253 case 'Responsibility':
260 $this->in_registration =
true;
262 switch($a_attribs[
'registrationType'])
277 $this->course_obj->setSubscriptionMaxMembers((
int) $a_attribs[
'maxMembers']);
278 $this->course_obj->enableSubscriptionMembershipLimitation($this->course_obj->getSubscriptionMaxMembers() > 0);
279 $this->course_obj->setSubscriptionNotify($a_attribs[
'notification'] ==
'Yes' ?
true :
false);
280 $this->course_obj->enableWaitingList($a_attribs[
'waitingList'] ==
'Yes' ?
true :
false);
284 include_once
'./Services/Container/classes/class.ilContainerSortingSettings.php';
288 $this->course_obj->setOrderType(
295 $this->in_archive =
true;
296 switch($a_attribs[
'Access'])
304 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
308 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
319 $this->in_meta_data =
true;
323 case 'ContainerSetting':
324 $this->current_container_setting = $a_attribs[
'id'];
339 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
342 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
345 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_MEMBER);
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);
354 $this->course_members_array[$id_data[
'usr_id']] =
"added";
359 if($a_attribs[
'blocked'] ==
'Yes')
361 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
363 if($a_attribs[
'passed'] ==
'Yes')
365 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
369 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id']))
372 $this->course_members->delete($id_data[
'usr_id']);
389 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
392 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
395 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_ADMIN);
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_array[$id_data[
'usr_id']] =
"added";
409 if($a_attribs[
'notification'] ==
'Yes')
411 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
413 if($a_attribs[
'passed'] ==
'Yes')
415 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
417 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
420 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id']))
423 $this->course_members->delete($id_data[
'usr_id']);
437 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
440 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
443 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_TUTOR);
444 if($a_attribs[
'notification'] ==
'Yes')
446 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
448 if($a_attribs[
'passed'] ==
'Yes')
450 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
452 $this->course_members_array[$id_data[
'usr_id']] =
"added";
456 if($a_attribs[
'notification'] ==
'Yes')
458 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
460 if($a_attribs[
'passed'] ==
'Yes')
462 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
464 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
467 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id']))
470 $this->course_members->delete($id_data[
'usr_id']);
485 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
488 if (!$this->course_members->isSubscriber($id_data[
'usr_id']))
491 $this->course_members->addSubscriber($id_data[
'usr_id']);
493 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
496 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id']))
499 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
512 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
515 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id']))
518 $this->course_waiting_list->addToList($id_data[
'usr_id']);
520 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
523 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id']))
526 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
540 if($this->in_meta_data)
549 $this->log->write(
'CourseXMLParser: import_id = '.$this->course_obj->getImportId());
550 $this->course_obj->MDUpdateListener(
'General');
551 $this->course_obj->update();
552 $this->adv_md_handler->save();
556 $this->in_settings =
false;
560 $this->in_availability =
false;
564 $this->in_registration =
false;
568 $this->in_archive =
false;
572 if($this->in_availability)
574 $this->course_obj->setActivationStart(trim($this->cdata));
576 if($this->in_registration)
578 $this->course_obj->setSubscriptionStart(trim($this->cdata));
580 if($this->in_archive)
582 $this->course_obj->setArchiveStart(trim($this->cdata));
587 if($this->in_availability)
589 $this->course_obj->setActivationEnd(trim($this->cdata));
591 if($this->in_registration)
593 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
595 if($this->in_archive)
597 $this->course_obj->setArchiveEnd(trim($this->cdata));
602 $this->course_obj->setSyllabus(trim($this->cdata));
606 case 'ImportantInformation':
607 $this->course_obj->setImportantInformation(trim($this->cdata));
611 $this->course_obj->setContactName(trim($this->cdata));
614 case 'Responsibility':
615 $this->course_obj->setContactResponsibility(trim($this->cdata));
619 $this->course_obj->setContactPhone(trim($this->cdata));
623 $this->course_obj->setContactEmail(trim($this->cdata));
627 $this->course_obj->setContactConsultation(trim($this->cdata));
631 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
635 $this->in_meta_data =
false;
639 case 'ContainerSetting':
640 if($this->current_container_setting)
643 $this->course_obj->getId(),
663 if($this->in_meta_data)
670 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
672 $this->cdata .= $a_data;
681 $fields = explode(
'_',$a_id);
683 if(!is_array($fields) or
684 $fields[0] !=
'il' or
685 !is_numeric($fields[1]) or
686 $fields[2] !=
'usr' or
687 !is_numeric($fields[3]))
693 return array(
'imported' =>
true,
699 return array(
'imported' =>
false,
701 'usr_id' => $fields[3]);