ILIAS  release_8 Revision v8.24
ilRatingGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilRatingGUI:
+ Collaboration diagram for ilRatingGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 execute command More...
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 
 setObject (int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id=0, ?string $a_sub_obj_type="")
 Set Object. More...
 
 setUserId (int $a_userid)
 
 getUserId ()
 
 setYourRatingText (string $a_val)
 
 getYourRatingText ()
 
 enableCategories (bool $a_value)
 
 setCtrlPath (array $a_value)
 
 getHTML (bool $a_show_overall=true, bool $a_may_rate=true, string $a_onclick=null, string $a_additional_id=null)
 
 getBlockHTML (string $a_title)
 
 saveRating ()
 Save Rating. More...
 
 setUpdateCallback ($a_callback)
 
 resetUserRating ()
 
 setExportCallback ($a_callback, string $a_subobj_title)
 
 getListGUIProperty (int $a_ref_id, bool $a_may_rate, string $a_ajax_hash, int $parent_ref_id)
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Protected Member Functions

 renderDetails (string $a_js_id, bool $a_may_rate, array $a_categories=null, string $a_onclick=null, bool $a_average=false, bool $add_tooltip=false)
 
 addTooltip (string $id, int $cnt=0, float $avg=0, int $user=0)
 

Protected Attributes

 ilLanguage$lng
 
ilCtrl $ctrl
 
ilObjUser $user
 
string $id = "rtg_"
 
 $export_callback
 
string $export_subobj_title = ""
 
array $ctrl_path = []
 
bool $enable_categories = false
 
string $your_rating_text = ""
 
ILIAS DI UIServices $ui
 
int $obj_id
 
string $obj_type
 
int $sub_obj_id
 
string $sub_obj_type
 
int $userid
 
 $update_callback = null
 
array $requested_ratings = null
 
int $requested_rating
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilRatingGUI. User interface class for rating.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de @ilCtrl_Calls ilRatingGUI: ilRatingCategoryGUI

Definition at line 25 of file class.ilRatingGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilRatingGUI::__construct ( )

Definition at line 47 of file class.ilRatingGUI.php.

48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->ctrl = $DIC->ctrl();
53 $this->user = $DIC->user();
54 $lng = $DIC->language();
55
56 $this->ui = $DIC->ui();
57
58 $params = $DIC->http()->request()->getQueryParams();
59 $body = $DIC->http()->request()->getParsedBody();
60
61 if (isset($body['rating'])) {
62 if (is_array($body['rating'])) {
63 $this->requested_ratings = ($body['rating'] ?? null);
64 } else {
65 $this->requested_rating = (int) ($body['rating'] ?? 0);
66 }
67 } else {
68 $this->requested_rating = (int) ($params['rating'] ?? 0);
69 }
70
71 $lng->loadLanguageModule("rating");
72 }
global $DIC
Definition: feed.php:28
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$lng

References $DIC, $lng, $params, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addTooltip()

ilRatingGUI::addTooltip ( string  $id,
int  $cnt = 0,
float  $avg = 0,
int  $user = 0 
)
protected

Definition at line 592 of file class.ilRatingGUI.php.

597 : void {
599
600 $tt = "";
601 if ($cnt == 0) {
602 $tt = $lng->txt("rat_not_rated_yet");
603 } else {
604 if ($cnt == 1) {
605 $tt = $lng->txt("rat_one_rating");
606 } else {
607 $tt = sprintf($lng->txt("rat_nr_ratings"), $cnt);
608 }
609 $tt .= "<br>" . $lng->txt("rating_avg_rating") . ": " . round($avg, 1);
610 }
611
612 if ($user > 0) {
613 $tt .= "<br>" . $lng->txt("rating_personal_rating") . ": " . $user;
614 }
615 if ($tt !== "") {
617 $id,
618 $tt,
619 "",
620 "bottom center",
621 "top center",
622 false
623 );
624 }
625 }
static addTooltip(string $a_el_id, string $a_text, string $a_container="", string $a_my="bottom center", string $a_at="top center", bool $a_use_htmlspecialchars=true)

References $lng.

◆ enableCategories()

ilRatingGUI::enableCategories ( bool  $a_value)

Definition at line 156 of file class.ilRatingGUI.php.

156 : void
157 {
158 $this->enable_categories = $a_value;
159 }

◆ executeCommand()

ilRatingGUI::executeCommand ( )

execute command

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

77 : void
78 {
79 $ilCtrl = $this->ctrl;
80
81 $next_class = $ilCtrl->getNextClass($this);
82 $cmd = $ilCtrl->getCmd();
83
84 switch ($next_class) {
85 case "ilratingcategorygui":
86 $gui = new ilRatingCategoryGUI($this->obj_id, $this->export_callback, $this->export_subobj_title);
87 $ilCtrl->forwardCommand($gui);
88 break;
89
90 default:
91 $this->$cmd();
92 break;
93 }
94 }
getNextClass($a_gui_class=null)
@inheritDoc
Class ilRatingCategoryGUI.

References $ctrl, and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ getBlockHTML()

ilRatingGUI::getBlockHTML ( string  $a_title)

Definition at line 627 of file class.ilRatingGUI.php.

627 : string
628 {
629 $ui = $this->ui;
630
631 $categories = array();
632 if ($this->enable_categories) {
633 $categories = ilRatingCategory::getAllForObject($this->obj_id);
634 }
635
636 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
637
638
639 $panel = $ui->factory()->panel()->secondary()->legacy(
640 $a_title,
641 $ui->factory()->legacy(
642 $this->renderDetails("rtsb_", $may_rate, $categories, null, true, true)
643 )
644 );
645
646 return $ui->renderer()->render($panel);
647 }
static getAllForObject(int $a_parent_obj_id)
ILIAS DI UIServices $ui
renderDetails(string $a_js_id, bool $a_may_rate, array $a_categories=null, string $a_onclick=null, bool $a_average=false, bool $add_tooltip=false)
const ANONYMOUS_USER_ID
Definition: constants.php:27
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198

References $panel, ANONYMOUS_USER_ID, and ilRatingCategory\getAllForObject().

+ Here is the call graph for this function:

◆ getHTML()

ilRatingGUI::getHTML ( bool  $a_show_overall = true,
bool  $a_may_rate = true,
string  $a_onclick = null,
string  $a_additional_id = null 
)

Definition at line 455 of file class.ilRatingGUI.php.

460 : string {
462 $unique_id = $this->id;
463 if ($a_additional_id) {
464 $unique_id .= "_" . $a_additional_id;
465 }
466
467 $categories = array();
468 if ($this->enable_categories) {
469 $categories = ilRatingCategory::getAllForObject($this->obj_id);
470 }
471
472 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
473 if ($may_rate && !$a_may_rate) {
474 $may_rate = false;
475 }
476
477 $has_overlay = false;
478 if ($may_rate || $categories) {
479 $has_overlay = true;
480 }
481
482 $ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
483
484 // user rating
485 $user_rating = 0;
486 if ($may_rate || !$a_show_overall) {
487 $user_rating = round(ilRating::getRatingForUserAndObject(
488 $this->obj_id,
489 $this->obj_type,
490 $this->sub_obj_id,
491 $this->sub_obj_type,
492 $this->getUserId()
493 ));
494 }
495
496 // (1) overall rating
497 if ($a_show_overall) {
499 $this->obj_id,
500 $this->obj_type,
501 $this->sub_obj_id,
502 $this->sub_obj_type
503 );
504 } else {
505 $rating = array("avg" => $user_rating);
506 }
507
508 for ($i = 1; $i <= 5; $i++) {
509 if ($a_show_overall &&
510 $i == $user_rating) {
511 $ttpl->setCurrentBlock("rating_mark");
512 $ttpl->setVariable(
513 "SRC_MARK",
514 ilUtil::getImagePath("icon_rate_marker.svg")
515 );
516 $ttpl->parseCurrentBlock();
517 }
518
519 $ttpl->setCurrentBlock("rating_icon");
520 if ($rating["avg"] >= $i) {
521 $ttpl->setVariable(
522 "SRC_ICON",
523 ilUtil::getImagePath("icon_rate_on.svg")
524 );
525 } elseif ($rating["avg"] + 1 <= $i) {
526 $ttpl->setVariable(
527 "SRC_ICON",
528 ilUtil::getImagePath("icon_rate_off.svg")
529 );
530 } else {
531 $nr = round(($rating["avg"] + 1 - $i) * 10);
532 $ttpl->setVariable(
533 "SRC_ICON",
534 ilUtil::getImagePath("icon_rate_$nr.svg")
535 );
536 }
537 $ttpl->setVariable("ALT_ICON", "");
538 $ttpl->parseCurrentBlock();
539 }
540 $ttpl->setCurrentBlock("rating_icon");
541
542 if ($a_show_overall) {
543 if ($rating["cnt"] > 0) {
544 $ttpl->setCurrentBlock("rat_nr");
545 $ttpl->setVariable("RT_NR", $rating["cnt"]);
546 $ttpl->parseCurrentBlock();
547 }
548 }
549
550 $this->addTooltip(
551 $unique_id . "_tt",
552 (int) ($rating["cnt"] ?? 0),
553 (float) ($rating["avg"] ?? 0),
554 (int) ($user_rating ?? 0)
555 );
556
557 // add overlay (trigger)
558 if ($has_overlay) {
559 $ov = new ilOverlayGUI($unique_id);
560 $ov->setTrigger("tr_" . $unique_id, "click", "tr_" . $unique_id);
561 $ov->add();
562
563 $ttpl->setCurrentBlock("act_rat_start");
564 $ttpl->setVariable("ID", $unique_id);
565 $ttpl->setVariable("TXT_OPEN_DIALOG", $lng->txt("rating_open_dialog"));
566 $ttpl->parseCurrentBlock();
567
568 $ttpl->touchBlock("act_rat_end");
569 }
570
571 $ttpl->parseCurrentBlock();
572
573
574 // (2) user rating
575
576 if ($has_overlay) {
577 $ttpl->setVariable(
578 "RATING_DETAILS",
579 $this->renderDetails("rtov_", $may_rate, $categories, $a_onclick)
580 );
581
582 $ttpl->setCurrentBlock("user_rating");
583 $ttpl->setVariable("ID", $unique_id);
584 $ttpl->parseCurrentBlock();
585 }
586
587 $ttpl->setVariable("TTID", $unique_id);
588
589 return $ttpl->get();
590 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTooltip(string $id, int $cnt=0, float $avg=0, int $user=0)
static getRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, int $a_category_id=null)
Get rating for a user and an object.
static getOverallRatingForObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=null, string $a_sub_obj_type=null, int $a_category_id=null)
Get overall rating for an object.
special template class to simplify handling of ITX/PEAR
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$i
Definition: metadata.php:41

◆ getListGUIProperty()

ilRatingGUI::getListGUIProperty ( int  $a_ref_id,
bool  $a_may_rate,
string  $a_ajax_hash,
int  $parent_ref_id 
)

Definition at line 722 of file class.ilRatingGUI.php.

727 : string {
728 return $this->getHTML(
729 true,
730 $a_may_rate,
731 "il.Object.saveRatingFromListGUI(" . $a_ref_id . ", '" . $a_ajax_hash . "', %rating%);",
732 $parent_ref_id
733 );
734 }
getHTML(bool $a_show_overall=true, bool $a_may_rate=true, string $a_onclick=null, string $a_additional_id=null)

◆ getSafePostCommands()

ilRatingGUI::getSafePostCommands ( )

This method must return a list of safe POST commands.

Safe post commands returned by this method will no longer be CSRF protected and will NOT be appended by an ilCtrlToken.

Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 101 of file class.ilRatingGUI.php.

101 : array
102 {
103 return [];
104 }

◆ getUnsafeGetCommands()

ilRatingGUI::getUnsafeGetCommands ( )

This method must return a list of unsafe GET commands.

Unsafe get commands returned by this method will now be CSRF protected, which means an ilCtrlToken is appended each time a link-target is generated to the class implementing this interface with a command from that list.

Tokens will be validated in

See also
ilCtrlInterface::getCmd(), whereas the fallback command will be used if the CSRF validation fails.
Returns
string[]

Implements ilCtrlSecurityInterface.

Definition at line 96 of file class.ilRatingGUI.php.

96 : array
97 {
98 return ['saveRating'];
99 }

◆ getUserId()

ilRatingGUI::getUserId ( )

Definition at line 141 of file class.ilRatingGUI.php.

141 : int
142 {
143 return $this->userid;
144 }

◆ getYourRatingText()

ilRatingGUI::getYourRatingText ( )

Definition at line 151 of file class.ilRatingGUI.php.

151 : string
152 {
154 }
string $your_rating_text

◆ renderDetails()

ilRatingGUI::renderDetails ( string  $a_js_id,
bool  $a_may_rate,
array  $a_categories = null,
string  $a_onclick = null,
bool  $a_average = false,
bool  $add_tooltip = false 
)
protected

Definition at line 167 of file class.ilRatingGUI.php.

174 : string {
176 $ilCtrl = $this->ctrl;
177
178 $ttpl = new ilTemplate("tpl.rating_details.html", true, true, "Services/Rating");
179
180 $rate_text = null;
181 if ($this->getYourRatingText() != "#") {
182 $rate_text = ($this->getYourRatingText() != "")
183 ? $this->getYourRatingText()
184 : $lng->txt("rating_your_rating");
185 }
186
187 // no categories: 1 simple rating (link)
188 if (!$a_categories) {
189 if ($a_may_rate) {
191 $this->obj_id,
192 $this->obj_type,
193 $this->sub_obj_id,
194 $this->sub_obj_type,
195 $this->getUserId(),
196 0
197 );
198 $overall_rating = [
199 "avg" => 0,
200 "cnt" => 0
201 ];
202 if ($a_average) {
203 $overall_rating = ilRating::getOverallRatingForObject(
204 $this->obj_id,
205 $this->obj_type,
206 $this->sub_obj_id,
207 $this->sub_obj_type
208 );
209 }
210
211 // user rating links
212 for ($i = 1; $i <= 5; $i++) {
213 if ($a_average &&
214 $i == $rating) {
215 $ttpl->setCurrentBlock("rating_mark_simple");
216 $ttpl->setVariable(
217 "SRC_MARK_SIMPLE",
218 ilUtil::getImagePath("icon_rate_marker.svg")
219 );
220 $ttpl->parseCurrentBlock();
221 }
222
223 $ttpl->setCurrentBlock("rating_link_simple");
224 if (stristr($a_onclick, "%rating%")) {
225 $url_save = "#";
226 } else {
227 $ilCtrl->setParameter($this, "rating", $i);
228 if (!$this->ctrl_path) {
229 $url_save = $ilCtrl->getLinkTarget($this, "saveRating");
230 } else {
231 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "saveRating");
232 }
233 }
234 $ttpl->setVariable("HREF_RATING", $url_save);
235
236 if ($a_onclick) {
237 $onclick = str_replace("%rating%", $i, $a_onclick);
238 $ttpl->setVariable("ONCLICK_RATING", ' onclick="' . $onclick . '"');
239 }
240
241 if ($a_average) {
242 $ref_rating = $overall_rating["avg"];
243 } else {
244 $ref_rating = $rating;
245 }
246
247 if ($ref_rating >= $i) {
248 $ttpl->setVariable(
249 "SRC_ICON",
250 ilUtil::getImagePath("icon_rate_on.svg")
251 );
252 } else {
253 $ttpl->setVariable(
254 "SRC_ICON",
255 ilUtil::getImagePath("icon_rate_off.svg")
256 );
257 }
258 $ttpl->setVariable(
259 "ALT_ICON",
260 sprintf($lng->txt("rating_rate_x_of_5"), $i)
261 );
262 $ttpl->parseCurrentBlock();
263 }
264
265 // remove
266 if ($rating) {
267 $ttpl->setCurrentBlock("rating_simple_del_bl");
268 $ttpl->setVariable("CAPTION_RATING_DEL", $lng->txt("rating_remove"));
269
270 if (stristr($a_onclick, "%rating%")) {
271 $url_save = "#";
272 } else {
273 $ilCtrl->setParameter($this, "rating", 0);
274 if (!$this->ctrl_path) {
275 $url_save = $ilCtrl->getLinkTarget($this, "saveRating");
276 } else {
277 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "saveRating");
278 }
279 }
280 $ttpl->setVariable("HREF_RATING_DEL", $url_save);
281
282 if ($a_onclick) {
283 $onclick = str_replace("%rating%", 0, $a_onclick);
284 $ttpl->setVariable("ONCLICK_RATING_DEL", ' onclick="' . $onclick . '"');
285 }
286
287 $ttpl->parseCurrentBlock();
288 }
289
290 if ($rate_text) {
291 $ttpl->setCurrentBlock("rating_simple_title");
292 $ttpl->setVariable("TXT_RATING_SIMPLE", $rate_text);
293 $ttpl->parseCurrentBlock();
294 }
295
296 if ($a_average &&
297 $overall_rating["cnt"]) {
298 $ttpl->setCurrentBlock("number_votes_simple");
299 $ttpl->setVariable("NUMBER_VOTES_SIMPLE", $overall_rating["cnt"]);
300 $ttpl->parseCurrentBlock();
301 }
302
303 if ($add_tooltip) {
304 $unique_id = $this->id . "_block";
305 $ttpl->setVariable("TTID", $unique_id);
306 $this->addTooltip(
307 $unique_id,
308 (int) ($overall_rating["cnt"] ?? 0),
309 (float) ($overall_rating["avg"] ?? 0),
310 (int) ($rating ?? 0)
311 );
312 }
313
314 // user rating text
315 $ttpl->setCurrentBlock("user_rating_simple");
316 $ttpl->parseCurrentBlock();
317 }
318 }
319 // categories: overall & user (form)
320 else {
321 $has_user_rating = false;
322 $overall_rating = [
323 "avg" => 0,
324 "cnt" => 0
325 ];
326 foreach ($a_categories as $category) {
327 $user_rating = round(ilRating::getRatingForUserAndObject(
328 $this->obj_id,
329 $this->obj_type,
330 $this->sub_obj_id,
331 $this->sub_obj_type,
332 $this->getUserId(),
333 $category["id"]
334 ));
335
336 $overall_rating = ilRating::getOverallRatingForObject(
337 $this->obj_id,
338 $this->obj_type,
339 $this->sub_obj_id,
340 $this->sub_obj_type,
341 $category["id"]
342 );
343
344 for ($i = 1; $i <= 5; $i++) {
345 if ($a_may_rate && $i == $user_rating) {
346 $has_user_rating = true;
347
348 $ttpl->setCurrentBlock("rating_mark");
349 $ttpl->setVariable(
350 "SRC_MARK",
351 ilUtil::getImagePath("icon_rate_marker.svg")
352 );
353 $ttpl->parseCurrentBlock();
354 }
355
356 $ttpl->setCurrentBlock("user_rating_icon");
357 if ($overall_rating["avg"] >= $i) {
358 $ttpl->setVariable(
359 "SRC_ICON",
360 ilUtil::getImagePath("icon_rate_on.svg")
361 );
362 } elseif ($overall_rating["avg"] + 1 <= $i) {
363 $ttpl->setVariable(
364 "SRC_ICON",
365 ilUtil::getImagePath("icon_rate_off.svg")
366 );
367 } else {
368 $nr = round(($overall_rating["avg"] + 1 - $i) * 10);
369 $ttpl->setVariable(
370 "SRC_ICON",
371 ilUtil::getImagePath("icon_rate_$nr.svg")
372 );
373 }
374 $ttpl->setVariable(
375 "ALT_ICON",
376 sprintf($lng->txt("rating_rate_x_of_5"), $i)
377 );
378
379 if ($a_may_rate) {
380 $ttpl->setVariable("HREF_RATING", "il.Rating.setValue(" . $category["id"] . "," . $i . ", '" . $a_js_id . "')");
381 $ttpl->setVariable("CATEGORY_ID", $category["id"]);
382 $ttpl->setVariable("ICON_VALUE", $i);
383 $ttpl->setVariable("JS_ID", $a_js_id);
384 $ttpl->setVariable("ICON_MOUSEACTION", " onmouseover=\"il.Rating.toggleIcon(this," . $i . ")\"" .
385 " onmouseout=\"il.Rating.toggleIcon(this," . $i . ",1)\"");
386 }
387
388 $ttpl->parseCurrentBlock();
389 }
390
391 if ($a_may_rate) {
392 $ttpl->setCurrentBlock("user_rating_category_column");
393 $ttpl->setVariable("JS_ID", $a_js_id);
394 $ttpl->setVariable("CATEGORY_ID", $category["id"]);
395 $ttpl->setVariable("CATEGORY_VALUE", $user_rating);
396 if ($add_tooltip) {
397 $unique_id = $this->id . "_block_" . $category["id"];
398 $ttpl->setVariable("CAT_TTID", $unique_id);
399 $this->addTooltip(
400 $unique_id,
401 (int) ($overall_rating["cnt"] ?? 0),
402 (float) ($overall_rating["avg"] ?? 0),
403 (int) ($user_rating ?? 0)
404 );
405 }
406 $ttpl->parseCurrentBlock();
407 }
408
409
410 // category title
411 $ttpl->setCurrentBlock("user_rating_category");
412 $ttpl->setVariable("TXT_RATING_CATEGORY", $category["title"]);
413 $ttpl->parseCurrentBlock();
414 }
415
416 if ($overall_rating["cnt"] > 0) {
417 $ttpl->setCurrentBlock("votes_number_bl");
418 $ttpl->setVariable("NUMBER_VOTES", sprintf($lng->txt("rating_number_votes"), $overall_rating["cnt"]));
419 $ttpl->parseCurrentBlock();
420 }
421
422 if ($a_may_rate) {
423 // remove
424 if ($has_user_rating) {
425 $ttpl->setCurrentBlock("user_rating_categories_del_bl");
426 $ttpl->setVariable("CAPTION_RATING_DEL_CAT", $lng->txt("rating_remove"));
427
428 $ilCtrl->setParameter($this, "rating", 0);
429 if (!$this->ctrl_path) {
430 $url_save = $ilCtrl->getLinkTarget($this, "resetUserRating");
431 } else {
432 $url_save = $ilCtrl->getLinkTargetByClass($this->ctrl_path, "resetUserRating");
433 }
434 $ttpl->setVariable("HREF_RATING_DEL_CAT", $url_save);
435
436 $ttpl->parseCurrentBlock();
437 }
438
439 if (!$this->ctrl_path) {
440 $url_form = $ilCtrl->getFormAction($this, "saveRating");
441 } else {
442 $url_form = $ilCtrl->getFormActionByClass($this->ctrl_path, "saveRating");
443 }
444 $ttpl->setVariable("FORM_ACTION", $url_form);
445 $ttpl->setVariable("TXT_SUBMIT", $lng->txt("rating_overlay_submit"));
446 $ttpl->setVariable("CMD_SUBMIT", "saveRating");
447 $ttpl->touchBlock("user_rating_categories_form_out");
448 }
449 }
450
451 return $ttpl->get();
452 }

◆ resetUserRating()

ilRatingGUI::resetUserRating ( )

Definition at line 704 of file class.ilRatingGUI.php.

704 : void
705 {
707 $this->obj_id,
708 $this->obj_type,
709 (int) $this->sub_obj_id,
710 $this->sub_obj_type,
711 $this->getUserId()
712 );
713 }
static resetRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id)
Reset rating for a user and an object.

References ilRating\resetRatingForUserAndObject().

+ Here is the call graph for this function:

◆ saveRating()

ilRatingGUI::saveRating ( )

Save Rating.

Definition at line 652 of file class.ilRatingGUI.php.

652 : void
653 {
654 $ilCtrl = $this->ctrl;
655
656 if (!is_array($this->requested_ratings)) {
657 $rating = $this->requested_rating;
658 if ($rating == 0) {
659 $this->resetUserRating();
660 } else {
662 $this->obj_id,
663 $this->obj_type,
664 $this->sub_obj_id,
665 $this->sub_obj_type,
666 $this->getUserId(),
667 $rating
668 );
669 }
670 } else {
671 foreach ($this->requested_ratings as $cat_id => $rating) {
673 $this->obj_id,
674 $this->obj_type,
675 $this->sub_obj_id,
676 $this->sub_obj_type,
677 $this->getUserId(),
678 $rating,
679 $cat_id
680 );
681 }
682 }
683
684 if ($this->update_callback) {
685 call_user_func(
686 $this->update_callback,
687 $this->obj_id,
688 $this->obj_type,
689 $this->sub_obj_id,
690 $this->sub_obj_type
691 );
692 }
693
694 if ($ilCtrl->isAsynch()) {
695 exit();
696 }
697 }
static writeRatingForUserAndObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id, ?string $a_sub_obj_type, int $a_user_id, int $a_rating, int $a_category_id=0)
Write rating for a user and an object.
exit
Definition: login.php:28

References exit, and ilRating\writeRatingForUserAndObject().

+ Here is the call graph for this function:

◆ setCtrlPath()

ilRatingGUI::setCtrlPath ( array  $a_value)

Definition at line 161 of file class.ilRatingGUI.php.

161 : void
162 {
163 $this->ctrl_path = $a_value;
164 }

◆ setExportCallback()

ilRatingGUI::setExportCallback (   $a_callback,
string  $a_subobj_title 
)

Definition at line 715 of file class.ilRatingGUI.php.

715 : void
716 {
717 $this->export_callback = $a_callback;
718 $this->export_subobj_title = $a_subobj_title;
719 }

◆ setObject()

ilRatingGUI::setObject ( int  $a_obj_id,
string  $a_obj_type,
?int  $a_sub_obj_id = 0,
?string  $a_sub_obj_type = "" 
)

Set Object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

Definition at line 114 of file class.ilRatingGUI.php.

119 : void {
121
122 if (!trim($a_sub_obj_type)) {
123 $a_sub_obj_type = "-";
124 }
125
126 $this->obj_id = $a_obj_id;
127 $this->obj_type = $a_obj_type;
128 $this->sub_obj_id = $a_sub_obj_id;
129 $this->sub_obj_type = $a_sub_obj_type;
130 $this->id = "rtg_" . $this->obj_id . "_" . $this->obj_type . "_" . $this->sub_obj_id . "_" .
132
133 $this->setUserId($ilUser->getId());
134 }
setUserId(int $a_userid)
$ilUser
Definition: imgupload.php:34

◆ setUpdateCallback()

ilRatingGUI::setUpdateCallback (   $a_callback)

Definition at line 699 of file class.ilRatingGUI.php.

699 : void
700 {
701 $this->update_callback = $a_callback;
702 }

◆ setUserId()

ilRatingGUI::setUserId ( int  $a_userid)

Definition at line 136 of file class.ilRatingGUI.php.

136 : void
137 {
138 $this->userid = $a_userid;
139 }

◆ setYourRatingText()

ilRatingGUI::setYourRatingText ( string  $a_val)

Definition at line 146 of file class.ilRatingGUI.php.

146 : void
147 {
148 $this->your_rating_text = $a_val;
149 }

Field Documentation

◆ $ctrl

ilCtrl ilRatingGUI::$ctrl
protected

Definition at line 28 of file class.ilRatingGUI.php.

Referenced by executeCommand().

◆ $ctrl_path

array ilRatingGUI::$ctrl_path = []
protected

Definition at line 33 of file class.ilRatingGUI.php.

◆ $enable_categories

bool ilRatingGUI::$enable_categories = false
protected

Definition at line 34 of file class.ilRatingGUI.php.

◆ $export_callback

ilRatingGUI::$export_callback
protected

Definition at line 31 of file class.ilRatingGUI.php.

◆ $export_subobj_title

string ilRatingGUI::$export_subobj_title = ""
protected

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

◆ $id

string ilRatingGUI::$id = "rtg_"
protected

Definition at line 30 of file class.ilRatingGUI.php.

◆ $obj_id

int ilRatingGUI::$obj_id
protected

Definition at line 38 of file class.ilRatingGUI.php.

◆ $obj_type

string ilRatingGUI::$obj_type
protected

Definition at line 39 of file class.ilRatingGUI.php.

◆ $requested_rating

int ilRatingGUI::$requested_rating
protected

Definition at line 45 of file class.ilRatingGUI.php.

◆ $requested_ratings

array ilRatingGUI::$requested_ratings = null
protected

Definition at line 44 of file class.ilRatingGUI.php.

◆ $sub_obj_id

int ilRatingGUI::$sub_obj_id
protected

Definition at line 40 of file class.ilRatingGUI.php.

◆ $sub_obj_type

string ilRatingGUI::$sub_obj_type
protected

Definition at line 41 of file class.ilRatingGUI.php.

◆ $ui

ILIAS DI UIServices ilRatingGUI::$ui
protected

Definition at line 36 of file class.ilRatingGUI.php.

◆ $update_callback

ilRatingGUI::$update_callback = null
protected

Definition at line 43 of file class.ilRatingGUI.php.

◆ $user

ilObjUser ilRatingGUI::$user
protected

Definition at line 29 of file class.ilRatingGUI.php.

◆ $userid

int ilRatingGUI::$userid
protected

Definition at line 42 of file class.ilRatingGUI.php.

◆ $your_rating_text

string ilRatingGUI::$your_rating_text = ""
protected

Definition at line 35 of file class.ilRatingGUI.php.

◆ ilLanguage$lng

ilRatingGUI::ilLanguage$lng
protected

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


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