if (defined('ROLE_MODEL')) { $adminUser = new RolePermUser(); if ($adminUser->store($storeHash)) { // add user to admin role $adminUser->addUserToRole($adminUser->mUserId, 1); // set admin role as default $adminUser->storeUserDefaultRole($adminUser->mUserId, 1); } else { vd($adminUser->mErrors); die; } } else { $adminUser = new BitPermUser(); if ($adminUser->store($storeHash)) { // add user to admin group $adminUser->addUserToGroup($adminUser->mUserId, 1); // set admin group as default $adminUser->storeUserDefaultGroup($adminUser->mUserId, 1); } else { vd($adminUser->mErrors); die; } } // kill admin info in $_SESSION // unset( $_SESSION['real_name'] ); // unset( $_SESSION['login'] ); // unset( $_SESSION['password'] ); // unset( $_SESSION['email'] ); } } // ---------------------- 8. ----------------------
// were there any users in the list? if (!is_array($userRecords)) { $gBitSystem->fatalError(tra("No records were found. Check the file please!")); } // Process user array $added = 0; $i = 1; foreach ($userRecords as $userRecord) { $newUser = new BitPermUser(); if ($newUser->importUser($userRecord)) { if (!empty($userRecord['groups'])) { // groups need to be separated by spaces since this is a csv file $groups = explode(" ", $userRecord['groups']); foreach ($groups as $group) { if ($groupId = $gBitUser->groupExists($group, ROOT_USER_ID)) { $newUser->addUserToGroup($newUser->mUserId, $groupId); } } } if (!empty($userRecord['roles'])) { // roles need to be separated by spaces since this is a csv file $roles = explode(" ", $userRecord['roles']); foreach ($roles as $role) { if ($roleId = $gBitUser->roleExists($role, ROOT_USER_ID)) { $newUser->addUserToRole($newUser->mUserId, $roleId); } } } if (empty($_REQUEST['admin_noemail_user'])) { $ret = users_admin_email_user($userRecord); if (is_array($ret)) {
// 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 BitPermUser($_REQUEST["assign_user"]); $assignUser->setCacheableObject(FALSE); $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->addUserToGroup($assignUser->mUserId, $_REQUEST["group_id"]); } elseif ($_REQUEST["action"] == 'removegroup') { $assignUser->removeUserFromGroup($_REQUEST["assign_user"], $_REQUEST["group_id"]); } header('Location: ' . $_SERVER['SCRIPT_NAME'] . '?assign_user='******'set_default'])) { $gBitUser->verifyTicket(); $assignUser->storeUserDefaultGroup($assignUser->mUserId, $_REQUEST['default_group']); $assignUser->load(); } $gBitSmarty->assignByRef('assignUser', $assignUser); $listHash = array('sort_mode' => 'group_name_asc'); $gBitSmarty->assign('groups', $gBitUser->getAllGroups($listHash)); $gBitSystem->setBrowserTitle('Edit User: ' . $assignUser->mUsername); if ($gBitSystem->isPackageActive("quota")) {
/** * Imports a user record from csv file * This is a admin specific function * * @param $pParamHash an array with user data * @return TRUE if import succeed **/ function importUser(&$pParamHash) { global $gBitUser; if (!$gBitUser->hasPermission('p_users_admin')) { return FALSE; } if ($this->verifyUserImport($pParamHash)) { $this->StartTrans(); $pParamHash['content_type_guid'] = BITUSER_CONTENT_TYPE_GUID; if (!empty($pParamHash['user_store']) && count($pParamHash['user_store'])) { // lookup and asign the default group for user $defaultGroups = BitPermUser::getDefaultGroup(); if (!empty($defaultGroups)) { $pParamHash['user_store']['default_group_id'] = key($defaultGroups); } if ($this->isValid()) { $userId = array("user_id" => $this->mUserId); $result = $this->mDb->associateUpdate(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store'], $userId); } else { if (empty($pParamHash['user_store']['user_id'])) { $pParamHash['user_store']['user_id'] = $this->mDb->GenID('users_users_user_id_seq'); } $this->mUserId = $pParamHash['user_store']['user_id']; $result = $this->mDb->associateInsert(BIT_DB_PREFIX . 'users_users', $pParamHash['user_store']); } // make sure user is added into the default group map if (!empty($pParamHash['user_store']['default_group_id'])) { BitPermUser::addUserToGroup($pParamHash['user_store']['user_id'], $pParamHash['user_store']['default_group_id']); } } // Prevent liberty from assuming ANONYMOUS_USER_ID while storing $pParamHash['user_id'] = $this->mUserId; if (LibertyContent::store($pParamHash)) { if (empty($this->mInfo['content_id']) || $pParamHash['content_id'] != $this->mInfo['content_id']) { $query = "UPDATE `" . BIT_DB_PREFIX . "users_users` SET `content_id`=? WHERE `user_id`=?"; $result = $this->mDb->query($query, array($pParamHash['content_id'], $this->mUserId)); $this->mInfo['content_id'] = $pParamHash['content_id']; } } $this->CompleteTrans(); // store any uploaded images $this->storeImages($pParamHash); $this->load(TRUE); } return count($this->mErrors) == 0; }