Public Member Functions | Data Fields | Private Member Functions

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)

Data Fields

 $lng
 $md_obj = null

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

Detailed Description

Course XML Parser.

Author:
Stefan Meyer <smeyer@databay.de>
Version:
Id:
class.ilCourseXMLParser.php 14615 2007-08-30 13:39:25Z smeyer

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


Member Function Documentation

ilCourseXMLParser::__parseId ( a_id  ) 

Definition at line 648 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;
                }
                if($id = ilObjUser::_getImportedUserId($a_id))
                {
                        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_attribs attribute of a node
array $id_data

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

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_attribs attributes of nod
array $id_data
int $roletype type of role, which is courseMember->

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

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_parser xml parser
string $a_name element name
array $a_attribs element attributes array

Implements ilSaxSubsetParser.

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

References __parseId(), ilObject::_writeImportId(), handleAdmin(), handleMember(), handleSubscriber(), handleTutor(), and handleWaitingList().

        {
                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']);
                                }
                                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(IL_CRS_SORT_MANUAL);
                                                break;

                                        case 'Title':
                                                $this->course_obj->setOrderType(IL_CRS_SORT_TITLE);
                                                break;

                                        case 'Activation':
                                                $this->course_obj->setOrderType(IL_CRS_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_parser xml parser
string $a_data character data

Implements ilSaxSubsetParser.

Definition at line 631 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_parser xml parser
string $a_name element name

Implements ilSaxSubsetParser.

Definition at line 520 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->updateSettings();
                                $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_attribs attribute of a node
array $id_data

Definition at line 466 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_attribs attribute of a node
array $id_data

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

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_attribs attribute of a node
array $id_data

Definition at line 492 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_object must be of type ilObjContentObject ilObjTest or ilObjQuestionPool
string $a_xml_file xml file
string $a_subdir subdirectory 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:
resource reference to the xml parser public

Definition at line 86 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: