Write rating for a user and an object.
{
global $ilDB;
if ($a_user_id == ANONYMOUS_USER_ID)
{
return;
}
if($a_category_id)
{
$ilDB->manipulate("DELETE FROM il_rating WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote((int) $a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true)." AND ".
"category_id = ".$ilDB->quote(0, "integer"));
}
$ilDB->manipulate("DELETE FROM il_rating WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote((int) $a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true)." AND ".
"category_id = ".$ilDB->quote((int) $a_category_id, "integer"));
$ilDB->manipulate("INSERT INTO il_rating (user_id, obj_id, obj_type,".
"sub_obj_id, sub_obj_type, category_id, rating, tstamp) VALUES (".
$ilDB->quote($a_user_id, "integer").",".
$ilDB->quote((int) $a_obj_id, "integer").",".
$ilDB->quote($a_obj_type, "text").",".
$ilDB->quote((int) $a_sub_obj_id, "integer").",".
$ilDB->quote($a_sub_obj_type, "text").",".
$ilDB->quote($a_category_id, "integer").",".
$ilDB->quote((int) $a_rating, "integer").",".
$ilDB->quote(time(), "integer").")");
}