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)
206 $this->course_obj->setOfflineStatus(
false);
209 elseif($this->in_registration)
215 case 'TemporarilyAvailable':
216 if($this->in_availability)
218 $this->course_obj->setOfflineStatus(
false);
221 elseif($this->in_registration)
240 case 'Responsibility':
247 $this->in_registration =
true;
249 switch($a_attribs[
'registrationType'])
264 $this->course_obj->setSubscriptionMaxMembers((
int) $a_attribs[
'maxMembers']);
265 $this->course_obj->enableSubscriptionMembershipLimitation($this->course_obj->getSubscriptionMaxMembers() > 0);
266 $this->course_obj->setSubscriptionNotify($a_attribs[
'notification'] ==
'Yes' ?
true :
false);
267 $this->course_obj->enableWaitingList($a_attribs[
'waitingList'] ==
'Yes' ?
true :
false);
271 switch($a_attribs[
'type'])
289 $this->in_archive =
true;
290 switch($a_attribs[
'Access'])
298 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
302 #$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
313 $this->in_meta_data =
true;
330 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
333 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
336 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_MEMBER);
337 if($a_attribs[
'blocked'] ==
'Yes')
339 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
341 if($a_attribs[
'passed'] ==
'Yes')
343 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
345 $this->course_members_array[$id_data[
'usr_id']] =
"added";
350 if($a_attribs[
'blocked'] ==
'Yes')
352 $this->course_members->updateBlocked($id_data[
'usr_id'],
true);
354 if($a_attribs[
'passed'] ==
'Yes')
356 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
360 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isMember($id_data[
'usr_id']))
363 $this->course_members->delete($id_data[
'usr_id']);
380 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
383 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
386 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_ADMIN);
387 if($a_attribs[
'notification'] ==
'Yes')
389 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
391 if($a_attribs[
'passed'] ==
'Yes')
393 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
395 $this->course_members_array[$id_data[
'usr_id']] =
"added";
400 if($a_attribs[
'notification'] ==
'Yes')
402 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
404 if($a_attribs[
'passed'] ==
'Yes')
406 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
408 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
411 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isAdmin($id_data[
'usr_id']))
414 $this->course_members->delete($id_data[
'usr_id']);
428 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
431 if (!array_key_exists($id_data[
'usr_id'], $this->course_members_array))
434 $this->course_members->add($id_data[
'usr_id'],
IL_CRS_TUTOR);
435 if($a_attribs[
'notification'] ==
'Yes')
437 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
439 if($a_attribs[
'passed'] ==
'Yes')
441 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
443 $this->course_members_array[$id_data[
'usr_id']] =
"added";
447 if($a_attribs[
'notification'] ==
'Yes')
449 $this->course_members->updateNotification($id_data[
'usr_id'],
true);
451 if($a_attribs[
'passed'] ==
'Yes')
453 $this->course_members->updatePassed($id_data[
'usr_id'],
true);
455 $this->course_members->updateBlocked($id_data[
'usr_id'],
false);
458 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isTutor($id_data[
'usr_id']))
461 $this->course_members->delete($id_data[
'usr_id']);
476 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
479 if (!$this->course_members->isSubscriber($id_data[
'usr_id']))
482 $this->course_members->addSubscriber($id_data[
'usr_id']);
484 $this->course_members->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
487 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_members->isSubscriber($id_data[
'usr_id']))
490 $this->course_members->deleteSubscriber($id_data[
"usr_id"]);
503 if (!isset($a_attribs[
'action']) || $a_attribs[
'action'] ==
'Attach')
506 if (!$this->course_waiting_list->isOnList($id_data[
'usr_id']))
509 $this->course_waiting_list->addToList($id_data[
'usr_id']);
511 $this->course_waiting_list->updateSubscriptionTime($id_data[
'usr_id'],$a_attribs[
'subscriptionTime']);
514 elseif (isset($a_attribs[
'action']) && $a_attribs[
'action'] ==
'Detach' && $this->course_waiting_list->isOnList($id_data[
'usr_id']))
517 $this->course_waiting_list->removeFromList($id_data[
'usr_id']);
531 if($this->in_meta_data)
540 $this->log->write(
'CourseXMLParser: import_id = '.$this->course_obj->getImportId());
541 $this->course_obj->MDUpdateListener(
'General');
542 $this->course_obj->update();
543 $this->adv_md_handler->save();
547 $this->in_settings =
false;
551 $this->in_availability =
false;
555 $this->in_registration =
false;
559 $this->in_archive =
false;
563 if($this->in_availability)
565 $this->course_obj->setActivationStart(trim($this->cdata));
567 if($this->in_registration)
569 $this->course_obj->setSubscriptionStart(trim($this->cdata));
571 if($this->in_archive)
573 $this->course_obj->setArchiveStart(trim($this->cdata));
578 if($this->in_availability)
580 $this->course_obj->setActivationEnd(trim($this->cdata));
582 if($this->in_registration)
584 $this->course_obj->setSubscriptionEnd(trim($this->cdata));
586 if($this->in_archive)
588 $this->course_obj->setArchiveEnd(trim($this->cdata));
593 $this->course_obj->setSyllabus(trim($this->cdata));
597 case 'ImportantInformation':
598 $this->course_obj->setImportantInformation(trim($this->cdata));
602 $this->course_obj->setContactName(trim($this->cdata));
605 case 'Responsibility':
606 $this->course_obj->setContactResponsibility(trim($this->cdata));
610 $this->course_obj->setContactPhone(trim($this->cdata));
614 $this->course_obj->setContactEmail(trim($this->cdata));
618 $this->course_obj->setContactConsultation(trim($this->cdata));
622 $this->course_obj->setSubscriptionPassword(trim($this->cdata));
626 $this->in_meta_data =
false;
644 if($this->in_meta_data)
651 $a_data = preg_replace(
"/\t+/",
" ",$a_data);
653 $this->cdata .= $a_data;
662 $fields = explode(
'_',$a_id);
664 if(!is_array($fields) or
665 $fields[0] !=
'il' or
666 !is_numeric($fields[1]) or
667 $fields[2] !=
'usr' or
668 !is_numeric($fields[3]))
674 return array(
'imported' =>
true,
680 return array(
'imported' =>
false,
682 'usr_id' => $fields[3]);