ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
5 include_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 }
A class that provides a collection of actions on users.
static getInstance()
Get instance.
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, instead it parses the serialized rbac_pa entries.
getJsScripts($a_action_type)
Get js scripts.
static getLocalJsTreeJsPath()
Get local path of jsTree js.
static getLocalExplorerJsPath()
Get local path of explorer js.
Group user actions (add to group)
collectActionsForTargetUser($a_target_user)
Collect user actions.
static getCommandAccess($a_user_id)
Get command access for user.
$DIC
Definition: xapitoken.php:46
Action that can be performed on a user.