mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
User Manager: Ability to edit Username, verifies unique.
This commit is contained in:
@@ -242,7 +242,7 @@
|
||||
$text['description-contact_view']['pt-pt'] = "Ver";
|
||||
$text['description-contact_view']['fr-fr'] = "Voir";
|
||||
|
||||
$text['description-status']['en-us'] = "Set the user\'s presence.";
|
||||
$text['description-status']['en-us'] = "Set the user's presence.";
|
||||
$text['description-status']['es-cl'] = "Configure la presencia del usuario.";
|
||||
$text['description-status']['pt-pt'] = "Escolher o estado de presença do utilizador.";
|
||||
$text['description-status']['fr-fr'] = "Choisir l'état de présence de l'utilisateur.";
|
||||
@@ -382,12 +382,17 @@
|
||||
$text['message-required']['pt-pt'] = "Por favor indique: ";
|
||||
$text['message-required']['fr-fr'] = "Merci d'indiquer: ";
|
||||
|
||||
$text['message-password_blank']['en-us'] = "Password cannot be blank.";
|
||||
$text['message-password_blank']['es-cl'] = "La contraseña no puede estar en blanco";
|
||||
$text['message-password_blank']['pt-pt'] = "O campo password não pode ser vazio.";
|
||||
$text['message-password_blank']['fr-fr'] = "Le mot de passe ne peut pas être vide.";
|
||||
$text['message-username_exists']['en-us'] = "Username Already Exists";
|
||||
$text['message-username_exists']['es-cl'] = "Ya existe Nombre de usuario";
|
||||
$text['message-username_exists']['pt-pt'] = "Nome de usuário já existe";
|
||||
$text['message-username_exists']['fr-fr'] = "Nom d'utilisateur existe déjà";
|
||||
|
||||
$text['message-password_mismatch']['en-us'] = "Passwords did not match.";
|
||||
$text['message-password_blank']['en-us'] = "Invalid Password";
|
||||
$text['message-password_blank']['es-cl'] = "Contraseña No Válida";
|
||||
$text['message-password_blank']['pt-pt'] = "Senha Inválida";
|
||||
$text['message-password_blank']['fr-fr'] = "Mot de Passe Incorrect";
|
||||
|
||||
$text['message-password_mismatch']['en-us'] = "Password Mismatch";
|
||||
$text['message-password_mismatch']['es-cl'] = "Contraseñas no coinciden";
|
||||
$text['message-password_mismatch']['pt-pt'] = "As passwords não correspondem.";
|
||||
$text['message-password_mismatch']['fr-fr'] = "les mots de passe ne correspondent pas";
|
||||
|
||||
@@ -47,26 +47,9 @@ else {
|
||||
}
|
||||
|
||||
//get data from the db
|
||||
if (strlen($_REQUEST["id"])> 0) {
|
||||
if (strlen($_REQUEST["id"]) > 0) {
|
||||
$user_uuid = $_REQUEST["id"];
|
||||
}
|
||||
else {
|
||||
if (strlen($_SESSION["username"]) > 0) {
|
||||
$username = $_SESSION["username"];
|
||||
}
|
||||
}
|
||||
|
||||
//get the username from v_users
|
||||
$sql = "select * from v_users ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and user_uuid = '$user_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$username = $row["username"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
//required to be a superadmin to update an account that is a member of the superadmin group
|
||||
$superadmins = superadmin_list($db);
|
||||
@@ -119,10 +102,11 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
|
||||
//get the HTTP values and set as variables
|
||||
$user_uuid = $_REQUEST["id"];
|
||||
$username_old = check_str($_POST["username_old"]);
|
||||
$username = check_str($_POST["username"]);
|
||||
$password = check_str($_POST["password"]);
|
||||
$confirm_password = check_str($_POST["confirm_password"]);
|
||||
$user_status = check_str($_POST["user_status"]);
|
||||
//$user_template_name = check_str($_POST["user_template_name"]);
|
||||
$user_language = check_str($_POST["user_language"]);
|
||||
$user_time_zone = check_str($_POST["user_time_zone"]);
|
||||
$contact_uuid = check_str($_POST["contact_uuid"]);
|
||||
@@ -130,23 +114,26 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
$user_enabled = check_str($_POST["user_enabled"]);
|
||||
$api_key = check_str($_POST["api_key"]);
|
||||
|
||||
//set the required values
|
||||
if ($password != $confirm_password) { $msg_error .= $text['message-password_mismatch']."<br>\n"; }
|
||||
//if (strlen($contact_uuid) == 0) { $msg_error .= $text['message-required'].$text['label-email']."<br>\n"; }
|
||||
//if (strlen($user_time_zone) == 0) { $msg_error .= $text['message-required'].$text['label-time_zone']."<br>\n"; }
|
||||
if (strlen($user_enabled) == 0) { $msg_error .= $text['message-required'].$text['label-enabled']."<br>\n"; }
|
||||
//check required values
|
||||
if ($username != $username_old) {
|
||||
$sql = "select count(*) as num_rows from v_users where domain_uuid = '".$domain_uuid."' and username = '".$username."'";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
if ($prep_statement) {
|
||||
$prep_statement->execute();
|
||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||
if (0 < $row['num_rows']) {
|
||||
$msg_error = $text['message-username_exists'];
|
||||
}
|
||||
}
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
if ($password != $confirm_password) { $msg_error = $text['message-password_mismatch']; }
|
||||
|
||||
if ($msg_error) {
|
||||
require_once "resources/header.php";
|
||||
echo "<div align='center'>";
|
||||
echo "<table><tr><td>";
|
||||
echo $msg_error;
|
||||
echo "</td></tr></table>";
|
||||
echo "<br />\n";
|
||||
require_once "resources/persist_form.php";
|
||||
echo persistform($_POST);
|
||||
echo "</div>";
|
||||
require_once "resources/footer.php";
|
||||
return;
|
||||
$_SESSION["message"] = $msg_error;
|
||||
header("Location: usersupdate.php?id=".$user_uuid);
|
||||
exit;
|
||||
}
|
||||
|
||||
//check to see if user language is set
|
||||
@@ -239,6 +226,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
$sql .= "'".$user_uuid."' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
else {
|
||||
if (strlen($user_time_zone) == 0) {
|
||||
@@ -257,6 +245,7 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
$sql .= "and user_setting_subcategory = 'time_zone' ";
|
||||
$sql .= "and user_uuid = '".$user_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,17 +277,9 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
}
|
||||
}
|
||||
|
||||
//if the template has not been assigned by the superadmin
|
||||
//if (strlen($_SESSION['domain']['template']['name']) == 0) {
|
||||
//set the session theme for the active user
|
||||
// if ($_SESSION["username"] == $username) {
|
||||
// $_SESSION['domain']['template']['name'] = $user_template_name;
|
||||
// }
|
||||
//}
|
||||
|
||||
//sql update
|
||||
$sql = "update v_users set ";
|
||||
if (if_group("admin") && strlen($_POST["username"])> 0) {
|
||||
if (strlen($username) > 0 && $username != $username_old) {
|
||||
$sql .= "username = '$username', ";
|
||||
}
|
||||
if (strlen($password) > 0 && $confirm_password == $password) {
|
||||
@@ -322,63 +303,57 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") {
|
||||
else {
|
||||
$sql .= "contact_uuid = '$contact_uuid' ";
|
||||
}
|
||||
if (strlen($user_uuid)> 0) {
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and user_uuid = '$user_uuid' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and username = '$username' ";
|
||||
}
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and user_uuid = '$user_uuid' ";
|
||||
$db->exec(check_sql($sql));
|
||||
|
||||
//update the user_status
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
$switch_cmd .= "callcenter_config agent set status ".$username."@".$_SESSION['domain_name']." '".$user_status."'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
|
||||
//update the user state
|
||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||
$response = event_socket_request($fp, $cmd);
|
||||
// if call center installed
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/app/call_center/app_config.php")) {
|
||||
|
||||
//clear the template so it will rebuild in case the template was changed
|
||||
//$_SESSION["template_content"] = '';
|
||||
// update agent and tiers tables
|
||||
$sql = "update v_call_center_agents set agent_name = '".$username."' where domain_uuid = '".$domain_uuid."' and agent_name = '".$username_old."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
$sql = "update v_call_center_tiers set agent_name = '".$username."' where domain_uuid = '".$domain_uuid."' and agent_name = '".$username_old."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
//syncrhonize the configuration
|
||||
save_call_center_xml();
|
||||
|
||||
//update the user_status
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
$switch_cmd .= "callcenter_config agent set status ".$username."@".$_SESSION['domain_name']." '".$user_status."'";
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
|
||||
//update the user state
|
||||
$cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting";
|
||||
$response = event_socket_request($fp, $cmd);
|
||||
|
||||
}
|
||||
|
||||
//redirect the browser
|
||||
$_SESSION["message"] = $text['message-update'];
|
||||
if (if_group("admin") || if_group("superadmin")) {
|
||||
header("Location: usersupdate.php?id=".$user_uuid);
|
||||
}
|
||||
else {
|
||||
header("Location: usersupdate.php");
|
||||
}
|
||||
header("Location: index.php");
|
||||
return;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
$sql = "select * from v_users ";
|
||||
//allow admin access
|
||||
if (if_group("admin") || if_group("superadmin")) {
|
||||
if (strlen($user_uuid)> 0) {
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and user_uuid = '$user_uuid' ";
|
||||
}
|
||||
else {
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and username = '$username' ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and username = '$username' ";
|
||||
$sql .= "and user_uuid = '$user_uuid' ";
|
||||
}
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$user_uuid = $row["user_uuid"];
|
||||
if (if_group("admin")) {
|
||||
$username = $row["username"];
|
||||
}
|
||||
$username = $row["username"];
|
||||
$password = $row["password"];
|
||||
$api_key = $row["api_key"];
|
||||
$user_enabled = $row["user_enabled"];
|
||||
@@ -389,6 +364,7 @@ else {
|
||||
//get the groups the user is a member of
|
||||
//group_members function defined in config.php
|
||||
$group_members = group_members($db, $user_uuid);
|
||||
|
||||
}
|
||||
|
||||
//include the header
|
||||
@@ -427,7 +403,14 @@ else {
|
||||
|
||||
echo " <tr>";
|
||||
echo " <td width='30%' class='vncellreq'>".$text['label-username'].":</td>";
|
||||
echo " <td width='70%' class='vtable'>$username</td>";
|
||||
echo " <td width='70%' class='vtable'>";
|
||||
if (if_group("admin") || if_group("superadmin")) {
|
||||
echo " <input type='txt' autocomplete='off' class='formfld' name='username' value='".$username."'>";
|
||||
}
|
||||
else {
|
||||
echo " ".$username;
|
||||
}
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
echo " <tr>";
|
||||
@@ -463,6 +446,7 @@ else {
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$assigned_groups[] = $field['group_name'];
|
||||
}
|
||||
}
|
||||
echo "</table>\n";
|
||||
@@ -476,13 +460,8 @@ else {
|
||||
echo "<option value=\"\"></option>\n";
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach($result as $field) {
|
||||
if ($field['group_name'] == "superadmin") {
|
||||
//only show the superadmin group to other users in the superadmin group
|
||||
if (if_group("superadmin")) {
|
||||
echo "<option value='".$field['group_name']."'>".$field['group_name']."</option>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other users in the superadmin group
|
||||
if (!in_array($field["group_name"], $assigned_groups)) {
|
||||
echo "<option value='".$field['group_name']."'>".$field['group_name']."</option>\n";
|
||||
}
|
||||
}
|
||||
@@ -592,40 +571,6 @@ else {
|
||||
echo " </tr>\n";
|
||||
}
|
||||
|
||||
//if the template has not been assigned by the superadmin
|
||||
/*
|
||||
if (strlen($_SESSION['domain']['template']['name']) == 0) {
|
||||
echo " <tr>\n";
|
||||
echo " <td width='20%' class=\"vncell\">\n";
|
||||
echo " Template: \n";
|
||||
echo " </td>\n";
|
||||
echo " <td class=\"vtable\">\n";
|
||||
echo " <select id='user_template_name' name='user_template_name' class='formfld' style=''>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
$theme_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
|
||||
if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes')) {
|
||||
while (false !== ($dir_name = readdir($handle))) {
|
||||
if ($dir_name != "." && $dir_name != ".." && $dir_name != ".svn" && is_dir($theme_dir.'/'.$dir_name)) {
|
||||
$dir_label = str_replace('_', ' ', $dir_name);
|
||||
$dir_label = str_replace('-', ' ', $dir_label);
|
||||
if ($dir_name == $user_settings['domain']['template']['name']) {
|
||||
echo " <option value='$dir_name' selected='selected'>$dir_label</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='$dir_name'>$dir_label</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo " <br />\n";
|
||||
echo " Select a template to set as the default and then press save.<br />\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
}
|
||||
*/
|
||||
|
||||
echo " <tr>\n";
|
||||
echo " <td width='20%' class=\"vncell\">\n";
|
||||
echo " ".$text['label-user_language'].": \n";
|
||||
@@ -726,7 +671,7 @@ else {
|
||||
echo " <tr>";
|
||||
echo " <td colspan='2' align='right'>";
|
||||
echo " <input type='hidden' name='id' value=\"$user_uuid\">";
|
||||
echo " <input type='hidden' name='username' value=\"$username\">";
|
||||
echo " <input type='hidden' name='username_old' value=\"$username\">";
|
||||
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
Reference in New Issue
Block a user