$gBitUser->mDb->query("INSERT INTO `" . BIT_DB_PREFIX . "users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`) VALUES ( " . ROOT_USER_ID . ", " . ANONYMOUS_GROUP_ID . ", 'Anonymous','Public users not logged')"); $gBitUser->mDb->query("INSERT INTO `" . BIT_DB_PREFIX . "users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`) VALUES ( " . ROOT_USER_ID . ", 2, 'Managers','Site Managers')"); $gBitUser->mDb->query("INSERT INTO `" . BIT_DB_PREFIX . "users_groups` (`user_id`, `group_id`, `group_name`,`group_desc`,`is_default`) VALUES ( " . ROOT_USER_ID . ", 3, 'Registered', 'Users logged into the system', 'y')"); } $gBitUser->assignLevelPermissions(ANONYMOUS_TEAM_ID, 'basic'); $gBitUser->assignLevelPermissions(3, 'registered'); $gBitUser->assignLevelPermissions(2, 'editors'); $gBitUser->assignLevelPermissions(1, 'admin'); // Create 'Anonymous' user has id= -1 just like phpBB $storeHash = array('real_name' => 'Guest', 'login' => 'guest', 'password' => $_SESSION['password'], 'email' => 'guest@localhost', 'pass_due' => FALSE, 'user_id' => ANONYMOUS_USER_ID, 'default_role_id' => ANONYMOUS_TEAM_ID); if (defined('ROLE_MODEL')) { $anonUser = new RolePermUser(); if ($anonUser->store($storeHash)) { // Remove anonymous from registered group $regRoleId = $anonUser->roleExists('Registered', ROOT_USER_ID); $anonUser->removeUserFromRole(ANONYMOUS_USER_ID, $regRoleId); $anonUser->addUserToRole(ANONYMOUS_USER_ID, ANONYMOUS_TEAM_ID); } } else { $anonUser = new BitPermUser(); if ($anonUser->store($storeHash)) { // Remove anonymous from registered group $regGroupId = $anonUser->groupExists('Registered', ROOT_USER_ID); $anonUser->removeUserFromGroup(ANONYMOUS_USER_ID, $regGroupId); $anonUser->addUserToGroup(ANONYMOUS_USER_ID, ANONYMOUS_GROUP_ID); } } // Create 'Admin' user has id= 2 $storeHash = array('real_name' => $_SESSION['real_name'], 'login' => $_SESSION['login'], 'password' => $_SESSION['password'], 'email' => $_SESSION['email'], 'pass_due' => FALSE); if (defined('ROLE_MODEL')) { $adminUser = new RolePermUser();
// ASSIGN USER TO ROLES // Initialization require_once '../../kernel/setup_inc.php'; $gBitSystem->verifyPermission('p_users_admin'); if (!$gBitUser->userExists(array('user_id' => $_REQUEST["assign_user"]))) { $gBitSystem->fatalError(tra("User doesnt exist")); } $assignUser = new RolePermUser($_REQUEST["assign_user"]); $assignUser->load(TRUE); if ($assignUser->isAdmin() && !$gBitUser->isAdmin()) { $gBitSystem->fatalError(tra('You cannot modify a system administrator.')); } if (isset($_REQUEST["action"])) { $gBitUser->verifyTicket(); if ($_REQUEST["action"] == 'assign') { $assignUser->addUserToRole($assignUser->mUserId, $_REQUEST["role_id"]); } elseif ($_REQUEST["action"] == 'removerole') { $assignUser->removeUserFromRole($_REQUEST["assign_user"], $_REQUEST["role_id"]); } bit_redirect('assign_role_user.php?assign_user='******'set_default'])) { $gBitUser->verifyTicket(); $assignUser->storeUserDefaultRole($assignUser->mUserId, $_REQUEST['default_role']); $assignUser->load(); } $gBitSmarty->assignByRef('assignUser', $assignUser); $listHash = array('sort_mode' => 'role_name_asc'); $gBitSmarty->assign('roles', $gBitUser->getAllRoles($listHash)); $gBitSystem->setBrowserTitle('Edit User: '******'bitpackage:users/admin_assign_role_user.tpl', NULL, array('display_mode' => 'admin'));