Is there a more efficient way to do this? It checks to see if a user has set an option to auto-accept friend invites
The privacy filed in the DB can contain:
NULL
2
2,8
2,8,9
2,7,8,9
anywhere from no numbers, up to 4 number seperated by a comma , in any order it just checks to see for this particular function if the number 8 exist
function checkautoapprovfriend($userid) {
// according to privacy setting
$autofriend_arr_id1 = "8" . ",";
$autofriend_arr_id2 = "," . "8" . ",";
$autofriend_arr_id3 = "," . "8";
$autofriend_arr_id4 = "8";
$privacy = "select user_id,privacy from friend_acc_setting where (privacy like '$autofriend_arr_id1%' or privacy like '%$autofriend_arr_id2%' or privacy like '%$autofriend_arr_id3' or privacy='$autofriend_arr_id4') and user_id='$userid'";
$result_privacy = executequery($privacy);
if (mysql_num_rows($result_privacy) > 0)
return true;
else
return false;
}
when I echo the query here is what it looks like for friend ID 1
select user_id,privacy from friend_acc_setting where (privacy like '8,%' or privacy like '%,8,%' or privacy like '%,8' or privacy='8') and user_id='1'