public function user_friends($uid, $startresults = 0, $totalresults = 20, $orderby = "friend", $orderdirection = "DESC", $ignoreusers = 0)
 {
     $db = new Database();
     $db->connect();
     $sess = new SessionData('account');
     $id = $sess->Retrieve('id');
     if ($id == $uid) {
         // run my_friends now to return more results than just user ids
         $myfriends = Relationship::my_friends($startresults, $totalresults, $orderby, $orderdirection, $ignoreusers);
         return $myfriends;
     }
     $relationshipquery = "\n\t\t\t\t\t(select distinct SQL_CALC_FOUND_ROWS\n\t\t\t\t\tr.senderid as friend\n\t\t\t\t\tfrom relationship r\n\t\t\t\t\tjoin user u on u.id=r.senderid\n\t\t\t\t\tWHERE r.receiverid IN (" . $uid . ")\n\t\t\t\t\tand r.senderid NOT IN (" . $ignoreusers . ")\n\t\t\t\t\tand r.senderid != '" . $id . "'\n\t\t\t\t\tand r.confirmed=1\n\t\t\t\t\tand u.accountstatusid>1)\n\t\t\t\t\tUNION\n\t\t\t\t\t(select distinct \n\t\t\t\t\tr.receiverid as friend\n\t\t\t\t\tfrom relationship r\n\t\t\t\t\tjoin user u on u.id=r.receiverid\n\t\t\t\t\tWHERE r.senderid IN (" . $uid . ")\n\t\t\t\t\tand r.receiverid NOT IN (" . $ignoreusers . ")\n\t\t\t\t\tand r.receiverid != '" . $id . "'\n\t\t\t\t\tand r.confirmed=1\n\t\t\t\t\tand u.accountstatusid>1)\n\t\t\t\t\torder by " . $orderby . " " . $orderdirection . "\n\t\t\t\t\tlimit " . $startresults . ", " . $totalresults . "\n\t\t\t\t\t";
     $db->query($relationshipquery);
     $tmp = $db->getresult();
     if ($tmp[0]['friend'] < 1) {
         $tmp2[0]['friend'] = $tmp['friend'];
     } else {
         $tmp2 = $tmp;
     }
     $farray = array();
     foreach ($tmp2 as $spaceid => $frienddata) {
         $farray[$spaceid] = $frienddata['friend'];
     }
     Profile::set_totalrows($db->getTotalRows());
     //if($farray[0]<1) $farray[0]=$id;
     return $farray;
 }
Example #2
0
 public function viewable_profile($uid)
 {
     if ($uid == 4) {
         return "Master and Commander";
     }
     $sess = new SessionData('account');
     $id = $sess->Retrieve('id');
     if ($id == $uid) {
         return "This is you.";
     }
     $relation = new Relationship();
     $their_friends = $relation->user_friends($uid, 0, 5000);
     $my_friends = $relation->my_friends();
     $connections = count(array_intersect($my_friends, $their_friends));
     $retvalue = $relation->find_connection($uid);
     if ($retvalue) {
         $retvalue .= "<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
         if ($connections != 1) {
             $retvalue .= "s";
         }
         $retvalue .= "</a> in common.";
         return $retvalue;
     }
     if ($connections > 0) {
         $retvalue = "This is a friend of a friend.<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
         if ($connections != 1) {
             $retvalue .= "s";
         }
         $retvalue .= "</a> in common.";
         return $retvalue;
     }
     $pendingrequest = $relation->pending_requests();
     if (in_array($uid, $pendingrequest)) {
         $retvalue = "Pending Request.<br>You have <a href='search.php?mfriends={$uid}&hide=y'>" . $connections . " friend";
         if ($connections != 1) {
             $retvalue .= "s";
         }
         $retvalue .= "</a> in common.";
         return $retvalue;
     }
     return FALSE;
 }