addGroupMember($_REQUEST['group'], $_REQUEST['user']); if ($status == 0) doProperties($lang['strmemberadded']); else doProperties($lang['strmemberaddedbad']); } /** * Show confirmation of drop user from group and perform actual drop */ function doDropMember($confirm) { global $data, $misc; global $lang; if ($confirm) { $misc->printTrail('group'); $misc->printTitle($lang['strdropmember'],'pg.group.alter'); echo "
", sprintf($lang['strconfdropmember'], $misc->printVal($_REQUEST['user']), $misc->printVal($_REQUEST['group'])), "
\n"; echo "\n"; } else { $status = $data->dropGroupMember($_REQUEST['group'], $_REQUEST['user']); if ($status == 0) doProperties($lang['strmemberdropped']); else doDropMember(true, $lang['strmemberdroppedbad']); } } /** * Show read only properties for a group */ function doProperties($msg = '') { global $data, $misc; global $lang; if (!isset($_POST['user'])) $_POST['user'] = ''; $misc->printTrail('group'); $misc->printTitle($lang['strproperties'],'pg.group'); $misc->printMsg($msg); $groupdata = $data->getGroup($_REQUEST['group']); $users = $data->getUsers(); if ($groupdata->recordCount() > 0) { echo "{$lang['strmembers']} | {$lang['stractions']} |
---|---|
", $misc->printVal($groupdata->fields['usename']), " | \n"; echo "href}&group=", urlencode($_REQUEST['group']), "&user=", urlencode($groupdata->fields['usename']), "\">{$lang['strdrop']} | \n"; echo "
{$lang['strnousers']}
\n"; // Display form for adding a user to the group echo "\n"; echo "href}\">{$lang['strshowallgroups']}
\n"; } /** * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { global $data, $misc; global $lang; if ($confirm) { $misc->printTrail('group'); $misc->printTitle($lang['strdrop'],'pg.group.drop'); echo "", sprintf($lang['strconfdropgroup'], $misc->printVal($_REQUEST['group'])), "
\n"; echo "\n"; } else { $status = $data->dropGroup($_REQUEST['group']); if ($status == 0) doDefault($lang['strgroupdropped']); else doDefault($lang['strgroupdroppedbad']); } } /** * Displays a screen where they can enter a new group */ function doCreate($msg = '') { global $data, $misc; global $lang; if (!isset($_POST['name'])) $_POST['name'] = ''; if (!isset($_POST['members'])) $_POST['members'] = array(); // Fetch a list of all users in the cluster $users = $data->getUsers(); $misc->printTrail('server'); $misc->printTitle($lang['strcreategroup'],'pg.group.create'); $misc->printMsg($msg); echo "\n"; } /** * Actually creates the new group in the database */ function doSaveCreate() { global $data; global $lang; if (!isset($_POST['members'])) $_POST['members'] = array(); // Check form vars if (trim($_POST['name']) == '') doCreate($lang['strgroupneedsname']); else { $status = $data->createGroup($_POST['name'], $_POST['members']); if ($status == 0) doDefault($lang['strgroupcreated']); else doCreate($lang['strgroupcreatedbad']); } } /** * Show default list of groups in the database */ function doDefault($msg = '') { global $data, $misc; global $lang; $misc->printTrail('server'); $misc->printTabs('server','groups'); $misc->printMsg($msg); $groups = $data->getGroups(); $columns = array( 'group' => array( 'title' => $lang['strgroup'], 'field' => field('groname'), 'url' => "groups.php?action=properties&{$misc->href}&", 'vars' => array('group' => 'groname'), ), 'actions' => array( 'title' => $lang['stractions'], ), ); $actions = array( 'drop' => array( 'title' => $lang['strdrop'], 'url' => "groups.php?action=confirm_drop&{$misc->href}&", 'vars' => array('group' => 'groname'), ), ); $misc->printTable($groups, $columns, $actions, $lang['strnogroups']); echo "\n"; } $misc->printHeader($lang['strgroups']); $misc->printBody(); switch ($action) { case 'add_member': doAddMember(); break; case 'drop_member': if (isset($_REQUEST['drop'])) doDropMember(false); else doProperties(); break; case 'confirm_drop_member': doDropMember(true); break; case 'save_create': if (isset($_REQUEST['cancel'])) doDefault(); else doSaveCreate(); break; case 'create': doCreate(); break; case 'drop': if (isset($_REQUEST['drop'])) doDrop(false); else doDefault(); break; case 'confirm_drop': doDrop(true); break; case 'save_edit': doSaveEdit(); break; case 'edit': doEdit(); break; case 'properties': doProperties(); break; default: doDefault(); break; } $misc->printFooter(); ?>