Ejemplo n.º 1
0
 public function friends_areFriends($ids1, $ids2)
 {
     $ids1 = $this->get_ids_from_list($ids1);
     $ids2 = $this->get_ids_from_list($ids2);
     $count = count($ids1);
     if (count($ids2) != $count) {
         $this->throw_code(api10_FacebookApiErrorCode::API_EC_PARAM);
     }
     $result = array();
     for ($i = 0; $i < $count; $i++) {
         $id1 = $ids1[$i];
         $id2 = $ids2[$i];
         if (!is_numeric($id1) || !is_numeric($id2)) {
             $this->throw_code(api10_FacebookApiErrorCode::API_EC_PARAM);
         }
         $result[$i] = new api10_friend_info(array('uid1' => $id1, 'uid2' => $id2, 'are_friends' => are_friends($id1, $id2)));
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Dummy privacy function that enforces privacy restrictions:
  * users can see data about themselves or their friends.
  */
 public function can_see($id)
 {
     if ($this->user == $id) {
         return true;
     }
     if ($this->user) {
         return are_friends($this->user, $id);
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Intersects two queries for this dummy implementation of
  * the friends table.
  *
  * A query for this table has the format uid1:uid2.
  * The following queries translate to these logical meanings:
  * ':'     => matches all rows in the table
  * '17:'   => matches all rows where uid1 = 17, a.k.a. all of 17's friends
  * ':21'   => matches all rows where uid2 = 21, a.k.a. all of 21's friends
  * '18:21' => matches rows where uid1 = 18 and uid2 = 21, only returns
  *            a row if 18 and 21 are friends
  *
  * Queries are intersected to return a single query that fulfills
  * the constraints expressed in the original queries. If no single
  * query can fulfill all the constraints (e.g. intersecting '17:' and
  * '18:' then it returns false. This function also performs an are_friends
  * check before returning a query of the form ('18:21') to ensure
  * that the two ids are indeed friends.
  */
 public function intersect_queries($query1, $query2)
 {
     $q1_arr = explode(':', $query1);
     $q2_arr = explode(':', $query2);
     $result_arr = array();
     if ($q1_arr[0]) {
         if ($q2_arr[0] && $q1_arr[0] != $q2_arr[0]) {
             return false;
         }
         $res_arr[0] = $q1_arr[0];
     } else {
         $res_arr[0] = $q2_arr[0];
     }
     if ($q1_arr[1]) {
         if ($q2_arr[1] && $q1_arr[1] != $q2_arr[1]) {
             return false;
         }
         $res_arr[1] = $q1_arr[1];
     } else {
         $res_arr[1] = $q2_arr[1];
     }
     if ($res_arr[0] && $res_arr[1] && !are_friends($res_arr[0], $res_arr[1])) {
         return false;
     }
     return implode(':', $res_arr);
 }
Ejemplo n.º 4
0
 public function can_see($id)
 {
     list($flid, $uid) = explode(':', $id);
     return friend_list_is_owner($flid, $this->user) && are_friends($this->user, $uid);
 }