3declare(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']);
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(
195 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'objId']);
199 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'parentRoles']);
203 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'localRoles']);
208 $writer->
xmlStartTag(
'roleFilter', [
'source' =>
'title']);
222 'localPolicyTemplate',
224 'type' =>
'overwrite',
232 'localPolicyTemplate',
234 'type' =>
'intersect',
242 'localPolicyTemplate',
255 $writer->
appendXML($exp->xmlDumpMem(
false));
256 $writer->
xmlEndTag(
'localPolicyTemplate');
274 $query =
'SELECT * FROM didactic_tpl_alp ' .
285 self::PATTERN_PARENT_TYPE
295 foreach ($this->review->getParentRoleIds(
$source->getRefId()) as $role_id => $tmp_role) {
296 if ((
int) $role_id === (
int) $role[
'obj_id']) {
297 $role_data = $tmp_role;
302 if (!$this->review->isRoleAssignedToObject((
int) $role[
'obj_id'],
$source->getRefId())) {
303 $this->admin->assignRoleToFolder(
304 (
int) $role[
'obj_id'],
312 (
int) $role[
'parent'] !==
$source->getRefId() &&
313 $this->review->isProtected(
$source->getRefId(), (
int) $role[
'obj_id'])
315 $this->
getLogger()->info(
'Ignoring protected role: ' . $role[
'title']);
322 $this->
logger->info(
'Using ilRbacAdmin::copyRolePermissionUnion()');
323 $this->admin->copyRolePermissionUnion(
324 (
int) $role_data[
'obj_id'],
325 (
int) $role_data[
'parent'],
328 (
int) $role_data[
'obj_id'],
335 $this->
logger->info(
'Using ilRbacAdmin::copyRoleTemplatePermission()');
336 $this->admin->copyRoleTemplatePermissions(
340 (
int) $role_data[
'obj_id'],
348 $this->admin->copyRolePermissionIntersection(
349 (
int) $role_data[
'obj_id'],
350 (
int) $role_data[
'parent'],
354 (
int) $role_data[
'obj_id']
360 $role_obj =
new ilObjRole((
int) $role_data[
'obj_id']);
361 $role_obj->changeExistingObjects(
372 $this->
logger->info(
'Reverting policy for role ' . $role[
'title']);
375 if (strpos($role[
'title'],
'il_') !== 0) {
376 $this->
logger->warning(
'Cannot revert local policy for role ' . $role[
'title']);
381 if (!$this->review->getLocalPolicies(
$source->getRefId())) {
385 $exploded_title = explode(
'_', $role[
'title']);
386 $rolt_title = $exploded_title[0] .
'_' . $exploded_title[1] .
'_' . $exploded_title[2];
389 $query =
'SELECT obj_id FROM object_data ' .
390 'WHERE title = ' . $this->db->quote($rolt_title,
'text') .
' ' .
391 'AND type = ' . $this->db->quote(
'rolt',
'text');
395 $rolt_id = (
int) $row->obj_id;
403 $this->admin->copyRoleTemplatePermissions(
407 (
int) $role[
'obj_id'],
412 $role_obj =
new ilObjRole((
int) $role[
'obj_id']);
413 $role_obj->changeExistingObjects(
Abstract class for template actions.
const FILTER_SOURCE_TITLE
const FILTER_PARENT_ROLES
const FILTER_SOURCE_OBJ_ID
filterRoles(ilObject $source)
static lookupPatternsByParentId(int $a_parent_id, string $a_parent_type)
Represents a filter pattern for didactic template actions.
revert()
Implement everthing that is necessary to revert a didactic template return bool.
const TPL_ACTION_SUBTRACT
setRoleTemplateType(int $a_tpl_type)
toXml(ilXmlWriter $writer)
const TPL_ACTION_INTERSECT
getType()
Get type of template.
getFilterPattern()
Get filter pattern.
revertLocalPolicy(ilObject $source, array $role)
setFilterPatterns(array $patterns)
Set filter patterns.
setFilterType(int $a_type)
const TPL_ACTION_OVERWRITE
save()
Write action to db Overwrite for filling additional db fields.
setRoleTemplateId(int $a_id)
__construct(int $action_id=0)
createLocalPolicy(ilObject $source, array $role)
addFilterPattern(ilDidacticTemplateFilterPattern $pattern)
const MODE_PROTECTED_DELETE_LOCAL_POLICIES
const MODE_UNPROTECTED_DELETE_LOCAL_POLICIES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlEndTag(string $tag)
Writes an endtag.
appendXML(string $a_str)
append xml string to document
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc