ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 (int $a_action_id=0)
 
 getType ()
 
 setRoleTemplateId (int $a_role_template_id)
 
 getRoleTemplateId ()
 
 apply ()
 
 revert ()
 
 save ()
 
 delete ()
 
 toXml (ilXmlWriter $writer)
 
 read ()
 
- Public Member Functions inherited from ilDidacticTemplateAction
 __construct (int $action_id=0)
 
 getLogger ()
 
 getActionId ()
 
 setActionId (int $a_action_id)
 
 setType (int $a_type_id)
 
 setTemplateId (int $a_id)
 
 getTemplateId ()
 
 setRefId (int $a_ref_id)
 
 getRefId ()
 
 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 ()
 
 getType ()
 Get type of template. More...
 
 apply ()
 Apply action. More...
 
 revert ()
 Implement everthing that is necessary to revert a didactic template return bool. More...
 
 __clone ()
 
 toXml (ilXmlWriter $writer)
 

Private Attributes

int $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 FILTER_PARENT_ROLES = 3
 
const FILTER_LOCAL_ROLES = 4
 
const PATTERN_PARENT_TYPE = 'action'
 
- Protected Member Functions inherited from ilDidacticTemplateAction
 initSourceObject ()
 
 filterRoles (ilObject $source)
 
- Protected Attributes inherited from ilDidacticTemplateAction
ilLogger $logger
 
ilDBInterface $db
 
ilRbacReview $review
 
ilRbacAdmin $admin
 

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 25 of file class.ilDidacticTemplateLocalRoleAction.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateLocalRoleAction::__construct ( int  $a_action_id = 0)

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

References ILIAS\GlobalScreen\Provider\__construct().

30  {
31  parent::__construct($a_action_id);
32  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ apply()

ilDidacticTemplateLocalRoleAction::apply ( )

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

References ilObject\_lookupDescription(), ilObject\_lookupTitle(), ilDidacticTemplateAction\getRefId(), getRoleTemplateId(), ilDidacticTemplateAction\initSourceObject(), ILIAS\Repository\logger(), and ROLE_FOLDER_ID.

49  : bool
50  {
51  $source = $this->initSourceObject();
52 
53  $role = new ilObjRole();
54  $role->setTitle(ilObject::_lookupTitle($this->getRoleTemplateId()) . '_' . $this->getRefId());
55  $role->setDescription(ilObject::_lookupDescription($this->getRoleTemplateId()));
56  $role->create();
57  $this->admin->assignRoleToFolder($role->getId(), $source->getRefId(), "y");
58  $this->logger->info(
59  'Using rolt: ' .
60  $this->getRoleTemplateId() .
61  ' with title "' .
63  '". '
64  );
65 
66  // Copy template permissions
67 
68  $this->logger->debug(
69  'Copy role template permissions ' .
70  'tpl_id: ' . $this->getRoleTemplateId() . ' ' .
71  'parent: ' . ROLE_FOLDER_ID . ' ' .
72  'role_id: ' . $role->getId() . ' ' .
73  'role_parent: ' . $source->getRefId()
74  );
75 
76  $this->admin->copyRoleTemplatePermissions(
77  $this->getRoleTemplateId(),
79  $source->getRefId(),
80  $role->getId(),
81  true
82  );
83  // Set permissions
84  $ops = $this->review->getOperationsOfRole($role->getId(), $source->getType(), $source->getRefId());
85  $this->admin->grantPermission($role->getId(), $ops, $source->getRefId());
86 
87  return true;
88  }
Class ilObjRole.
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
const ROLE_FOLDER_ID
Definition: constants.php:34
+ Here is the call graph for this function:

◆ delete()

ilDidacticTemplateLocalRoleAction::delete ( )

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

References ilDidacticTemplateAction\getActionId().

114  : void
115  {
116  parent::delete();
117 
118  $query = 'DELETE FROM didactic_tpl_alr ' .
119  'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
120  $this->db->manipulate($query);
121  }
+ Here is the call graph for this function:

◆ getRoleTemplateId()

ilDidacticTemplateLocalRoleAction::getRoleTemplateId ( )

Definition at line 44 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 ( )

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

34  : int
35  {
36  return self::TYPE_LOCAL_ROLE;
37  }

◆ read()

ilDidacticTemplateLocalRoleAction::read ( )

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

References $res, ilDBConstants\FETCHMODE_OBJECT, ilDidacticTemplateAction\getActionId(), and setRoleTemplateId().

145  : void
146  {
147  parent::read();
148  $query = 'SELECT * FROM didactic_tpl_alr ' .
149  'WHERE action_id = ' . $this->db->quote($this->getActionId(), 'integer');
150  $res = $this->db->query($query);
151  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
152  $this->setRoleTemplateId((int) $row->role_template_id);
153  }
154  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ revert()

ilDidacticTemplateLocalRoleAction::revert ( )

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

90  : bool
91  {
92  // @todo: revert could delete the generated local role. But on the other hand all users
93  // assigned to this local role would be deassigned. E.g. if course or group membership
94  // is handled by didactic templates, all members would get lost.
95  return false;
96  }

◆ save()

ilDidacticTemplateLocalRoleAction::save ( )

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

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

98  : int
99  {
100  if (!parent::save()) {
101  return 0;
102  }
103 
104  $query = 'INSERT INTO didactic_tpl_alr (action_id,role_template_id) ' .
105  'VALUES ( ' .
106  $this->db->quote($this->getActionId(), 'integer') . ', ' .
107  $this->db->quote($this->getRoleTemplateId(), 'integer') . ' ' .
108  ') ';
109  $res = $this->db->manipulate($query);
110 
111  return $this->getActionId();
112  }
$res
Definition: ltiservices.php:66
+ Here is the call graph for this function:

◆ setRoleTemplateId()

ilDidacticTemplateLocalRoleAction::setRoleTemplateId ( int  $a_role_template_id)

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

Referenced by read().

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

◆ toXml()

ilDidacticTemplateLocalRoleAction::toXml ( ilXmlWriter  $writer)

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

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

123  : void
124  {
125  $writer->xmlStartTag('localRoleAction');
126 
127  $il_id = 'il_' . IL_INST_ID . '_' . ilObject::_lookupType($this->getRoleTemplateId()) . '_' . $this->getRoleTemplateId();
128 
129  $writer->xmlStartTag(
130  'roleTemplate',
131  [
132  'id' => $il_id
133  ]
134  );
135 
136  $exp = new ilRoleXmlExport();
137  $exp->setMode(ilRoleXmlExport::MODE_DTPL);
138  $exp->addRole($this->getRoleTemplateId(), ROLE_FOLDER_ID);
139  $exp->write();
140  $writer->appendXML($exp->xmlDumpMem(false));
141  $writer->xmlEndTag('roleTemplate');
142  $writer->xmlEndTag('localRoleAction');
143  }
const IL_INST_ID
Definition: constants.php:40
appendXML(string $a_str)
append xml string to document
xmlEndTag(string $tag)
Writes an endtag.
const ROLE_FOLDER_ID
Definition: constants.php:34
Xml export of roles and role templates.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $role_template_id

int ilDidacticTemplateLocalRoleAction::$role_template_id = 0
private

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

Referenced by getRoleTemplateId().


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