Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looking through your code, I assume you want to drive the friendships from a database. I don't quite see the relevance of a lot of the code posted but I can make a few recommendations:</p> <p><strong>Write a function to return the friendship "status"</strong></p> <p>I guess you'll be wanting to do similar things (content-hiding/primitive privacy) elsewhere, so this'll hopefully be useful. Obviously I can't test this but something like:</p> <pre><code>function checkUserFriendship($user1,$user2) { $sql = "SELECT status FROM friends WHERE user1_id = $user1 AND user2_id = $user2 OR user1_id = $user2 AND user2_id = $user1"; $query = mysql_query($sql); $data = mysql_fetch_array($query); return $data['status']; } </code></pre> <p>Now, I highly doubt that will work straight off, but what it would (hopefully) achieve is returning the "status" field you have in the "friends" table. You could then use this when outputting. For instance:</p> <pre><code>$friendshipStatus = checkUserFriendship($user1,$user2); switch($friendshipStatus){ case "accepted": //Show something break; case "pending": //Show "pending" message break; case 0: //Show nothing (or an error message) break; } </code></pre> <p>This might not be what you are looking for, but it's how I would tackle the situation. It looks like you may have already done this with the line containing</p> <pre><code>rawfeeds_user_core::check_active_friends </code></pre> <p>but you posted a lot of code and I'm not entirely sure how it all pieces together.</p> <p><strong>Use Of Globals</strong></p> <p>This is a side note, but I'd avoid the use of defined globals. It doesn't look like they serve a purpose here.</p> <p><strong>Unnecessary Code (?)</strong></p> <p>In your user streams (let us refer to them as that) you have a huge block of code constructing the "IN (n,n,n,n)" part of the SQL to only select certain friends. I imagine this is necessary on the global / public / "News Feed" part of the site but I can't see where you use it. (It may be an oversight / just stupidity on my part!)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload