ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilUserActionCollector.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected static $instances = array();
15
19 protected $collection;
20
24 protected $user_id;
25
29 protected $action_context;
30
37 protected function __construct($a_user_id, ilUserActionContext $a_context)
38 {
39 $this->user_id = $a_user_id;
40 $this->action_context = $a_context;
41 }
42
43
51 public static function getInstance($a_user_id, ilUserActionContext $a_context)
52 {
53 if (!isset(self::$instances[$a_user_id])) {
54 self::$instances[$a_user_id] = new ilUserActionCollector($a_user_id, $a_context);
55 }
56
57 return self::$instances[$a_user_id];
58 }
59
65 public function getActionsForTargetUser($a_target_user)
66 {
67 // overall collection of users
68 include_once("./Services/User/Actions/classes/class.ilUserActionCollection.php");
69 $this->collection = ilUserActionCollection::getInstance();
70
71 include_once("./Services/User/Actions/classes/class.ilUserActionAdmin.php");
72
73 include_once("./Services/User/Actions/classes/class.ilUserActionProviderFactory.php");
75 if (!$this->hasProviderActiveActions($prov)) {
76 continue;
77 }
78 $prov->setUserId($this->user_id);
79 $coll = $prov->collectActionsForTargetUser($a_target_user);
80 foreach ($coll->getActions() as $action) {
82 $this->action_context->getComponentId(),
83 $this->action_context->getContextId(),
84 $prov->getComponentId(),
85 $action->getType()
86 )) {
87 $this->collection->addAction($action);
88 }
89 }
90 }
91
92 return $this->collection;
93 }
94
95 protected function hasProviderActiveActions(ilUserActionProvider $prov) : bool
96 {
97 foreach ($prov->getActionTypes() as $act_type => $act_txt) {
99 $this->action_context->getComponentId(),
100 $this->action_context->getContextId(),
101 $prov->getComponentId(),
102 $act_type
103 )) {
104 return true;
105 }
106 }
107 return false;
108 }
109
110}
An exception for terminatinating execution or to throw for unit testing.
static lookupActive($a_context_comp, $a_context_id, $a_action_comp, $a_action_type)
Is activated?
Collects actions from all action providers.
getActionsForTargetUser($a_target_user)
Collect actions.
hasProviderActiveActions(ilUserActionProvider $prov)
__construct($a_user_id, ilUserActionContext $a_context)
Constructor.
static getInstance($a_user_id, ilUserActionContext $a_context)
Get instance (for a user)
A context where user actions are used (e.g.
static getAllProviders()
Get all action providers.
A class that provides a collection of actions on users.