ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAwarenessGUI Class Reference

Awareness GUI class. More...

+ Collaboration diagram for ilAwarenessGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getMainMenuHTML ()
 Get main menu html. More...
 
 getAwarenessList ()
 Get awareness list (ajax) More...
 

Static Public Member Functions

static getInstance ()
 Get instance. More...
 

Protected Attributes

 $user
 
 $ctrl
 
 $ui
 
 $lng
 

Detailed Description

Awareness GUI class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilAwarenessGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAwarenessGUI::__construct ( )

Constructor.

Definition at line 37 of file class.ilAwarenessGUI.php.

38 {
39 global $DIC;
40
41 $this->user = $DIC->user();
42 global $DIC;
43 $this->ui = $DIC->ui();
44
45 $this->ref_id = (int) $_GET["ref_id"];
46 $this->ctrl = $DIC->ctrl();
47 $this->lng = $DIC->language();
48 $this->lng->loadLanguageModule("awrn");
49 }
user()
Definition: user.php:4
$_GET["client_id"]
global $DIC
Definition: saml.php:7

References $_GET, $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilAwarenessGUI::executeCommand ( )

Execute command.

Definition at line 54 of file class.ilAwarenessGUI.php.

55 {
56 $cmd = $this->ctrl->getCmd();
57
58 if (in_array($cmd, array("getAwarenessList"))) {
59 $this->$cmd();
60 }
61 }

◆ getAwarenessList()

ilAwarenessGUI::getAwarenessList ( )

Get awareness list (ajax)

Definition at line 172 of file class.ilAwarenessGUI.php.

173 {
175
176 $filter = $_GET["filter"];
177
178 $tpl = new ilTemplate("tpl.awareness_list.html", true, true, "Services/Awareness");
179
180 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
181 $act = ilAwarenessAct::getInstance($ilUser->getId());
182 $act->setRefId($this->ref_id);
183
184 $ad = $act->getAwarenessData($filter);
185
186 // update counter
187 $now = time();
188 $cnt = explode(":", $ad["cnt"]);
189 $hcnt = $cnt[1];
190 $cnt = $cnt[0];
191 ilSession::set("awrn_last_update", $now);
192 ilSession::set("awrn_nr_users", $cnt);
193 ilSession::set("awrn_nr_husers", $hcnt);
194
195
196 $users = $ad["data"];
197
198 $ucnt = 0;
199 $last_uc_title = "";
200 foreach ($users as $u) {
201 if ($u->collector != $last_uc_title) {
202 if ($u->highlighted) {
203 $tpl->touchBlock("highlighted");
204 }
205 $tpl->setCurrentBlock("uc_title");
206 $tpl->setVariable("UC_TITLE", $u->collector);
207 $tpl->parseCurrentBlock();
208 $tpl->setCurrentBlock("item");
209 $tpl->parseCurrentBlock();
210 }
211 $last_uc_title = $u->collector;
212
213 $ucnt++;
214
215 $fcnt = 0;
216 foreach ($u->actions as $act) {
217 $fcnt++;
218 if ($fcnt == 1) {
219 $tpl->touchBlock("arrow");
220 //$tpl->setCurrentBlock("arrow");
221 //$tpl->parseCurrentBlock();
222 }
223 if (is_array($act->data) && count($act->data) > 0) {
224 foreach ($act->data as $k => $v) {
225 $tpl->setCurrentBlock("f_data");
226 $tpl->setVariable("DATA_KEY", $k);
227 $tpl->setVariable("DATA_VAL", ilUtil::prepareFormOutput($v));
228 $tpl->parseCurrentBlock();
229 }
230 }
231 $tpl->setCurrentBlock("feature");
232 $tpl->setVariable("FEATURE_HREF", $act->href);
233 $tpl->setVariable("FEATURE_TEXT", $act->text);
234 $tpl->parseCurrentBlock();
235 }
236
237 if ($u->online) {
238 $tpl->touchBlock("uonline");
239 $tpl->setCurrentBlock("uonline_text");
240 $tpl->setVariable("TXT_ONLINE", $this->lng->txt("awrn_online"));
241 $tpl->parseCurrentBlock();
242 }
243
244 $tpl->setCurrentBlock("user");
245 if ($u->public_profile) {
246 $tpl->setVariable("UNAME", $u->lastname . ", " . $u->firstname);
247 } else {
248 $tpl->setVariable("UNAME", " ");
249 }
250 $tpl->setVariable("UACCOUNT", $u->login);
251
252 $tpl->setVariable("USERIMAGE", $u->img);
253 $tpl->setVariable("CNT", $ucnt);
254 $tpl->parseCurrentBlock();
255 $tpl->setCurrentBlock("item");
256 $tpl->parseCurrentBlock();
257 }
258
259 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
260 $tpl->setCurrentBlock("filter");
261 $tpl->setVariable("GL_FILTER", ilGlyphGUI::get(ilGlyphGUI::FILTER));
262 $tpl->parseCurrentBlock();
263
264 echo json_encode(array("html" => $tpl->get(),
265 "filter_val" => ilUtil::prepareFormOutput($filter),
266 "cnt" => $ad["cnt"]));
267 exit;
268 }
$tpl
Definition: ilias.php:10
$users
Definition: authpage.php:44
static getInstance($a_user_id)
Get instance (for a user)
static get($a_glyph, $a_text="")
Get glyph html.
static set($a_var, $a_val)
Set a value.
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$ilUser
Definition: imgupload.php:18

References $_GET, $ilUser, $tpl, $user, $users, exit, ilGlyphGUI\FILTER, ilGlyphGUI\get(), ilAwarenessAct\getInstance(), ilUtil\prepareFormOutput(), and ilSession\set().

+ Here is the call graph for this function:

◆ getInstance()

static ilAwarenessGUI::getInstance ( )
static

Get instance.

Returns
ilAwarenessGUI awareness gui object

Definition at line 69 of file class.ilAwarenessGUI.php.

70 {
71 return new ilAwarenessGUI();
72 }
Awareness GUI class.

Referenced by ilMainMenuGUI\renderAwareness().

+ Here is the caller graph for this function:

◆ getMainMenuHTML()

ilAwarenessGUI::getMainMenuHTML ( )

Get main menu html.

Definition at line 77 of file class.ilAwarenessGUI.php.

78 {
80
81 $awrn_set = new ilSetting("awrn");
82 if (!$awrn_set->get("awrn_enabled", false) || ANONYMOUS_USER_ID == $ilUser->getId()) {
83 return "";
84 }
85
86 $cache_period = (int) $awrn_set->get("caching_period");
87 $last_update = ilSession::get("awrn_last_update");
88 $now = time();
89
90 // init js
91 $GLOBALS["tpl"]->addJavascript("./Services/Awareness/js/Awareness.js");
92 $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
93 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setBaseUrl('" . $this->ctrl->getLinkTarget(
94 $this,
95 "",
96 "",
97 true,
98 false
99 ) . "');");
100 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.setLoaderSrc('" . ilUtil::getImagePath("loader.svg") . "');");
101 $GLOBALS["tpl"]->addOnloadCode("il.Awareness.init();");
102
103 // include user action js
104 include_once("./Services/User/Actions/classes/class.ilUserActionGUI.php");
105 include_once("./Services/Awareness/classes/class.ilAwarenessUserActionContext.php");
107 $ua_gui->init();
108
109 $tpl = new ilTemplate("tpl.awareness.html", true, true, "Services/Awareness");
110
111 include_once("./Services/Awareness/classes/class.ilAwarenessAct.php");
112 $act = ilAwarenessAct::getInstance($ilUser->getId());
113 $act->setRefId($this->ref_id);
114
115 if ($last_update == "" || ($now - $last_update) >= $cache_period) {
116 $cnt = explode(":", $act->getAwarenessUserCounter());
117 $hcnt = $cnt[1];
118 $cnt = $cnt[0];
119 $act->notifyOnNewOnlineContacts();
120 ilSession::set("awrn_last_update", $now);
121 ilSession::set("awrn_nr_users", $cnt);
122 ilSession::set("awrn_nr_husers", $hcnt);
123 } else {
124 $cnt = (int) ilSession::get("awrn_nr_users");
125 $hcnt = (int) ilSession::get("awrn_nr_husers");
126 }
127
128 if ($hcnt > 0 || $cnt > 0) {
129 /*
130 $tpl->setCurrentBlock("status_text");
131 $tpl->setVariable("STATUS_TXT", $cnt);
132 if ($cnt == 0)
133 {
134 $tpl->setVariable("HIDDEN", "ilAwrnBadgeHidden");
135 }
136 $tpl->parseCurrentBlock();
137 $tpl->setCurrentBlock("h_status_text");
138 $tpl->setVariable("H_STATUS_TXT", $hcnt);
139 if ($hcnt == 0)
140 {
141 $tpl->setVariable("H_HIDDEN", "ilAwrnBadgeHidden");
142 }
143 $tpl->parseCurrentBlock();
144 $tpl->setVariable("HSP", " ");*/
145
146 $f = $this->ui->factory();
147 $renderer = $this->ui->renderer();
148
149 $glyph = $f->glyph()->user("#");
150 if ($cnt > 0) {
151 $glyph = $glyph->withCounter($f->counter()->status((int) $cnt));
152 }
153 if ($hcnt > 0) {
154 $glyph =$glyph->withCounter($f->counter()->novelty((int) $hcnt));
155 }
156 $glyph_html = $renderer->render($glyph);
157 $tpl->setVariable("GLYPH", $glyph_html);
158
159
160
161 $tpl->setVariable("LOADER", ilUtil::getImagePath("loader.svg"));
162
163 return $tpl->get();
164 }
165
166 return "";
167 }
Awareness context for user actions.
static get($a_var)
Get a value.
ILIAS Setting Class.
static getInstance(ilUserActionContext $a_user_action_context, ilTemplate $a_global_tpl, $a_current_user_id)
Get instance.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, $ilUser, $tpl, $user, ilSession\get(), ilUtil\getImagePath(), ilAwarenessAct\getInstance(), ilUserActionGUI\getInstance(), and ilSession\set().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilAwarenessGUI::$ctrl
protected

Definition at line 22 of file class.ilAwarenessGUI.php.

◆ $lng

ilAwarenessGUI::$lng
protected

Definition at line 32 of file class.ilAwarenessGUI.php.

◆ $ui

ilAwarenessGUI::$ui
protected

Definition at line 27 of file class.ilAwarenessGUI.php.

◆ $user

ilAwarenessGUI::$user
protected

Definition at line 17 of file class.ilAwarenessGUI.php.

Referenced by getAwarenessList(), and getMainMenuHTML().


The documentation for this class was generated from the following file: