ILIAS  release_8 Revision v8.24
class.ilUserActionAdminGUI.php
Go to the documentation of this file.
1<?php
2
24{
26 protected int $ref_id;
27 protected \ILIAS\User\StandardGUIRequest $request;
28 protected ilCtrl $ctrl;
30 protected ilLanguage $lng;
32
33 public function __construct(int $ref_id)
34 {
35 global $DIC;
36
37 $this->ctrl = $DIC->ctrl();
38 $this->lng = $DIC->language();
39 $this->tpl = $DIC["tpl"];
40 $this->ref_id = $ref_id;
41 $this->rbabsystem = $DIC->rbac()->system();
42
43 $this->lng->loadLanguageModule("usr");
44 $this->request = new \ILIAS\User\StandardGUIRequest(
45 $DIC->http(),
46 $DIC->refinery()
47 );
48 }
49
50 public function setActionContext(ilUserActionContext $a_val = null): void
51 {
52 $this->action_context = $a_val;
53 }
54
56 {
58 }
59
60 public function executeCommand(): void
61 {
62 $next_class = $this->ctrl->getNextClass($this);
63 $cmd = $this->ctrl->getCmd("show");
64
65 switch ($next_class) {
66 default:
67 if (in_array($cmd, array("show", "save"))) {
68 $this->$cmd();
69 }
70 }
71 }
72
73 public function show(): void
74 {
75 $this->tpl->setOnScreenMessage('info', $this->lng->txt("user_actions_activation_info"));
76
78 $this,
79 "show",
80 $this->getActions(),
81 $this->rbabsystem->checkAccess("write", $this->ref_id)
82 );
83 $this->tpl->setContent($tab->getHTML());
84 }
85
89 public function save(): void
90 {
91 if (!$this->rbabsystem->checkAccess("write", $this->ref_id)) {
92 $this->ctrl->redirect($this, "show");
93 }
94
95 $active = $this->request->getActionActive();
96 foreach ($this->getActions() as $a) {
98 $this->action_context->getComponentId(),
99 $this->action_context->getContextId(),
100 $a["action_comp_id"],
101 $a["action_type_id"],
102 (bool) ($active[$a["action_comp_id"] . ":" . $a["action_type_id"]] ?? false)
103 );
104 }
105 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
106 $this->ctrl->redirect($this, "show");
107 }
108
113 public function getActions(): array
114 {
115 $data = array();
117 foreach ($p->getActionTypes() as $id => $name) {
118 $data[] = array(
119 "action_comp_id" => $p->getComponentId(),
120 "action_type_id" => $id,
121 "action_type_name" => $name,
123 $this->action_context->getComponentId(),
124 $this->action_context->getContextId(),
125 $p->getComponentId(),
126 $id
127 )
128 );
129 }
130 }
131 return $data;
132 }
133}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilCtrl provides processing control methods.
language handling
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getActions()
Get actions, !!!! note in the future this must depend on the context, currently we only have one.
setActionContext(ilUserActionContext $a_val=null)
save()
Save !!!! note in the future this must depend on the context, currently we only have one.
ilUserActionContext $action_context
ILIAS User StandardGUIRequest $request
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static activateAction(string $a_context_comp, string $a_context_id, string $a_action_comp, string $a_action_type, bool $a_active)
static lookupActive(string $a_context_comp, string $a_context_id, string $a_action_comp, string $a_action_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllProviders()
Get all action providers.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($format !==null) $name
Definition: metadata.php:247
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples