ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupUserActionProvider.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/User/Actions/classes/class.ilUserActionProvider.php");
6
15{
19 protected static $grp_ops = array();
20
24 public function getComponentId()
25 {
26 return "grp";
27 }
28
32 public function getActionTypes()
33 {
34 $this->lng->loadLanguageModule("grp");
35
36 return array(
37 "add_to" => $this->lng->txt("grp_add_to_group")
38 );
39 }
40
47 public static function getCommandAccess($a_user_id)
48 {
49 if (!isset(self::$grp_ops[$a_user_id])) {
50 $ops = array();
51 $o = ilUtil::_getObjectsByOperations(array("root", "crs", "cat"), "create_grp", $a_user_id, 1);
52 if (count($o) > 0) {
53 $ops[] = "create_grp";
54 }
55 $o = ilUtil::_getObjectsByOperations("grp", "manage_members", $a_user_id, 1);
56 if (count($o) > 0) {
57 $ops[] = "manage_members";
58 }
59 self::$grp_ops[$a_user_id] = $ops;
60 }
61 return self::$grp_ops[$a_user_id];
62 }
63
64
71 public function collectActionsForTargetUser($a_target_user)
72 {
73 global $DIC;
74
75 $ctrl = $DIC->ctrl();
76
77 $this->lng->loadLanguageModule("grp");
78
80
81 $commands = self::getCommandAccess($this->user_id);
82 if (count($commands) == 0) {
83 return $coll;
84 }
85
86 $f = new ilUserAction();
87 $f->setType("add_to");
88 $f->setText($this->lng->txt("grp_add_to_group"));
89 $f->setHref("#");
90 $ctrl->setParameterByClass("ilGroupAddToGroupActionGUI", "user_id", $a_target_user);
91 $f->setData(array(
92 "grp-action-add-to" => "1",
93 "url" => $ctrl->getLinkTargetByClass(array("ilPersonalDesktopGUI", "ilGroupUserActionsGUI", "ilGroupAddToGroupActionGUI"), "", "", true, false)
94 ));
95 $coll->addAction($f);
96
97 return $coll;
98 }
99
106 public function getJsScripts($a_action_type)
107 {
108 switch ($a_action_type) {
109 case "add_to":
110 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
111 return array(
112 "./Modules/Group/UserActions/js/GroupUserActions.js",
113 "./src/UI/templates/js/Modal/modal.js",
116 );
117 break;
118 }
119 return array();
120 }
121}
An exception for terminatinating execution or to throw for unit testing.
static getLocalExplorerJsPath()
Get local path of explorer js.
static getLocalJsTreeJsPath()
Get local path of jsTree js.
Group user actions (add to group)
collectActionsForTargetUser($a_target_user)
Collect user actions.
getJsScripts($a_action_type)
Get js scripts.
static getCommandAccess($a_user_id)
Get command access for user.
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...
A class that provides a collection of actions on users.
Action that can be performed on a user.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
global $DIC
Definition: saml.php:7