ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDidacticTemplateLocalRoleAction Class Reference

represents a creation of local roles action More...

+ Inheritance diagram for ilDidacticTemplateLocalRoleAction:
+ Collaboration diagram for ilDidacticTemplateLocalRoleAction:

Public Member Functions

 __construct ($a_action_id=0)
 Constructor. More...
 
 getType ()
 Get action type. More...
 
 setRoleTemplateId ($a_role_template_id)
 Set role template id. More...
 
 getRoleTemplateId ()
 get role template id More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Revert action. More...
 
 save ()
 Create new action. More...
 
 delete ()
 Delete ilDB $ilDB. More...
 
 toXml (ilXmlWriter $writer)
 Write xml of template action. More...
 
 read ()
 Read db entry ilDB $ilDB. More...
 
- Public Member Functions inherited from ilDidacticTemplateAction
 __construct ($action_id=0)
 Constructor. More...
 
 getActionId ()
 Get action id. More...
 
 setActionId ($a_action_id)
 Set action id. More...
 
 setType ($a_type_id)
 Set type id. More...
 
 setTemplateId ($a_id)
 Set template id. More...
 
 getTemplateId ()
 Get template id. More...
 
 setRefId ($a_ref_id)
 Set ref id of target object. More...
 
 getRefId ()
 Get ref id of target object. More...
 
 save ()
 write action to db overwrite for filling additional db fields More...
 
 delete ()
 Delete didactic template action overwrite for filling additional db fields. More...
 
 read ()
 ilDB $ilDB More...
 
 getType ()
 Get type of template. More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template. More...
 
 __clone ()
 Clone method. More...
 
 toXml (ilXmlWriter $writer)
 Write xml for export. More...
 

Private Attributes

 $role_template_id = 0
 

Additional Inherited Members

- Data Fields inherited from ilDidacticTemplateAction
const TYPE_LOCAL_POLICY = 1
 
const TYPE_LOCAL_ROLE = 2
 
const TYPE_BLOCK_ROLE = 3
 
const FILTER_SOURCE_TITLE = 1
 
const FILTER_SOURCE_OBJ_ID = 2
 
const PATTERN_PARENT_TYPE = 'action'
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 Init the source object. More...
 
 filterRoles (ilObject $source)
 Filter roles. More...
 

Detailed Description

represents a creation of local roles action

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

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

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateLocalRoleAction::__construct (   $a_action_id = 0)

Constructor.

Parameters
int$a_action_id

Definition at line 21 of file class.ilDidacticTemplateLocalRoleAction.php.

22  {
23  parent::__construct($a_action_id);
24  }

Member Function Documentation

◆ apply()

ilDidacticTemplateLocalRoleAction::apply ( )

Apply action.

Definition at line 56 of file class.ilDidacticTemplateLocalRoleAction.php.

References $GLOBALS, ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilObjectFactory\getInstanceByRefId(), getRoleTemplateId(), and ilDidacticTemplateAction\initSourceObject().

57  {
58  global $rbacreview, $rbacadmin;
59 
60  $source = $this->initSourceObject();
61 
62  // Check if role folder already exists
63  $rolf_id = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
64  if(!$rolf_id)
65  {
66  $source->createRoleFolder();
67  }
68  $rolf_id = $rbacreview->getRoleFolderIdOfObject($source->getRefId());
69 
70  $GLOBALS['ilLog']->write(__METHOD__.': Current role folder id is: '.$rolf_id);
71 
72  // Create role
73  $rolf = ilObjectFactory::getInstanceByRefId($rolf_id,false);
74  $role = $rolf->createRole(
77  );
78 
79  $GLOBALS['ilLog']->write(__METHOD__.': Using rolt: '.$this->getRoleTemplateId().' with title "'.ilObject::_lookupTitle($this->getRoleTemplateId().'". '));
80 
81  // Copy template permissions
82  $rbacadmin->copyRoleTemplatePermissions(
83  $this->getRoleTemplateId(),
84  ROLE_FOLDER_ID,
85  $rolf->getRefId(),
86  $role->getId(),
87  true
88  );
89 
90  // Set permissions
91  $ops = $rbacreview->getOperationsOfRole($role->getId(),$source->getType(),$rolf->getRefId());
92  $rbacadmin->grantPermission($role->getId(),$ops,$source->getRefId());
93 
94  return true;
95  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupTitle($a_id)
lookup object title
$GLOBALS['ct_recipient']
static _lookupDescription($a_id)
lookup object description
initSourceObject()
Init the source object.
+ Here is the call graph for this function:

◆ delete()

ilDidacticTemplateLocalRoleAction::delete ( )

Delete ilDB $ilDB.

Returns
bool

Definition at line 131 of file class.ilDidacticTemplateLocalRoleAction.php.

References $query, and ilDidacticTemplateAction\getActionId().

132  {
133  global $ilDB;
134 
135  parent::delete();
136 
137  $query = 'DELETE FROM didactic_tpl_alr '.
138  'WHERE action_id = '.$ilDB->quote($this->getActionId(),'integer');
139  $ilDB->manipulate($query);
140 
141  return true;
142  }
+ Here is the call graph for this function:

◆ getRoleTemplateId()

ilDidacticTemplateLocalRoleAction::getRoleTemplateId ( )

get role template id

Returns
int

Definition at line 48 of file class.ilDidacticTemplateLocalRoleAction.php.

References $role_template_id.

Referenced by apply(), save(), and toXml().

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateLocalRoleAction::getType ( )

Get action type.

Returns
int

Definition at line 30 of file class.ilDidacticTemplateLocalRoleAction.php.

31  {
32  return self::TYPE_LOCAL_ROLE;
33  }

◆ read()

ilDidacticTemplateLocalRoleAction::read ( )

Read db entry ilDB $ilDB.

Returns
bool

Definition at line 178 of file class.ilDidacticTemplateLocalRoleAction.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, ilDidacticTemplateAction\getActionId(), and setRoleTemplateId().

179  {
180  global $ilDB;
181 
182  parent::read();
183 
184  $query = 'SELECT * FROM didactic_tpl_alr '.
185  'WHERE action_id = '.$ilDB->quote($this->getActionId(),'integer');
186  $res = $ilDB->query($query);
187  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
188  {
189  $this->setRoleTemplateId($row->role_template_id);
190  }
191  return true;
192  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setRoleTemplateId($a_role_template_id)
Set role template id.
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateLocalRoleAction::revert ( )

Revert action.

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

101  {
102  // @todo: revert could delete the generated local role. But on the other hand all users
103  // assigned to this local role would be deassigned. E.g. if course or group membership
104  // is handled by didactic templates, all members would get lost.
105  }

◆ save()

ilDidacticTemplateLocalRoleAction::save ( )

Create new action.

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

References $query, $res, ilDidacticTemplateAction\getActionId(), and getRoleTemplateId().

111  {
112  global $ilDB;
113 
114  parent::save();
115 
116  $query = 'INSERT INTO didactic_tpl_alr (action_id,role_template_id) '.
117  'VALUES ( '.
118  $ilDB->quote($this->getActionId(),'integer').', '.
119  $ilDB->quote($this->getRoleTemplateId(),'integer').' '.
120  ') ';
121  $res = $ilDB->manipulate($query);
122 
123  return true;
124  }
+ Here is the call graph for this function:

◆ setRoleTemplateId()

ilDidacticTemplateLocalRoleAction::setRoleTemplateId (   $a_role_template_id)

Set role template id.

Parameters
int$a_role_template_id

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

Referenced by read().

40  {
41  $this->role_template_id = $a_role_template_id;
42  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateLocalRoleAction::toXml ( ilXmlWriter  $writer)

Write xml of template action.

Parameters
ilXmlWriter$writer

Definition at line 148 of file class.ilDidacticTemplateLocalRoleAction.php.

References ilObject\_lookupType(), ilXmlWriter\appendXML(), getRoleTemplateId(), ilRoleXmlExport\MODE_DTPL, ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

149  {
150  $writer->xmlStartTag('localRoleAction');
151 
152 
153 
154  $il_id = 'il_'.IL_INST_ID.'_'.ilObject::_lookupType($this->getRoleTemplateId()).'_'.$this->getRoleTemplateId();
155 
156  $writer->xmlStartTag(
157  'roleTemplate',
158  array(
159  'id' => $il_id
160  )
161  );
162 
163  include_once './Services/AccessControl/classes/class.ilRoleXmlExport.php';
164  $exp = new ilRoleXmlExport();
165  $exp->setMode(ilRoleXmlExport::MODE_DTPL);
166  $exp->addRole($this->getRoleTemplateId(), ROLE_FOLDER_ID);
167  $exp->write();
168  $writer->appendXML($exp->xmlDumpMem(FALSE));
169  $writer->xmlEndTag('roleTemplate');
170  $writer->xmlEndTag('localRoleAction');
171  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
static _lookupType($a_id, $a_reference=false)
lookup object type
Xml export of roles and role templates.
appendXML($a_str)
append xml string to document
+ Here is the call graph for this function:

Field Documentation

◆ $role_template_id

ilDidacticTemplateLocalRoleAction::$role_template_id = 0
private

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

Referenced by getRoleTemplateId().


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