ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Repository\Permission\CmdPermission Class Reference
+ Inheritance diagram for ILIAS\Repository\Permission\CmdPermission:
+ Collaboration diagram for ILIAS\Repository\Permission\CmdPermission:

Public Member Functions

 __construct (protected \ilLanguage $lng, protected ?\ilGlobalTemplateInterface $tpl=null, protected ?\ilCtrlInterface $ctrl=null,)
 
 isRequestCommandPermitted ()
 
 isRequestMultiCommand ()
 
 isTableCommandPermitted (string $cmd, string $entity_id)
 
 isCommandPermittedMulti (string $cmd, int $node_id, string $entity, array $entity_ids)
 
 getPermittedCommand ()
 
 getRequestCommand ()
 
 getDefaultCommand ()
 
 checkCommand (string $cmd, int $node_id, string $entity, string $entity_id="")
 
 forwardPermitted (object $from_gui, object $to_gui)
 
 classImplementsMethodDirectly (string $className, string $method)
 For intermediate solutions that don't implement the concept for all subclasses yet. More...
 
- Public Member Functions inherited from ILIAS\Repository\Permission\CmdPermissionInterface
 isRequestCommandPermitted ()
 
 getPermittedCommand ()
 
 getRequestCommand ()
 
 getRequestEntity ()
 
 getRequestNodeId ()
 
 isCommandPermitted (string $cmd, int $node_id, string $entity, string $entity_id="")
 
 isCommandPermittedMulti (string $cmd, int $node_id, string $entity, array $entity_ids)
 
 isRequestMultiCommand ()
 
 checkCommand (string $cmd, int $node_id, string $entity, string $entity_id="")
 
 isForwardPermitted (string $from_class, string $to_class)
 
 forwardPermitted (object $from_gui, object $to_gui)
 

Protected Member Functions

 isClass (string $class)
 
 cmdEntity (string $type, string|array $id="")
 

Detailed Description

Definition at line 23 of file CmdPermission.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\Permission\CmdPermission::__construct ( protected \ilLanguage  $lng,
protected ?\ilGlobalTemplateInterface  $tpl = null,
protected ?\ilCtrlInterface  $ctrl = null 
)

Definition at line 25 of file CmdPermission.php.

29 {
30 }

Member Function Documentation

◆ checkCommand()

ILIAS\Repository\Permission\CmdPermission::checkCommand ( string  $cmd,
int  $node_id,
string  $entity,
string  $entity_id = "" 
)
Exceptions

ILIAS\Repository\Permission\ilNoCmdPermissionException

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 116 of file CmdPermission.php.

116 : void
117 {
118 if (!$this->isCommandPermitted($cmd, $node_id, $entity, $entity_id)) {
119 throw new \ILIAS\Repository\Permission\ilNoCmdPermissionException("No permission to execute command $cmd on $entity $entity_id");
120 }
121 }
isCommandPermitted(string $cmd, int $node_id, string $entity, string $entity_id="")

◆ classImplementsMethodDirectly()

ILIAS\Repository\Permission\CmdPermission::classImplementsMethodDirectly ( string  $className,
string  $method 
)

For intermediate solutions that don't implement the concept for all subclasses yet.

Definition at line 154 of file CmdPermission.php.

154 : bool
155 {
156 try {
157 $class = new \ReflectionClass($className);
158 } catch (\Exception $e) {
159 return false;
160 }
161
162 return $class->hasMethod($method)
163 && $class->getMethod($method)->getDeclaringClass()->getName() === $class->getName();
164 }

References Vendor\Package\$e.

◆ cmdEntity()

ILIAS\Repository\Permission\CmdPermission::cmdEntity ( string  $type,
string|array  $id = "" 
)
protected

Definition at line 123 of file CmdPermission.php.

126 : CmdEntity {
127 return new CmdEntity(
128 $type,
129 $id
130 );
131 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ forwardPermitted()

ILIAS\Repository\Permission\CmdPermission::forwardPermitted ( object  $from_gui,
object  $to_gui 
)

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 133 of file CmdPermission.php.

136 : mixed {
137 if (is_null($this->ctrl)) {
138 return null;
139 }
140 if ($this->isForwardPermitted(get_class($from_gui), get_class($to_gui))) {
141 return $this->ctrl->forwardCommand($to_gui);
142 }
143 if ($this->access->checkAccess("read", "", ROOT_FOLDER_ID)) {
144 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
145 $this->ctrl->setParameterByClass("ilRepositoryGUI", "ref_id", ROOT_FOLDER_ID);
146 $this->ctrl->redirectByClass("ilRepositoryGUI");
147 }
148 throw new \ilPermissionException($this->lng->txt("permission_denied"));
149 }
const ROOT_FOLDER_ID
Definition: constants.php:32
isForwardPermitted(string $from_class, string $to_class)

◆ getDefaultCommand()

ILIAS\Repository\Permission\CmdPermission::getDefaultCommand ( )

Reimplemented in ILIAS\Blog\Permission\BlogCmdPermission, and ILIAS\Category\Permission\CategoryCmdPermission.

Definition at line 107 of file CmdPermission.php.

107 : string
108 {
109 return "";
110 }

◆ getPermittedCommand()

ILIAS\Repository\Permission\CmdPermission::getPermittedCommand ( )

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 85 of file CmdPermission.php.

85 : string
86 {
87 if ($this->isRequestCommandPermitted()) {
88 return $this->getRequestCommand();
89 }
90 return "";
91 }

◆ getRequestCommand()

ILIAS\Repository\Permission\CmdPermission::getRequestCommand ( )

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 93 of file CmdPermission.php.

93 : string
94 {
95 return $this->ctrl->getCmd($this->getDefaultCommand());
96 }

References ILIAS\Repository\ctrl().

Referenced by ILIAS\Repository\Permission\CmdPermission\isRequestCommandPermitted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isClass()

ILIAS\Repository\Permission\CmdPermission::isClass ( string  $class)
protected

Definition at line 98 of file CmdPermission.php.

98 : bool
99 {
100 if (is_null($this->ctrl)) {
101 return false;
102 }
103 $cmd_class = $this->ctrl->getCmdClass();
104 return $cmd_class === strtolower($class);
105 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ isCommandPermittedMulti()

ILIAS\Repository\Permission\CmdPermission::isCommandPermittedMulti ( string  $cmd,
int  $node_id,
string  $entity,
array  $entity_ids 
)

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 72 of file CmdPermission.php.

77 : bool {
78 return array_all(
79 $entity_ids,
80 fn($entity_id) => $this->isCommandPermitted($cmd, $node_id, $entity, $entity_id)
81 );
82 }

Referenced by ILIAS\Repository\Permission\CmdPermission\isRequestCommandPermitted().

+ Here is the caller graph for this function:

◆ isRequestCommandPermitted()

ILIAS\Repository\Permission\CmdPermission::isRequestCommandPermitted ( )

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 32 of file CmdPermission.php.

32 : bool
33 {
34 if (is_null($this->ctrl)) {
35 return false;
36 }
37 if (!$this->isRequestMultiCommand()) {
38 return $this->isCommandPermitted(
39 $this->getRequestCommand(),
40 $this->getRequestNodeId(),
41 (string) $this?->getRequestEntity()->getType(),
42 (string) $this?->getRequestEntity()->getId()
43 );
44 } else {
45 return $this->isCommandPermittedMulti(
46 $this->getRequestCommand(),
47 $this->getRequestNodeId(),
48 (string) $this?->getRequestEntity()->getType(),
49 (array) $this?->getRequestEntity()->getId()
50 );
51 }
52 }
isCommandPermittedMulti(string $cmd, int $node_id, string $entity, array $entity_ids)

References ILIAS\Repository\ctrl(), ILIAS\Survey\Mode\getId(), ILIAS\Repository\Permission\CmdPermission\getRequestCommand(), ILIAS\Repository\Permission\CmdPermissionInterface\getRequestEntity(), ILIAS\Repository\Permission\CmdPermissionInterface\getRequestNodeId(), ILIAS\Repository\Permission\CmdPermissionInterface\isCommandPermitted(), ILIAS\Repository\Permission\CmdPermission\isCommandPermittedMulti(), and ILIAS\Repository\Permission\CmdPermission\isRequestMultiCommand().

+ Here is the call graph for this function:

◆ isRequestMultiCommand()

ILIAS\Repository\Permission\CmdPermission::isRequestMultiCommand ( )

Implements ILIAS\Repository\Permission\CmdPermissionInterface.

Definition at line 54 of file CmdPermission.php.

54 : bool
55 {
56 return is_array($this?->getRequestEntity()->getId());
57 }

References ILIAS\Survey\Mode\getId(), and ILIAS\Repository\Permission\CmdPermissionInterface\getRequestEntity().

Referenced by ILIAS\Repository\Permission\CmdPermission\isRequestCommandPermitted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isTableCommandPermitted()

ILIAS\Repository\Permission\CmdPermission::isTableCommandPermitted ( string  $cmd,
string  $entity_id 
)

Definition at line 59 of file CmdPermission.php.

59 : bool
60 {
61 if (is_null($this->ctrl)) {
62 return false;
63 }
64 return $this->isCommandPermitted(
65 $cmd,
66 $this->getRequestNodeId(),
67 (string) $this?->getRequestEntity()->getType(),
68 $entity_id
69 );
70 }

References ILIAS\Repository\ctrl(), ILIAS\Repository\Permission\CmdPermissionInterface\getRequestEntity(), ILIAS\Repository\Permission\CmdPermissionInterface\getRequestNodeId(), and ILIAS\Repository\Permission\CmdPermissionInterface\isCommandPermitted().

+ Here is the call graph for this function:

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