ILIAS  release_8 Revision v8.24
class.ilGroupUserActionProvider.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
6
14{
15 protected static $grp_ops = [];
16
20 public function getComponentId(): string
21 {
22 return "grp";
23 }
24
28 public function getActionTypes(): array
29 {
30 $this->lng->loadLanguageModule("grp");
31
32 return array(
33 "add_to" => $this->lng->txt("grp_add_to_group")
34 );
35 }
36
37 public static function getCommandAccess(int $a_user_id): array
38 {
39 if (!isset(self::$grp_ops[$a_user_id])) {
40 $ops = array();
41 $o = ilUtil::_getObjectsByOperations(array("root", "crs", "cat"), "create_grp", $a_user_id, 1);
42 if (count($o) > 0) {
43 $ops[] = "create_grp";
44 }
45 $o = ilUtil::_getObjectsByOperations("grp", "manage_members", $a_user_id, 1);
46 if (count($o) > 0) {
47 $ops[] = "manage_members";
48 }
49 self::$grp_ops[$a_user_id] = $ops;
50 }
51 return self::$grp_ops[$a_user_id];
52 }
53
57 public function collectActionsForTargetUser(int $a_target_user): ilUserActionCollection
58 {
59 global $DIC;
60
61 $ctrl = $DIC->ctrl();
62 $this->lng->loadLanguageModule("grp");
64
65 $commands = self::getCommandAccess($this->user_id);
66 if (count($commands) == 0) {
67 return $coll;
68 }
69
70 $f = new ilUserAction();
71 $f->setType("add_to");
72 $f->setText($this->lng->txt("grp_add_to_group"));
73 $f->setHref("#");
74 $ctrl->setParameterByClass("ilGroupAddToGroupActionGUI", "user_id", $a_target_user);
75 $f->setData(array(
76 "grp-action-add-to" => "1",
77 "url" => $ctrl->getLinkTargetByClass(array("ildashboardgui", "ilGroupUserActionsGUI", "ilGroupAddToGroupActionGUI"), "", "", true, false)
78 ));
79 $coll->addAction($f);
80
81 return $coll;
82 }
83
87 public function getJsScripts(string $a_action_type): array
88 {
89 switch ($a_action_type) {
90 case "add_to":
91 return array(
92 "./Modules/Group/UserActions/js/GroupUserActions.js",
93 "./src/UI/templates/js/Modal/modal.js",
96 );
97 }
98 return array();
99 }
100}
Group user actions (add to group)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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: feed.php:28