ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilUserActionAdminGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 {
30  private int $ref_id;
32  private ilCtrl $ctrl;
34  private ilLanguage $lng;
37 
38  public function __construct(int $ref_id)
39  {
40  global $DIC;
41 
42  $this->ctrl = $DIC->ctrl();
43  $this->lng = $DIC->language();
44  $this->tpl = $DIC["tpl"];
45  $this->ref_id = $ref_id;
46  $this->rbabsystem = $DIC->rbac()->system();
47  $this->lng->loadLanguageModule("usr");
48  $this->request = new UserGUIRequest(
49  $DIC->http(),
50  $DIC->refinery()
51  );
52  $this->user_action_admin = new ilUserActionAdmin($DIC['ilDB']);
53  }
54 
55  public function setActionContext(ilUserActionContext $a_val = null): void
56  {
57  $this->action_context = $a_val;
58  }
59 
61  {
62  return $this->action_context;
63  }
64 
65  public function executeCommand(): void
66  {
67  $next_class = $this->ctrl->getNextClass($this);
68  $cmd = $this->ctrl->getCmd("show");
69 
70  switch ($next_class) {
71  default:
72  if (in_array($cmd, ["show", "save"])) {
73  $this->$cmd();
74  }
75  }
76  }
77 
78  public function show(): void
79  {
80  $this->tpl->setOnScreenMessage('info', $this->lng->txt("user_actions_activation_info"));
81 
82  $tab = new ilUserActionAdminTableGUI(
83  $this,
84  "show",
85  $this->getActions(),
86  $this->rbabsystem->checkAccess("write", $this->ref_id)
87  );
88  $this->tpl->setContent($tab->getHTML());
89  }
90 
94  public function save(): void
95  {
96  if (!$this->rbabsystem->checkAccess("write", $this->ref_id)) {
97  $this->ctrl->redirect($this, "show");
98  }
99 
100  $active = $this->request->getActionActive();
101  foreach ($this->getActions() as $a) {
102  $this->user_action_admin->activateAction(
103  $this->action_context->getComponentId(),
104  $this->action_context->getContextId(),
105  $a["action_comp_id"],
106  $a["action_type_id"],
107  (bool) ($active[$a["action_comp_id"] . ":" . $a["action_type_id"]] ?? false)
108  );
109  }
110  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
111  $this->ctrl->redirect($this, "show");
112  }
113 
118  public function getActions(): array
119  {
120  $data = [];
121  $action_provider_factory = new ilUserActionProviderFactory();
122  foreach ($action_provider_factory->getProviders() as $p) {
123  foreach ($p->getActionTypes() as $id => $name) {
124  $data[] = [
125  "action_comp_id" => $p->getComponentId(),
126  "action_type_id" => $id,
127  "action_type_name" => $name,
128  "active" => $this->user_action_admin->isActionActive(
129  $this->action_context->getComponentId(),
130  $this->action_context->getContextId(),
131  $p->getComponentId(),
132  $id
133  )
134  ];
135  }
136  }
137  return $data;
138  }
139 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setActionContext(ilUserActionContext $a_val=null)
User action administration GUI class.
ilUserActionAdmin $user_action_admin
global $DIC
Definition: feed.php:28
User action administration.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
save()
Save !!!! note in the future this must depend on the context, currently we only have one...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
ilGlobalTemplateInterface $tpl
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...
ilUserActionContext $action_context