<?php /** ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [filename] is a part of PeopleAggregator. * [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ $login_required = TRUE; //including necessary files $use_theme = 'Beta'; //TODO : Remove this when new UI is completely implemented. include_once "web/includes/page.php"; require 'api/Rating/Rating.php'; $Rating = new Rating(); if (!empty($_POST)) { $Rating->set_rating_type(@$_POST['rating_type']); $Rating->set_type_id(@(int) $_POST['type_id']); $Rating->set_rating(@(int) $_POST['rating']); $Rating->set_max_rating(@(int) $_POST['max_rating']); $Rating->set_user_id(@(int) $login_uid); $Rating->rate(); $rating = rating(@$_POST['rating_type'], @(int) $_POST['type_id']); print $rating['overall']; }
function render_for_ajax() { $this->anon = TRUE; if (!empty(PA::$login_user)) { $login_id = PA::$login_user->user_id; $this->anon = FALSE; } switch ($this->params["op"]) { /* case "add_oneliner": Oneliners::create( @(int)$login_id, $this->params['genre'], (int)$this->params['rating'], $this->params['body'], TRUE); // change to FALSE for production once we have approval UI $this->note = __("Your One-liner submission was received - thank you for participating!") . " \n" . __("Your submisssion will appear if it is approved by our staff."); break; */ case "add_rating": if ($this->anon) { $this->err = __("Please log in or register to add ratings!"); break; } $rating = new Rating(); $this->subject_type = $this->params['subject_type']; $this->subject_id = $this->params['subject_id']; $rating->set_rating_type($this->subject_type); $rating->set_type_id($this->subject_id); $rating->set_rating((int) $this->params['rating']); $rating->set_max_rating(5); $rating->set_user_id(@(int) $login_id); try { $rating->rate(); // for rivers of people $activity = 'user_post_a_rating'; $extra = serialize(array('info' => PA::$login_user->login_name . ' posted a rating.', 'subject_type' => $this->subject_type, 'subject_id' => $this->subject_id)); Activities::save(PA::$login_uid, $activity, -1, $extra, array($activity)); } catch (PAException $e) { return $e->getMessage(); break; } $this->note = __("Rating was added - thank you for participating!"); // $this->add_oneliner = true; // flag it so we can ask for Onle-liner break; default: // just ignore unknown ops break; } return $this->render(); }