<?php
/*
Copyright (C) 2005-2011 UserDot
Visit XennoBB at www.userdot.net/projects/xennobb
Originally based on PunBB www.punbb.org
XennoBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
XennoBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
*/
define('IN_FORUM_ADMIN', 1);
require dirname(__FILE__) . '/../include/init.php';
if ($forum_user['g_id'] > USER_ADMIN)
BB_Functions::Message($lang['No permission'], true, 1);
$page = isset($_GET['Page']) ? BB_Input::Htmlspecialchars($_GET['Page']) : null;
$submenu = array($lang['Add'] => 'usergroups.php?Page=Add', $lang['Default'] => 'usergroups.php?Page=Default', $lang['Edit'] => 'usergroups.php?Page=Edit', $lang['Batch move'] => 'usergroups.php?Page=BatchMove');
if (isset($_GET['action']))
{
$action = strval($_GET['action']);
switch ($action)
{
case "batch_mail_change":
if (isset($_POST['newgroup'], $_POST['mail_crit']))
{
$newgroup = intval($_POST['newgroup']);
$mail_crit = strval($_POST['mail_crit']);
$sql_mail = addslashes(preg_replace("#[*]#", "%", $mail_crit));
$db->query("UPDATE " . $db->prefix . "users SET gid='$db->escape($newgroup)' WHERE email LIKE '$sql_mail'");
echo "<br /><fieldset><legend>" . $lang['Result'] . "</legend>" . $lang['Done'] . "</fieldset>";
}
break;
case "batch_username_change":
if (isset($_POST['newgroup'], $_POST['user_crit']))
{
$newgroup = intval($_POST['newgroup']);
$user_crit = strval($_POST['user_crit']);
$sql_user = addslashes(preg_replace("#[*]#", "%", $user_crit));
$db->query("UPDATE " . $db->prefix . "users SET gid='$db->escape($newgroup)' WHERE username LIKE '$sql_user'");
echo "<br /><fieldset><legend>" . $lang['Result'] . "</legend>" . $lang['Done'] . "</fieldset>";
}
break;
case "batch_usergroup_change":
if (isset($_POST['newgroup'], $_POST['group']))
{
$newgroup = strval($_POST['newgroup']);
$group = strval($_POST['group']);
$db->query("UPDATE users SET gid='$db->escape($newgroup)' WHERE gid='$db->escape($group)'");
echo "<br /><fieldset><legend>" . $lang['Result'] . "</legend>" . $lang['Done'] . "</fieldset>";
}
break;
default:
break;
}
}
if (isset($_POST['add_group']) || isset($_GET['edit_group']))
{
if (isset($_POST['add_group']))
{
$base_group = intval($_POST['base_group']);
$result = $db->query('SELECT * FROM ' . $db->prefix . 'usergroups WHERE g_id=' . $db->escape($base_group)) or BB_Functions::Error('Unable to fetch user group info', __FILE__, __LINE__, $db->error());
$group = $db->fetch_assoc($result);
$mode = 'add';
}
else
{
$gid = intval($_GET['edit_group']);
if ($gid < 1)
BB_Functions::Message($lang['Bad request']);
$result = $db->query('SELECT * FROM ' . $db->prefix . 'usergroups WHERE g_id=' . $db->escape($gid)) or BB_Functions::Error('Unable to fetch user group info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
BB_Functions::Message($lang['Bad request']);
$group = $db->fetch_assoc($result);
$mode = 'edit';
}
$page_title = BB_Input::Htmlspecialchars($lang['Admin'] . $lang['UserGroups']);
$required_fields = array('req_title' => 'Group title');
$focus_element = array('groups2', 'req_title');
require FORUM_ROOT . 'admin/header.php';
?>
<div class="blockform">
<h2><?php echo $lang['Setup_group_perms'] ?></h2>
<form name="zuzu" id="groups2" method="post" action="usergroups.php" onsubmit="return process_form(this)">
<div class="inform">
<div class="infldset file" style="padding:10px">
<p><?php echo $lang['Setup_group_perms_desc'] ?></p>
</div>
</div>
<div class="inform">
<input type="hidden" name="mode" value="<?php echo $mode ?>" />
<?php if ($mode == 'edit'): ?>
<input type="hidden" name="gid" value="<?php echo $gid ?>" />
<?php endif;
if ($mode == 'add'): ?>
<input type="hidden" name="base_group" value="<?php echo $base_group ?>" />
<?php endif; ?>
<div class="infldset file" style="padding:10px">
<table class="aligntop" cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Group_title'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_62']) ?></td>
<td><input type="text" class="textbox" name="req_title" size="25" maxlength="50" value="<?php if ($mode == 'edit')
echo BB_Input::Htmlspecialchars($group['g_title']); ?>" tabindex="1" /></td>
</tr>
<tr>
<th class="header"><?php echo $lang['User title'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_63']) ?></td>
<td><input type="text" class="textbox" name="user_title" size="25" maxlength="50" value="<?php echo BB_Input::Htmlspecialchars($group['g_user_title']) ?>" tabindex="2" /></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Group_color'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_64']) ?></td>
<td><input type="text" class="textbox" name="group_color" size="9" maxlength="7" value="<?php echo $group['g_color'] ?>" tabindex="25" /></td>
</tr>
<?php
if ($group['g_id'] != USER_ADMIN)
{
?>
<tr>
<th class="header"><?php echo $lang['Read_board'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_65']) ?></td>
<td><input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1')
echo ' checked="checked"' ?> tabindex="3" /> <?php echo $lang['Yes'] ?> <input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0')
echo ' checked="checked"' ?> tabindex="4" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Post_replies'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_66']) ?></td>
<td><input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1')
echo ' checked="checked"' ?> tabindex="5" /> <?php echo $lang['Yes'] ?> <input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0')
echo ' checked="checked"' ?> tabindex="6" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Post_topics'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_67']) ?></td>
<td><input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1')
echo ' checked="checked"' ?> tabindex="7" /> <?php echo $lang['Yes'] ?> <input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0')
echo ' checked="checked"' ?> tabindex="8" /> <?php echo $lang['No'] ?></td>
</tr>
<?php
if ($group['g_id'] != USER_GUEST)
{
?>
<tr>
<th class="header"><?php echo $lang['Edit_posts'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_68']) ?></td>
<td><input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1')
echo ' checked="checked"' ?> tabindex="11" /> <?php echo $lang['Yes'] ?> <input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0')
echo ' checked="checked"' ?> tabindex="12" /> <?php echo $lang['No'] ?></td>
</tr>
<?php
if ($group['g_id'] != USER_MOD)
{
?>
<tr>
<th class="header"><?php echo $lang['Global_moderator'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_190']) ?></td>
<td><input type="radio" name="global_moderation" value="1"<?php if ($group['g_global_moderation'] == '1')
echo ' checked="checked"' ?> /> Yes <input type="radio" name="global_moderation" value="0"<?php if ($group['g_global_moderation'] == '0')
echo ' checked="checked"' ?> /> No</td>
</tr>
<?php
}
?>
<tr>
<th class="header"><?php echo $lang['Delete_posts'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_69']) ?></td>
<td><input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1')
echo ' checked="checked"' ?> tabindex="13" /> <?php echo $lang['Yes'] ?> <input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0')
echo ' checked="checked"' ?> tabindex="14" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Delete_topics'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_70']) ?></td>
<td><input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1')
echo ' checked="checked"' ?> tabindex="15" /> <?php echo $lang['Yes'] ?> <input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0')
echo ' checked="checked"' ?> tabindex="16" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Set_user_title'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_71']) ?></td>
<td><input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1')
echo ' checked="checked"' ?> tabindex="17" /> <?php echo $lang['Yes'] ?> <input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0')
echo ' checked="checked"' ?> tabindex="18" /> <?php echo $lang['No'] ?></td>
</tr>
<?php
}
?>
<tr>
<th class="header"><?php echo $lang['Use_search'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_72']) ?></td>
<td><input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1')
echo ' checked="checked"' ?> tabindex="19" /> <?php echo $lang['Yes'] ?> <input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0')
echo ' checked="checked"' ?> tabindex="20" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['View_user_list'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_73']) ?></td>
<td><input type="radio" name="view_users" value="1"<?php if ($group['g_view_users'] == '1')
echo ' checked="checked"' ?> tabindex="21" /> <?php echo $lang['Yes'] ?> <input type="radio" name="view_users" value="0"<?php if ($group['g_view_users'] == '0')
echo ' checked="checked"' ?> tabindex="22" /> <?php echo $lang['No'] ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Search_user_list'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_74']) ?></td>
<td><input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1')
echo ' checked="checked"' ?> tabindex="21" /> <?php echo $lang['Yes'] ?> <input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0')
echo ' checked="checked"' ?> tabindex="22" /> <?php echo $lang['No'] ?></td>
</tr>
<?php
if ($group['g_id'] != USER_GUEST)
{
?>
<tr>
<th class="header"><?php echo $lang['Edit_sub_int'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_75']) ?></td>
<td><input type="text" class="textbox" name="edit_subjects_interval" size="5" maxlength="5" value="<?php echo $group['g_edit_subjects_interval'] ?>" tabindex="23" /></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Post_flo_int'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_76']) ?></td>
<td><input type="text" class="textbox" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="24" /></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Search_flo_int'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_77']) ?></td>
<td><input type="text" class="textbox" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="25" /></td>
</tr>
<?php
}
}
?>
</table>
<?php
if ($group['g_id'] == USER_MOD)
{
?>
<p class="warntext"><?php echo $lang['Note_mod_forum'] ?></p>
<?php
}
?>
</div>
</div>
<div><input type="button" class="b1" onclick="javascript:history.go(-1)" value="<?php echo $lang['Go back'] ?>"> <input type="submit" name="add_edit_group" class="b1" value="<?php echo $lang['Update']; ?>" tabindex="26" /></div>
</form>
</div>
<?php
require FORUM_ROOT . 'admin/footer.php';
}
else if (isset($_POST['add_edit_group']))
{
BB_Input::Confirm_Referrer('usergroups.php');
$is_admin_group = (isset($_POST['gid']) && $_POST['gid'] == USER_ADMIN) ? true : false;
$title = trim($_POST['req_title']);
$user_title = trim($_POST['user_title']);
$group_color = trim($_POST['group_color']);
$read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1';
$post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1';
$post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1';
$edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0';
$delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0';
$delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0';
$set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0';
$search = isset($_POST['search']) ? intval($_POST['search']) : '1';
$view_users = isset($_POST['view_users']) ? intval($_POST['view_users']) : '1';
$search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1';
$edit_subjects_interval = isset($_POST['edit_subjects_interval']) ? intval($_POST['edit_subjects_interval']) : '0';
$post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0';
$search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0';
$global_moderation = isset($_POST['global_moderation']) ? $_POST['global_moderation'] : '0';
if ($group_color != '')
{
if (!preg_match('{^(#){1}([a-fA-F0-9]){6}$}', $group_color))
BB_Functions::Message($lang['group_color_invalid']);
}
if ($title == '')
BB_Functions::Message($lang['enter_group_title']);
$user_title = ($user_title != '') ? '\'' . $db->escape($user_title) . '\'' : 'NULL';
if ($_POST['mode'] == 'add')
{
$result = $db->query('SELECT 1 FROM ' . $db->prefix . 'usergroups WHERE g_title=\'' . $db->escape($title) . '\'') or BB_Functions::Error('Unable to check group title collision', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
BB_Functions::Message('There is already a group with the title \'' . BB_Input::Htmlspecialchars($title) . '\'.');
$db->query('INSERT INTO ' . $db->prefix . 'usergroups (g_title, g_user_title, g_read_board, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_view_users, g_search_users, g_edit_subjects_interval, g_post_flood, g_search_flood, g_global_moderation, g_color) VALUES(\'' . $db->escape($title) . '\', ' . $user_title . ', ' . $db->escape($read_board) . ', ' . $db->escape($post_replies) . ', ' . $db->escape($post_topics) . ', ' . $db->escape($edit_posts) . ', ' . $db->escape($delete_posts) . ', ' . $db->escape($delete_topics) . ', ' . $db->escape($set_title) . ', ' . $db->escape($search) . ', ' . $db->escape($view_users) . ', ' . $db->escape($search_users) . ', ' . $db->escape($edit_subjects_interval) . ', ' . $db->escape($post_flood) . ', ' . $db->escape($search_flood) . ', ' . $db->escape($global_moderation) . ', \'' . $db->escape($group_color) . '\')') or BB_Functions::Error('Unable to add group', __FILE__, __LINE__, $db->error());
$new_gid = $db->insert_id();
$result = $db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM ' . $db->prefix . 'permissions WHERE gid=' . intval($_POST['base_group'])) or BB_Functions::Error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
while ($cur_forum_perm = $db->fetch_assoc($result))
$db->query('INSERT INTO ' . $db->prefix . 'permissions (gid, forum_id, read_forum, post_replies, post_topics) VALUES(' . $db->escape($new_gid) . ', ' . $db->escape($cur_forum_perm['forum_id']) . ', ' . $db->escape($cur_forum_perm['read_forum']) . ', ' . $db->escape($cur_forum_perm['post_replies']) . ', ' . $db->escape($cur_forum_perm['post_topics']) . ')') or BB_Functions::Error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
}
else
{
$result = $db->query('SELECT 1 FROM ' . $db->prefix . 'usergroups WHERE g_title=\'' . $db->escape($title) . '\' AND g_id!=' . $db->escape($_POST['gid'])) or BB_Functions::Error('Unable to check group title collision', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result))
BB_Functions::Message('There is already a group with the title \'' . BB_Input::Htmlspecialchars($title) . '\'.');
$db->query('UPDATE ' . $db->prefix . 'usergroups SET g_title=\'' . $title . '\', g_user_title=' . $user_title . ', g_read_board=' . $read_board . ', g_post_replies=' . $post_replies . ', g_post_topics=' . $post_topics . ', g_edit_posts=' . $edit_posts . ', g_delete_posts=' . $delete_posts . ', g_delete_topics=' . $delete_topics . ', g_set_title=' . $set_title . ', g_search=' . $search . ', g_view_users=' . $view_users . ', g_search_users=' . $search_users . ', g_edit_subjects_interval=' . $edit_subjects_interval . ', g_post_flood=' . $post_flood . ', g_search_flood=' . $search_flood . ', g_global_moderation=' . $global_moderation . ', g_color=\'' . $group_color . '\' WHERE g_id=' . intval($_POST['gid'])) or BB_Functions::Error('Unable to update group', __FILE__, __LINE__, $db->error());
}
BB_Admin_Functions::Log_Action('New usergroup added ' . $title, 1);
BB_Functions::Redirect('usergroups.php?Page=Edit', 'Group ' . (($_POST['mode'] == 'edit') ? 'edited' : 'added') . '. Redirecting …');
}
else if (isset($_POST['set_default_group']))
{
BB_Input::Confirm_Referrer('usergroups.php');
$gid = intval($_POST['default_group']);
if ($gid < 4)
BB_Functions::Message($lang['Bad request']);
$db->query('UPDATE ' . $db->prefix . 'config SET conf_value=' . $db->escape($gid) . ' WHERE conf_name=\'o_default_user_group\'') or BB_Functions::Error('Unable to update board config', __FILE__, __LINE__, $db->error());
BB_Functions::Redirect('usergroups.php?Page=Default', $lang['redirect_default_group']);
}
else if (isset($_GET['del_group']))
{
BB_Input::Confirm_Referrer('usergroups.php');
$gid = intval($_GET['del_group']);
if ($gid < 5)
BB_Functions::Message($lang['Bad request']);
if ($gid == bb_default_user_group)
BB_Functions::Message('The default group cannot be removed. In order to delete this group, you must first setup a different group as the default.');
$result = $db->query('SELECT g.g_title, COUNT(u.id) FROM ' . $db->prefix . 'usergroups AS g INNER JOIN ' . $db->prefix . 'users AS u ON g.g_id=u.gid WHERE g.g_id=' . $db->escape($gid) . ' GROUP BY g.g_id, g_title') or BB_Functions::Error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result) || isset($_POST['del_group']))
{
if (isset($_POST['del_group']))
{
$move_to_group = intval($_POST['move_to_group']);
$db->query('UPDATE ' . $db->prefix . 'users SET gid=' . $move_to_group . ' WHERE gid=' . $db->escape($gid)) or BB_Functions::Error('Unable to move users into group', __FILE__, __LINE__, $db->error());
}
$db->query('DELETE FROM ' . $db->prefix . 'usergroups WHERE g_id=' . $db->escape($gid)) or BB_Functions::Error('Unable to delete group', __FILE__, __LINE__, $db->error());
$db->query('DELETE FROM ' . $db->prefix . 'permissions WHERE gid=' . $db->escape($gid)) or BB_Functions::Error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
BB_Admin_Functions::Log_Action('Usergroup removed ' . $gid, 1);
BB_Functions::Redirect('usergroups.php?Page=Edit', $lang['redirect_group_removed']);
}
list($group_title, $group_members) = $db->fetch_row($result);
$page_title = BB_Input::Htmlspecialchars($lang['Admin'] . $lang['UserGroups']);
require FORUM_ROOT . 'admin/header.php';
?>
<div class="blockform">
<div class="box">
<form id="groups" method="post" action="usergroups.php?del_group=<?php echo $gid ?>">
<div class="inform">
<h2><?php echo $lang['Move_users_group'] ?></h2>
<div class="infldset file" style="padding:10px">
<p><?php echo $lang['The_group'] ?>"<?php echo BB_Input::Htmlspecialchars($group_title) ?>" <?php echo $lang['Currently_has'] ?> <?php echo $group_members ?> <?php echo $lang['Members'] ?>. <?php echo $lang['Select_group_members'] ?></p>
<label><?php echo $lang['Move users to'] ?>
<select name="move_to_group">
<?php
$result = $db->query('SELECT g_id, g_title FROM ' . $db->prefix . 'usergroups WHERE g_id!=' . USER_GUEST . ' AND g_id!=' . $db->escape($gid) . ' ORDER BY g_title') or BB_Functions::Error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
{
if ($cur_group['g_id'] == USER_MEMBER)
echo "\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
else
echo "\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
}
?>
</select>
</br>
</label>
</div>
</div>
<p class="submitend" style="text-align:left;"><input type="submit" class="b1" name="del_group" value="<?php echo $lang['Remove']; ?>" /></p>
</form>
</div>
<div class="clearer"></div>
<?php
require FORUM_ROOT . 'admin/footer.php';
}
$page_title = BB_Input::Htmlspecialchars($lang['Admin'] . $lang['UserGroups']);
require FORUM_ROOT . 'admin/header.php';
if ($page == 'Add')
{
echo BB_Template::Generate_Menu($submenu);
?>
<div class="blockform">
<form id="groups" method="post" action="usergroups.php">
<div class="inform">
<div class="infldset file" style="padding:10px">
<table class="aligntop" cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Base_group'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_79']) ?></td>
<td>
<select id="base_group" name="base_group" tabindex="1">
<?php
$result = $db->query('SELECT g_id, g_title FROM ' . $db->prefix . 'usergroups WHERE g_id>' . USER_GUEST . ' ORDER BY g_title') or BB_Functions::Error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
{
if ($cur_group['g_id'] == bb_default_user_group)
echo "\t\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
else
echo "\t\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
</table>
</div>
</div>
<div><input type="submit" class="b1" name="add_group" value="<?php echo $lang['Add'] ?>" tabindex="2" /></div>
</form>
</div>
<?php
}
else if ($page == 'Default')
{
echo BB_Template::Generate_Menu($submenu);
?>
<div class="blockform">
<form id="groups" method="post" action="usergroups.php">
<div class="inform">
<div class="infldset file" style="padding:10px">
<table class="aligntop" cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Default_group'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_80']) ?></td>
<td>
<select id="default_group" name="default_group" tabindex="3">
<?php
$result = $db->query('SELECT g_id, g_title FROM ' . $db->prefix . 'usergroups WHERE g_id>' . USER_GUEST . ' ORDER BY g_title') or BB_Functions::Error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
{
if ($cur_group['g_id'] == bb_default_user_group)
echo "\t\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '" selected="selected">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
else
echo "\t\t\t\t\t\t\t\t\t\t\t" . '<option value="' . $cur_group['g_id'] . '">' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
</table>
</div>
</div>
<div><input type="submit" class="b1" name="set_default_group" value="<?php echo $lang['Save'] ?>" tabindex="4" /></div>
</form>
</div>
<?php
}
else if ($page == 'Edit')
{
echo BB_Template::Generate_Menu($submenu);
?>
<div class="blockform">
<form>
<div class="inform">
<div class="infldset file" style="padding:10px">
<p><?php echo $lang['Remove_group_note'] ?></p>
</div>
</div>
<div class="infldset file" style="padding:10px">
<table cellspacing="0">
<?php
$result = $db->query('SELECT g_id, g_title FROM ' . $db->prefix . 'usergroups ORDER BY g_id') or BB_Functions::Error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
echo "\t\t\t\t\t\t\t\t" . '<tr><th style="width:150px" scope="row"><a href="usergroups.php?edit_group=' . $cur_group['g_id'] . '">' . $lang['Edit'] . '</a>' . (($cur_group['g_id'] > USER_MEMBER) ? ' - <a href="usergroups.php?del_group=' . $cur_group['g_id'] . '">' . $lang['Remove'] . '</a>' : '') . '</th><td>' . BB_Input::Htmlspecialchars($cur_group['g_title']) . '</td></tr>' . "\n";
?>
</table>
</div>
</form>
</div>
<?php
}
else if ($page == 'BatchMove')
{
echo BB_Template::Generate_Menu($submenu);
?>
<div class="blockform">
<form id="form1" name="form1" method="post" action="usergroups.php?action=batch_mail_change">
<?php
$g_result = $db->query("SELECT g_id, g_title, g_user_title FROM " . $db->prefix . "usergroups ORDER BY g_id ASC");
if ($db->num_rows($g_result) > 0)
{
while ($g_row = $db->fetch_assoc($g_result))
$groups[$g_row['g_id']] = $g_row['g_title'];
}
?>
<div class="inform">
<div class="infldset file" style="padding:10px">
<?php
$u_result = $db->query("SELECT id, username, gid, email FROM " . $db->prefix . "users ORDER BY id");
$select = "\n<select name=\"newgroup\">\n";
foreach ($groups as $key => $value)
$select .= "<option value=\"" . $key . "\">" . $groups[$key] . "</option>\n";
$select .= "</select>\n";
$select2 = "\n<select name=\"group\">\n";
foreach ($groups as $key => $value)
$select2 .= "<option value=\"" . $key . "\">" . $groups[$key] . "</option>\n";
$select2 .= "</select>\n";
if ($db->num_rows($u_result) > 0)
{
while ($u_row = $db->fetch_assoc($u_result))
$users[] = $u_row['id'] . ", " . $u_row['username'] . ", " . $groups[$u_row['gid']] . ", " . $u_row['email'];
}
?>
<table cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Group'] ?></th>
<td class="tips"> </td>
<td><?php echo $select; ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Email criteria'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_81']) ?></td>
<td><input name="mail_crit" class="textbox" type="text" /></td>
</tr>
</table>
</div>
</div>
<div><input type="submit" class="b1" name="submit" value="<?php echo $lang['Update'] ?>" /></div>
</form>
<form id="form1" name="form1" method="post" action="usergroups.php?action=batch_username_change">
<div class="inform">
<div class="infldset file" style="padding:10px">
<table cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Group'] ?></th>
<td class="tips"> </td>
<td><?php echo $select; ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Username criteria'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_82']) ?></td>
<td><input name="user_crit" class="textbox" type="text" /></td>
</tr>
</table>
</div>
</div>
<div><input type="submit" class="b1" name="submit" value="<?php echo $lang['Update'] ?>" /></div>
</form>
<form id="form1" name="form1" method="post" action="usergroups.php?action=batch_usergroup_change">
<div class="inform">
<div class="infldset file" style="padding:10px">
<table cellspacing="0">
<tr>
<th class="header"><?php echo $lang['Current group'] ?></th>
<td class="tips"> </td>
<td><?php echo $select2; ?></td>
</tr>
<tr>
<th class="header"><?php echo $lang['Future group'] ?></th>
<td class="tips"><?php BB_Template::Print_Tooltip($lang['tip_83']) ?></td>
<td><?php echo $select; ?></td>
</tr>
</table>
</div>
</div>
<div><input type="submit" class="b1" name="submit" value="<?php echo $lang['Update'] ?>" /></div>
</form>
</div>
<?php
}
else
BB_Functions::Message($lang['Bad request']);
require FORUM_ROOT . 'admin/footer.php';
?>