private function loadTopicsAndSuggestions($application)
 {
     if (!empty($this->suggestions)) {
         return;
     }
     $restClient = $application->getClient();
     $suggestionClient = new SuggestionClient($restClient);
     $friends = $restClient->friends_get();
     $friends[] = $application->getCurrentUser();
     //add current user to list of friends in order to get suggestions of current user as well as their friends
     //	   $this->suggestions = $suggestionClient->suggestion_get( $application->getApplicationId(), $friends );
     $this->suggestions = $suggestionClient->suggestion_get('yaya', $friends);
     $this->topics = array();
     if (!empty($this->suggestions)) {
         foreach ($this->suggestions as $suggestion) {
             if (!in_array(array($suggestion['owneruid'], $suggestion['topic']), $this->topics)) {
                 $this->topics[] = array($suggestion['owneruid'], $suggestion['topic']);
             }
         }
     }
 }
Example #2
0
    // Topics are messed up for new topics
    if (isset($_REQUEST['existingtopic']) && $_REQUEST['existingtopic'] != 'none') {
        $str = $_REQUEST['existingtopic'];
        // comes in the form ownerid:topic
        $pos = strpos($str, ':');
        if ($pos) {
            $ownerid = substr($str, 0, $pos);
            $topic = substr($str, $pos + 1, strlen($str));
        } else {
            throw new Exception("Invalid existing topic syntax: {$str}");
        }
    } else {
        $topic = $_REQUEST['newtopic'];
        $ownerid = $userid;
    }
    $suggestionClient = new SuggestionClient($ringside->api_client);
    $result = $suggestionClient->suggestion_add($topic, $ownerid, 'yaya', $suggestion);
} else {
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'rate') {
        if (isset($_REQUEST['iid']) & isset($_REQUEST['vote'])) {
            $iid = $_REQUEST['iid'];
            $vote = $_REQUEST['vote'];
            // Using a null type, type allows you to put things in buckets
            // For instance, type could equal a bookmark.  But, ratings are app
            // specific, so since we only have 1 type we can leave it null.
            $rest = new RingsideRestClient($ringside->api_client);
            $rest->ratings_set($iid, $vote, null);
        } else {
            error_log("Rating error, bad params!");
        }
    }