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

Description of class. More...

+ Collaboration diagram for ilRoleXmlImporter:

Public Member Functions

 __construct ($a_role_folder_id=0)
 Constructor.
 setXml ($a_xml)
 getXml ()
 getRoleFolderId ()
 Get role folder id.
 getRole ()
 Get role.
 setRole (ilObject $role)
 Set role or role template.
 import ()
 import role | role templatae
 importSimpleXml (SimpleXMLElement $role)
 Import using simplexml.

Protected Member Functions

 assigntoRoleFolder ()
 Assign role to folder type $rbacadmin.
 initRole ($import_id)
 parseXmlErrors ()

Protected Attributes

 $role_folder = 0
 $role = null
 $xml = ''

Detailed Description

Description of class.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.ilRoleXmlImporter.php.

Constructor & Destructor Documentation

ilRoleXmlImporter::__construct (   $a_role_folder_id = 0)

Constructor.

Definition at line 22 of file class.ilRoleXmlImporter.php.

{
$this->role_folder = $a_role_folder_id;
}

Member Function Documentation

ilRoleXmlImporter::assigntoRoleFolder ( )
protected

Assign role to folder type $rbacadmin.

Returns
type

Definition at line 170 of file class.ilRoleXmlImporter.php.

References getRole(), and getRoleFolderId().

{
global $rbacadmin;
if(!$this->getRoleFolderId())
{
return;
}
$rbacadmin->assignRoleToFolder(
$this->getRole()->getId(),
$this->getRoleFolderId(),
$this->getRole() instanceof ilObjRole ? 'y' : 'n'
);
}

+ Here is the call graph for this function:

ilRoleXmlImporter::getRole ( )

Get role.

Returns
ilObjRole

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

References $role.

Referenced by assigntoRoleFolder(), importSimpleXml(), and initRole().

{
return $this->role;
}

+ Here is the caller graph for this function:

ilRoleXmlImporter::getRoleFolderId ( )

Get role folder id.

Returns
int

Definition at line 41 of file class.ilRoleXmlImporter.php.

References $role_folder.

Referenced by assigntoRoleFolder(), and importSimpleXml().

{
}

+ Here is the caller graph for this function:

ilRoleXmlImporter::getXml ( )

Definition at line 32 of file class.ilRoleXmlImporter.php.

References $xml.

Referenced by import().

{
return $this->xml;
}

+ Here is the caller graph for this function:

ilRoleXmlImporter::import ( )

import role | role templatae

Exceptions
ilRoleXmlImporterException

Definition at line 68 of file class.ilRoleXmlImporter.php.

References getXml(), importSimpleXml(), and parseXmlErrors().

{
libxml_use_internal_errors(true);
$root = simplexml_load_string($this->getXml());
if(!$root instanceof SimpleXMLElement)
{
}
foreach($root->role as $roleElement)
{
$this->importSimpleXml($roleElement);
// only one role is parsed
break;
}
}

+ Here is the call graph for this function:

ilRoleXmlImporter::importSimpleXml ( SimpleXMLElement  $role)

Import using simplexml.

Parameters
SimpleXMLElement$role

Definition at line 91 of file class.ilRoleXmlImporter.php.

References $GLOBALS, getRole(), getRoleFolderId(), and initRole().

Referenced by import().

{
global $rbacadmin, $rbacreview;
$import_id = (string) $role['id'];
$GLOBALS['ilLog']->write(__METHOD__.' Importing role with import id '. $import_id);
if(!$this->initRole($import_id))
{
return 0;
}
$this->getRole()->setTitle(trim((string) $role->title));
$this->getRole()->setDescription(trim((string) $role->description));
// Create or update
if($this->getRole()->getId())
{
$this->getRole()->update();
}
else
{
$this->getRole()->create();
}
$this->assignToRoleFolder();
$protected = (string) $role['protected'];
if($protected)
{
$rbacadmin->setProtected(0,$this->getRole()->getId(),'y');
}
// Add operations
$ops = $rbacreview->getOperations();
$operations = array();
foreach($ops as $ope)
{
$operations[$ope['operation']] = $ope['ops_id'];
}
foreach($role->operations as $sxml_operations)
{
foreach($sxml_operations as $sxml_op)
{
$ops_group = (string) $sxml_op['group'];
$ops_id = (int) $operations[trim((string) $sxml_op)];
$ops = trim((string) $sxml_op);
if($ops_group and $ops_id)
{
$rbacadmin->setRolePermission(
$this->getRole()->getId(),
$ops_group,
array($ops_id),
$this->getRoleFolderId() // #10161
);
}
else
{
$GLOBALS['ilLog']->write(__METHOD__.': Cannot create operation for...');
$GLOBALS['ilLog']->write(__METHOD__.': New operation for group '. $ops_group);
$GLOBALS['ilLog']->write(__METHOD__.': New operation '.$ops);
$GLOBALS['ilLog']->write(__METHOD__.': New operation '. $ops_id);
}
}
}
return $this->getRole()->getId();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRoleXmlImporter::initRole (   $import_id)
protected

Definition at line 187 of file class.ilRoleXmlImporter.php.

References ilObject\_lookupObjIdByImportId(), ilObjectFactory\getInstanceByObjId(), and getRole().

Referenced by importSimpleXml().

{
if($this->getRole())
{
return true;
}
$obj_id = ilObject::_lookupObjIdByImportId($import_id);
include_once './Services/Object/classes/class.ilObjectFactory.php';
if($obj_id)
{
$this->role = ilObjectFactory::getInstanceByObjId($obj_id,false);
}
if(!$this->getRole() instanceof ilObjRole or !$this->getRole() instanceof ilObjRoleTemplate)
{
include_once './Services/AccessControl/classes/class.ilObjRoleTemplate.php';
$this->role = new ilObjRoleTemplate();
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilRoleXmlImporter::parseXmlErrors ( )
protected

Definition at line 208 of file class.ilRoleXmlImporter.php.

References $errors.

Referenced by import().

{
$errors = '';
foreach(libxml_get_errors() as $err)
{
$errors .= $err->code.'<br/>';
}
return $errors;
}

+ Here is the caller graph for this function:

ilRoleXmlImporter::setRole ( ilObject  $role)

Set role or role template.

Parameters
ilObject$role

Definition at line 59 of file class.ilRoleXmlImporter.php.

References $role.

{
$this->role = $role;
}
ilRoleXmlImporter::setXml (   $a_xml)

Definition at line 27 of file class.ilRoleXmlImporter.php.

{
$this->xml = $a_xml;
}

Field Documentation

ilRoleXmlImporter::$role = null
protected

Definition at line 15 of file class.ilRoleXmlImporter.php.

Referenced by getRole(), and setRole().

ilRoleXmlImporter::$role_folder = 0
protected

Definition at line 14 of file class.ilRoleXmlImporter.php.

Referenced by getRoleFolderId().

ilRoleXmlImporter::$xml = ''
protected

Definition at line 17 of file class.ilRoleXmlImporter.php.

Referenced by getXml().


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