1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-15 05:24:41 +01:00
git-svn-id: file:///svn/phpbb/trunk@5939 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-05-20 11:41:27 +00:00
parent 86f5226025
commit c81a44ea30
2 changed files with 28 additions and 29 deletions

View File

@ -23,6 +23,8 @@ class ucp_zebra
if ($submit) if ($submit)
{ {
$data = array();
$var_ary = array( $var_ary = array(
'usernames' => array(0), 'usernames' => array(0),
'add' => '', 'add' => '',
@ -38,12 +40,10 @@ class ucp_zebra
); );
$error = validate_data($data, $var_ary); $error = validate_data($data, $var_ary);
extract($data);
unset($data);
if ($add && !sizeof($error)) if ($data['add'] && !sizeof($error))
{ {
$add = explode("\n", $add); $data['add'] = explode("\n", $data['add']);
// Do these name/s exist on a list already? If so, ignore ... we could be // Do these name/s exist on a list already? If so, ignore ... we could be
// 'nice' and automatically handle names added to one list present on // 'nice' and automatically handle names added to one list present on
@ -51,8 +51,8 @@ class ucp_zebra
// may lead to complaints // may lead to complaints
$sql = 'SELECT z.*, u.username $sql = 'SELECT z.*, u.username
FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u FROM ' . ZEBRA_TABLE . ' z, ' . USERS_TABLE . ' u
WHERE z.user_id = ' . $user->data['user_id'] . " WHERE z.user_id = ' . $user->data['user_id'] . '
AND u.user_id = z.zebra_id"; AND u.user_id = z.zebra_id';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$friends = $foes = array(); $friends = $foes = array();
@ -69,32 +69,33 @@ class ucp_zebra
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
$add = array_diff($add, $friends, $foes, array($user->data['username'])); $data['add'] = array_diff($data['add'], $friends, $foes, array($user->data['username']));
unset($friends, $foes); unset($friends, $foes);
$add = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $add)); $data['add'] = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", $data['add']));
if ($add) if ($data['add'])
{ {
$sql = 'SELECT user_id $sql = 'SELECT user_id, user_type
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE username IN (' . $add . ')'; WHERE username IN (' . $data['add'] . ')
AND user_type NOT IN (' . USER_IGNORE . ', ' . USER_INACTIVE . ')';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) $user_id_ary = array();
while ($row = $db->sql_fetchrow($result))
{ {
$user_id_ary = array(); if ($row['user_id'] != ANONYMOUS)
do
{ {
if ($row['user_id'] != ANONYMOUS) $user_id_ary[] = $row['user_id'];
{
$user_id_ary[] = $row['user_id'];
}
} }
while ($row = $db->sql_fetchrow($result)); }
$db->sql_freeresult($result);
if (sizeof($user_id_ary))
{
// Remove users from foe list if they are admins or moderators // Remove users from foe list if they are admins or moderators
if (($mode == 'foes') && sizeof($user_id_ary)) if ($mode == 'foes')
{ {
$perms = array(); $perms = array();
foreach ($auth->acl_get_list($user_id_ary, array('a_', 'm_')) as $forum_id => $forum_ary) foreach ($auth->acl_get_list($user_id_ary, array('a_', 'm_')) as $forum_id => $forum_ary)
@ -153,20 +154,18 @@ class ucp_zebra
} }
else else
{ {
$error[] = 'USER_NOT_FOUND'; $error[] = 'USER_NOT_FOUND_OR_INACTIVE';
} }
$db->sql_freeresult($result);
} }
} }
else if ($usernames && !sizeof($error)) else if (sizeof($data['usernames']) && !sizeof($error))
{ {
// Force integer values // Force integer values
$usernames = array_map('intval', $usernames); $data['usernames'] = array_map('intval', $data['usernames']);
$sql = 'DELETE FROM ' . ZEBRA_TABLE . ' $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . ' WHERE user_id = ' . $user->data['user_id'] . '
AND zebra_id IN (' . implode(', ', $usernames) . ')'; AND zebra_id IN (' . implode(', ', $data['usernames']) . ')';
$db->sql_query($sql); $db->sql_query($sql);
} }
@ -200,7 +199,7 @@ class ucp_zebra
$template->assign_vars(array( $template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_ZEBRA_' . strtoupper($mode)], 'L_TITLE' => $user->lang['UCP_ZEBRA_' . strtoupper($mode)],
'U_SEARCH_USER' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=searchuser&form=ucp&field=add", 'U_SEARCH_USER' => "{$phpbb_root_path}memberlist.$phpEx$SID&mode=searchuser&form=ucp&field=add",
'S_USERNAME_OPTIONS' => $s_username_options, 'S_USERNAME_OPTIONS' => $s_username_options,
'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_HIDDEN_FIELDS' => $s_hidden_fields,

View File

@ -415,7 +415,7 @@ $lang = array_merge($lang, array(
'USERNAME_CHARS_ANY_EXPLAIN' => 'Length must be between %1$d and %2$d characters.', 'USERNAME_CHARS_ANY_EXPLAIN' => 'Length must be between %1$d and %2$d characters.',
'USERNAME_TAKEN_USERNAME' => 'The username you entered is already in use, please select an alternative.', 'USERNAME_TAKEN_USERNAME' => 'The username you entered is already in use, please select an alternative.',
'USERNAME_USERNAME_DISALLOWED' => 'The username you entered has been banned.', 'USERNAME_USERNAME_DISALLOWED' => 'The username you entered has been banned.',
'USER_NOT_FOUND' => 'The usernames you specified could not be found.', 'USER_NOT_FOUND_OR_INACTIVE' => 'The usernames you specified could either not be found or are not activated users.',
'VIEW_AVATARS' => 'Display Avatars', 'VIEW_AVATARS' => 'Display Avatars',
'VIEW_EDIT' => 'View/Edit', 'VIEW_EDIT' => 'View/Edit',