From d9576fd70ba9f60c99a2ece5e520b309a86f7362 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 23 Apr 2006 13:08:48 +0000 Subject: [PATCH] - allow user A to have user B as a friend if A is a foe of B - don't allow users to have the Anonymous user on their foe/friend list [Bug #1205] - properly hide users on the online/offline friend list in ucp [Bug #1206] git-svn-id: file:///svn/phpbb/trunk@5836 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/ucp/ucp_zebra.php | 30 +++++------------------------- phpBB/language/en/ucp.php | 4 ++-- phpBB/ucp.php | 6 +++--- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index cfe1fb9071..e061aa590c 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -87,12 +87,15 @@ class ucp_zebra $user_id_ary = array(); do { - $user_id_ary[] = $row['user_id']; + if ($row['user_id'] != ANONYMOUS) + { + $user_id_ary[] = $row['user_id']; + } } while ($row = $db->sql_fetchrow($result)); // Remove users from foe list if they are admins or moderators - if ($mode == 'foes') + if (($mode == 'foes') && sizeof($user_id_ary)) { $perms = array(); foreach ($auth->acl_get_list($user_id_ary, array('a_', 'm_')) as $forum_id => $forum_ary) @@ -108,29 +111,6 @@ class ucp_zebra unset($perms); } - // Do not let add users to friends if the user is within the foes list of the to-be-added users - if ($mode == 'friends' && sizeof($user_id_ary)) - { - $sql = 'SELECT user_id - FROM ' . ZEBRA_TABLE . ' - WHERE user_id IN (' . implode(', ', $user_id_ary) . ') - AND zebra_id = ' . $user->data['user_id'] . ' - AND foe = 1'; - $result = $db->sql_query($sql); - - $remove_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $remove_user_ids[] = $row['user_id']; - } - - if (sizeof($remove_user_ids)) - { - $user_id_ary = array_diff($user_id_ary, $remove_user_ids); - } - unset($remove_user_ids); - } - if (sizeof($user_id_ary)) { $sql_mode = ($mode == 'friends') ? 'friend' : 'foe'; diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 5f5db94f07..20976a3875 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -242,8 +242,8 @@ $lang = array_merge($lang, array( 'NOTIFY_METHOD_EXPLAIN' => 'Method for sending messages sent via this board.', 'NOTIFY_METHOD_IM' => 'Jabber only', 'NOTIFY_ON_PM' => 'Email me on new private messages', - 'NOT_ADDED_FRIENDS' => 'Usernames not added to friends list because you are within their foes list.', - 'NOT_ADDED_FOES' => 'Usernames not added to foes list because of administrator/moderator status.', + 'NOT_ADDED_FRIENDS' => 'You cannot add the anonymous user to your friends list.', + 'NOT_ADDED_FOES' => 'Usernames not added to foes list because of administrator/moderator status or because you tried to add the anonymous user.', 'NOT_AGREE' => 'I do not agree to these terms', 'NOT_ENOUGH_SPACE_FOLDER' => 'The Destination Folder "%s" seems to be full. The requested action has not been taken.', 'NOT_MOVED_MESSAGE' => 'You have 1 private message currently on hold because of full folder.', diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 9775e5fd81..65e9adaabe 100755 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -243,18 +243,18 @@ if (!$user->data['is_registered']) // Output listing of friends online $update_time = $config['load_online_time'] * 60; -$sql = 'SELECT DISTINCT u.user_id, u.username, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline +$sql = 'SELECT DISTINCT u.user_id, u.username, u.user_allow_viewonline, MAX(s.session_time) as online_time, MIN(s.session_viewonline) AS viewonline FROM (' . USERS_TABLE . ' u, ' . ZEBRA_TABLE . ' z) LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = z.zebra_id) WHERE z.user_id = ' . $user->data['user_id'] . ' AND z.friend = 1 AND u.user_id = z.zebra_id - GROUP BY z.zebra_id, u.user_id, u.username'; + GROUP BY z.zebra_id, u.user_id, u.username, u.user_allow_viewonline'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - $which = (time() - $update_time < $row['online_time'] && $row['viewonline']) ? 'online' : 'offline'; + $which = (time() - $update_time < $row['online_time'] && $row['viewonline'] && $row['user_allow_viewonline']) ? 'online' : 'offline'; $template->assign_block_vars("friends_{$which}", array( 'U_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=viewprofile&u=" . $row['user_id'],