Example #1
0
function api_canvas_parameters_other($app_id, $user)
{
    // Add the list of friends and the friends who've added the app
    // to the POST we make
    $app_info = application_get_info($app_id);
    $api_friends = user_get_all_friends($user);
    foreach ($api_friends as $k => $friend) {
        if (!platform_can_see_app($app_id, $friend, $app_info)) {
            unset($api_friends[$k]);
        }
    }
    $csv_api_friends = implode(',', $api_friends);
    return array('friends' => $csv_api_friends);
}
Example #2
0
 public function friends_getAppUsers()
 {
     $friend_list = user_get_all_friends($this->user_id);
     $result = array();
     foreach ($friend_list as $friend_id) {
         if (platform_app_has_full_permission($this->app_id, $friend_id)) {
             $result[] = $friend_id;
         }
     }
     return $result;
 }
Example #3
0
/**
 * Dummy helper function for sample implementation.
 * Returns whether or not $id1 and $id2 are friends.
 *
 * @param  $id1 first user
 * @param  $id2 second user
 * @return boolean, true if $id1 and $id2 are friends
 */
function are_friends($id1, $id2)
{
    $friends = user_get_all_friends($id1);
    return in_array($id2, $friends);
}
Example #4
0
 /**
  * Dummy helper function for sample implementation that fetches
  * all rows where $id is one of the friends. The parameter $pos
  * indicates whether we are looking for $id to be uid1 or uid2
  * ($pos has a value of either 0 or 1), so that the id returned
  * is of the correct format.
  * Fills in the appropriate field in $result (passed by reference)
  *
  * Enforces the restriction that you can only request all friends of
  * a user if that is the currently logged in user.
  *
  * @param  $id1 first user
  * @param  $id2 second user
  * @return boolean, true if $id1 and $id2 are friends
  */
 private function get_all_friends($id, $pos, &$result)
 {
     if ($this->user != $id) {
         throw new NoIndexFunctionException("Can't lookup all friends of {$id}; only for the logged in user(" . $this->user . ") or for pairs of users.");
     }
     $friend_arr = user_get_all_friends($id);
     foreach ($friend_arr as $friend) {
         if ($pos == 0) {
             $result["{$id}:{$friend}"] = 1;
         } else {
             $result["{$friend}:{$id}"] = 1;
         }
     }
 }