function registerNewUser($username, $password, $firstname, $lastname, $email, $phone, $groups) { $info = array(); $info["uid"] = $username; $info["userPassword"] = $password; $info["givenName"] = $firstname; $info["sn"] = $lastname; $info["cn"] = $firstname . $lastname; $info["mail"] = $email; $info["telephoneNumber"] = $phone; $info["objectClass"][0] = "top"; $info["objectClass"][1] = "person"; $info["objectClass"][2] = "organizationalPerson"; $info["objectClass"][3] = "inetorgperson"; $info["objectClass"][4] = "posixAccount"; $info["objectClass"][5] = "inetuser"; if (ldap_add($connection, $DN, $info) == false) { return false; } foreach ($groups as $group) { addUserToGroup($username, $group); } return true; }
/* verify that user is admin */ checkAdmin(); /* parse result */ foreach ($_POST as $k => $p) { if (substr($k, 0, 4) == "user") { $users[substr($k, 4)] = substr($k, 4); } } /* verify that description is present if action != delete */ if (strlen($_POST['gid'] == 0)) { die("<div class='alert alert alert-danger'>" . _('Error - no group ID') . "</div>"); } /* add each user to group */ if (sizeof($users) > 0) { foreach ($users as $key => $u) { if (!addUserToGroup($_POST['gid'], $u)) { # get user details $user = getUserDetailsById($u); $errors[] = $user['real_name']; } } } else { $errors[] = _("Please select user(s) to add to selected group!"); } /* print result */ if (isset($errors)) { print "<div class='alert alert alert-danger'>"; print _("Failed to add users") . ":<hr>"; print "<ul>"; foreach ($errors as $e) { print "<li>{$e}</li>";
// Convert string of comma-separated group_id's into array $group_ids_arr = explode(',', $rm_groups); foreach ($group_ids_arr as $group_id) { if (removeUserFromGroup($user_id, $group_id)) { $success_count++; } else { $error_count++; } } } // Add groups if (!empty($add_groups)) { // Convert string of comma-separated group_id's into array $group_ids_arr = explode(',', $add_groups); foreach ($group_ids_arr as $group_id) { if (addUserToGroup($user_id, $group_id)) { $success_count++; } else { $error_count++; } } } // Set primary group (must be done after group membership is set) if ($primary_group_id && $userdetails['primary_group_id'] != $primary_group_id) { if (updateUserPrimaryGroup($user_id, $primary_group_id)) { $success_count++; } else { $error_count++; } } restore_error_handler();
} else { $require_activation = $emailActivation; } // Try to create the new user if ($new_user_id = createUser($user_name, $display_name, $email, $title, $password, $passwordc, $require_activation, $admin)) { } else { apiReturnError($ajax, $admin == "true" ? ACCOUNT_ROOT : SITE_ROOT); } // If creation succeeds, try to add groups // If we're in admin mode and add_groups is specified, try to add those groups if ($admin == "true" && $add_groups) { // Convert string of comma-separated group_id's into array $group_ids_arr = explode(',', $add_groups); $addition_count = 0; foreach ($group_ids_arr as $group_id) { $addition_count += addUserToGroup($new_user_id, $group_id); } // Set primary group if (!empty($primary_group_id)) { if (updateUserPrimaryGroup($new_user_id, $primary_group_id)) { // Account creation was successful! addAlert("success", lang("ACCOUNT_PRIMARY_GROUP_SET")); addAlert("success", lang("ACCOUNT_CREATION_COMPLETE", array($user_name))); } else { $error_count++; } } // Otherwise, add default groups and set primary group for new users } else { if (dbAddUserToDefaultGroups($new_user_id)) { if ($require_activation) {
function groups_admin_main($var) { $op = pnVarCleanFromInput('op'); extract($var); if (!pnSecAuthAction(0, 'Groups::', '::', ACCESS_EDIT)) { include 'header.php'; echo _GROUPSNOAUTH; include 'footer.php'; } else { switch ($op) { case "secviewgroups": viewGroups(); break; case "secviewgroup": viewGroup(); break; case "secnewgroup": newGroup(); break; case "secaddgroup": addGroup(); break; case "secdeletegroup": deleteGroup(); break; case "secselectuserforgroup": selectUserForGroup(); break; case "secaddusertogroup": addUserToGroup(); break; case "secdeleteuserfromgroup": deleteUserFromGroup(); break; case "secmodifygroup": modifyGroup(); break; case "secrenamegroup": renameGroup(); break; default: viewGroups(); break; } } }
$response = getUserList($json["userId"], $json["raw"], true); } else { if ($request == "save") { $response = saveUser($json["data"]); } else { if ($request == "createUser") { $response = createUser($json["raw"]); } else { if ($request == "saveGroups") { $response = saveGroups($json["data"]); } else { if ($request == "removeUserFromGroup") { $response = removeUserFromGroup($json["data"]); } else { if ($request == "addUserToGroup") { $response = addUserToGroup($json["data"]); } else { if ($request == "getUsersUngroup") { $response = getUsersUngroup($json["data"]); } else { if ($request == "removeGroup") { $response = removeGroup($json["data"]); } else { if ($request == "createGroup") { $response = createGroup($json["data"]); } else { $response = getJSONFromCodeError(202); } } } }
protected function post_id_name_newUser_handler() { addUserToGroup($this->id, $this->name); header('Location: ' . filter_input(INPUT_SERVER, 'PHP_SELF')); return false; }
updateDashboard(); } else { if (isset($_POST['savePlugins'])) { updatePlugins(); } else { if (isset($_POST['plugin_update'])) { updatePluginConfig(); } else { if (isset($_POST['savePaths'])) { updatePaths(); } else { if (isset($_POST['addUser'])) { addUser(); } else { if (isset($_POST['userToGroup'])) { addUserToGroup(); } else { if (isset($_POST['delUserFromGroup'])) { delUserFromGroup(); } else { if (isset($_POST['delUser'])) { removeUser(); } else { if (isset($_POST['updateUser'])) { updateUser(); } else { if (isset($_POST['addGroup'])) { addGroup(); } else { if (isset($_POST['delGroup'])) { removeGroup();