Multilinguified User Manager & Group Manager

This commit is contained in:
Nate Jones
2013-06-09 04:32:24 +00:00
parent 431461d667
commit 626208cde3
10 changed files with 275 additions and 152 deletions

View File

@@ -27,7 +27,7 @@ include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists("user_add") ||
permission_exists("user_edit") ||
permission_exists("user_edit") ||
permission_exists("user_delete") ||
if_group("superadmin")) {
//access allowed
@@ -37,6 +37,12 @@ else {
return;
}
//add multi-lingual support
require_once "app_languages.php";
foreach($text as $key => $value) {
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//get data from the db
if (strlen($_REQUEST["id"])> 0) {
$user_uuid = $_REQUEST["id"];
@@ -64,7 +70,7 @@ else {
//required to be a superadmin to update an account that is a member of the superadmin group
$superadmin_list = superadmin_list($db);
if (if_superadmin($superadmin_list, $_SESSION['user_uuid'])) {
if (!if_group("superadmin")) {
if (!if_group("superadmin")) {
echo "access denied";
return;
}
@@ -83,7 +89,7 @@ else {
//redirect the user
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=usersupdate.php?id=$user_uuid\">\n";
echo "<div align='center'>Update Complete</div>";
echo "<div align='center'>".$text['message-update']."</div>";
require_once "includes/footer.php";
return;
}
@@ -121,12 +127,10 @@ if (count($_POST)>0 && $_POST["persistform"] != "1") {
$group_member = check_str($_POST["group_member"]);
$user_enabled = check_str($_POST["user_enabled"]);
//if (strlen($password) == 0) { $msg_error .= "Password cannot be blank.<br>\n"; }
//if (strlen($username) == 0) { $msg_error .= "Please provide the username.<br>\n"; }
if ($password != $confirm_password) { $msg_error .= "Passwords did not match.<br>\n"; }
//if (strlen($contact_uuid) == 0) { $msg_error .= "Please provide an email.<br>\n"; }
//if (strlen($user_time_zone) == 0) { $msg_error .= "Please provide an time zone.<br>\n"; }
if (strlen($user_enabled) == 0) { $msg_error .= "Please provide an enable or disable the user.<br>\n"; }
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"; }
if ($msg_error) {
require_once "includes/header.php";
@@ -142,7 +146,7 @@ if (count($_POST)>0 && $_POST["persistform"] != "1") {
return;
}
//get the number of rows in v_user_settings
//get the number of rows in v_user_settings
$sql = "select count(*) as num_rows from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
@@ -283,7 +287,7 @@ if (count($_POST)>0 && $_POST["persistform"] != "1") {
else {
echo "<meta http-equiv=\"refresh\" content=\"2;url=usersupdate.php?id=$user_uuid\">\n";
}
echo "<div align='center'>Update Complete</div>";
echo "<div align='center'>".$text['message-update']."</div>";
require_once "includes/footer.php";
return;
}
@@ -326,11 +330,11 @@ else {
//include the header
require_once "includes/header.php";
$page["title"] = $text['title-user_edit'];
//show the content
$table_width ='width="100%"';
echo "<form method='post' action=''>";
echo "<br />\n";
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
@@ -338,15 +342,15 @@ else {
echo "<td>\n";
echo "<table $table_width cellpadding='3' cellspacing='0' border='0'>";
echo "<td align='left' width='90%' nowrap><b>User Manager</b></td>\n";
echo "<td align='left' width='90%' nowrap><b>".$text['header-user_edit']."</b></td>\n";
echo "<td nowrap='nowrap'>\n";
echo " <input type='submit' name='submit' class='btn' value='Save'>";
echo " <input type='button' class='btn' onclick=\"window.location='index.php'\" value='Back'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo " <input type='button' class='btn' onclick=\"window.location='index.php'\" value='".$text['button-back']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo " Edit user information and group membership. \n";
echo " ".$text['description-user_edit']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
@@ -355,25 +359,25 @@ else {
echo "<table $table_width cellpadding='6' cellspacing='0' border='0'>";
echo "<tr>\n";
echo " <th class='th' colspan='2' align='left'>User Info</th>\n";
echo " <th class='th' colspan='2' align='left'>".$text['label-user_info']."</th>\n";
echo "</tr>\n";
echo " <tr>";
echo " <td width='30%' class='vncellreq'>Username:</td>";
echo " <td width='30%' class='vncellreq'>".$text['label-username'].":</td>";
echo " <td width='70%' class='vtable'>$username</td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Password:</td>";
echo " <td class='vncell'>".$text['label-password'].":</td>";
echo " <td class='vtable'><input type='password' autocomplete='off' class='formfld' name='password' value=\"\"></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>Confirm Password:</td>";
echo " <td class='vncell'>".$text['label-confirm_password'].":</td>";
echo " <td class='vtable'><input type='password' autocomplete='off' class='formfld' name='confirm_password' value=\"\"></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>Groups:</td>";
echo " <td class='vncell' valign='top'>".$text['label-groups'].":</td>";
echo " <td class='vtable'>";
echo "<table width='52%'>\n";
@@ -392,7 +396,7 @@ else {
echo " <td class='vtable'>".$field['group_name']."</td>\n";
echo " <td>\n";
if (permission_exists('group_member_delete') || if_group("superadmin")) {
echo " <a href='usersupdate.php?id=".$user_uuid."&domain_uuid=".$domain_uuid."&group_name=".$field['group_name']."&a=delete' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
echo " <a href='usersupdate.php?id=".$user_uuid."&domain_uuid=".$domain_uuid."&group_name=".$field['group_name']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
@@ -420,7 +424,7 @@ else {
}
}
echo "</select>";
echo "<input type=\"submit\" class='btn' value=\"Add\">\n";
echo "<input type=\"submit\" class='btn' value=\"".$text['button-add']."\">\n";
unset($sql, $result);
echo " </td>";
echo " </tr>";
@@ -431,11 +435,11 @@ else {
echo "<table $table_width cellpadding='6' cellspacing='0'>";
echo " <tr>\n";
echo " <th class='th' colspan='2' align='left'>Additional Info</th>\n";
echo " <th class='th' colspan='2' align='left'>".$text['label-additional_info']."</th>\n";
echo " </tr>\n";
echo " <tr>";
echo " <td width='30%' class='vncell'>Contact:</td>";
echo " <td width='30%' class='vncell'>".$text['label-contact'].":</td>";
echo " <td width='70%' class='vtable'>\n";
$sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family from v_contacts ";
$sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' ";
@@ -469,9 +473,9 @@ else {
unset($sql, $result, $row_count);
echo "</select>\n";
echo "<br />\n";
echo "Assign a contact to this user account.\n";
echo $text['description-contact']."\n";
if (strlen($contact_uuid) > 0) {
echo " <a href=\"/app/contacts/contacts_edit.php?id=$contact_uuid\">View</a>\n";
echo " <a href=\"/app/contacts/contacts_edit.php?id=$contact_uuid\">".$text['description-contact_view']."</a>\n";
}
echo " </td>";
echo " </tr>";
@@ -482,45 +486,45 @@ else {
else {
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" style='text-align: left;'>\n";
echo " Status:\n";
echo " ".$text['label-status'].":\n";
echo " </td>\n";
echo " <td class=\"vtable\">\n";
$cmd = "'".PROJECT_PATH."/app/calls_active/v_calls_exec.php?cmd=callcenter_config+agent+set+status+".$_SESSION['username']."@".$_SESSION['domain_name']."+'+this.value";
echo " <select id='user_status' name='user_status' class='formfld' style='' onchange=\"send_cmd($cmd);\">\n";
echo " <option value=''></option>\n";
if ($user_status == "Available") {
echo " <option value='Available' selected='selected'>Available</option>\n";
echo " <option value='Available' selected='selected'>".$text['option-available']."</option>\n";
}
else {
echo " <option value='Available'>Available</option>\n";
echo " <option value='Available'>".$text['option-available']."</option>\n";
}
if ($user_status == "Available (On Demand)") {
echo " <option value='Available (On Demand)' selected='selected'>Available (On Demand)</option>\n";
echo " <option value='Available (On Demand)' selected='selected'>".$text['option-available_on_demand']."</option>\n";
}
else {
echo " <option value='Available (On Demand)'>Available (On Demand)</option>\n";
echo " <option value='Available (On Demand)'>".$text['option-available_on_demand']."</option>\n";
}
if ($user_status == "Logged Out") {
echo " <option value='Logged Out' selected='selected'>Logged Out</option>\n";
echo " <option value='Logged Out' selected='selected'>".$text['option-logged_out']."</option>\n";
}
else {
echo " <option value='Logged Out'>Logged Out</option>\n";
echo " <option value='Logged Out'>".$text['option-logged_out']."</option>\n";
}
if ($user_status == "On Break") {
echo " <option value='On Break' selected='selected'>On Break</option>\n";
echo " <option value='On Break' selected='selected'>".$text['option-on_break']."</option>\n";
}
else {
echo " <option value='On Break'>On Break</option>\n";
echo " <option value='On Break'>".$text['option-on_break']."</option>\n";
}
if ($user_status == "Do Not Disturb") {
echo " <option value='Do Not Disturb' selected='selected'>Do Not Disturb</option>\n";
echo " <option value='Do Not Disturb' selected='selected'>".$text['option-do_not_disturb']."</option>\n";
}
else {
echo " <option value='Do Not Disturb'>Do Not Disturb</option>\n";
echo " <option value='Do Not Disturb'>".$text['option-do_not_disturb']."</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " Select a the user status.<br />\n";
echo " ".$text['description-status']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
}
@@ -561,7 +565,7 @@ else {
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" style='text-align: left;'>\n";
echo " Time Zone: \n";
echo " ".$text['label-time_zone'].": \n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='user_time_zone' name='user_time_zone' class='formfld' style=''>\n";
@@ -590,34 +594,34 @@ else {
}
echo " </select>\n";
echo " <br />\n";
echo " Select the default time zone.<br />\n";
echo " ".$text['description-time_zone']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Enabled:\n";
echo " ".$text['label-enabled'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='user_enabled'>\n";
echo " <option value=''></option>\n";
if ($user_enabled == "true" || $user_enabled == "") {
echo " <option value='true' selected='selected'>true</option>\n";
if ($user_enabled == "true" || $user_enabled == "") {
echo " <option value='true' selected='selected'>".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>true</option>\n";
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($user_enabled == "false") {
echo " <option value='false' selected='selected'>false</option>\n";
if ($user_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>false</option>\n";
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "Enable/disable this user.\n";
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</tr>\n";
echo " </table>";
echo "<br>";
@@ -628,7 +632,7 @@ else {
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='submit' name='submit' class='btn' value='Save'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo " </td>";
echo " </tr>";
echo "</table>";