ILIAS  release_8 Revision v8.24
class.ilUserActionCollector.php
Go to the documentation of this file.
1<?php
2
24{
25 protected static array $instances = array();
26
28 protected int $user_id;
30
31 protected function __construct(int $a_user_id, ilUserActionContext $a_context)
32 {
33 $this->user_id = $a_user_id;
34 $this->action_context = $a_context;
35 }
36
37
41 public static function getInstance(
42 int $a_user_id,
43 ilUserActionContext $a_context
44 ): self {
45 if (!isset(self::$instances[$a_user_id])) {
46 self::$instances[$a_user_id] = new ilUserActionCollector($a_user_id, $a_context);
47 }
48
49 return self::$instances[$a_user_id];
50 }
51
52 public function getActionsForTargetUser(int $a_target_user): ilUserActionCollection
53 {
54 // overall collection of users
55 $this->collection = ilUserActionCollection::getInstance();
57 if (!$this->hasProviderActiveActions($prov)) {
58 continue;
59 }
60 $prov->setUserId($this->user_id);
61 $coll = $prov->collectActionsForTargetUser($a_target_user);
62 foreach ($coll->getActions() as $action) {
64 $this->action_context->getComponentId(),
65 $this->action_context->getContextId(),
66 $prov->getComponentId(),
67 $action->getType()
68 )) {
69 $this->collection->addAction($action);
70 }
71 }
72 }
73
74 return $this->collection;
75 }
76
77 protected function hasProviderActiveActions(ilUserActionProvider $prov): bool
78 {
79 foreach ($prov->getActionTypes() as $act_type => $act_txt) {
81 $this->action_context->getComponentId(),
82 $this->action_context->getContextId(),
83 $prov->getComponentId(),
84 $act_type
85 )) {
86 return true;
87 }
88 }
89 return false;
90 }
91}
static lookupActive(string $a_context_comp, string $a_context_id, string $a_action_comp, string $a_action_type)
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 getInstance(int $a_user_id, ilUserActionContext $a_context)
Get instance (for a user)
ilUserActionCollection $collection
getActionsForTargetUser(int $a_target_user)
hasProviderActiveActions(ilUserActionProvider $prov)
__construct(int $a_user_id, ilUserActionContext $a_context)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getAllProviders()
Get all action providers.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20