".$locale['401']."";
} elseif ($status == "sn") {
$title = $locale['402'];
$message = "".$locale['403']."";
} elseif ($status == "addall") {
$title = $locale['404'];
$message = "".$locale['405']."";
} elseif ($status == "remall") {
$title = $locale['404'];
$message = "".$locale['406']."";
} elseif ($status == "sel") {
$title = $locale['404'];
$message = "".$locale['407']."";
} elseif ($status == "deln") {
$title = $locale['408'];
$message = "".$locale['409']."
\n".$locale['410'];
} elseif ($status == "dely") {
$title = $locale['408'];
$message = "".$locale['411']."";
}
opentable($title);
echo "
".$message."
\n";
closetable();
tablebreak();
}
if (isset($_POST['save_group'])) {
$group_name = stripinput($_POST['group_name']);
$group_description = stripinput($_POST['group_description']);
if (isset($group_id)) {
$result = dbquery("UPDATE ".$db_prefix."user_groups SET group_name='$group_name', group_description='$group_description' WHERE group_id='$group_id'");
redirect(FUSION_SELF.$aidlink."&status=su");
} else {
$result = dbquery("INSERT INTO ".$db_prefix."user_groups (group_name, group_description) VALUES ('$group_name', '$group_description')");
redirect(FUSION_SELF.$aidlink."&status=sn");
}
} elseif (isset($_POST['add_all'])) {
$group_id = $_POST['group_id'];
$result = dbquery("SELECT user_id,user_name,user_groups FROM ".$db_prefix."users");
while ($data = dbarray($result)) {
if (!preg_match("(^\.{$group_id}|\.{$group_id}\.|\.{$group_id}$)", $data['user_groups'])) {
$user_groups = $data['user_groups'].".".$group_id;
$result2 = dbquery("UPDATE ".$db_prefix."users SET user_groups='$user_groups' WHERE user_id='".$data['user_id']."'");
}
}
redirect(FUSION_SELF.$aidlink."&status=addall");
} elseif (isset($_POST['remove_all'])) {
$group_id = $_POST['group_id'];
$result = dbquery("SELECT user_id,user_name,user_groups FROM ".$db_prefix."users WHERE user_groups REGEXP('^\\\.{$group_id}$|\\\.{$group_id}\\\.|\\\.{$group_id}$')");
while ($data = dbarray($result)) {
$user_groups = $data['user_groups'];
$user_groups = preg_replace(array("(^\.{$group_id}$)","(\.{$group_id}\.)","(\.{$group_id}$)"), array("",".",""), $user_groups);
$result2 = dbquery("UPDATE ".$db_prefix."users SET user_groups='$user_groups' WHERE user_id='".$data['user_id']."'");
}
redirect(FUSION_SELF.$aidlink."&status=remall");
} elseif (isset($_POST['save_selected'])) {
$group_id = $_POST['group_id']; $group_users = $_POST['group_users'];
$result = dbquery("SELECT user_id,user_name,user_groups FROM ".$db_prefix."users");
while ($data = dbarray($result)) {
$user_id = $data['user_id'];
if (preg_match("(^{$user_id}$|^{$user_id}\.|\.{$user_id}\.|\.{$user_id}$)", $group_users)) {
if (!preg_match("(^\.{$group_id}$|\.{$group_id}\.|\.{$group_id}$)", $data['user_groups'])) {
$user_groups = $data['user_groups'].".".$group_id;
$result2 = dbquery("UPDATE ".$db_prefix."users SET user_groups='$user_groups' WHERE user_id='".$data['user_id']."'");
}
} elseif (preg_match("(^\.$group_id$|\.$group_id\.|\.$group_id$)", $data['user_groups'])) {
$user_groups = $data['user_groups'];
$user_groups = preg_replace(array("(^{$group_id}\.)","(\.{$group_id}\.)","(\.{$group_id}$)"), array("",".",""), $user_groups);
$result2 = dbquery("UPDATE ".$db_prefix."users SET user_groups='$user_groups' WHERE user_id='".$data['user_id']."'");
}
unset($user_id);
}
redirect(FUSION_SELF.$aidlink."&status=sel");
} elseif (isset($_POST['delete'])) {
if (dbcount("(*)", "users", "user_groups REGEXP('^\\\.{$group_id}$|\\\.{$group_id}\\\.|\\\.{$group_id}$')") != 0) {
redirect(FUSION_SELF.$aidlink."&status=deln");
} else {
$result = dbquery("DELETE FROM ".$db_prefix."user_groups WHERE group_id='$group_id'");
redirect(FUSION_SELF.$aidlink."&status=dely");
}
} else {
$result = dbquery("SELECT * FROM ".$db_prefix."user_groups ORDER BY group_name");
if (dbrows($result) != 0) {
opentable($locale['420']);
echo "\n";
closetable();
tablebreak();
}
if (isset($_POST['edit'])) {
$result = dbquery("SELECT * FROM ".$db_prefix."user_groups WHERE group_id='$group_id'");
if (dbrows($result) == 0) fallback(FUSION_SELF.$aidlink);
$data = dbarray($result);
$group_name = $data['group_name'];
$group_description = $data['group_description'];
$form_action = FUSION_SELF.$aidlink."&group_id=$group_id";
opentable($locale['430']);
} else {
$group_name = "";
$group_description = "";
$form_action = FUSION_SELF.$aidlink;
opentable($locale['431']);
}
echo "";
closetable();
tablebreak();
if (isset($group_id)) {
opentable($locale['404']);
$result = dbquery("SELECT user_id,user_name,user_groups FROM ".$db_prefix."users ORDER BY user_level DESC, user_name");
while ($data = dbarray($result)) {
if (!preg_match("(^\.{$group_id}$|\.{$group_id}\.|\.{$group_id}$)", $data['user_groups'])) {
$group1_user_id[] = $data['user_id'];
$group1_user_name[] = $data['user_name'];
} else {
$group2_user_id[] = $data['user_id'];
$group2_user_name[] = $data['user_name'];
}
}
echo "\n";
closetable();
// Script Original Author: Kathi O'Shea (Kathi.O'Shea@internet.com)
// http://www.webdesignhelper.co.uk/sample_code/sample_code/sample_code10/sample_code10.shtml
echo "\n";
}
}
echo "\n";
echo "\n";
require_once BASEDIR."footer.php";
?>