ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjRoleFolder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
26{
27 public function __construct(int $a_id = 0, bool $a_call_by_reference = true)
28 {
29 $this->type = "rolf";
30 parent::__construct($a_id, $a_call_by_reference);
31 }
32
33 public function read(): void
34 {
35 parent::read();
36
37 if ($this->getId() != ROLE_FOLDER_ID) {
38 $this->setDescription($this->lng->txt("obj_" . $this->getType() . "_local_desc") . $this->getTitle() . $this->getDescription());
39 $this->setTitle($this->lng->txt("obj_" . $this->getType() . "_local"));
40 }
41 }
42
43 public function delete(): bool
44 {
45 // always call parent delete function first!!
46 if (!parent::delete()) {
47 return false;
48 }
49 // put here rolefolder specific stuff
50 $roles = $this->rbac_review->getRolesOfRoleFolder($this->getRefId());
51 foreach ($roles as $role_id) {
52 $roleObj = ilObjectFactory::getInstanceByObjId($role_id);
53 $roleObj->setParent($this->getRefId());
54 $roleObj->delete();
55 unset($roleObj);
56 }
57 return true;
58 }
59
63 public function createRole(string $a_title, string $a_desc, int $a_import_id = 0): ilObjRole
64 {
65 global $DIC;
66
67 $rbacadmin = $DIC['rbacadmin'];
68
69 $roleObj = new ilObjRole();
70 $roleObj->setTitle($a_title);
71 $roleObj->setDescription($a_desc);
72 //echo "aaa-1-";
73 if ($a_import_id != "") {
74 //echo "aaa-2-".$a_import_id."-";
75 $roleObj->setImportId((string) $a_import_id);
76 }
77 $roleObj->create();
78
79 // ...and put the role into local role folder...
80 $rbacadmin->assignRoleToFolder($roleObj->getId(), $this->getRefId(), "y");
81
82 return $roleObj;
83 }
84}
Class ilObjRoleFolder.
__construct(int $a_id=0, bool $a_call_by_reference=true)
createRole(string $a_title, string $a_desc, int $a_import_id=0)
creates a local role in current rolefolder (this object)
Class ilObjRole.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
setTitle(string $title)
setDescription(string $description)
const ROLE_FOLDER_ID
Definition: constants.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26