3 /** @file rating_action.php Handle ratings action.
4 * This file handles a rating action based on input
7 @require_once
("../../includes.php");
9 global $messages, $CFG;
12 $action = optional_param('action',''); // Action - rate etc
13 $rating_ident = optional_param('rating_ident',''); // Ident of the action field
14 $ratedby = optional_param('ratedby',''); // User rating this object
15 $rating = optional_param('rating',''); // Rating they gave it
16 $displaymode = optional_param('displaymode',''); // Display XML or normal (default)
17 $returnurl = urldecode(optional_param('returnurl','')); // The return url
18 $object_id = optional_param('object_id','');
19 $object_type = optional_param('object_type','');
26 if ($action == "rating::add")
29 $success = ratings_storerating($rating_ident, $ratedby, $rating);
34 $messages[] = __gettext("Object rated.");
35 if ($displaymode=="xml")
36 $messages[] = __gettext(" Click here to see the updated rating.");
38 // Hook for the river plugin (if installed)
39 if (function_exists('river_save_event'))
41 $username = "<a href=\"" . river_get_userurl($userid) . "\">" . user_info("username", $userid) . "</a>";
43 river_save_event($userid, $object_id, $userid, $object_type, $username . " " . __gettext("rated") . " " . river_get_friendly_id($object_type, $object_id) );
49 $messages[] = __gettext("Object could not be rated");
52 // Are we outputing XML or text
53 if ($displaymode=="xml")
55 $message = implode(" \n", $messages);
61 $page = "<ajax>\n<message>$message</message>\n<error>$err</error>\n</ajax>\n";
66 <p
>Your rating has been recorded
.</p
>
67 <a href
="$returnurl">Go back
...</a
>
70 templates_page_setup();
72 $page = templates_page_draw(
77 'title' => __gettext("Rating"),
78 'context' => 'contentholder'
89 if ($displaymode=="xml")
90 header("Content-type: text/xml");