public function add($domain_key, $owner_uid, $target_uid)
 {
     // error_log('in the add method of better friends **********');
     // error_log("domain=".$domain_key." owner=".$owner_uid." target=".$target_uid);
     if (!$domain_key || !$owner_uid || !$target_uid) {
         return false;
     } elseif (is_array($this->get($domain_key, $owner_uid)) && array_search($target_uid, $this->get($domain_key, $owner_uid)) !== false) {
         return false;
     }
     // if the owner_uid and target_uid are already friends
     $friend = new RingsideFriend();
     $friend->domain_key = $domain_key;
     $friend->from_id = $owner_uid;
     $friend->to_id = $target_uid;
     $friend->access = 1;
     $friend->status = 2;
     if ($friend->trySave()) {
         return true;
     } else {
         throw new Exception("[BetterFriendsImpl] could not create friend with domain={$domain_key}, owner_uid={$owner_uid}, target_uid={$target_uid}");
     }
 }
Example #2
0
 /**
  * Accept a friend invite
  *
  * @param unknown_type $uid
  * @param unknown_type $fuid
  * @param unknown_type $access
  * @param unknown_type $dbCon
  */
 public static function acceptInvite($uid, $fuid, $status, $access)
 {
     $q = Doctrine_Query::create();
     $q->from('RingsideFriend f')->where("from_id={$fuid} AND to_id={$uid}");
     $f = $q->execute();
     // If there is no outstanding connection, create one; this enables email invites
     if ($f == null || sizeof($f) == 0) {
         $f = new RingsideFriend();
         $f->from_id = $fuid;
         $f->to_id = $uid;
         $f->status = $status;
         $f->access = $access;
     } else {
         $f[0]['status'] = $status;
         $f[0]['access'] = $access;
     }
     $f->save();
 }