diff options
author | Meik Sievertsen <acydburn@phpbb.com> | 2005-06-10 18:57:21 +0000 |
---|---|---|
committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-06-10 18:57:21 +0000 |
commit | e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a (patch) | |
tree | 46afcc3a92fe0b61f83d35a854fe4d663915f95c /phpBB/includes/functions_user.php | |
parent | d24f5d734b2a2f059005ce45241d6564fea047e3 (diff) | |
download | forums-e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a.tar forums-e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a.tar.gz forums-e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a.tar.bz2 forums-e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a.tar.xz forums-e6469bb0d0bc7cdb7a237fab5cc2056517b8be4a.zip |
- log removing posts
- fix queue saving if package size is 0
- user memberships (not used atm)
git-svn-id: file:///svn/phpbb/trunk@5157 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r-- | phpBB/includes/functions_user.php | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index c2146d2e5a..b9e462e76b 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1267,7 +1267,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false, case 'mssql': case 'sqlite': $sql = 'INSERT INTO ' . USER_GROUP_TABLE . " (user_id, group_id, group_leader) - " . implode(' UNION ALL ', preg_replace('#^([0-9]+)$#', "(\\1, $group_id, $leader)", $add_id_ary)); + VALUES " . implode(', ', preg_replace('#^([0-9]+)$#', "(\\1, $group_id, $leader)", $add_id_ary)); $db->sql_query($sql); break; @@ -1677,26 +1677,58 @@ function group_user_attributes($action, $group_id, $user_id_ary = false, $userna } /** -* Obtain either the members of a specified group or the groups to -* which the specified users are members +* Obtain either the members of a specified group, the groups the specified user is subscribed to +* or checking if a specified user is in a specified group +* +* Note: Extend select statement as needed +* Note2: Never use this more than once... first group your users/groups */ -function group_memberships($group_id = false, $user_id_ary = false) +function group_memberships($group_id_ary = false, $user_id_ary = false, $return_bool = false) { global $db; - if (!$group_id && !$user_id_ary) + if (!$group_id_ary && !$user_id_ary) { return true; } - if ($group_id) + $sql = 'SELECT group_id, user_id + FROM ' . USER_GROUP_TABLE . ' + WHERE '; + + if ($group_id_ary && $user_id_ary) + { + $sql .= " group_id " . ((is_array($group_id_ary)) ? ' IN (' . implode(', ', $group_id_ary) . ')' : " = $group_id_ary") . " + AND user_id " . ((is_array($user_id_ary)) ? ' IN (' . implode(', ', $user_id_ary) . ')' : " = $user_id_ary"); + } + else if ($group_id) { + $sql .= " group_id " . ((is_array($group_id_ary)) ? ' IN (' . implode(', ', $group_id_ary) . ')' : " = $group_id_ary"); } else if ($user_id_ary) { + $sql .= " user_id " . ((is_array($user_id_ary)) ? ' IN (' . implode(', ', $user_id_ary) . ')' : " = $user_id_ary"); } + + $result = ($return_bool) ? $db->sql_query_limit($sql, 1) : $db->sql_query($sql); + + $row = $db->sql_fetchrow($result); - return false; + if ($return_bool) + { + $db->sql_freeresult($result); + return ($row) ? true : false; + } + + $result = array(); + + do + { + $result[] = $row; + } + while ($row = $db->sql_fetchrow($result)); + + return $result; } ?>
\ No newline at end of file |