ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGroupUserActionProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 protected static $grp_ops = [];
24
28 public function getComponentId(): string
29 {
30 return "grp";
31 }
32
36 public function getActionTypes(): array
37 {
38 $this->lng->loadLanguageModule("grp");
39
40 return array(
41 "add_to" => $this->lng->txt("grp_add_to_group")
42 );
43 }
44
45 public static function getCommandAccess(int $a_user_id): array
46 {
47 if (!isset(self::$grp_ops[$a_user_id])) {
48 $ops = array();
49 $o = ilUtil::_getObjectsByOperations(array("root", "crs", "cat"), "create_grp", $a_user_id, 1);
50 if (count($o) > 0) {
51 $ops[] = "create_grp";
52 }
53 $o = ilUtil::_getObjectsByOperations("grp", "manage_members", $a_user_id, 1);
54 if (count($o) > 0) {
55 $ops[] = "manage_members";
56 }
57 self::$grp_ops[$a_user_id] = $ops;
58 }
59 return self::$grp_ops[$a_user_id];
60 }
61
65 public function collectActionsForTargetUser(int $a_target_user): ilUserActionCollection
66 {
67 global $DIC;
68
69 $ctrl = $DIC->ctrl();
70 $this->lng->loadLanguageModule("grp");
71 $coll = new ilUserActionCollection();
72
73 $commands = self::getCommandAccess($this->user_id);
74 if (count($commands) == 0) {
75 return $coll;
76 }
77
78 $f = new ilUserAction();
79 $f->setType("add_to");
80 $f->setText($this->lng->txt("grp_add_to_group"));
81 $f->setHref("#");
82 $ctrl->setParameterByClass("ilGroupAddToGroupActionGUI", "user_id", $a_target_user);
83 $f->setData(array(
84 "grp-action-add-to" => "1",
85 "url" => $ctrl->getLinkTargetByClass(array("ildashboardgui", "ilGroupUserActionsGUI", "ilGroupAddToGroupActionGUI"), "", "", true, false)
86 ));
87 $coll->addAction($f);
88
89 return $coll;
90 }
91
95 public function getJsScripts(string $a_action_type): array
96 {
97 global $DIC;
98 $gui = $DIC->repository()->internal()->gui();
99 switch ($a_action_type) {
100 case "add_to":
101 return array(
102 "assets/js/GroupUserActions.js",
103 "assets/js/modal.min.js",
106 );
107 }
108 return array();
109 }
110}
collectActionsForTargetUser(int $a_target_user)
@inheritDoc
getComponentId()
string component id as defined in services.xml/module.xml
getActionTypes()
array[string] keys must be unique action ids (strings), values should be the names of the actions (fr...
getJsScripts(string $a_action_type)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A class that provides a collection of actions on users.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getObjectsByOperations( $a_obj_type, string $a_operation, int $a_usr_id=0, int $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
global $DIC
Definition: shib_login.php:26