ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilGroupXMLParser Class Reference

Group Import Parser. More...

+ Inheritance diagram for ilGroupXMLParser:
+ Collaboration diagram for ilGroupXMLParser:

Public Member Functions

 ilGroupXMLParser ($a_xml, $a_parent_id)
 Constructor.
 __pushParentId ($a_id)
 __popParentId ()
 __getParentId ()
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private
 startParsing ()
 start the parser
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element
 handlerEndTag ($a_xml_parser, $a_name)
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data
 __save ()
 __saveFolder ()
 __saveFile ()
 __assignMembers ()
 __initGroupObject ()
 __initFolderObject ()
 __initImportFileObject ()
 __initFileObject ()
 __destroyFolderObject ()
 __parseId ($a_id)
 setMode ($mode)
 setGroup (&$grp)
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file= '', $throwException=false)
 Constructor setup ILIAS global object public.
 setXMLContent ($a_xml_content)
 getXMLContent ()
 getInputType ()
 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

 $group_data
 $group_obj
 $parent
 $counter
 $mode
 $grp
- 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()

Static Public Attributes

static $CREATE = 1
static $UPDATE = 2

Private Attributes

 $participants = null

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

Group Import Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilGroupXMLParser.php 15678 2008-01-06 20:40:55Z akill

Definition at line 39 of file class.ilGroupXMLParser.php.

Member Function Documentation

ilGroupXMLParser::__assignMembers ( )

Definition at line 457 of file class.ilGroupXMLParser.php.

References ilSaxParser\$ilias, $ilUser, __parseId(), ilParticipants\add(), IL_GRP_ADMIN, and IL_GRP_MEMBER.

Referenced by __save().

{
global $ilias,$ilUser;
$this->participants = new ilGroupParticipants($this->group_obj->getId());
$this->participants->add($ilUser->getId(),IL_GRP_ADMIN);
$this->participants->updateNotification($ilUser->getId(),true);
// attach ADMINs
if (count($this->group_data["admin"]["attach"]))
{
foreach($this->group_data["admin"]["attach"] as $user)
{
if($id_data = $this->__parseId($user))
{
if($id_data['local'] or $id_data['imported'])
{
$this->participants->add($id_data['usr_id'],IL_GRP_ADMIN);
if(in_array($user,(array) $this->group_data['notifications']))
{
$this->participants->updateNotification($id_data['usr_id'],true);
}
}
}
}
}
// detach ADMINs
if (count($this->group_data["admin"]["detach"]))
{
foreach($this->group_data["admin"]["detach"] as $user)
{
if($id_data = $this->__parseId($user))
{
if($id_data['local'] or $id_data['imported'])
{
if($this->participants->isAssigned($id_data['usr_id']))
{
$this->participants->delete($id_data['usr_id']);
}
}
}
}
}
// MEMBER
if (count($this->group_data["member"]["attach"]))
{
foreach($this->group_data["member"]["attach"] as $user)
{
if($id_data = $this->__parseId($user))
{
if($id_data['local'] or $id_data['imported'])
{
$this->participants->add($id_data['usr_id'],IL_GRP_MEMBER);
}
}
}
}
if (count($this->group_data["member"]["detach"]))
{
foreach($this->group_data["member"]["detach"] as $user)
{
if($id_data = $this->__parseId($user))
{
if($id_data['local'] or $id_data['imported'])
{
if($this->participants->isAssigned($id_data['usr_id']))
{
$this->participants->delete($id_data['usr_id']);
}
}
}
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGroupXMLParser::__destroyFolderObject ( )

Definition at line 575 of file class.ilGroupXMLParser.php.

Referenced by __saveFolder().

{
unset($this->folder_obj);
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__getParentId ( )

Definition at line 90 of file class.ilGroupXMLParser.php.

Referenced by __save(), __saveFile(), and __saveFolder().

{
return $this->parent[count($this->parent) - 1];
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__initFileObject ( )

Definition at line 566 of file class.ilGroupXMLParser.php.

Referenced by __saveFile().

{
include_once "./Modules/File/classes/class.ilObjFile.php";
$this->file_obj =& new ilObjFile();
return true;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__initFolderObject ( )

Definition at line 548 of file class.ilGroupXMLParser.php.

Referenced by __saveFolder().

{
include_once "./Modules/Folder/classes/class.ilObjFolder.php";
$this->folder_obj =& new ilObjFolder();
return true;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__initGroupObject ( )

Definition at line 534 of file class.ilGroupXMLParser.php.

References $CREATE, $grp, and $UPDATE.

Referenced by __save().

{
include_once "./Modules/Group/classes/class.ilObjGroup.php";
if ($this->mode == ilGroupXMLParser::$CREATE)
{
$this->group_obj =& new ilObjGroup();
} elseif ($this->mode == ilGroupXMLParser::$UPDATE) {
$this->group_obj = $this->grp;
}
return true;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__initImportFileObject ( )

Definition at line 557 of file class.ilGroupXMLParser.php.

Referenced by __saveFile().

{
include_once "./Modules/Group/classes/class.ilFileDataImportGroup.php";
$this->import_file_obj =& new ilFileDataImportGroup();
return true;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__parseId (   $a_id)

Definition at line 580 of file class.ilGroupXMLParser.php.

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

Referenced by __assignMembers().

{
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 ($user = ilObjUser::_lookupName($fields[3])))
{
if(strlen($user['login']))
{
return array('imported' => false,
'local' => true,
'usr_id' => $fields[3]);
}
}
$GLOBALS['ilLog']->write(__METHOD__.' Parsing id failed: '.$a_id);
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGroupXMLParser::__popParentId ( )

Definition at line 84 of file class.ilGroupXMLParser.php.

Referenced by handlerEndTag().

{
array_pop($this->parent);
return true;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__pushParentId (   $a_id)

Definition at line 80 of file class.ilGroupXMLParser.php.

Referenced by __save(), __saveFolder(), and ilGroupXMLParser().

{
$this->parent[] = $a_id;
}

+ Here is the caller graph for this function:

ilGroupXMLParser::__save ( )

mode can be create or update

Definition at line 288 of file class.ilGroupXMLParser.php.

References $CREATE, __assignMembers(), ilUtil\__extractId(), __getParentId(), __initGroupObject(), __pushParentId(), GRP_REGISTRATION_DEACTIVATED, GRP_REGISTRATION_DIRECT, GRP_REGISTRATION_PASSWORD, GRP_REGISTRATION_REQUEST, GRP_TYPE_CLOSED, GRP_TYPE_PUBLIC, and IL_CAL_UNIX.

Referenced by handlerBeginTag(), and handlerEndTag().

{
if($this->group_imported)
{
return true;
}
$this->group_obj->setImportId($this->group_data["id"]);
$this->group_obj->setTitle($this->group_data["title"]);
$this->group_obj->setDescription($this->group_data["description"]);
$ownerChanged = false;
if (isset($this->group_data["owner"]))
{
$owner = $this->group_data["owner"];
if (!is_numeric($owner))
{
$owner = ilUtil::__extractId ($owner, IL_INST_ID);
}
if (is_numeric($owner) && $owner > 0)
{
$this->group_obj->setOwner($owner);
$ownerChanged = true;
}
}
if ($this->mode == ilGroupXMLParser::$CREATE)
{
$this->group_obj->create();
$this->group_obj->createReference();
$this->group_obj->putInTree($this->__getParentId());
$this->group_obj->setPermissions($this->__getParentId());
$this->group_obj->initGroupStatus($this->group_data["type"] == "open" ? GRP_TYPE_PUBLIC : GRP_TYPE_CLOSED);
}
else
{
switch($this->group_data['type'])
{
case 'open':
$grp_status = GRP_TYPE_PUBLIC;
break;
case 'closed':
$grp_status = GRP_TYPE_CLOSED;
break;
}
$this->group_obj->updateOwner();
if($this->group_obj->getGroupStatus() != $grp_status)
{
$this->group_obj->setGroupType($grp_status);
$this->group_obj->updateGroupType();
}
}
// SET GROUP SPECIFIC DATA
switch($this->group_data['registration_type'])
{
case 'direct':
case 'enabled':
break;
case 'disabled':
break;
case 'confirmation':
break;
case 'password':
break;
default:
}
$this->group_obj->setRegistrationType($flag);
$end = new ilDateTime(time(),IL_CAL_UNIX);
if($this->group_data['expiration_end'])
{
$end = new ilDateTime($this->group_data['expiration_end'],IL_CAL_UNIX);
}
$start = clone $end;
if($this->group_data['expiration_start'])
{
$start = new ilDateTime($this->group_data['expiration_start'],IL_CAL_UNIX);
}
$this->group_obj->setRegistrationStart($start);
$this->group_obj->setRegistrationEnd($end);
$this->group_obj->setPassword($this->group_data['password']);
$this->group_obj->enableUnlimitedRegistration(!isset($this->group_data['expiration_end']));
$this->group_obj->enableMembershipLimitation($this->group_data['max_members_enabled']);
$this->group_obj->setMaxMembers($this->group_data['max_members'] ? $this->group_data['max_members'] : 0);
$this->group_obj->enableWaitingList($this->group_data['waiting_list_enabled']);
if ($this->mode == ilGroupXMLParser::$CREATE)
{
$this->group_obj->initGroupStatus($this->group_data["type"] == "open" ? 0 : 1);
}
$this->group_obj->update();
// ASSIGN ADMINS/MEMBERS
$this->__assignMembers();
$this->__pushParentId($this->group_obj->getRefId());
$this->group_imported = true;
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGroupXMLParser::__saveFile ( )

Definition at line 429 of file class.ilGroupXMLParser.php.

References __getParentId(), __initFileObject(), and __initImportFileObject().

Referenced by handlerBeginTag().

{
$this->__initFileObject();
$this->file_obj->setType("file");
$this->file_obj->setTitle($this->file["fileName"]);
$this->file_obj->setFileName($this->file["fileName"]);
$this->file_obj->create();
$this->file_obj->createReference();
$this->file_obj->putInTree($this->__getParentId());
$this->file_obj->setPermissions($this->__getParentId());
// COPY FILE
$this->file_obj->createDirectory();
if($this->import_file_obj->findObjectFile($this->file["id"]))
{
$this->file_obj->copy($this->import_file_obj->getObjectFile(),$this->file["fileName"]);
}
unset($this->file_obj);
unset($this->import_file_obj);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilGroupXMLParser::__saveFolder ( )

Definition at line 413 of file class.ilGroupXMLParser.php.

References __destroyFolderObject(), __getParentId(), __initFolderObject(), and __pushParentId().

Referenced by handlerEndTag().

{
$this->folder_obj->setTitle($this->folder);
$this->folder_obj->create();
$this->folder_obj->createReference();
$this->folder_obj->putInTree($this->__getParentId());
$this->__pushParentId($this->folder_obj->getRefId());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

handler for begin of element

Definition at line 128 of file class.ilGroupXMLParser.php.

References $GLOBALS, $ilErr, __save(), and __saveFile().

{
global $ilErr;
switch($a_name)
{
// GROUP DATA
case "group":
#if($a_attribs["exportVersion"] < EXPORT_VERSION)
#{
# $ilErr->raiseError("!!! This export Version isn't supported, update your ILIAS 2 installation"
# ,$ilErr->WARNING);
#}
// DEFAULT
$this->group_data["admin"] = array();
$this->group_data["member"] = array();
$this->group_data["type"] = $a_attribs["type"];
$this->group_data["id"] = $a_attribs["id"];
break;
case 'title':
break;
case "owner":
$this->group_data["owner"] = $a_attribs["id"];
break;
case 'registration':
$this->group_data['registration_type'] = $a_attribs['type'];
$this->group_data['waiting_list_enabled'] = $a_attribs['waitingList'] == 'Yes' ? true : false;
break;
case 'maxMembers':
$this->group_data['max_members_enabled'] = $a_attribs['enabled'] == 'Yes' ? true : false;
break;
case "admin":
if (!isset($a_attribs['action']) || $a_attribs['action'] == "Attach")
{
$this->group_data["admin"]["attach"][] = $a_attribs["id"];
}
elseif (isset($a_attribs['action']) || $a_attribs['action'] == "Detach")
{
$this->group_data["admin"]["detach"][] = $a_attribs["id"];
}
if(isset($a_attribs['notification']) and $a_attribs['notification'] == 'Yes')
{
$this->group_data['notifications'][] = $a_attribs['id'];
}
break;
case "member":
if (!isset($a_attribs['action']) || $a_attribs['action'] == "Attach")
{
$GLOBALS['ilLog']->write(__METHOD__.': new member with id '.$a_attribs['id']);
$this->group_data["member"]["attach"][] = $a_attribs["id"];
} elseif (isset($a_attribs['action']) || $a_attribs['action'] == "Detach")
{
$GLOBALS['ilLog']->write(__METHOD__.': deprecated member with id '.$a_attribs['id']);
$this->group_data["member"]["detach"][] = $a_attribs["id"];
}
break;
case "folder":
// NOW SAVE THE NEW OBJECT (if it hasn't been imported)
$this->__save();
break;
case "file":
// NOW SAVE THE NEW OBJECT (if it hasn't been imported)
$this->__save();
$this->file["fileName"] = $a_attribs["fileName"];
$this->file["id"] = $a_attribs["id"];
// SAVE IT
$this->__saveFile();
break;
}
}

+ Here is the call graph for this function:

ilGroupXMLParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 272 of file class.ilGroupXMLParser.php.

{
// i don't know why this is necessary, but
// the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
// in character data, but we don't want that, because it's the
// way we mask user html in our content, so we convert back...
$a_data = str_replace("<","&lt;",$a_data);
$a_data = str_replace(">","&gt;",$a_data);
if(!empty($a_data))
{
$this->cdata .= $a_data;
}
}
ilGroupXMLParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

Definition at line 215 of file class.ilGroupXMLParser.php.

References __popParentId(), __save(), and __saveFolder().

{
switch($a_name)
{
case "title":
$this->group_data["title"] = trim($this->cdata);
break;
case "description":
$this->group_data["description"] = trim($this->cdata);
break;
case 'information':
$this->group_data['information'] = trim($this->cdata);
break;
case 'password':
$this->group_data['password'] = trim($this->cdata);
break;
case 'maxMembers':
$this->group_data['max_members'] = trim($this->cdata);
break;
case 'expiration':
$this->group_data['expiration_end'] = trim($this->cdata);
break;
case 'start':
$this->group_data['expiration_start'] = trim($this->cdata);
break;
case 'end':
$this->group_data['expiration_end'] = trim($this->cdata);
break;
case "folder":
$this->__popParentId();
break;
case "folderTitle":
$this->folder = trim($this->cdata);
$this->__saveFolder();
break;
case "group":
// NOW SAVE THE NEW OBJECT (if it hasn't been imported)
$this->__save();
break;
}
$this->cdata = '';
}

+ Here is the call graph for this function:

ilGroupXMLParser::ilGroupXMLParser (   $a_xml,
  $a_parent_id 
)

Constructor.

Parameters
string$a_xml_filexml file

public

Definition at line 63 of file class.ilGroupXMLParser.php.

References $CREATE, __pushParentId(), ilSaxParser\ilSaxParser(), and ilSaxParser\setXMLContent().

{
define('EXPORT_VERSION',2);
$this->grp = null;
$this->setXMLContent($a_xml);
// SET MEMBER VARIABLES
$this->__pushParentId($a_parent_id);
}

+ Here is the call graph for this function:

ilGroupXMLParser::setGroup ( $grp)

Definition at line 618 of file class.ilGroupXMLParser.php.

References $grp.

{
$this->grp = $grp;
}
ilGroupXMLParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Reimplemented from ilSaxParser.

Definition at line 100 of file class.ilGroupXMLParser.php.

{
xml_set_object($a_xml_parser,$this);
xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
}
ilGroupXMLParser::setMode (   $mode)

Definition at line 614 of file class.ilGroupXMLParser.php.

References $mode.

{
$this->mode = $mode;
}
ilGroupXMLParser::startParsing ( )

start the parser

Reimplemented from ilSaxParser.

Definition at line 110 of file class.ilGroupXMLParser.php.

References $CREATE.

{
if ($this->mode == ilGroupXMLParser::$CREATE)
{
return is_object($this->group_obj) ? $this->group_obj->getRefId() : false;
}
else
{
return is_object($this->group_obj) ? $this->group_obj->update() : false;
}
}

Field Documentation

ilGroupXMLParser::$counter

Definition at line 50 of file class.ilGroupXMLParser.php.

ilGroupXMLParser::$CREATE = 1
static
ilGroupXMLParser::$group_data

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

ilGroupXMLParser::$group_obj

Definition at line 47 of file class.ilGroupXMLParser.php.

ilGroupXMLParser::$grp

Definition at line 53 of file class.ilGroupXMLParser.php.

Referenced by __initGroupObject(), and setGroup().

ilGroupXMLParser::$mode

Definition at line 52 of file class.ilGroupXMLParser.php.

Referenced by setMode().

ilGroupXMLParser::$parent

Definition at line 49 of file class.ilGroupXMLParser.php.

ilGroupXMLParser::$participants = null
private

Definition at line 44 of file class.ilGroupXMLParser.php.

ilGroupXMLParser::$UPDATE = 2
static

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