ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAwarenessGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $ctrl;
15
19 function __construct()
20 {
21 global $ilCtrl;
22
23 $this->ref_id = (int) $_GET["ref_id"];
24 $this->ctrl = $ilCtrl;
25 }
26
30 function executeCommand()
31 {
32 $cmd = $this->ctrl->getCmd();
33
34 if (in_array($cmd, array("getAwarenessList")))
35 {
36 $this->$cmd();
37 }
38 }
39
40
46 static function getInstance()
47 {
48 return new ilAwarenessGUI();
49 }
50
54 function getMainMenuHTML()
55 {
56 global $ilUser;
57
58 $awrn_set = new ilSetting("awrn");
59 if (!$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId())
60 {
61 return "";
62 }
63
64 $cache_period = (int) $awrn_set->get("caching_period");
65 $last_update = ilSession::get("awrn_last_update");
66 $now = time();
67
68 // init js
69 $GLOBALS["tpl"]->addJavascript("./Services/Awareness/js/Awareness.js");
70 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
71 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setBaseUrl('".$this->ctrl->getLinkTarget($this,
72 "", "", true, false)."');");
73 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setLoaderSrc('".ilUtil::getImagePath("loader.svg")."');");
74 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.init();");
75
76 $tpl = new ilTemplate("tpl.awareness.html", true, true, "Services/Awareness");
77
78 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
79 $act = ilAwarenessAct::getInstance($ilUser->getId());
80 $act->setRefId($this->ref_id);
81
82 if ($last_update == "" || ($now - $last_update) >= $cache_period)
83 {
84 $cnt = explode(":", $act->getAwarenessUserCounter());
85 $hcnt = $cnt[1];
86 $cnt = $cnt[0];
87 $act->notifyOnNewOnlineContacts();
88 ilSession::set("awrn_last_update", $now);
89 ilSession::set("awrn_nr_users", $cnt);
90 ilSession::set("awrn_nr_husers", $hcnt);
91 }
92 else
93 {
94 $cnt = (int) ilSession::get("awrn_nr_users");
95 $hcnt = (int) ilSession::get("awrn_nr_husers");
96 }
97
98 if ($hcnt > 0 || $cnt > 0)
99 {
100 $tpl->setCurrentBlock("status_text");
101 $tpl->setVariable("STATUS_TXT", $cnt);
102 if ($cnt == 0)
103 {
104 $tpl->setVariable("HIDDEN", "ilAwrnBadgeHidden");
105 }
106 $tpl->parseCurrentBlock();
107 $tpl->setCurrentBlock("h_status_text");
108 $tpl->setVariable("H_STATUS_TXT", $hcnt);
109 if ($hcnt == 0)
110 {
111 $tpl->setVariable("H_HIDDEN", "ilAwrnBadgeHidden");
112 }
113 $tpl->parseCurrentBlock();
114 $tpl->setVariable("HSP", "&nbsp;");
115
116 $tpl->setVariable("LOADER", ilUtil::getImagePath("loader.svg"));
117
118 return $tpl->get();
119 }
120
121 return "";
122 }
123
128 {
129 global $ilUser;
130
131 $filter = $_GET["filter"];
132
133 $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "Services/Awareness");
134
135 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
136 $act = ilAwarenessAct::getInstance($ilUser->getId());
137 $act->setRefId($this->ref_id);
138
139 $ad = $act->getAwarenessData($filter);
140
141 // update counter
142 $now = time();
143 $cnt = explode(":",$ad["cnt"]);
144 $hcnt = $cnt[1];
145 $cnt = $cnt[0];
146 ilSession::set("awrn_last_update", $now);
147 ilSession::set("awrn_nr_users", $cnt);
148 ilSession::set("awrn_nr_husers", $hcnt);
149
150
151 $users = $ad["data"];
152
153 $ucnt = 0;
154 $last_uc_title = "";
155 foreach ($users as $u)
156 {
157 if ($u->collector != $last_uc_title)
158 {
159 if ($u->highlighted)
160 {
161 $tpl->touchBlock("highlighted");
162 }
163 $tpl->setCurrentBlock("uc_title");
164 $tpl->setVariable("UC_TITLE", $u->collector);
165 $tpl->parseCurrentBlock();
166 $tpl->setCurrentBlock("item");
167 $tpl->parseCurrentBlock();
168 }
169 $last_uc_title = $u->collector;
170
171 $ucnt++;
172
173 $fcnt = 0;
174 foreach ($u->features as $f)
175 {
176 $fcnt++;
177 if ($fcnt == 1)
178 {
179 $tpl->touchBlock("arrow");
180 //$tpl->setCurrentBlock("arrow");
181 //$tpl->parseCurrentBlock();
182 }
183 if (is_array($f->data) && count($f->data) > 0)
184 {
185 foreach ($f->data as $k => $v)
186 {
187 $tpl->setCurrentBlock("f_data");
188 $tpl->setVariable("DATA_KEY", $k);
189 $tpl->setVariable("DATA_VAL", ilUtil::prepareFormOutput($v));
190 $tpl->parseCurrentBlock();
191 }
192 }
193 $tpl->setCurrentBlock("feature");
194 $tpl->setVariable("FEATURE_HREF", $f->href);
195 $tpl->setVariable("FEATURE_TEXT", $f->text);
196 $tpl->parseCurrentBlock();
197 }
198
199 if ($u->online)
200 {
201 $tpl->touchBlock("uonline");
202 }
203
204 $tpl->setCurrentBlock("user");
205 if ($u->public_profile)
206 {
207 $tpl->setVariable("UNAME", $u->lastname.", ".$u->firstname);
208 }
209 else
210 {
211 $tpl->setVariable("UNAME", "&nbsp;");
212 }
213 $tpl->setVariable("UACCOUNT", $u->login);
214
215 $tpl->setVariable("USERIMAGE", $u->img);
216 $tpl->setVariable("CNT", $ucnt);
217 $tpl->parseCurrentBlock();
218 $tpl->setCurrentBlock("item");
219 $tpl->parseCurrentBlock();
220 }
221
222 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
223 $tpl->setCurrentBlock("filter");
224 $tpl->setVariable("GL_FILTER", ilGlyphGUI::get(ilGlyphGUI::FILTER));
225 $tpl->setVariable("VAL_FILTER", ilUtil::prepareFormOutput($filter));
226 $tpl->parseCurrentBlock();
227
228 echo json_encode(array("html" => $tpl->get(),
229 "cnt" => $ad["cnt"]));
230 exit;
231 }
232
233}
234?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
static getInstance($a_user_id)
Get instance (for a user)
Awareness GUI class.
static getInstance()
Get instance.
executeCommand()
Execute command.
getMainMenuHTML()
Get main menu html.
__construct()
Constructor.
getAwarenessList()
Get awareness list (ajax)
static get($a_glyph, $a_text="")
Get glyph html.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15