aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-03-02 19:48:16 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-03-02 19:48:16 +0000
commit2f8b3797c66e83dd15de4d616612a8c9f60dd808 (patch)
treedfe8532fbcb756a7e12559d96fecca331b4a09cd /phpBB/includes
parent5cdf74ea0c8af4f9437824cb5d396d60004bf056 (diff)
downloadforums-2f8b3797c66e83dd15de4d616612a8c9f60dd808.tar
forums-2f8b3797c66e83dd15de4d616612a8c9f60dd808.tar.gz
forums-2f8b3797c66e83dd15de4d616612a8c9f60dd808.tar.bz2
forums-2f8b3797c66e83dd15de4d616612a8c9f60dd808.tar.xz
forums-2f8b3797c66e83dd15de4d616612a8c9f60dd808.zip
- update_foes() now can be given a user or a group. This should make some operations much faster
git-svn-id: file:///svn/phpbb/trunk@7109 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/acp/acp_permissions.php4
-rw-r--r--phpBB/includes/functions_admin.php90
-rw-r--r--phpBB/includes/functions_user.php2
3 files changed, 92 insertions, 4 deletions
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index b0a163fc60..225daf01c6 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -659,7 +659,7 @@ class acp_permissions
// Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_')
{
- update_foes();
+ update_foes($group_id, $user_id);
}
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id);
@@ -726,7 +726,7 @@ class acp_permissions
// Remove users who are now moderators or admins from everyones foes list
if ($permission_type == 'm_' || $permission_type == 'a_')
{
- update_foes();
+ update_foes($group_id, $user_id);
}
$this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids);
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 074d8456be..99135eeadb 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2401,10 +2401,98 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
/**
* Update foes - remove moderators and administrators from foe lists...
*/
-function update_foes()
+function update_foes($group_id = false, $user_id = false)
{
global $db, $auth;
+ // update foes for some user
+ if (is_array($user_id) && sizeof($user_id))
+ {
+ $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
+ WHERE ' . $db->sql_in_set('zebra_id', $user_id) . '
+ AND foe = 1';
+ $db->sql_query($sql);
+ return;
+ }
+
+ // update foes for some group
+ if (is_array($group_id) && sizeof($group_id))
+ {
+ // Grab group settings...
+ $sql = $db->sql_build_query('SELECT', array(
+ 'SELECT' => 'a.group_id',
+
+ 'FROM' => array(
+ ACL_OPTIONS_TABLE => 'ao',
+ ACL_GROUPS_TABLE => 'a'
+ ),
+
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(ACL_ROLES_DATA_TABLE => 'r'),
+ 'ON' => 'a.auth_role_id = r.role_id'
+ ),
+ ),
+
+ 'WHERE' => '(ao.auth_option_id = a.auth_option_id OR ao.auth_option_id = r.auth_option_id)
+ AND ' . $db->sql_in_set('a.group_id', $group_id) . "
+ AND ao.auth_option IN ('a_', 'm_')",
+
+ 'GROUP_BY' => 'a.group_id'
+ ));
+ $result = $db->sql_query($sql);
+
+ $groups = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $groups[] = (int) $row['group_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (!sizeof($groups))
+ {
+ return;
+ }
+
+ switch ($db->sql_layer)
+ {
+ case 'mysqli':
+ case 'mysql4':
+ $sql = 'DELETE z.*
+ FROM ' . ZEBRA_TABLE . ' z, ' . USER_GROUP_TABLE . ' ug
+ WHERE z.zebra_id = ug.user_id
+ AND z.foe = 1
+ AND ' . $db->sql_in_set('ug.group_id', $groups);
+ $db->sql_query($sql);
+ break;
+
+ default:
+ $sql = 'SELECT user_id
+ FROM ' . USER_GROUP_TABLE . '
+ WHERE ' . $db->sql_in_set('group_id', $groups);
+ $result = $db->sql_query($sql);
+
+ $users = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $users[] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($users))
+ {
+ $sql = 'DELETE FROM ' . ZEBRA_TABLE . '
+ WHERE ' . $db->sql_in_set('zebra_id', $users) . '
+ AND foe = 1';
+ $db->sql_query($sql);
+ }
+ break;
+ }
+
+ return;
+ }
+
+ // update foes for everyone
$perms = array();
foreach ($auth->acl_get_list(false, array('a_', 'm_'), false) as $forum_id => $forum_ary)
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 3e3ee90c1b..31226ac30c 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -2519,7 +2519,7 @@ function group_update_listings($group_id)
global $phpbb_root_path, $phpEx;
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
}
- update_foes();
+ update_foes(array($group_id));
}
}