Esempio n. 1
0
 /**
  * Returns the average rating information across the uids.
  *
  * @param int $iid the item used to calculate the average
  * @param array $uids the uids used to retrieve the ratings to calculate the average, otherwise default to all users
  * 
  * public function ratings_getAverage($iid, $uids = null)
  */
 public function execute()
 {
     $vote = Api_Bo_Ratings::getAverage($this->getAppId(), $this->item_id, $this->uids);
     $retVal = array();
     $retVal['rating'] = array();
     $retVal['rating'][0] = array('iid' => $this->item_id, 'average_vote' => $vote);
     return $retVal;
 }
Esempio n. 2
0
 /**
  * Gets the rating given for an item by one or more users, or for the logged in user.
  *
  * Data format:
  * <code>
  * 
  * </code>
  * @param array $iids the items that are being rated
  * @param array $uids optional - the list of users to retrieve ratings for. Defaults to the logged in user if not provided
  * @return array of ratings
  * 
  * public function ratings_get($iids, $uids = null)
  */
 public function execute()
 {
     $ratings = Api_Bo_Ratings::getRatings($this->getAppId(), $this->item_ids, $this->uids);
     $retVal = array();
     if (count($ratings) > 0) {
         $retVal['rating'] = array();
         $i = 0;
         foreach ($ratings as $rating) {
             $retVal['rating'][$i++] = array('uid' => $rating['uid'], 'iid' => $rating['item_id'], 'vote' => $rating['vote']);
         }
     }
     return $retVal;
 }
Esempio n. 3
0
 /**
  * Sets the user's rating for an item.
  *
  * @param int $iid the item to rate
  * @param number $vote the score given by the user for the item
  * 
  * public function ratings_set($iid, $vote)
  */
 public function execute()
 {
     $ret = Api_Bo_Ratings::setRating($this->getAppId(), $this->getUserId(), $this->iid, $this->vote);
     $response['result'] = $ret ? '1' : '0';
     return $response;
 }