ILIAS  release_7 Revision v7.30-3-g800a261c036
ilRatingGUI Class Reference

Class ilRatingGUI. More...

+ Collaboration diagram for ilRatingGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 execute command More...
 
 setObject ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set Object. More...
 
 setUserId ($a_userid)
 Set User ID. More...
 
 getUserId ()
 Get User ID. More...
 
 setYourRatingText ($a_val)
 Set "Your Rating" text. More...
 
 getYourRatingText ()
 Get "Your Rating" text. More...
 
 enableCategories ($a_value)
 Toggle categories status. More...
 
 setCtrlPath (array $a_value)
 ilCtrl path More...
 
 getHTML ($a_show_overall=true, $a_may_rate=true, $a_onclick=null, $a_additional_id=null)
 Get HTML for rating of an object (and a user) More...
 
 getBlockHTML ($a_title)
 
 saveRating ()
 Save Rating. More...
 
 setUpdateCallback ($a_callback)
 
 resetUserRating ()
 Reset Rating. More...
 
 setExportCallback ($a_callback, $a_subobj_title)
 
 getListGUIProperty ($a_ref_id, $a_may_rate, $a_ajax_hash, $_parent_ref_id)
 Build list gui property for object. More...
 

Protected Member Functions

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

Protected Attributes

 $lng
 
 $ctrl
 
 $user
 
 $id = "rtg_"
 
 $export_callback
 
 $export_subobj_title
 
 $ctrl_path
 
 $ui
 

Detailed Description

Class ilRatingGUI.

User interface class for rating.

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

@ilCtrl_Calls ilRatingGUI: ilRatingCategoryGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilRatingGUI::__construct ( )

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

45 {
46 global $DIC;
47
48 $this->lng = $DIC->language();
49 $this->ctrl = $DIC->ctrl();
50 $this->user = $DIC->user();
51 $lng = $DIC->language();
52
53 $this->ui = $DIC->ui();
54
55 $lng->loadLanguageModule("rating");
56 }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5

References $DIC, $lng, ui(), and 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 608 of file class.ilRatingGUI.php.

613 : void
614 {
616
617 $tt = "";
618 if ($cnt == 0) {
619 $tt = $lng->txt("rat_not_rated_yet");
620 } else {
621 if ($cnt == 1) {
622 $tt = $lng->txt("rat_one_rating");
623 } else {
624 $tt = sprintf($lng->txt("rat_nr_ratings"), $cnt);
625 }
626 $tt.= "<br>".$lng->txt("rating_avg_rating").": ".round($avg, 1);
627 }
628
629 if ($user > 0) {
630 $tt.= "<br>".$lng->txt("rating_personal_rating").": ".$user;
631 }
632 if ($tt !== "") {
634 $id,
635 $tt,
636 "",
637 "bottom center",
638 "top center",
639 false
640 );
641 }
642 }
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.

References $id, $lng, $user, and ilTooltipGUI\addTooltip().

Referenced by getHTML(), and renderDetails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enableCategories()

ilRatingGUI::enableCategories (   $a_value)

Toggle categories status.

Parameters
bool$a_value

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

153 {
154 $this->enable_categories = (bool) $a_value;
155 }

◆ executeCommand()

ilRatingGUI::executeCommand ( )

execute command

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

62 {
63 $ilCtrl = $this->ctrl;
64
65 $next_class = $ilCtrl->getNextClass($this);
66 $cmd = $ilCtrl->getCmd();
67
68 switch ($next_class) {
69 case "ilratingcategorygui":
70 include_once("./Services/Rating/classes/class.ilRatingCategoryGUI.php");
71 $gui = new ilRatingCategoryGUI($this->obj_id, $this->export_callback, $this->export_subobj_title);
72 $ilCtrl->forwardCommand($gui);
73 break;
74
75 default:
76 return $this->$cmd();
77 break;
78 }
79 }
Class ilRatingCategoryGUI.

References $ctrl.

◆ getBlockHTML()

ilRatingGUI::getBlockHTML (   $a_title)

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

645 {
646 $ui = $this->ui;
647
648 $categories = array();
649 if ($this->enable_categories) {
650 $categories = ilRatingCategory::getAllForObject($this->obj_id);
651 }
652
653 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
654
655
656 $panel = $ui->factory()->panel()->secondary()->legacy(
657 $a_title,
658 $ui->factory()->legacy(
659 $this->renderDetails("rtsb_", $may_rate, $categories, null, true, true)
660 )
661 );
662
663 return $ui->renderer()->render($panel);
664 }
static getAllForObject($a_parent_obj_id)
Get all categories for object.
renderDetails( $a_js_id, $a_may_rate, array $a_categories=null, $a_onclick=null, $a_average=false, bool $add_tooltip=false)
Render rating details.
getUserId()
Get User ID.
const ANONYMOUS_USER_ID
Definition: constants.php:25
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138

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

+ Here is the call graph for this function:

◆ getHTML()

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

Get HTML for rating of an object (and a user)

Parameters
bool$a_show_overall
bool$a_may_rate
string$a_onclick
string$a_additional_id
Returns
string

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

475 {
477 $unique_id = $this->id;
478 if ($a_additional_id) {
479 $unique_id .= "_" . $a_additional_id;
480 }
481
482 $categories = array();
483 if ($this->enable_categories) {
484 $categories = ilRatingCategory::getAllForObject($this->obj_id);
485 }
486
487 $may_rate = ($this->getUserId() != ANONYMOUS_USER_ID);
488 if ($may_rate && !$a_may_rate) {
489 $may_rate = false;
490 }
491
492 $has_overlay = false;
493 if ($may_rate || $categories) {
494 $has_overlay = true;
495 }
496
497 $ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
498
499 // user rating
500 $user_rating = 0;
501 if ($may_rate || !$a_show_overall) {
502 $user_rating = round(ilRating::getRatingForUserAndObject(
503 $this->obj_id,
504 $this->obj_type,
505 $this->sub_obj_id,
506 $this->sub_obj_type,
507 $this->getUserId()
508 ));
509 }
510
511 // (1) overall rating
512 if ($a_show_overall) {
514 $this->obj_id,
515 $this->obj_type,
516 $this->sub_obj_id,
517 $this->sub_obj_type
518 );
519 } else {
520 $rating = array("avg" => $user_rating);
521 }
522
523 for ($i = 1; $i <= 5; $i++) {
524 if ($a_show_overall &&
525 $i == $user_rating) {
526 $ttpl->setCurrentBlock("rating_mark");
527 $ttpl->setVariable(
528 "SRC_MARK",
529 ilUtil::getImagePath("icon_rate_marker.svg")
530 );
531 $ttpl->parseCurrentBlock();
532 }
533
534 $ttpl->setCurrentBlock("rating_icon");
535 if ($rating["avg"] >= $i) {
536 $ttpl->setVariable(
537 "SRC_ICON",
538 ilUtil::getImagePath("icon_rate_on.svg")
539 );
540 } elseif ($rating["avg"] + 1 <= $i) {
541 $ttpl->setVariable(
542 "SRC_ICON",
543 ilUtil::getImagePath("icon_rate_off.svg")
544 );
545 } else {
546 $nr = round(($rating["avg"] + 1 - $i) * 10);
547 $ttpl->setVariable(
548 "SRC_ICON",
549 ilUtil::getImagePath("icon_rate_$nr.svg")
550 );
551 }
552 $ttpl->setVariable("ALT_ICON", "");
553 $ttpl->parseCurrentBlock();
554 }
555 $ttpl->setCurrentBlock("rating_icon");
556
557 if ($a_show_overall) {
558 if ($rating["cnt"] > 0) {
559 $ttpl->setCurrentBlock("rat_nr");
560 $ttpl->setVariable("RT_NR", $rating["cnt"]);
561 $ttpl->parseCurrentBlock();
562 }
563 }
564
565 $this->addTooltip(
566 $unique_id . "_tt",
567 (int) $rating["cnt"] ?? 0,
568 (float) $rating["avg"] ?? 0,
569 (int) $user_rating ?? 0
570 );
571
572 // add overlay (trigger)
573 if ($has_overlay) {
574 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
575 $ov = new ilOverlayGUI($unique_id);
576 $ov->setTrigger("tr_" . $unique_id, "click", "tr_" . $unique_id);
577 $ov->add();
578
579 $ttpl->setCurrentBlock("act_rat_start");
580 $ttpl->setVariable("ID", $unique_id);
581 $ttpl->setVariable("TXT_OPEN_DIALOG", $lng->txt("rating_open_dialog"));
582 $ttpl->parseCurrentBlock();
583
584 $ttpl->touchBlock("act_rat_end");
585 }
586
587 $ttpl->parseCurrentBlock();
588
589
590 // (2) user rating
591
592 if ($has_overlay) {
593 $ttpl->setVariable(
594 "RATING_DETAILS",
595 $this->renderDetails("rtov_", $may_rate, $categories, $a_onclick)
596 );
597
598 $ttpl->setCurrentBlock("user_rating");
599 $ttpl->setVariable("ID", $unique_id);
600 $ttpl->parseCurrentBlock();
601 }
602
603 $ttpl->setVariable("TTID", $unique_id);
604
605 return $ttpl->get();
606 }
This is a utility class for the yui overlays.
addTooltip(string $id, int $cnt=0, float $avg=0, int $user=0)
static getRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_category_id=null)
Get rating for a user and an object.
static getOverallRatingForObject($a_obj_id, $a_obj_type, $a_sub_obj_id=null, $a_sub_obj_type=null, $a_category_id=null)
Get overall rating for an object.
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)
$i
Definition: metadata.php:24

References $i, $id, $lng, addTooltip(), ANONYMOUS_USER_ID, ilRatingCategory\getAllForObject(), ilUtil\getImagePath(), ilRating\getOverallRatingForObject(), ilRating\getRatingForUserAndObject(), getUserId(), and renderDetails().

Referenced by getListGUIProperty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getListGUIProperty()

ilRatingGUI::getListGUIProperty (   $a_ref_id,
  $a_may_rate,
  $a_ajax_hash,
  $_parent_ref_id 
)

Build list gui property for object.

Parameters
int$a_ref_id
bool$a_may_rate
string$a_ajax_hash
int$_parent_ref_id
Returns
string

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

751 {
752 return $this->getHTML(
753 true,
754 $a_may_rate,
755 "il.Object.saveRatingFromListGUI(" . $a_ref_id . ", '" . $a_ajax_hash . "', %rating%);",
756 $_parent_ref_id
757 );
758 }
getHTML($a_show_overall=true, $a_may_rate=true, $a_onclick=null, $a_additional_id=null)
Get HTML for rating of an object (and a user)

References getHTML().

+ Here is the call graph for this function:

◆ getUserId()

ilRatingGUI::getUserId ( )

Get User ID.

Returns
int User ID

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

123 {
124 return $this->userid;
125 }

Referenced by getBlockHTML(), getHTML(), renderDetails(), resetUserRating(), and saveRating().

+ Here is the caller graph for this function:

◆ getYourRatingText()

ilRatingGUI::getYourRatingText ( )

Get "Your Rating" text.

Returns
string text

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

143 {
144 return $this->your_rating_text;
145 }

Referenced by renderDetails().

+ Here is the caller graph for this function:

◆ renderDetails()

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

Render rating details.

Parameters
string$a_js_id
bool$a_may_rate
array$a_categories
bool$a_onclick
bool$a_average
Returns
string

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

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

References $ctrl, $i, $lng, addTooltip(), ilUtil\getImagePath(), ilRating\getOverallRatingForObject(), ilRating\getRatingForUserAndObject(), getUserId(), and getYourRatingText().

Referenced by getBlockHTML(), and getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetUserRating()

ilRatingGUI::resetUserRating ( )

Reset Rating.

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

725 {
727 $this->obj_id,
728 $this->obj_type,
729 $this->sub_obj_id,
730 $this->sub_obj_type,
731 $this->getUserId()
732 );
733 }
static resetRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
Reset rating for a user and an object.

References getUserId(), and ilRating\resetRatingForUserAndObject().

Referenced by saveRating().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveRating()

ilRatingGUI::saveRating ( )

Save Rating.

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

670 {
671 $ilCtrl = $this->ctrl;
672
673 if (!is_array($_REQUEST["rating"])) {
674 $rating = (int) ilUtil::stripSlashes($_GET["rating"]);
675 if (!$rating) {
676 $this->resetUserRating();
677 } else {
679 $this->obj_id,
680 $this->obj_type,
681 $this->sub_obj_id,
682 $this->sub_obj_type,
683 $this->getUserId(),
684 $rating
685 );
686 }
687 } else {
688 foreach ($_POST["rating"] as $cat_id => $rating) {
690 $this->obj_id,
691 $this->obj_type,
692 $this->sub_obj_id,
693 $this->sub_obj_type,
694 $this->getUserId(),
695 $rating,
696 $cat_id
697 );
698 }
699 }
700
701 if ($this->update_callback) {
702 call_user_func(
703 $this->update_callback,
704 $this->obj_id,
705 $this->obj_type,
706 $this->sub_obj_id,
707 $this->sub_obj_type
708 );
709 }
710
711 if ($ilCtrl->isAsynch()) {
712 exit();
713 }
714 }
$_GET["client_id"]
$_POST["username"]
resetUserRating()
Reset Rating.
static writeRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_rating, $a_category_id=0)
Write rating for a user and an object.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
exit
Definition: login.php:29

References $_GET, $_POST, $ctrl, exit, getUserId(), resetUserRating(), ilUtil\stripSlashes(), and ilRating\writeRatingForUserAndObject().

+ Here is the call graph for this function:

◆ setCtrlPath()

ilRatingGUI::setCtrlPath ( array  $a_value)

ilCtrl path

Parameters
array$a_value

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

163 {
164 $this->ctrl_path = $a_value;
165 }

◆ setExportCallback()

ilRatingGUI::setExportCallback (   $a_callback,
  $a_subobj_title 
)

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

736 {
737 $this->export_callback = $a_callback;
738 $this->export_subobj_title = $a_subobj_title;
739 }

◆ setObject()

ilRatingGUI::setObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id = 0,
  $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 89 of file class.ilRatingGUI.php.

90 {
92
93 if (!trim($a_sub_obj_type)) {
94 $a_sub_obj_type = "-";
95 }
96
97 $this->obj_id = $a_obj_id;
98 $this->obj_type = $a_obj_type;
99 $this->sub_obj_id = $a_sub_obj_id;
100 $this->sub_obj_type = $a_sub_obj_type;
101 $this->id = "rtg_" . $this->obj_id . "_" . $this->obj_type . "_" . $this->sub_obj_id . "_" .
102 $this->sub_obj_type;
103
104 $this->setUserId($ilUser->getId());
105 }
setUserId($a_userid)
Set User ID.
$ilUser
Definition: imgupload.php:18

References $ilUser, $user, and setUserId().

+ Here is the call graph for this function:

◆ setUpdateCallback()

ilRatingGUI::setUpdateCallback (   $a_callback)

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

717 {
718 $this->update_callback = $a_callback;
719 }

◆ setUserId()

ilRatingGUI::setUserId (   $a_userid)

Set User ID.

Parameters
int$a_useridUser ID

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

113 {
114 $this->userid = $a_userid;
115 }

Referenced by setObject().

+ Here is the caller graph for this function:

◆ setYourRatingText()

ilRatingGUI::setYourRatingText (   $a_val)

Set "Your Rating" text.

Parameters
string$a_valtext

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

133 {
134 $this->your_rating_text = $a_val;
135 }

Field Documentation

◆ $ctrl

ilRatingGUI::$ctrl
protected

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

Referenced by executeCommand(), renderDetails(), and saveRating().

◆ $ctrl_path

ilRatingGUI::$ctrl_path
protected

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

◆ $export_callback

ilRatingGUI::$export_callback
protected

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

◆ $export_subobj_title

ilRatingGUI::$export_subobj_title
protected

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

◆ $id

ilRatingGUI::$id = "rtg_"
protected

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

Referenced by addTooltip(), and getHTML().

◆ $lng

ilRatingGUI::$lng
protected

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

Referenced by __construct(), addTooltip(), getHTML(), and renderDetails().

◆ $ui

ilRatingGUI::$ui
protected

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

Referenced by getBlockHTML().

◆ $user

ilRatingGUI::$user
protected

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

Referenced by addTooltip(), and setObject().


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