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) { $columns = array ( 'members' => array ( 'title' => $lang['strmembers'], 'field' => field('usename') ), 'actions' => array ( 'title' => $lang['stractions'], ) ); $actions = array ( 'drop' => array ( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'groups.php', 'urlvars' => array ( 'action' => 'confirm_drop_member', 'group' => $_REQUEST['group'], 'user' => field('usename') ) ) ) ) ); $misc->printTable($groupdata, $columns, $actions, 'groups-members', $lang['strnousers']); } // Display form for adding a user to the group echo "\n"; $misc->printNavLinks(array ('showall' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'groups.php', 'urlvars' => array ( 'server' => $_REQUEST['server'] ) ) ), 'content' => $lang['strshowallgroups'] )), 'groups-properties', get_defined_vars()); } /** * 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( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'groups.php', 'urlvars' => array ( 'action' => 'confirm_drop', 'group' => field('groname') ) ) ) ), ); $misc->printTable($groups, $columns, $actions, 'groups-properties', $lang['strnogroups']); $misc->printNavLinks(array ('create' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'groups.php', 'urlvars' => array ( 'action' => 'create', 'server' => $_REQUEST['server'] ) ) ), 'content' => $lang['strcreategroup'] )), 'groups-groups', get_defined_vars()); } $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(); ?>