Created
June 18, 2010 11:33
-
-
Save erikfrerejean/443531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @package phpBB3 | |
* @copyright (c) 2010 Erik Frèrejean | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
* | |
*/ | |
/** | |
* Security message: | |
* | |
* This script is potentially dangerous. | |
* Remove or comment the next line (die(".... ) to enable this script. | |
* Do NOT FORGET to either remove this script or disable it after you have used it. | |
*/ | |
die("Please read the first lines of this script for instructions on how to enable it"); | |
/** | |
* @ignore | |
*/ | |
define('IN_PHPBB', true); | |
$phpbb_root_path = './'; | |
$phpEx = substr(strrchr(__FILE__, '.'), 1); | |
include($phpbb_root_path . 'common.'.$phpEx); | |
include($phpbb_root_path . 'includes/functions_user.' . $phpEx); | |
$user->session_begin(); | |
$auth->acl($user->data); | |
$user->setup(); | |
/* | |
* Settings | |
*/ | |
define('FROM_GROUP', 'NCM'); | |
define('TO_GROUP', 'REGISTERED'); | |
define('POST_CNT', 10); | |
define('NEW_GROUP_DEFAULT', true); | |
// Fetch all the users | |
$users = array(); | |
$sql = 'SELECT user_id | |
FROM ' . USERS_TABLE . ' | |
WHERE user_posts < ' . POST_CNT; | |
$result = $db->sql_auery($sql); | |
while ($row = $db->sql_fetchrow($result)) | |
{ | |
$users[] = $row['user_id']; | |
} | |
$db->sql_freeresult($result); | |
// Get the two group ids | |
$from = $to = 0; | |
$sql = 'SELECT group_id, group_name | |
FROM ' . GROUPS_TABLE . ' | |
WHERE ' . $db->sql_in_set('group_name', array(FROM_GROUP, TO_GROUP)); | |
$result = $db->sql_query_limit($sql, 2); | |
while ($group = $db->sql_fetchrow($result)) | |
{ | |
switch ($row['group_name']) | |
{ | |
case FROM_GROUP : | |
$from = $row['group_id']; | |
break; | |
case TO_GROUP : | |
$to = $row['group_id']; | |
break; | |
} | |
} | |
$db->sql_freeresult($result); | |
/** | |
* Do tha adding/removing | |
*/ | |
// Make sure they are in the dest group | |
group_user_add($to, $users, false, false, NEW_GROUP_DEFAULT); | |
// Remove from old | |
group_user_del($from, $users); | |
trigger_error('Done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment