3 declare(strict_types=1);
41 $this->pattern = $patterns;
55 $this->filter_type = $a_type;
65 $this->role_template_type = $a_tpl_type;
75 $this->role_template_id = $a_id;
85 if (!parent::save()) {
89 $query =
'INSERT INTO didactic_tpl_alp (action_id,filter_type,template_type,template_id) ' .
91 $this->db->quote($this->
getActionId(),
'integer') .
', ' .
96 $this->db->manipulate($query);
101 $pattern->setParentType(self::PATTERN_PARENT_TYPE);
108 public function delete():
void 111 $query =
'DELETE FROM didactic_tpl_alp ' .
112 'WHERE action_id = ' . $this->db->quote($this->
getActionId(),
'integer');
113 $this->db->manipulate($query);
127 foreach ($roles as $role_id => $role) {
128 $this->
getLogger()->debug(
'Apply to role: ' . $role[
'title']);
129 $this->
getLogger()->debug(
'Role parent: ' . $role[
'parent']);
130 $this->
getLogger()->debug(
'Source ref_id: ' . $source->getRefId());
134 (
int) $role[
'parent'] !== $source->getRefId() &&
135 $this->review->isProtected($role[
'parent'], $role_id)
137 $this->
getLogger()->debug(
'Ignoring protected role.');
152 foreach ($roles as $role_id => $role) {
154 if (!$this->review->isGlobalRole($role[
'obj_id']) &&
155 $this->review->isAssignable($role[
'obj_id'], $source->getRefId()) &&
156 $this->review->isSystemGeneratedRole($role[
'obj_id'])) {
157 $this->
getLogger()->debug(
'Reverting local policy of auto generated role: ' . $role[
'title']);
160 $this->
getLogger()->debug(
'Reverting local policy and deleting local role: ' . $role[
'title']);
163 $this->admin->deleteLocalRole($role_id, $source->getRefId());
168 $protected = $this->review->isProtected($role[
'parent'], $role[
'rol_id']);
170 $role_obj->changeExistingObjects(
185 return self::TYPE_LOCAL_POLICY;
193 case self::FILTER_SOURCE_OBJ_ID:
194 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'objId']);
197 case self::FILTER_PARENT_ROLES:
198 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'parentRoles']);
201 case self::FILTER_LOCAL_ROLES:
202 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'localRoles']);
205 case self::FILTER_SOURCE_TITLE:
207 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'title']);
212 $pattern->toXml($writer);
219 case self::TPL_ACTION_OVERWRITE:
221 'localPolicyTemplate',
223 'type' =>
'overwrite',
229 case self::TPL_ACTION_INTERSECT:
231 'localPolicyTemplate',
233 'type' =>
'intersect',
239 case self::TPL_ACTION_UNION:
241 'localPolicyTemplate',
254 $writer->
appendXML($exp->xmlDumpMem(
false));
255 $writer->
xmlEndTag(
'localPolicyTemplate');
273 $query =
'SELECT * FROM didactic_tpl_alp ' .
275 $res = $this->db->query($query);
284 self::PATTERN_PARENT_TYPE
294 foreach ($this->review->getParentRoleIds($source->
getRefId()) as $role_id => $tmp_role) {
295 if ((
int) $role_id === (
int) $role[
'obj_id']) {
296 $role_data = $tmp_role;
301 if (!$this->review->isRoleAssignedToObject((
int) $role[
'obj_id'], $source->
getRefId())) {
302 $this->admin->assignRoleToFolder(
303 (
int) $role[
'obj_id'],
311 (
int) $role[
'parent'] !== $source->
getRefId() &&
312 $this->review->isProtected($source->
getRefId(), (
int) $role[
'obj_id'])
314 $this->
getLogger()->info(
'Ignoring protected role: ' . $role[
'title']);
319 case self::TPL_ACTION_UNION:
321 $this->
logger->info(
'Using ilRbacAdmin::copyRolePermissionUnion()');
322 $this->admin->copyRolePermissionUnion(
323 (
int) $role_data[
'obj_id'],
324 (
int) $role_data[
'parent'],
327 (
int) $role_data[
'obj_id'],
332 case self::TPL_ACTION_OVERWRITE:
334 $this->
logger->info(
'Using ilRbacAdmin::copyRoleTemplatePermission()');
335 $this->admin->copyRoleTemplatePermissions(
339 (
int) $role_data[
'obj_id'],
344 case self::TPL_ACTION_INTERSECT:
347 $this->admin->copyRolePermissionIntersection(
348 (
int) $role_data[
'obj_id'],
349 (
int) $role_data[
'parent'],
353 (
int) $role_data[
'obj_id']
358 $role_obj =
new ilObjRole((
int) $role_data[
'obj_id']);
359 $role_obj->changeExistingObjects(
370 $this->
logger->info(
'Reverting policy for role ' . $role[
'title']);
373 if (strpos($role[
'title'],
'il_') !== 0) {
374 $this->
logger->warning(
'Cannot revert local policy for role ' . $role[
'title']);
379 if (!$this->review->getLocalPolicies($source->
getRefId())) {
383 $exploded_title = explode(
'_', $role[
'title']);
384 $rolt_title = $exploded_title[0] .
'_' . $exploded_title[1] .
'_' . $exploded_title[2];
387 $query =
'SELECT obj_id FROM object_data ' .
388 'WHERE title = ' . $this->db->quote($rolt_title,
'text') .
' ' .
389 'AND type = ' . $this->db->quote(
'rolt',
'text');
390 $res = $this->db->query($query);
393 $rolt_id = (
int) $row->obj_id;
401 $this->admin->copyRoleTemplatePermissions(
405 (
int) $role[
'obj_id'],
410 $role_obj =
new ilObjRole((
int) $role[
'obj_id']);
411 $role_obj->changeExistingObjects(
const MODE_PROTECTED_DELETE_LOCAL_POLICIES
const TPL_ACTION_INTERSECT
const TPL_ACTION_SUBTRACT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
appendXML(string $a_str)
append xml string to document
toXml(ilXmlWriter $writer)
const TPL_ACTION_OVERWRITE
getFilterPattern()
Get filter pattern.
xmlEndTag(string $tag)
Writes an endtag.
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
filterRoles(ilObject $source)
__construct(int $action_id=0)
setFilterType(int $a_type)
createLocalPolicy(ilObject $source, array $role)
revertLocalPolicy(ilObject $source, array $role)
Abstract class for template actions.
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
setFilterPatterns(array $patterns)
Set filter patterns.
static _lookupType(int $id, bool $reference=false)
Represents a filter pattern for didactic template actions.
setRoleTemplateId(int $a_id)
setRoleTemplateType(int $a_tpl_type)