aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorHenry Sudhof <kellanved@phpbb.com>2009-06-21 14:31:00 +0000
committerHenry Sudhof <kellanved@phpbb.com>2009-06-21 14:31:00 +0000
commit794e122cfa01539e912786455da59e25d459a56f (patch)
treeac5b8dbb3a82837c501d8930c2d4f03ab7229bce /phpBB/includes/functions_user.php
parentc2c79d8297369fa461976061e0b7b95dd8c8a721 (diff)
downloadforums-794e122cfa01539e912786455da59e25d459a56f.tar
forums-794e122cfa01539e912786455da59e25d459a56f.tar.gz
forums-794e122cfa01539e912786455da59e25d459a56f.tar.bz2
forums-794e122cfa01539e912786455da59e25d459a56f.tar.xz
forums-794e122cfa01539e912786455da59e25d459a56f.zip
add quicktool to remove users from the newly registered special group.
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9646 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 17534376de..bb54a14262 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -3456,4 +3456,77 @@ function group_update_listings($group_id)
}
}
+
+
+/**
+* Funtion to make a user leave the NEWLY_REGISTERED system group.
+* @access public
+* @param $user_id The id of the user to remove from the group
+*/
+function remove_newly_registered($user_id, $user_data = false)
+{
+ global $db;
+
+ if ($user_data === false)
+ {
+ $sql = 'SELECT *
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . $user_id;
+ $result = $db->sql_query($sql);
+ $user_row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if (!$user_row)
+ {
+ return false;
+ }
+ else
+ {
+ $user_data = $user_row;
+ }
+ }
+
+ if (empty($user_data['user_new']))
+ {
+ return false;
+ }
+
+ $sql = 'SELECT group_id
+ FROM ' . GROUPS_TABLE . "
+ WHERE group_name = 'NEWLY_REGISTERED'
+ AND group_type = " . GROUP_SPECIAL;
+ $result = $db->sql_query($sql);
+ $group_id = (int) $db->sql_fetchfield('group_id');
+ $db->sql_freeresult($result);
+
+ if (!$group_id)
+ {
+ return false;
+ }
+
+ // We need to call group_user_del here, because this function makes sure everything is correctly changed.
+ // A downside for a call within the session handler is that the language is not set up yet - so no log entry
+ group_user_del($group_id, $user_id);
+
+ // Set user_new to 0 to let this not be triggered again
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new = 0
+ WHERE user_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ // The new users group was the users default group?
+ if ($user_data['group_id'] == $group_id)
+ {
+ // Which group is now the users default one?
+ $sql = 'SELECT group_id
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . $user_id;
+ $result = $db->sql_query($sql);
+ $user_data['group_id'] = $db->sql_fetchfield('group_id');
+ $db->sql_freeresult($result);
+ }
+
+ return $user_data['group_id'];
+}
+
?> \ No newline at end of file