ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseXMLParser Class Reference

Course XML Parser. More...

+ Inheritance diagram for ilCourseXMLParser:
+ Collaboration diagram for ilCourseXMLParser:

Public Member Functions

 ilCourseXMLParser ($a_course_obj, $a_xml_file= '')
 Constructor.
 setHandlers ($a_xml_parser)
 set event handlers
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
 __parseId ($a_id)
- Public Member Functions inherited from ilMDSaxParser
 ilMDSaxParser ($a_xml_file= '')
 Constructor.
 enableMDParsing ($a_status)
 getMDParsingStatus ()
 setMDObject (&$md)
getMDObject ()
 inMetaData ()
 __getCharacterData ()
 __pushParent (&$md_obj)
__popParent ()
__getParent ()
 ilMDSaxParser ($a_xml_file= '')
 Constructor.
 setMDObject (&$md)
 inMetaData ()
 __getCharacterData ()
 __pushParent (&$md_obj)
__popParent ()
__getParent ()
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 startParsing ()
 stores xml data in array
 createParser ()
 create parser
 setOptions ($a_xml_parser)
 set parser options
 openXMLFile ()
 open xml file
 parse ($a_xml_parser, $a_fp=null)
 parse xml file
 freeParser ($a_xml_parser)
 free xml parser handle
 setThrowException ($throwException)
 set error handling
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $lng
 $md_obj = null
- Data Fields inherited from ilMDSaxParser
 $md_in_md = false
 $md_chr_data = ''
 $md_cur_el = null
 $md_parsing_enabled = null
 $md = null
 $md_gen
- Data Fields inherited from ilSaxParser
 $input_type = null
 $xml_content = ''
 $ilias
 $lng
 $xml_file
 $throwException = false
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Private Member Functions

 handleMember ($a_attribs, $id_data)
 attach or detach user/member/admin from course member
 handleAdmin ($a_attribs, $id_data)
 attach or detach admin from course member
 handleTutor ($a_attribs, $id_data)
 attach or detach admin from course member
 handleSubscriber ($a_attribs, $id_data)
 attach or detach members from subscribers
 handleWaitingList ($a_attribs, $id_data)
 attach or detach members from waitinglist

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle

Detailed Description

Course XML Parser.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilCourseXMLParser.php 25784 2010-09-28 10:23:24Z hschottm

Definition at line 43 of file class.ilCourseXMLParser.php.

Member Function Documentation

ilCourseXMLParser::__parseId (   $a_id)

Definition at line 654 of file class.ilCourseXMLParser.php.

References ilSaxParser\$ilias, ilObjUser\_getImportedUserId(), and ilObjUser\_lookupLogin().

Referenced by handlerBeginTag().

{
global $ilias;
$fields = explode('_',$a_id);
if(!is_array($fields) or
$fields[0] != 'il' or
!is_numeric($fields[1]) or
$fields[2] != 'usr' or
!is_numeric($fields[3]))
{
return false;
}
{
return array('imported' => true,
'local' => false,
'usr_id' => $id);
}
if(($fields[1] == $ilias->getSetting('inst_id',0)) and strlen(ilObjUser::_lookupLogin($fields[3])))
{
return array('imported' => false,
'local' => true,
'usr_id' => $fields[3]);
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseXMLParser::handleAdmin (   $a_attribs,
  $id_data 
)
private

attach or detach admin from course member

Parameters
string$a_attribsattribute of a node
array$id_data

Definition at line 372 of file class.ilCourseXMLParser.php.

References IL_CRS_ADMIN.

Referenced by handlerBeginTag().

{
global $rbacadmin;
if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach')
// if action not set, or attach
{
if (!array_key_exists($id_data['usr_id'], $this->course_members_array))
// add only if member is not assigned yet
{
$this->course_members->add($id_data['usr_id'],IL_CRS_ADMIN);
if($a_attribs['notification'] == 'Yes')
{
$this->course_members->updateNotification($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
$this->course_members_array[$id_data['usr_id']] = "added";
}
else
// update
{
if($a_attribs['notification'] == 'Yes')
{
$this->course_members->updateNotification($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
$this->course_members->updateBlocked($id_data['usr_id'],false);
}
}
elseif (isset($a_attribs['action']) && $a_attribs['action'] == 'Detach' && $this->course_members->isAdmin($id_data['usr_id']))
// if action set and detach and is admin of course
{
$this->course_members->delete($id_data['usr_id']);
}
}

+ Here is the caller graph for this function:

ilCourseXMLParser::handleMember (   $a_attribs,
  $id_data 
)
private

attach or detach user/member/admin from course member

Parameters
array$a_attribsattributes of nod
array$id_data
int$roletypetype of role, which is courseMember->

Definition at line 324 of file class.ilCourseXMLParser.php.

References IL_CRS_MEMBER.

Referenced by handlerBeginTag().

{
if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach')
// if action not set, or set and attach
{
if (!array_key_exists($id_data['usr_id'], $this->course_members_array))
// add only if member is not yet assigned as tutor or admin
{
$this->course_members->add($id_data['usr_id'],IL_CRS_MEMBER);
if($a_attribs['blocked'] == 'Yes')
{
$this->course_members->updateBlocked($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
$this->course_members_array[$id_data['usr_id']] = "added";
}
else
// the member does exist. Now update status etc. only
{
if($a_attribs['blocked'] == 'Yes')
{
$this->course_members->updateBlocked($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
}
}
elseif (isset($a_attribs['action']) && $a_attribs['action'] == 'Detach' && $this->course_members->isMember($id_data['usr_id']))
// if action set and detach and is member of course
{
$this->course_members->delete($id_data['usr_id']);
}
}

+ Here is the caller graph for this function:

ilCourseXMLParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name
array$a_attribselement attributes array

Reimplemented from ilMDSaxParser.

Definition at line 106 of file class.ilCourseXMLParser.php.

References __parseId(), ilObject\_writeImportId(), handleAdmin(), handleMember(), handleSubscriber(), handleTutor(), handleWaitingList(), IL_CRS_ACTIVATION_LIMITED, IL_CRS_ACTIVATION_OFFLINE, IL_CRS_ACTIVATION_UNLIMITED, IL_CRS_ARCHIVE_DOWNLOAD, IL_CRS_ARCHIVE_NONE, IL_CRS_SUBSCRIPTION_CONFIRMATION, IL_CRS_SUBSCRIPTION_DEACTIVATED, IL_CRS_SUBSCRIPTION_DIRECT, IL_CRS_SUBSCRIPTION_LIMITED, IL_CRS_SUBSCRIPTION_PASSWORD, IL_CRS_SUBSCRIPTION_UNLIMITED, ilContainer\SORT_ACTIVATION, ilContainer\SORT_MANUAL, and ilContainer\SORT_TITLE.

{
if($this->in_meta_data)
{
parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
return;
}
switch($a_name)
{
case 'Course':
if(strlen($a_attribs['importId']))
{
$this->log->write("CourseXMLParser: importId = ".$a_attribs['importId']);
$this->course_obj->setImportId($a_attribs['importId']);
ilObject::_writeImportId($this->course_obj->getId(),$a_attribs['importId']);
}
if(strlen($a_attribs['showMembers']))
{
$this->course_obj->setShowMembers(
$a_attribs['showMembers'] == 'Yes' ? true : false
);
}
break;
case 'Admin':
if($id_data = $this->__parseId($a_attribs['id']))
{
if($id_data['local'] or $id_data['imported'])
{
$this->handleAdmin($a_attribs, $id_data);
}
}
break;
case 'Tutor':
if($id_data = $this->__parseId($a_attribs['id']))
{
if($id_data['local'] or $id_data['imported'])
{
$this->handleTutor($a_attribs, $id_data);
}
}
break;
case 'Member':
if($id_data = $this->__parseId($a_attribs['id']))
{
if($id_data['local'] or $id_data['imported'])
{
$this->handleMember($a_attribs, $id_data);
}
}
break;
case 'Subscriber':
if($id_data = $this->__parseId($a_attribs['id']))
{
if($id_data['local'] or $id_data['imported'])
{
$this->handleSubscriber($a_attribs, $id_data);
}
}
break;
case 'WaitingList':
if($id_data = $this->__parseId($a_attribs['id']))
{
if($id_data['local'] or $id_data['imported'])
{
$this->handleWaitingList($a_attribs, $id_data);
}
}
break;
case 'Settings':
$this->in_settings = true;
break;
case 'Availability':
$this->in_availability = true;
break;
case 'NotAvailable':
if($this->in_availability)
{
$this->course_obj->setActivationType(IL_CRS_ACTIVATION_OFFLINE);
}
elseif($this->in_registration)
{
$this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
}
break;
case 'Unlimited':
if($this->in_availability)
{
$this->course_obj->setActivationType(IL_CRS_ACTIVATION_UNLIMITED);
}
elseif($this->in_registration)
{
$this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_UNLIMITED);
}
break;
case 'TemporarilyAvailable':
if($this->in_availability)
{
$this->course_obj->setActivationType(IL_CRS_ACTIVATION_LIMITED);
}
elseif($this->in_registration)
{
$this->course_obj->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_LIMITED);
}
break;
case 'Start':
break;
case 'End':
break;
case 'Syllabus':
break;
case 'Contact':
break;
case 'Name':
case 'Responsibility':
case 'Phone':
case 'Email':
case 'Consultation':
break;
case 'Registration':
$this->in_registration = true;
switch($a_attribs['registrationType'])
{
case 'Confirmation':
$this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_CONFIRMATION);
break;
case 'Direct':
$this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DIRECT);
break;
case 'Password':
$this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_PASSWORD);
break;
}
$this->course_obj->setSubscriptionMaxMembers((int) $a_attribs['maxMembers']);
$this->course_obj->setSubscriptionNotify($a_attribs['notification'] == 'Yes' ? true : false);
$this->course_obj->enableWaitingList($a_attribs['waitingList'] == 'Yes' ? true : false);
break;
case 'Sort':
switch($a_attribs['type'])
{
case 'Manual':
$this->course_obj->setOrderType(ilContainer::SORT_MANUAL);
break;
case 'Title':
$this->course_obj->setOrderType(ilContainer::SORT_TITLE);
break;
case 'Activation':
$this->course_obj->setOrderType(ilContainer::SORT_ACTIVATION);
break;
}
break;
case 'Archive':
$this->in_archive = true;
switch($a_attribs['Access'])
{
case 'Disabled':
$this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
break;
case 'Read':
$this->course_obj->setArchiveType(IL_CRS_ARCHIVE_NONE);
#$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
break;
case 'Download':
#$this->course_obj->setViewMode(IL_CRS_VIEW_ARCHIVE);
$this->course_obj->setArchiveType(IL_CRS_ARCHIVE_DOWNLOAD);
break;
}
break;
case 'Disabled':
$this->course_obj->setSubscriptionType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
break;
case "MetaData":
$this->in_meta_data = true;
parent::handlerBeginTag($a_xml_parser,$a_name,$a_attribs);
break;
}
}

+ Here is the call graph for this function:

ilCourseXMLParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Parameters
resource$a_xml_parserxml parser
string$a_datacharacter data

Reimplemented from ilMDSaxParser.

Definition at line 637 of file class.ilCourseXMLParser.php.

{
// call meta data handler
if($this->in_meta_data)
{
parent::handlerCharacterData($a_xml_parser,$a_data);
}
if($a_data != "\n")
{
// Replace multiple tabs with one space
$a_data = preg_replace("/\t+/"," ",$a_data);
$this->cdata .= $a_data;
}
}
ilCourseXMLParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Parameters
resource$a_xml_parserxml parser
string$a_nameelement name

Reimplemented from ilMDSaxParser.

Definition at line 525 of file class.ilCourseXMLParser.php.

{
if($this->in_meta_data)
{
parent::handlerEndTag($a_xml_parser,$a_name);
}
switch($a_name)
{
case 'Course':
$this->log->write('CourseXMLParser: import_id = '.$this->course_obj->getImportId());
$this->course_obj->MDUpdateListener('General');
$this->course_obj->update();
$this->adv_md_handler->save();
break;
case 'Settings':
$this->in_settings = false;
break;
case 'Availability':
$this->in_availability = false;
break;
case 'Registration':
$this->in_registration = false;
break;
case 'Archive':
$this->in_archive = false;
break;
case 'Start':
if($this->in_availability)
{
$this->course_obj->setActivationStart(trim($this->cdata));
}
if($this->in_registration)
{
$this->course_obj->setSubscriptionStart(trim($this->cdata));
}
if($this->in_archive)
{
$this->course_obj->setArchiveStart(trim($this->cdata));
}
break;
case 'End':
if($this->in_availability)
{
$this->course_obj->setActivationEnd(trim($this->cdata));
}
if($this->in_registration)
{
$this->course_obj->setSubscriptionEnd(trim($this->cdata));
}
if($this->in_archive)
{
$this->course_obj->setArchiveEnd(trim($this->cdata));
}
break;
case 'Syllabus':
$this->course_obj->setSyllabus(trim($this->cdata));
break;
case 'ImportantInformation':
$this->course_obj->setImportantInformation(trim($this->cdata));
break;
case 'Name':
$this->course_obj->setContactName(trim($this->cdata));
break;
case 'Responsibility':
$this->course_obj->setContactResponsibility(trim($this->cdata));
break;
case 'Phone':
$this->course_obj->setContactPhone(trim($this->cdata));
break;
case 'Email':
$this->course_obj->setContactEmail(trim($this->cdata));
break;
case 'Consultation':
$this->course_obj->setContactConsultation(trim($this->cdata));
break;
case 'Password':
$this->course_obj->setSubscriptionPassword(trim($this->cdata));
break;
case 'MetaData':
$this->in_meta_data = false;
parent::handlerEndTag($a_xml_parser,$a_name);
break;
}
$this->cdata = '';
return;
}
ilCourseXMLParser::handleSubscriber (   $a_attribs,
  $id_data 
)
private

attach or detach members from subscribers

Parameters
string$a_attribsattribute of a node
array$id_data

Definition at line 470 of file class.ilCourseXMLParser.php.

Referenced by handlerBeginTag().

{
if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach')
// if action not set, or attach
{
if (!$this->course_members->isSubscriber($id_data['usr_id']))
// add only if not exist
{
$this->course_members->addSubscriber($id_data['usr_id']);
}
$this->course_members->updateSubscriptionTime($id_data['usr_id'],$a_attribs['subscriptionTime']);
}
elseif (isset($a_attribs['action']) && $a_attribs['action'] == 'Detach' && $this->course_members->isSubscriber($id_data['usr_id']))
// if action set and detach and is subscriber
{
$this->course_members->deleteSubscriber($id_data["usr_id"]);
}
}

+ Here is the caller graph for this function:

ilCourseXMLParser::handleTutor (   $a_attribs,
  $id_data 
)
private

attach or detach admin from course member

Parameters
string$a_attribsattribute of a node
array$id_data

Definition at line 423 of file class.ilCourseXMLParser.php.

References IL_CRS_TUTOR.

Referenced by handlerBeginTag().

{
if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach')
// if action not set, or attach
{
if (!array_key_exists($id_data['usr_id'], $this->course_members_array))
// add only if member is not assigned yet
{
$this->course_members->add($id_data['usr_id'],IL_CRS_TUTOR);
if($a_attribs['notification'] == 'Yes')
{
$this->course_members->updateNotification($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
$this->course_members_array[$id_data['usr_id']] = "added";
}
else
{
if($a_attribs['notification'] == 'Yes')
{
$this->course_members->updateNotification($id_data['usr_id'],true);
}
if($a_attribs['passed'] == 'Yes')
{
$this->course_members->updatePassed($id_data['usr_id'],true);
}
$this->course_members->updateBlocked($id_data['usr_id'],false);
}
}
elseif (isset($a_attribs['action']) && $a_attribs['action'] == 'Detach' && $this->course_members->isTutor($id_data['usr_id']))
// if action set and detach and is tutor of course
{
$this->course_members->delete($id_data['usr_id']);
}
}

+ Here is the caller graph for this function:

ilCourseXMLParser::handleWaitingList (   $a_attribs,
  $id_data 
)
private

attach or detach members from waitinglist

Parameters
string$a_attribsattribute of a node
array$id_data

Definition at line 497 of file class.ilCourseXMLParser.php.

Referenced by handlerBeginTag().

{
if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach')
// if action not set, or attach
{
if (!$this->course_waiting_list->isOnList($id_data['usr_id']))
// add only if not exists
{
$this->course_waiting_list->addToList($id_data['usr_id']);
}
$this->course_waiting_list->updateSubscriptionTime($id_data['usr_id'],$a_attribs['subscriptionTime']);
}
elseif (isset($a_attribs['action']) && $a_attribs['action'] == 'Detach' && $this->course_waiting_list->isOnList($id_data['usr_id']))
// if action set and detach and is on list
{
$this->course_waiting_list->removeFromList($id_data['usr_id']);
}
}

+ Here is the caller graph for this function:

ilCourseXMLParser::ilCourseXMLParser (   $a_course_obj,
  $a_xml_file = '' 
)

Constructor.

Parameters
object$a_content_objectmust be of type ilObjContentObject ilObjTest or ilObjQuestionPool
string$a_xml_filexml file
string$a_subdirsubdirectory in import directory public

Definition at line 57 of file class.ilCourseXMLParser.php.

References $ilLog, $lng, ilCourseParticipants\_getInstanceByObjId(), ilMDSaxParser\ilMDSaxParser(), and ilMDSaxParser\setMDObject().

{
global $lng,$ilLog;
parent::ilMDSaxParser($a_xml_file);
$this->sax_controller = new ilSaxController();
$this->log =& $ilLog;
$this->course_obj = $a_course_obj;
$this->course_members = ilCourseParticipants::_getInstanceByObjId($this->course_obj->getId());
$this->course_waiting_list = new ilCourseWaitingList($this->course_obj->getId());
// flip the array so we can use array_key_exists
$this->course_members_array = array_flip($this->course_members->getParticipants());
$this->md_obj = new ilMD($this->course_obj->getId(),0,'crs');
$this->setMDObject($this->md_obj);
$this->lng =& $lng;
}

+ Here is the call graph for this function:

ilCourseXMLParser::setHandlers (   $a_xml_parser)

set event handlers

Parameters
resourcereference to the xml parser public

Reimplemented from ilMDSaxParser.

Definition at line 85 of file class.ilCourseXMLParser.php.

{
$this->sax_controller->setHandlers($a_xml_parser);
$this->sax_controller->setDefaultElementHandler($this);
include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValueParser.php');
$this->sax_controller->setElementHandler(
$this->adv_md_handler = new ilAdvancedMDValueParser($this->course_obj->getId()),
'AdvancedMetaData');
}

Field Documentation

ilCourseXMLParser::$lng

Definition at line 45 of file class.ilCourseXMLParser.php.

Referenced by ilCourseXMLParser().

ilCourseXMLParser::$md_obj = null

Definition at line 46 of file class.ilCourseXMLParser.php.


The documentation for this class was generated from the following file: