ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $this->lng->loadLanguageModule("grp");
78
79 $commands = self::getCommandAccess($this->user_id);
80 if (count($commands) == 0) {
81 return $coll;
82 }
83
84 $f = new ilUserAction();
85 $f->setType("add_to");
86 $f->setText($this->lng->txt("grp_add_to_group"));
87 $f->setHref("#");
88 $ctrl->setParameterByClass("ilGroupAddToGroupActionGUI", "user_id", $a_target_user);
89 $f->setData(array(
90 "grp-action-add-to" => "1",
91 "url" => $ctrl->getLinkTargetByClass(array("ildashboardgui", "ilGroupUserActionsGUI", "ilGroupAddToGroupActionGUI"), "", "", true, false)
92 ));
93 $coll->addAction($f);
94
95 return $coll;
96 }
97
104 public function getJsScripts($a_action_type)
105 {
106 switch ($a_action_type) {
107 case "add_to":
108 include_once("./Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php");
109 return array(
110 "./Modules/Group/UserActions/js/GroupUserActions.js",
111 "./src/UI/templates/js/Modal/modal.js",
114 );
115 break;
116 }
117 return array();
118 }
119}
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: goto.php:24