ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilAwarenessMetaBarProvider.php
Go to the documentation of this file.
1<?php
2
3
8
15{
16
20 private function getId() : IdentificationInterface
21 {
22 return $this->if->identifier('awareness');
23 }
24
25
29 public function getAllIdentifications() : array
30 {
31 return [$this->getId()];
32 }
33
34
38 public function getMetaBarItems() : array
39 {
40 global $DIC;
41
42 $ilUser = $DIC->user();
43
44 $awrn_set = new ilSetting("awrn");
45 if (!$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId() || $ilUser->getId() == 0) {
46 return [];
47 }
48
49 $cache_period = (int) $awrn_set->get("caching_period");
50 $last_update = ilSession::get("awrn_last_update");
51 $now = time();
52
53 $act = ilAwarenessAct::getInstance($ilUser->getId());
54 $act->setRefId((int) $_GET["ref_id"]);
55 if ($last_update == "" || ($now - $last_update) >= $cache_period) {
56 $cnt = explode(":", $act->getAwarenessUserCounter());
57 $hcnt = $cnt[1];
58 $cnt = $cnt[0];
59 $act->notifyOnNewOnlineContacts();
60 ilSession::set("awrn_last_update", $now);
61 ilSession::set("awrn_nr_users", $cnt);
62 ilSession::set("awrn_nr_husers", $hcnt);
63 } else {
64 $cnt = (int) ilSession::get("awrn_nr_users");
65 $hcnt = (int) ilSession::get("awrn_nr_husers");
66 }
67
68
69 $gui = new ilAwarenessGUI();
70 $result = $gui->getAwarenessList(true);
71
72 $content = function () use ($result) {
73 return $this->dic->ui()->factory()->legacy($result["html"]);
74 };
75
76 $mb = $this->globalScreen()->metaBar();
77
78 $f = $DIC->ui()->factory();
79
80 $online = explode(":", $result["cnt"]);
81 $online = $online[0];
82
83 $item = $mb
84 ->topLegacyItem($this->getId())
85 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) : ILIAS\UI\Component\Component {
86 if ($c instanceof Bulky) {
87 return $c->withAdditionalOnLoadCode(static function (string $id) : string {
88
89 // ...we never get the bulky button of the legacy slate item here
90 return "$('#$id').on('click', function() {
91 console.log('click slate button');
92 })";
93 });
94 }
95 return $c;
96 })
97 ->withLegacyContent($content())
98 ->withSymbol(
99 $this->dic->ui()->factory()
100 ->symbol()
101 ->glyph()
102 ->user()
103 ->withCounter($f->counter()->status((int) $cnt))
104 ->withCounter($f->counter()->novelty((int) $hcnt))
105 )
106 ->withTitle($this->dic->language()->txt("awra"))
107 ->withPosition(2)
108 ->withAvailableCallable(
109 function () use ($DIC, $online) {
110 $ilUser = $DIC->user();
111
112 $awrn_set = new ilSetting("awrn");
113 if ($online <= 0 || !$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId()) {
114 return false;
115 }
116 return true;
117 }
118 );
119
120 return [$item];
121 }
122}
$result
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static getInstance($a_user_id)
Get instance (for a user)
Awareness GUI class.
Who-Is-Online meta bar provider.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
ILIAS Setting Class.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46