function rate_article() { $user = JFactory::getUser(); if (!$user->authorise('articles.rate', CJBLOG)) { echo json_encode(array('error' => JText::_('JERROR_ALERTNOAUTHOR'))); } else { $app = JFactory::getApplication(); $id = $app->input->getInt('id'); $rating = $app->input->getFloat('rating'); if ($id > 0 && $rating > 0) { $return = CJFunctions::store_rating(CJBLOG_ASSET_ID, $id, $rating, $user->id); if ($return) { $hash = CJFunctions::get_hash('com_content.article.rating.item_' . $id); $domain = JRoute::_(ContentHelperRoute::getArticleRoute($id)); $app->input->cookie->set($hash, 1, time() + 60 * 60 * 24 * 365, $domain); echo json_encode(array('data' => JText::_('MSG_THANK_YOU_FOR_RATING'))); } else { if ($return == -1) { echo json_encode(array('error' => JText::_('MSG_ALREADY_RATED'))); } else { echo json_encode(array('error' => JText::_('MSG_ERROR_PROCESSING') . ' - Error Code: 1.')); } } } else { echo json_encode(array('error' => '')); } } jexit(); }