Users: Revamp and consolidate code, integrate ORM.

This commit is contained in:
reliberate 2016-10-05 10:29:30 -06:00
parent d98bac68a6
commit d20a495548
32 changed files with 2613 additions and 2342 deletions

241
core/groups/app_config.php Normal file
View File

@ -0,0 +1,241 @@
<?php
//application details
$apps[$x]['name'] = "Group Manager";
$apps[$x]['uuid'] = "2caf27b0-540a-43d5-bb9b-c9871a1e4f84";
$apps[$x]['category'] = "Core";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "Manage user groups and permissions.";
$apps[$x]['description']['es-cl'] = "Administrar grupos de usuarios y permisos.";
$apps[$x]['description']['de-de'] = "";
$apps[$x]['description']['de-ch'] = "";
$apps[$x]['description']['de-at'] = "";
$apps[$x]['description']['fr-fr'] = "Gérer les groupes d'utilisateurs et des autorisations.";
$apps[$x]['description']['fr-ca'] = "";
$apps[$x]['description']['fr-ch'] = "";
$apps[$x]['description']['pt-pt'] = "Gerenciar grupos de usuários e permissões.";
$apps[$x]['description']['pt-br'] = "Gerenciar grupos de usuários e permissões.";
//permission details
$y = 0;
$apps[$x]['permissions'][$y]['name'] = "group_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = 'group_domain';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'group_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_add";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_delete";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permissions";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
//schema details
$y = 0; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_groups";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupid";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_protected";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_description";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupdesc";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y = 1; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_group_users";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_user_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupid";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_groups";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "username";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y = 2; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_group_permissions";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_permission_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "group_permission_name";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "permission_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "permission_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
?>

View File

@ -0,0 +1,65 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
if ($domains_processed == 1) {
//if the default groups do not exist add them
$group = new groups;
$group->defaults();
//find rows that have a null group_uuid and set the correct group_uuid
$sql = "select * from v_group_users ";
$sql .= "where group_uuid is null; ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$db->beginTransaction();
foreach($result as $row) {
if (strlen($row['group_name']) > 0) {
//get the group_uuid
$sql = "select group_uuid from v_groups ";
$sql .= "where group_name = '".$row['group_name']."' ";
$prep_statement_sub = $db->prepare($sql);
$prep_statement_sub->execute();
$sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC);
unset ($prep_statement_sub);
$group_uuid = $sub_result['group_uuid'];
//set the group_uuid
$sql = "update v_group_users set ";
$sql .= "group_uuid = '".$group_uuid."' ";
$sql .= "where group_user_uuid = '".$row['group_user_uuid']."'; ";
$db->exec($sql);
unset($sql);
}
}
$db->commit();
unset ($prep_statement);
}
}
?>

File diff suppressed because it is too large Load Diff

19
core/groups/app_menu.php Normal file
View File

@ -0,0 +1,19 @@
<?php
$apps[$x]['menu'][3]['title']['en-us'] = "Group Manager";
$apps[$x]['menu'][3]['title']['es-cl'] = "Administración de Grupos";
$apps[$x]['menu'][3]['title']['fr-fr'] = "Gestion des groupes";
$apps[$x]['menu'][3]['title']['pt-pt'] = "'Gestão de Grupos";
$apps[$x]['menu'][3]['title']['pt-br'] = "Gerenciar grupos";
$apps[$x]['menu'][3]['title']['pl'] = "Menedżer grup";
$apps[$x]['menu'][3]['title']['uk'] = "Групи";
$apps[$x]['menu'][3]['title']['sv-se'] = "Grupp Inställningar";
$apps[$x]['menu'][3]['title']['de-at'] = "Gruppenverwaltung";
$apps[$x]['menu'][3]['title']['he'] = "מנהל קבוצה";
$apps[$x]['menu'][3]['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['menu'][3]['parent_uuid'] = "594d99c5-6128-9c88-ca35-4b33392cec0f";
$apps[$x]['menu'][3]['category'] = "internal";
$apps[$x]['menu'][3]['path'] = "/core/groups/groups.php";
$apps[$x]['menu'][3]['groups'][] = "superadmin";
?>

View File

@ -43,7 +43,7 @@
$text = $language->get();
//permission restore default
require_once "core/users/resources/classes/permission.php";
require_once "core/groups/resources/classes/permission.php";
$permission = new permission;
$permission->db = $db;
$permission->restore();

90
core/groups/root.php Normal file
View File

@ -0,0 +1,90 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
umask(2);
if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";");
} else {
define("PATH_SEPARATOR", ":");
}
}
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) {
$path = '/';
} else {
$i = 1;
$path = '';
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
}
$_SERVER["DOCUMENT_ROOT"] = $path;
}else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
}
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used
if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', '');
} else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1;
$path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
if(!file_exists($path. '/project_root.php')){
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
}
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path);
}
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
}
?>

View File

@ -106,7 +106,7 @@
// restore default permissions
if ($do["permissions"] && permission_exists("group_edit")) {
$included = true;
require_once("core/users/permissions_default.php");
require_once("core/groups/permissions_default.php");
$response_message = "Permission Defaults Restored";
}
@ -129,9 +129,9 @@
echo "<br><br>";
echo $text['description-upgrade'];
echo "<br><br>";
echo "<form name='frm' method='post' action=''>\n";
if (permission_exists("upgrade_source") && !is_dir("/usr/share/examples/fusionpbx") && is_writeable($_SERVER["PROJECT_ROOT"]."/.git")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -144,7 +144,7 @@
echo "</tr>\n";
echo "</table>\n";
}
if (permission_exists("upgrade_schema")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -156,7 +156,7 @@
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<div id='tr_data_types' style='display: none;'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -170,7 +170,7 @@
echo "</table>\n";
echo "</div>\n";
}
if (permission_exists("upgrade_apps")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -183,7 +183,7 @@
echo "</tr>\n";
echo "</table>\n";
}
if (permission_exists("menu_restore")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -207,7 +207,7 @@
echo "</tr>\n";
echo "</table>\n";
}
if (permission_exists("group_edit")) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
@ -220,12 +220,12 @@
echo "</tr>\n";
echo "</table>\n";
}
echo "<br>";
echo "<div style='text-align: right;'><input type='submit' class='btn' value='".$text['button-upgrade_execute']."'></div>";
echo "<br><br>";
echo "</form>\n";
// output result of source update
if (sizeof($_SESSION["response_source_update"]) > 0) {
echo "<br />";
@ -237,7 +237,7 @@
echo "<br /><br />";
unset($_SESSION["response_source_update"]);
}
// output result of upgrade schema
if ($_SESSION["schema"]["response"] != '') {
echo "<br />";

View File

@ -1,25 +1,5 @@
<?php
$apps[$x]['menu'][0]['title']['en-us'] = "Account Settings";
$apps[$x]['menu'][0]['title']['es-cl'] = "Config de Cuenta";
$apps[$x]['menu'][0]['title']['fr-fr'] = "Configuration du Compte";
$apps[$x]['menu'][0]['title']['pt-pt'] = "Configurações da Conta";
$apps[$x]['menu'][0]['title']['pt-br'] = "Configurações da conta";
$apps[$x]['menu'][0]['title']['pl'] = "Ustawienia konta";
$apps[$x]['menu'][0]['title']['he'] = "הגדרת חשבון";
$apps[$x]['menu'][0]['title']['uk'] = "Обліковий запис";
$apps[$x]['menu'][0]['title']['sv-se'] = "Kontoinställningar";
$apps[$x]['menu'][0]['title']['de-at'] = "Kontoeinstellungen";
$apps[$x]['menu'][0]['title']['ro'] = "Setări cont";
$apps[$x]['menu'][0]['title']['ar-eg'] = "إعدادات الحساب";
$apps[$x]['menu'][0]['uuid'] = "4d532f0b-c206-c39d-ff33-fc67d668fb69";
$apps[$x]['menu'][0]['parent_uuid'] = "02194288-6d56-6d3e-0b1a-d53a2bc10788";
$apps[$x]['menu'][0]['category'] = "internal";
$apps[$x]['menu'][0]['path'] = "/core/user_settings/user_edit.php";
$apps[$x]['menu'][0]['groups'][] = "user";
$apps[$x]['menu'][0]['groups'][] = "admin";
$apps[$x]['menu'][0]['groups'][] = "superadmin";
$apps[$x]['menu'][1]['title']['en-us'] = "Dashboard";
$apps[$x]['menu'][1]['title']['es-cl'] = "Dashboard Usuario";
$apps[$x]['menu'][1]['title']['fr-fr'] = "Tableau de bord de l'utilisateur";

View File

@ -1,532 +0,0 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists("user_account_setting_view")) {
//access granted
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the username from v_users
$username = $_SESSION["username"];
$user_uuid = $_SESSION["user_uuid"];
//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, $user_uuid)) {
if (!if_group("superadmin")) {
echo "access denied";
return;
}
}
//get the user settings
$sql = "select * from v_user_settings ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$sql .= "and user_setting_enabled = 'true' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
$name = $row['user_setting_name'];
$category = $row['user_setting_category'];
$subcategory = $row['user_setting_subcategory'];
if (strlen($subcategory) == 0) {
//$$category[$name] = $row['domain_setting_value'];
$user_settings[$category][$name] = $row['user_setting_value'];
}
else {
$user_settings[$category][$subcategory][$name] = $row['user_setting_value'];
}
}
}
//process http post data
if (count($_POST) > 0 && $_POST["persistform"] != "1") {
//get the HTTP values and set as variables
$password = check_str($_POST["password"]);
$password_confirm = check_str($_POST["password_confirm"]);
$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"]);
$group_member = check_str($_POST["group_member"]);
//check required values
if ($password != $password_confirm) { $msg_error = $text['message-password_mismatch']; }
if ($msg_error != '') {
$_SESSION["message"] = $msg_error;
$_SESSION["message_mood"] = 'negative';
header("Location: user_edit.php");
exit;
}
if (!check_password_strength($password, $text)) {
header("Location: user_edit.php");
exit;
}
//check to see if user language is set
$sql = "select count(*) as num_rows from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$user_setting_uuid = uuid();
$sql = "insert into v_user_settings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "user_setting_uuid, ";
$sql .= "user_setting_category, ";
$sql .= "user_setting_subcategory, ";
$sql .= "user_setting_name, ";
$sql .= "user_setting_value, ";
$sql .= "user_setting_enabled, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$_SESSION["domain_uuid"]."', ";
$sql .= "'".$user_setting_uuid."', ";
$sql .= "'domain', ";
$sql .= "'language', ";
$sql .= "'code', ";
$sql .= "'".$user_language."', ";
$sql .= "'true', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
$db->exec(check_sql($sql));
}
else {
if (strlen($user_language) == 0) {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
$sql = "update v_user_settings set ";
$sql .= "user_setting_value = '".$user_language."', ";
$sql .= "user_setting_enabled = 'true' ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
}
}
}
//check to see if user time_zone is set
$sql = "select count(*) as num_rows from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$user_setting_uuid = uuid();
$sql = "insert into v_user_settings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "user_setting_uuid, ";
$sql .= "user_setting_category, ";
$sql .= "user_setting_subcategory, ";
$sql .= "user_setting_name, ";
$sql .= "user_setting_value, ";
$sql .= "user_setting_enabled, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$_SESSION["domain_uuid"]."', ";
$sql .= "'".$user_setting_uuid."', ";
$sql .= "'domain', ";
$sql .= "'time_zone', ";
$sql .= "'name', ";
$sql .= "'".$user_time_zone."', ";
$sql .= "'true', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
$db->exec(check_sql($sql));
}
else {
if (strlen($user_time_zone) == 0) {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
$sql = "update v_user_settings set ";
$sql .= "user_setting_value = '".$user_time_zone."', ";
$sql .= "user_setting_enabled = 'true' ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
}
}
}
//sql update
$sql = "update v_users set ";
if (strlen($password) > 0 && $password_confirm == $password) {
//salt used with the password to create a one way hash
$salt = generate_password('20', '4');
//set the password
$sql .= "password = '".md5($salt.$password)."', ";
$sql .= "salt = '".$salt."', ";
}
$sql .= "user_status = '$user_status' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and user_uuid = '$user_uuid' ";
if (permission_exists("user_account_setting_edit")) {
$count = $db->exec(check_sql($sql));
}
//if call center app is installed then update the user_status
if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/call_center')) {
//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['confirm-update'];
header("Location: ".PROJECT_PATH."/core/user_settings/user_edit.php");
return;
}
else {
$sql = "select * from v_users ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and user_uuid = '$user_uuid' ";
$sql .= "and user_enabled = 'true' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as $row) {
//$password = $row["password"];
$user_status = $row["user_status"];
break; //limit to 1 row
}
//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
require_once "resources/header.php";
//show the content
$table_width ='width="100%"';
echo "<script>\n";
echo " function compare_passwords() {\n";
echo " if (document.getElementById('password') === document.activeElement || document.getElementById('password_confirm') === document.activeElement) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " if ($('#password').val() != $('#password_confirm').val()) {\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " $('#password').addClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').addClass('formfld_highlight_bad');\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').addClass('formfld_highlight_good');\n";
echo " $('#password_confirm').addClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
$req['length'] = $_SESSION['security']['password_length']['numeric'];
$req['number'] = ($_SESSION['security']['password_number']['boolean'] == 'true') ? true : false;
$req['lowercase'] = ($_SESSION['security']['password_lowercase']['boolean'] == 'true') ? true : false;
$req['uppercase'] = ($_SESSION['security']['password_uppercase']['boolean'] == 'true') ? true : false;
$req['special'] = ($_SESSION['security']['password_special']['boolean'] == 'true') ? true : false;
echo " function check_password_strength(pwd) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " var msg_errors = [];\n";
if (is_numeric($req['length']) && $req['length'] != 0) {
echo " var re = /.{".$req['length'].",}/;\n"; //length
echo " if (!re.test(pwd)) { msg_errors.push('".$req['length']."+ ".$text['label-characters']."'); }\n";
}
if ($req['number']) {
echo " var re = /(?=.*[\d])/;\n"; //number
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-numbers']."'); }\n";
}
if ($req['lowercase']) {
echo " var re = /(?=.*[a-z])/;\n"; //lowercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-lowercase_letters']."'); }\n";
}
if ($req['uppercase']) {
echo " var re = /(?=.*[A-Z])/;\n"; //uppercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-uppercase_letters']."'); }\n";
}
if ($req['special']) {
echo " var re = /(?=.*[\W])/;\n"; //special
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-special_characters']."'); }\n";
}
echo " if (msg_errors.length > 0) {\n";
echo " var msg = '".$text['message-password_requirements'].": ' + msg_errors.join(', ');\n";
echo " display_message(msg, 'negative', '6000');\n";
echo " return false;\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " function show_strenth_meter() {\n";
echo " $('#pwstrength_progress').slideDown();\n";
echo " }\n";
echo "</script>\n";
echo "<form name='frm' id='frm' method='post' action=''>";
echo "<table $table_width cellpadding='0' cellspacing='0' border='0'>";
echo "<td align='left' width='100%' nowrap><b>".$text['title']."</b></td>\n";
echo "<td nowrap='nowrap'>\n";
if (strlen($_SESSION['login']['destination']['url']) > 0) {
echo " <input type='button' class='btn' onclick=\"window.location='".$_SESSION['login']['destination']['url']."'\" value='".$text['button-back']."'>";
}
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo " ".$text['description']." \n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<table $table_width cellpadding='0' cellspacing='0' border='0'>";
echo "<tr>\n";
echo " <th class='th' colspan='2' align='left'>".$text['table-title']."</th>\n";
echo "</tr>\n";
echo " <tr>";
echo " <td width='30%' class='vncellreq' valign='top'>".$text['label-username']."</td>";
echo " <td width='70%' class='vtable'>";
echo " ".$username."<input type='hidden' id='username' value='".$username."'>\n";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-password']."</td>";
echo " <td class='vtable'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password' id='password' value='' onkeypress='show_strenth_meter();' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " <div id='pwstrength_progress' class='pwstrength_progress'></div>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-confirm-password']."</td>";
echo " <td class='vtable'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password_confirm' id='password_confirm' value='' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " </td>";
echo " </tr>";
echo " </td>";
echo " </tr>";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-user_language']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='user_language' name='user_language' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
//get all language codes from database
$sql = "select * from v_languages order by language asc";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$language_codes[$row["code"]] = $row["language"];
}
unset($prep_statement, $result, $row);
foreach ($_SESSION['app']['languages'] as $code) {
$selected = ($code == $user_settings['domain']['language']['code']) ? "selected='selected'" : null;
echo " <option value='".$code."' ".$selected.">".$language_codes[$code]." [".$code."]</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-user_language']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-time']."\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";
echo " <option value=''></option>\n";
//$list = DateTimeZone::listAbbreviations();
$time_zone_identifiers = DateTimeZone::listIdentifiers();
$previous_category = '';
$x = 0;
foreach ($time_zone_identifiers as $key => $row) {
$time_zone = explode("/", $row);
$category = $time_zone[0];
if ($category != $previous_category) {
if ($x > 0) {
echo " </optgroup>\n";
}
echo " <optgroup label='".$category."'>\n";
}
if ($row == $user_settings['domain']['time_zone']['name']) {
echo " <option value='".$row."' selected='selected'>".$row."</option>\n";
}
else {
echo " <option value='".$row."'>".$row."</option>\n";
}
$previous_category = $category;
$x++;
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-timezone']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
if ($_SESSION['user_status_display'] == "false") {
//hide the user_status when it is set to false
}
else {
echo " <tr>\n";
echo " <td width='30%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-status']."\n";
echo " </td>\n";
echo " <td width='70%' class=\"vtable\" align='left'>\n";
echo " <select id='user_status' name='user_status' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
if ($user_status == "Available") {
echo " <option value='Available' selected='selected'>".$text['check-available-status']."</option>\n";
}
else {
echo " <option value='Available'>".$text['check-available-status']."</option>\n";
}
if ($user_status == "Available (On Demand)") {
echo " <option value='Available (On Demand)' selected='selected'>".$text['check-available-ondemand-status']."</option>\n";
}
else {
echo " <option value='Available (On Demand)'>".$text['check-available-ondemand-status']."</option>\n";
}
if ($user_status == "Logged Out") {
echo " <option value='Logged Out' selected='selected'>".$text['check-loggedout-status']."</option>\n";
}
else {
echo " <option value='Logged Out'>".$text['check-loggedout-status']."</option>\n";
}
if ($user_status == "On Break") {
echo " <option value='On Break' selected='selected'>".$text['check-onbreak-status']."</option>\n";
}
else {
echo " <option value='On Break'>".$text['check-onbreak-status']."</option>\n";
}
if ($user_status == "Do Not Disturb") {
echo " <option value='Do Not Disturb' selected='selected'>".$text['check-do-not-disturb-status']."</option>\n";
}
else {
echo " <option value='Do Not Disturb'>".$text['check-do-not-disturb-status']."</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-status']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
}
echo "</table>";
echo "<br />";
echo "<div align='right'><input type='button' class='btn' value='".$text['button-save']."' onclick=\"if (check_password_strength(document.getElementById('password').value)) { submit_form(); }\"></div>";
echo "<br />";
echo "</form>";
//capture enter key to submit form
echo "<script>\n";
echo " $(window).keypress(function(event){\n";
echo " if (event.which == 13) { submit_form(); }\n";
echo " });\n";
// convert password fields to text
echo " function submit_form() {\n";
echo " $('input:password').css('visibility','hidden');\n";
echo " $('input:password').attr({type:'text'});\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
//include the footer
require_once "resources/footer.php";
?>

View File

@ -43,72 +43,6 @@
$apps[$x]['permissions'][$y]['name'] = 'user_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = 'group_domain';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = 'group_all';
$apps[$x]['permissions'][$y]['groups'][] = 'superadmin';
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_add";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_member_delete";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permissions";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_user_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "group_permission_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "user_setting_view";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
@ -218,156 +152,6 @@
$y = 1; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_groups";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupid";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_protected";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_description";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupdesc";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y = 2; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_group_users";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_user_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "groupid";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_groups";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "username";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y = 3; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_group_permissions";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_permission_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "id";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "group_permission_name";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "serial";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "integer";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "INT NOT NULL AUTO_INCREMENT";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "v_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$apps[$x]['db'][$y]['fields'][$z]['deprecated'] = "true";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "permission_name";
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "permission_id";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_name";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "group_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y = 4; //table array index
$z = 0; //field array index
$apps[$x]['db'][$y]['table'] = "v_user_settings";
$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_setting_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";

View File

@ -60,29 +60,6 @@ if ($domains_processed == 1) {
unset ($prep_statement);
}
//if user_enabled is null then set to enabled true
$sql = "select count(*) as count from v_users ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and user_enabled is null ";
$prep_statement = $db->prepare($sql);
$prep_statement->execute();
$sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset ($prep_statement);
if ($sub_result['count'] > 0) {
//begin the transaction
$db->beginTransaction();
//send output
if ($display_type == "text") {
echo " Users: set enabled=true\n";
}
//set the user_enabled to true
$sql = "update v_users set ";
$sql .= "user_enabled = 'true' ";
$db->exec($sql);
unset($sql);
//end the transaction
$db->commit();
}
}
?>

View File

@ -43,61 +43,6 @@ $text['title-user_add']['ro'] = "Utilizator";
$text['title-user_add']['de-at'] = "Benutzer";
$text['title-user_add']['he'] = "משתמש";
$text['title-group_permissions']['en-us'] = "Group Permissions";
$text['title-group_permissions']['es-cl'] = "Permisos de Grupo";
$text['title-group_permissions']['pt-pt'] = "Permissões do Grupo";
$text['title-group_permissions']['fr-fr'] = "Permissions du Groupe";
$text['title-group_permissions']['pl'] = "Uprawnienia grupy:";
$text['title-group_permissions']['uk'] = "Привілеї групи";
$text['title-group_permissions']['sv-se'] = "Grupp Rättigheter";
$text['title-group_permissions']['ro'] = "Permisiuni grup";
$text['title-group_permissions']['de-at'] = "Gruppenberechtigung";
$text['title-group_permissions']['he'] = "הרשאות קבוצה";
$text['title-group_members']['en-us'] = "Group Members";
$text['title-group_members']['es-cl'] = "Miembros del Grupo";
$text['title-group_members']['pt-pt'] = "Membros do Grupo";
$text['title-group_members']['fr-fr'] = "Membres du Groupe";
$text['title-group_members']['pl'] = "Członkowie grupy:";
$text['title-group_members']['uk'] = "Учасники групи";
$text['title-group_members']['sv-se'] = "Grupp Medlemmar";
$text['title-group_members']['ro'] = "Membri grup";
$text['title-group_members']['de-at'] = "Gruppenmitglieder";
$text['title-group_members']['he'] = "חברי קבוצה";
$text['title-group_manager']['en-us'] = "Group Manager";
$text['title-group_manager']['es-cl'] = "Administración de Grupo";
$text['title-group_manager']['pt-pt'] = "Gestão de Grupos";
$text['title-group_manager']['fr-fr'] = "Gestion de Groupe";
$text['title-group_manager']['pl'] = "Menedżer grup";
$text['title-group_manager']['uk'] = "Групи";
$text['title-group_manager']['sv-se'] = "Grupp Inställningar";
$text['title-group_manager']['ro'] = "";
$text['title-group_manager']['de-at'] = "Gruppenverwaltung";
$text['title-group_manager']['he'] = "מנהל קבוצה";
$text['title-group_edit']['en-us'] = "Edit Group";
$text['title-group_edit']['es-cl'] = "Editar Grupo";
$text['title-group_edit']['pt-pt'] = "Editar Grupo";
$text['title-group_edit']['fr-fr'] = "Modifier le Groupe";
$text['title-group_edit']['pl'] = "Edycja grupy";
$text['title-group_edit']['uk'] = "Редагувати групу";
$text['title-group_edit']['sv-se'] = "Editera Grupp";
$text['title-group_edit']['ro'] = "Editare grup";
$text['title-group_edit']['de-at'] = "Gruppe ändern";
$text['title-group_edit']['he'] = "ערוך קבוצה";
$text['title-group_add']['en-us'] = "Add Group";
$text['title-group_add']['es-cl'] = "Agregar Grupo";
$text['title-group_add']['pt-pt'] = "Adicionar Grupo";
$text['title-group_add']['fr-fr'] = "Ajouter un Groupe";
$text['title-group_add']['pl'] = "Dodaj grupę";
$text['title-group_add']['uk'] = "Додати групу";
$text['title-group_add']['sv-se'] = "Lägg Till Grupp";
$text['title-group_add']['ro'] = "Adăugare grup";
$text['title-group_add']['de-at'] = "Gruppe hinzufügen";
$text['title-group_add']['he'] = "הוסף קבוצה";
$text['option-true']['en-us'] = "True";
$text['option-true']['es-cl'] = "Verdadero";
$text['option-true']['pt-pt'] = "Sim";
@ -230,28 +175,6 @@ $text['message-password_requirements']['ro'] = "Cerințe privind parola";
$text['message-password_requirements']['de-at'] = "Kennwortanforderungen ";
$text['message-password_requirements']['he'] = "דרישות סיסמא";
$text['message-new_group_name']['en-us'] = "Enter a Name for the new Group...";
$text['message-new_group_name']['es-cl'] = "Introduzca un Nombre para el nuevo Grupo...";
$text['message-new_group_name']['pt-pt'] = "Digite um Nome para o novo Grupo...";
$text['message-new_group_name']['fr-fr'] = "Entrez un Nom pour le nouveau Groupe...";
$text['message-new_group_name']['pl'] = "Wprowadź nazwę nowej grupy";
$text['message-new_group_name']['uk'] = "Введіть назву нової групи";
$text['message-new_group_name']['sv-se'] = "Ange ett Namn för den nya Gruppen...";
$text['message-new_group_name']['ro'] = "";
$text['message-new_group_name']['de-at'] = "Geben Sie den Namen der neuen Gruppe an...";
$text['message-new_group_name']['he'] = "הכנס שם לקבוצה";
$text['message-new_group_description']['en-us'] = "Enter a Description for the new Group...";
$text['message-new_group_description']['es-cl'] = "Introduzca una Descripción para el nuevo Grupo...";
$text['message-new_group_description']['pt-pt'] = "Digite uma Descrição para o novo grupo...";
$text['message-new_group_description']['fr-fr'] = "Entrez une Description pour le nouveau groupe...";
$text['message-new_group_description']['pl'] = "Wprowadź opis nowej grupy";
$text['message-new_group_description']['uk'] = "Введіть опис нової групи";
$text['message-new_group_description']['sv-se'] = "Ange en Beskrivning för den nya Gruppen...";
$text['message-new_group_description']['ro'] = "";
$text['message-new_group_description']['de-at'] = "Geben Sie eine Beschreiben für die neue Gruppe an...";
$text['message-new_group_description']['he'] = "הכנס תאור לקבוצה";
$text['message-maximum_users']['en-us'] = "Maximum Users:";
$text['message-maximum_users']['es-cl'] = "Usuarios Máximo Permitido:";
$text['message-maximum_users']['pt-pt'] = "Usuários Máximo Permitido:";
@ -263,28 +186,6 @@ $text['message-maximum_users']['ro'] = "";
$text['message-maximum_users']['de-at'] = "Maximale Anzahl an Benutzern:";
$text['message-maximum_users']['he'] = "מקסימום משתמשים";
$text['message-group_exists']['en-us'] = "Group Already Exists";
$text['message-group_exists']['es-cl'] = "El Grupo ya Existe";
$text['message-group_exists']['pt-pt'] = "O Grupo já Existe";
$text['message-group_exists']['fr-fr'] = "Le groupe existe déjà";
$text['message-group_exists']['pl'] = "Grupa już istnieje";
$text['message-group_exists']['uk'] = "Група вже існує";
$text['message-group_exists']['sv-se'] = "Gruppen Existerar Redan";
$text['message-group_exists']['ro'] = "";
$text['message-group_exists']['de-at'] = "Gruppe existiert bereits";
$text['message-group_exists']['he'] = "הקבוצה כבר קיימת";
$text['message-default_system_group']['en-us'] = "Default system groups cannot be edited or deleted.";
$text['message-default_system_group']['es-cl'] = "Grupos predeterminados del sistema no pueden ser editados o eliminados.";
$text['message-default_system_group']['pt-pt'] = "Grupos de sistema padrão não podem ser editados ou apagados.";
$text['message-default_system_group']['fr-fr'] = "Les groupes par défaut du système ne peuvent pas être modifiés ou supprimés.";
$text['message-default_system_group']['pl'] = "Domyślne grupy systemowe nie mogą być edytowane lub usuwane";
$text['message-default_system_group']['uk'] = "Системні групи за замовчуванням не можна редагувати або видаляти";
$text['message-default_system_group']['sv-se'] = "Standard system grupper kan inte redigeras eller tas bort.";
$text['message-default_system_group']['ro'] = "";
$text['message-default_system_group']['de-at'] = "Systemgruppen können nicht bearbeitet oder gelöscht werden.";
$text['message-default_system_group']['he'] = "";
$text['message-copy']['en-us'] = "Copy Completed";
$text['message-copy']['es-cl'] = "Copia Completada";
$text['message-copy']['pt-pt'] = "Cópia Efectuada";
@ -624,72 +525,6 @@ $text['label-groups']['ro'] = "";
$text['label-groups']['de-at'] = "Gruppen";
$text['label-groups']['he'] = "קבוצות";
$text['label-group_tools']['en-us'] = "Tools";
$text['label-group_tools']['es-cl'] = "Instrumentos";
$text['label-group_tools']['pt-pt'] = "Ferramentas";
$text['label-group_tools']['fr-fr'] = "Outils";
$text['label-group_tools']['pl'] = "Narzędzia";
$text['label-group_tools']['uk'] = "Інструменти";
$text['label-group_tools']['sv-se'] = "Verktyg";
$text['label-group_tools']['ro'] = "";
$text['label-group_tools']['de-at'] = "Funktionen";
$text['label-group_tools']['he'] = "כלים";
$text['label-group_protected']['en-us'] = "Protected";
$text['label-group_protected']['es-cl'] = "Protegido";
$text['label-group_protected']['pt-pt'] = "Protegido";
$text['label-group_protected']['fr-fr'] = "Protégé";
$text['label-group_protected']['pl'] = "Zabezpieczony";
$text['label-group_protected']['uk'] = "Захищено";
$text['label-group_protected']['sv-se'] = "Skyddad";
$text['label-group_protected']['ro'] = "";
$text['label-group_protected']['de-at'] = "Geschützt";
$text['label-group_protected']['he'] = "שמור";
$text['label-group_permissions']['en-us'] = "Permissions";
$text['label-group_permissions']['es-cl'] = "Permisos";
$text['label-group_permissions']['pt-pt'] = "Permissões";
$text['label-group_permissions']['fr-fr'] = "Permissions";
$text['label-group_permissions']['pl'] = "Uprawnienia";
$text['label-group_permissions']['uk'] = "Дозволи";
$text['label-group_permissions']['sv-se'] = "Rättigheter";
$text['label-group_permissions']['ro'] = "";
$text['label-group_permissions']['de-at'] = "Berechtigungen";
$text['label-group_permissions']['he'] = "הראשות";
$text['label-group_name']['en-us'] = "Name";
$text['label-group_name']['es-cl'] = "Nombre";
$text['label-group_name']['pt-pt'] = "Nome";
$text['label-group_name']['fr-fr'] = "Nom";
$text['label-group_name']['pl'] = "Nazwa";
$text['label-group_name']['uk'] = "Назва";
$text['label-group_name']['sv-se'] = "Namn";
$text['label-group_name']['ro'] = "";
$text['label-group_name']['de-at'] = "Name";
$text['label-group_name']['he'] = "שם";
$text['label-group_members']['en-us'] = "Members";
$text['label-group_members']['es-cl'] = "Miembros";
$text['label-group_members']['pt-pt'] = "Membros";
$text['label-group_members']['fr-fr'] = "Membres";
$text['label-group_members']['pl'] = "Członkowie";
$text['label-group_members']['uk'] = "Учасники";
$text['label-group_members']['sv-se'] = "Medlemmar";
$text['label-group_members']['ro'] = "";
$text['label-group_members']['de-at'] = "Mitglieder";
$text['label-group_members']['he'] = "משתמשים";
$text['label-group_description']['en-us'] = "Description";
$text['label-group_description']['es-cl'] = "Descripción";
$text['label-group_description']['pt-pt'] = "Descrição";
$text['label-group_description']['fr-fr'] = "Description";
$text['label-group_description']['pl'] = "Opis";
$text['label-group_description']['uk'] = "Опис";
$text['label-group_description']['sv-se'] = "Beskrivning";
$text['label-group_description']['ro'] = "";
$text['label-group_description']['de-at'] = "Beschreibung";
$text['label-group_description']['he'] = "תאור";
$text['label-group']['en-us'] = "Group";
$text['label-group']['es-cl'] = "Grupo";
$text['label-group']['pt-pt'] = "Grupo";
@ -927,61 +762,6 @@ $text['header-user_add']['ro'] = "";
$text['header-user_add']['de-at'] = "Benutzer";
$text['header-user_add']['he'] = "משתמש";
$text['header-group_permissions']['en-us'] = "Group Permissions: ";
$text['header-group_permissions']['es-cl'] = "Permisos de Grupo: ";
$text['header-group_permissions']['pt-pt'] = "Permissões do Grupo: ";
$text['header-group_permissions']['fr-fr'] = "Permissions du Groupe: ";
$text['header-group_permissions']['pl'] = "Uprawnienia grupy";
$text['header-group_permissions']['uk'] = "Привілеї групи:";
$text['header-group_permissions']['sv-se'] = "Grupp Rättigheter";
$text['header-group_permissions']['ro'] = "";
$text['header-group_permissions']['de-at'] = "Gruppenberechtigungen:";
$text['header-group_permissions']['he'] = "הרשאות קבוצה";
$text['header-group_members']['en-us'] = "Group Members: ";
$text['header-group_members']['es-cl'] = "Miembros de Grupo: ";
$text['header-group_members']['pt-pt'] = "Membros do Grupo: ";
$text['header-group_members']['fr-fr'] = "Membres du Groupe: ";
$text['header-group_members']['pl'] = "Członkowie grupy:";
$text['header-group_members']['uk'] = "Учасники групи: ";
$text['header-group_members']['sv-se'] = "Grupp Medlemmar:";
$text['header-group_members']['ro'] = "";
$text['header-group_members']['de-at'] = "Gruppenmitglieder:";
$text['header-group_members']['he'] = "משתמשי קבוצה";
$text['header-group_manager']['en-us'] = "Group Manager";
$text['header-group_manager']['es-cl'] = "Administración de Grupo";
$text['header-group_manager']['pt-pt'] = "Gestão de Grupos";
$text['header-group_manager']['fr-fr'] = "Gestion de Groupe";
$text['header-group_manager']['pl'] = "Menadżer grup";
$text['header-group_manager']['uk'] = "Групи";
$text['header-group_manager']['sv-se'] = "Grupp Inställningar";
$text['header-group_manager']['ro'] = "";
$text['header-group_manager']['de-at'] = "Gruppenverwaltung";
$text['header-group_manager']['he'] = "מנהל קבוצה";
$text['header-group_edit']['en-us'] = "Edit Group";
$text['header-group_edit']['es-cl'] = "Editar Grupo";
$text['header-group_edit']['pt-pt'] = "Editar Grupo";
$text['header-group_edit']['fr-fr'] = "Modifier le Groupe";
$text['header-group_edit']['pl'] = "Edycja grupy";
$text['header-group_edit']['uk'] = "Редагувати групу";
$text['header-group_edit']['sv-se'] = "Editera Grupp";
$text['header-group_edit']['ro'] = "";
$text['header-group_edit']['de-at'] = "Gruppe bearbeiten";
$text['header-group_edit']['he'] = "ערוך קבוצה";
$text['header-group_add']['en-us'] = "Add Group";
$text['header-group_add']['es-cl'] = "Agregar Grupo";
$text['header-group_add']['pt-pt'] = "Adicionar Grupo";
$text['header-group_add']['fr-fr'] = "Ajouter un Groupe";
$text['header-group_add']['pl'] = "Dodaj grupę";
$text['header-group_add']['uk'] = "Додати групу";
$text['header-group_add']['sv-se'] = "Lägg Till Grupp";
$text['header-group_add']['ro'] = "";
$text['header-group_add']['de-at'] = "Gruppe hinzufügen";
$text['header-group_add']['he'] = "הוסף קבוצה";
$text['description-user_setting-edit']['en-us'] = "Edit a setting for this user.";
$text['description-user_setting-edit']['es-cl'] = "Editar un escenario de este usuario.";
$text['description-user_setting-edit']['pt-pt'] = "Editar uma configuração para este usuário.";
@ -1058,39 +838,6 @@ $text['description-status']['ro'] = "Selectați starea utilizatorului";
$text['description-status']['de-at'] = "Benutzerstatus auswählen";
$text['description-status']['he'] = "בחר את סטטוס המשתמש";
$text['description-group_permissions']['en-us'] = "Assign permissions for this group.";
$text['description-group_permissions']['es-cl'] = "Asigne permisos para este grupo.";
$text['description-group_permissions']['pt-pt'] = "Atribua permissões para este grupo.";
$text['description-group_permissions']['fr-fr'] = "Assignez des permissions à ce groupe.";
$text['description-group_permissions']['pl'] = "Przypisywanie uprawnień tej grupie.";
$text['description-group_permissions']['uk'] = "Призначення привілеїв для цієї групи.";
$text['description-group_permissions']['sv-se'] = "Tilldela rättigheter till denna grupp.";
$text['description-group_permissions']['ro'] = "";
$text['description-group_permissions']['de-at'] = "Ordnen Sie Berechtigungen für diese Gruppe zu.";
$text['description-group_permissions']['he'] = "צור הרשאות לקבוצה";
$text['description-group_edit']['en-us'] = "Edit the properties of the group.";
$text['description-group_edit']['es-cl'] = "Editar las propiedades del grupo.";
$text['description-group_edit']['pt-pt'] = "Editar as propriedades do grupo.";
$text['description-group_edit']['fr-fr'] = "Modifier les propriétés du groupe.";
$text['description-group_edit']['pl'] = "Edytuj właściwości grupy.";
$text['description-group_edit']['uk'] = "Зміна властивостей групи.";
$text['description-group_edit']['sv-se'] = "Editera inställningar för gruppen.";
$text['description-group_edit']['ro'] = "";
$text['description-group_edit']['de-at'] = "Bearbeiten Sie die Eigenschaften dieser Gruppe";
$text['description-group_edit']['he'] = "";
$text['description-group_add']['en-us'] = "Create a new user group.";
$text['description-group_add']['es-cl'] = "Crear un nuevo grupo de usuarios.";
$text['description-group_add']['pt-pt'] = "Criar um novo grupo de usuários.";
$text['description-group_add']['fr-fr'] = "Créez un nouveau groupe d'utilisateurs.";
$text['description-group_add']['pl'] = "Utwórz nową grupę użytkowników.";
$text['description-group_add']['uk'] = "Створити нову групу користувачів.";
$text['description-group_add']['sv-se'] = "Skapa en ny användargrupp.";
$text['description-group_add']['ro'] = "";
$text['description-group_add']['de-at'] = "Legen Sie einen neue Gruppe an.";
$text['description-group_add']['he'] = "";
$text['description-enabled']['en-us'] = "Set the status of this account.";
$text['description-enabled']['es-cl'] = "Indique el estaso de esta cuenta.";
$text['description-enabled']['pt-pt'] = "Escolha o estado desta conta.";

View File

@ -13,24 +13,28 @@ $apps[$x]['menu'][2]['title']['he'] = "מנהל משתמש";
$apps[$x]['menu'][2]['uuid'] = "0d57cc1e-1874-47b9-7ddd-fe1f57cec99b";
$apps[$x]['menu'][2]['parent_uuid'] = "bc96d773-ee57-0cdd-c3ac-2d91aba61b55";
$apps[$x]['menu'][2]['category'] = "internal";
$apps[$x]['menu'][2]['path'] = "/core/users/index.php";
$apps[$x]['menu'][2]['path'] = "/core/users/users.php";
$apps[$x]['menu'][2]['groups'][] = "admin";
$apps[$x]['menu'][2]['groups'][] = "superadmin";
$apps[$x]['menu'][3]['title']['en-us'] = "Group Manager";
$apps[$x]['menu'][3]['title']['es-cl'] = "Administración de Grupos";
$apps[$x]['menu'][3]['title']['fr-fr'] = "Gestion des groupes";
$apps[$x]['menu'][3]['title']['pt-pt'] = "'Gestão de Grupos";
$apps[$x]['menu'][3]['title']['pt-br'] = "Gerenciar grupos";
$apps[$x]['menu'][3]['title']['pl'] = "Menedżer grup";
$apps[$x]['menu'][3]['title']['uk'] = "Групи";
$apps[$x]['menu'][3]['title']['sv-se'] = "Grupp Inställningar";
$apps[$x]['menu'][3]['title']['de-at'] = "Gruppenverwaltung";
$apps[$x]['menu'][3]['title']['he'] = "מנהל קבוצה";
$apps[$x]['menu'][3]['uuid'] = "3b4acc6d-827b-f537-bf21-0093d94ffec7";
$apps[$x]['menu'][3]['parent_uuid'] = "594d99c5-6128-9c88-ca35-4b33392cec0f";
$apps[$x]['menu'][3]['category'] = "internal";
$apps[$x]['menu'][3]['path'] = "/core/users/groups.php";
$apps[$x]['menu'][3]['groups'][] = "superadmin";
$apps[$x]['menu'][0]['title']['en-us'] = "Account Settings";
$apps[$x]['menu'][0]['title']['es-cl'] = "Config de Cuenta";
$apps[$x]['menu'][0]['title']['fr-fr'] = "Configuration du Compte";
$apps[$x]['menu'][0]['title']['pt-pt'] = "Configurações da Conta";
$apps[$x]['menu'][0]['title']['pt-br'] = "Configurações da conta";
$apps[$x]['menu'][0]['title']['pl'] = "Ustawienia konta";
$apps[$x]['menu'][0]['title']['he'] = "הגדרת חשבון";
$apps[$x]['menu'][0]['title']['uk'] = "Обліковий запис";
$apps[$x]['menu'][0]['title']['sv-se'] = "Kontoinställningar";
$apps[$x]['menu'][0]['title']['de-at'] = "Kontoeinstellungen";
$apps[$x]['menu'][0]['title']['ro'] = "Setări cont";
$apps[$x]['menu'][0]['title']['ar-eg'] = "إعدادات الحساب";
$apps[$x]['menu'][0]['uuid'] = "4d532f0b-c206-c39d-ff33-fc67d668fb69";
$apps[$x]['menu'][0]['parent_uuid'] = "02194288-6d56-6d3e-0b1a-d53a2bc10788";
$apps[$x]['menu'][0]['category'] = "internal";
$apps[$x]['menu'][0]['path'] = "/core/users/user_edit.php?id=user";
$apps[$x]['menu'][0]['groups'][] = "user";
$apps[$x]['menu'][0]['groups'][] = "admin";
$apps[$x]['menu'][0]['groups'][] = "superadmin";
?>

View File

@ -1,55 +0,0 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2013
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('user_view') || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-user_manager'];
//show the user list
require_once "users.php";
//include the footer
include "resources/footer.php";
?>

View File

@ -1,376 +0,0 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2015
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (if_group("admin") || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get total user count from the database, check limit, if defined
if ($_SESSION['limit']['users']['numeric'] != '') {
$sql = "select count(*) as num_rows from v_users where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$total_users = $row['num_rows'];
}
unset($prep_statement, $row);
if ($total_users >= $_SESSION['limit']['users']['numeric']) {
$_SESSION['message_mood'] = 'negative';
$_SESSION['message'] = $text['message-maximum_users'].' '.$_SESSION['limit']['users']['numeric'];
header('Location: index.php');
return;
}
}
//get the values from http and set as variables
if (sizeof($_POST) > 0) {
$username = check_str($_POST["username"]);
$password = check_str($_POST["password"]);
$confirmpassword = check_str($_POST["confirmpassword"]);
$group_uuid_name = check_str($_POST["group_uuid_name"]);
$user_email = check_str($_POST["user_email"]);
$contact_organization = check_str($_POST["contact_organization"]);
$contact_name_given = check_str($_POST["contact_name_given"]);
$contact_name_family = check_str($_POST["contact_name_family"]);
if ($group_uuid_name != '') {
$group_data = explode('|', $group_uuid_name);
$group_uuid = $group_data[0];
$group_name = $group_data[1];
}
}
if (count($_POST) > 0 && check_str($_POST["persistform"]) != "1") {
$msg = '';
//--- begin captcha verification ---------------------
//ini_set("session.cookie_httponly", True); //session_start(); //make sure sessions are started
if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || strlen($_SESSION["captcha"]) == 0) {
//$msg .= "Captcha Verification Failed<br>\n";
}
else {
//echo "verified";
}
//--- end captcha verification -----------------------
//username is already used.
if (strlen($username) == 0) {
$msg .= $text['message-required'].$text['label-username']."<br>\n";
}
else {
$sql = "select * from v_users ";
$sql .= "where username = '$username' ";
if ($_SESSION["user"]["unique"]["text"] != "global") {
$sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
//$sql .= "and user_enabled = 'true' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) > 0) {
$msg .= $text['message-username_exists'];
}
}
if (strlen($password) == 0) { $msg .= $text['message-password_blank']."<br>\n"; }
if ($password != $confirmpassword) { $msg .= $text['message-password_mismatch']."<br>\n"; }
//if (strlen($contact_organization) == 0) { $msg .= $text['message-required'].$text['label-company_name']."<br>\n"; }
//if (strlen($contact_name_given) == 0) { $msg .= $text['message-required'].$text['label-first_name']."<br>\n"; }
//if (strlen($contact_name_family) == 0) { $msg .= $text['message-required'].$text['label-last_name']."<br>\n"; }
if (strlen($user_email) == 0) { $msg .= $text['message-required'].$text['label-email']."<br>\n"; }
if (strlen($group_uuid_name) == 0) { $msg .= $text['message-required'].$text['label-group']."<br>\n"; }
if (strlen($msg) > 0) {
require_once "resources/header.php";
echo "<div align='center'>";
echo "<table><tr><td>";
echo $msg;
echo "</td></tr></table>";
require_once "resources/persist_form.php";
echo persistform($_POST);
echo "</div>";
require_once "resources/footer.php";
return;
}
//salt used with the password to create a one way hash
$salt = uuid();
//prepare the uuids
$user_uuid = uuid();
$group_user_uuid = uuid();
$contact_uuid = uuid();
$contact_email_uuid = uuid();
//add the user
$sql = "insert into v_users ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "user_uuid, ";
$sql .= "contact_uuid, ";
$sql .= "username, ";
$sql .= "password, ";
$sql .= "salt, ";
$sql .= "add_date, ";
$sql .= "add_user, ";
$sql .= "user_enabled ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$_SESSION['domain_uuid']."', ";
$sql .= "'".$user_uuid."', ";
$sql .= "'".$contact_uuid."', ";
$sql .= "'".$username."', ";
$sql .= "'".md5($salt.$password)."', ";
$sql .= "'".$salt."', ";
$sql .= "now(), ";
$sql .= "'".$_SESSION["username"]."', ";
$sql .= "'true' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//add the user to the group
if (strlen($group_uuid) > 0) {
if ( ($group_name == "superadmin" && if_group("superadmin")) || $group_name != "superadmin") {
$sql = "insert into v_group_users ";
$sql .= "( ";
$sql .= "group_user_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "group_name, ";
$sql .= "group_uuid, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$group_user_uuid."', ";
$sql .= "'".$_SESSION['domain_uuid']."', ";
$sql .= "'".$group_name."', ";
$sql .= "'".$group_uuid."', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
}
//add to contacts
$sql = "insert into v_contacts ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "contact_uuid, ";
$sql .= "contact_type, ";
$sql .= "contact_organization, ";
$sql .= "contact_name_given, ";
$sql .= "contact_name_family, ";
$sql .= "contact_nickname ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$_SESSION['domain_uuid']."', ";
$sql .= "'".$contact_uuid."', ";
$sql .= "'user', ";
$sql .= "'".$contact_organization."', ";
$sql .= "'".$contact_name_given."', ";
$sql .= "'".$contact_name_family."', ";
$sql .= "'".$username."' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//add to emails
$sql = "insert into v_contact_emails ";
$sql .= "(";
$sql .= "contact_email_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "contact_uuid, ";
$sql .= "email_address, ";
$sql .= "email_primary ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$contact_email_uuid."', ";
$sql .= "'".$_SESSION['domain_uuid']."', ";
$sql .= "'".$contact_uuid."', ";
$sql .= "'".$user_email."', ";
$sql .= "1 ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//log the success
//$log_type = 'user'; $log_status='add'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." user added.";
//log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]);
$_SESSION["message"] = $text['message-add'];
header("Location: index.php");
return;
}
//show the header
require_once "resources/header.php";
$document['title'] = $text['title-user_add'];
//show the content
echo "<script>";
echo " function compare_passwords() {";
echo " if (document.getElementById('password') === document.activeElement || document.getElementById('confirmpassword') === document.activeElement) {";
echo " if (document.getElementById('password').value != '' || document.getElementById('confirmpassword').value != '') {";
echo " if (document.getElementById('password').value != document.getElementById('confirmpassword').value) {";
echo " $('#password').removeClass('formfld_highlight_good');";
echo " $('#confirmpassword').removeClass('formfld_highlight_good');";
echo " $('#password').addClass('formfld_highlight_bad');";
echo " $('#confirmpassword').addClass('formfld_highlight_bad');";
echo " }";
echo " else {";
echo " $('#password').removeClass('formfld_highlight_bad');";
echo " $('#confirmpassword').removeClass('formfld_highlight_bad');";
echo " $('#password').addClass('formfld_highlight_good');";
echo " $('#confirmpassword').addClass('formfld_highlight_good');";
echo " }";
echo " }";
echo " }";
echo " else {";
echo " if (document.getElementById('password').value == document.getElementById('confirmpassword').value) {";
echo " $('#password').removeClass('formfld_highlight_bad');";
echo " $('#confirmpassword').removeClass('formfld_highlight_bad');";
echo " $('#password').removeClass('formfld_highlight_good');";
echo " $('#confirmpassword').removeClass('formfld_highlight_good');";
echo " }";
echo " }";
echo " }";
echo "</script>";
$tablewidth ='width="100%"';
echo "<form name='frm' id='frm' method='post' action=''>";
echo "<table border='0' $tablewidth cellpadding='0' cellspacing='0'>";
echo " <tr>\n";
echo " <td width='80%' valign='top'>\n";
echo " <b>".$text['header-user_add']."</b>\n";
echo " <br><br>\n";
echo " ".$text['description-user_add']."\n";
echo " <br><br>\n";
echo " </td>\n";
echo " <td width='20%' valign='top' align='right'>\n";
echo " <input type='button' class='btn' name='back' alt='".$text['button-back']."' onclick=\"document.location.href='index.php';\" value='".$text['button-back']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<table border='0' $tablewidth cellpadding='0' cellspacing='0'>";
echo " <tr>";
echo " <td class='vncellreq' width='30%'>".$text['label-username']."</td>";
echo " <td class='vtable' width='70%'><input style='display:none;' type='password' name='autocomplete'><input type='text' class='formfld' autocomplete='off' name='username' value='$username'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncellreq'>".$text['label-password']."</td>";
echo " <td class='vtable'><input style='display:none;' type='password' name='autocomplete'><input type='password' class='formfld' autocomplete='off' name='password' id='password' value='$password' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncellreq'>".$text['label-confirm_password']."</td>";
echo " <td class='vtable'><input type='password' class='formfld' autocomplete='off' name='confirmpassword' id='confirmpassword' value='$confirmpassword' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncellreq'>".$text['label-email']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='user_email' value='$user_email'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncellreq' valign='top'>".$text['label-group']."</td>";
echo " <td class='vtable'>";
$sql = "select * from v_groups ";
$sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null) ";
$sql .= "order by domain_uuid desc, group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
echo " <select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
echo " <option value=''></option>\n";
foreach($result as $field) {
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins
echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
}
echo " </select>";
unset($sql, $prep_statement, $result);
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-first_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_name_given' value='$contact_name_given'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-last_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_name_family' value='$contact_name_family'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-company_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_organization' value='$contact_organization'></td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan='2' align='right'>";
echo " <br><input type='button' class='btn' value='".$text['button-create_account']."' onclick='submit_form();'>";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "</form>";
echo "<script>\n";
//capture enter key to submit form
echo " $(window).keypress(function(event){\n";
echo " if (event.which == 13) { submit_form(); }\n";
echo " });\n";
// convert password fields to
echo " function submit_form() {\n";
echo " $('input:password').css('visibility','hidden');\n";
echo " $('input:password').attr({type:'text'});\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
//show the footer
require_once "resources/footer.php";
?>

View File

@ -103,6 +103,6 @@
//redirect the user
$_SESSION["message"] = $text['message-delete'];
header("Location: index.php");
header("Location: users.php");
?>

947
core/users/user_edit.php Normal file
View File

@ -0,0 +1,947 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//add multi-lingual support
$language = new text;
$text = $language->get();
//get user uuid
if (
(is_uuid($_REQUEST["id"]) && permission_exists('user_edit')) ||
(is_uuid($_REQUEST["id"]) && $_REQUEST["id"] == $_SESSION['user_uuid'])
) {
$user_uuid = check_str($_REQUEST["id"]);
$action = 'edit';
}
else if (permission_exists('user_add') && $_REQUEST["id"] == '') {
$user_uuid = uuid();
$action = 'add';
}
else {
// load users own account
header("Location: user_edit.php?id=".$_SESSION['user_uuid']);
exit;
}
//get total user count from the database, check limit, if defined
if (permission_exists('user_add') && $action == 'add' && $_SESSION['limit']['users']['numeric'] != '') {
$sql = "select count(user_uuid) as num_rows from v_users where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$total_users = $row['num_rows'];
}
unset($prep_statement, $row);
if ($total_users >= $_SESSION['limit']['users']['numeric']) {
$_SESSION['message_mood'] = 'negative';
$_SESSION['message'] = $text['message-maximum_users'].' '.$_SESSION['limit']['users']['numeric'];
header('Location: users.php');
exit;
}
}
//required to be a superadmin to update an account that is a member of the superadmin group
if (permission_exists('user_edit') && $action == 'edit') {
$superadmins = superadmin_list($db);
if (if_superadmin($superadmins, $user_uuid)) {
if (!if_group("superadmin")) {
echo "access denied";
exit;
}
}
}
//delete the group from the user
if ($_GET["a"] == "delete" && permission_exists("user_delete")) {
//set the variables
$group_uuid = check_str($_GET["group_uuid"]);
//delete the group from the users
$sql = "delete from v_group_users ";
$sql .= "where group_uuid = '".$group_uuid."' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
//redirect the user
$_SESSION["message"] = $text['message-update'];
header("Location: user_edit.php?id=".$user_uuid);
return;
}
if (count($_POST) > 0 && $_POST["persistform"] != "1") {
//get the HTTP values and set as variables
if (permission_exists('user_edit') && $action == 'edit') {
$user_uuid = $_REQUEST["id"];
$username_old = check_str($_POST["username_old"]);
}
$domain_uuid = check_str($_POST["domain_uuid"]);
$username = check_str($_POST["username"]);
$password = check_str($_POST["password"]);
$password_confirm = check_str($_POST["password_confirm"]);
$user_status = check_str($_POST["user_status"]);
$user_language = check_str($_POST["user_language"]);
$user_time_zone = check_str($_POST["user_time_zone"]);
if (permission_exists('user_edit') && $action == 'edit') {
$contact_uuid = check_str($_POST["contact_uuid"]);
}
else if (permission_exists('user_add') && $action == 'add') {
$user_email = check_str($_POST["user_email"]);
$contact_organization = check_str($_POST["contact_organization"]);
$contact_name_given = check_str($_POST["contact_name_given"]);
$contact_name_family = check_str($_POST["contact_name_family"]);
}
$group_uuid_name = check_str($_POST["group_uuid_name"]);
$user_enabled = check_str($_POST["user_enabled"]);
$api_key = check_str($_POST["api_key"]);
//check required values
if ($username == '') { $msg_error = $text['message-required'].$text['label-username']; }
if (permission_exists('user_edit') && $action == 'edit') {
if ($username != $username_old && $username != '') {
$sql = "select count(user_uuid) 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 != '' && $password != $password_confirm) { $msg_error = $text['message-password_mismatch']; }
if (permission_exists('user_add') && $action == 'add') {
if ($password == '') { $msg_error = $text['message-password_blank']; }
if ($user_email == '') { $msg_error = $text['message-required'].$text['label-email']; }
if ($group_uuid_name == '') { $msg_error = $text['message-required'].$text['label-group']; }
}
if ($msg_error != '') {
$_SESSION["message"] = $msg_error;
$_SESSION["message_mood"] = 'negative';
if ($action == 'edit') {
header("Location: user_edit.php?id=".$user_uuid);
}
else {
header("Location: user_edit.php");
}
exit;
}
if (!check_password_strength($password, $text)) {
if ($action == 'edit') {
header("Location: user_edit.php?id=".$user_uuid);
}
else {
header("Location: user_edit.php");
}
exit;
}
//set initial array indexes
$i = $n = $x = $c = 0;
//check to see if user language is set
$sql = "select user_setting_uuid, user_setting_value from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['user_setting_uuid'] == '' && $user_language != '') {
//add user setting to array for insert
$array['user_settings'][$i]['user_setting_uuid'] = uuid();
$array['user_settings'][$i]['user_uuid'] = $user_uuid;
$array['user_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['user_settings'][$i]['user_setting_category'] = 'domain';
$array['user_settings'][$i]['user_setting_subcategory'] = 'language';
$array['user_settings'][$i]['user_setting_name'] = 'code';
$array['user_settings'][$i]['user_setting_value'] = $user_language;
$array['user_settings'][$i]['user_setting_enabled'] = 'true';
$i++;
}
else {
if ($row['user_setting_value'] == '' || $user_language == '') {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
//add user setting to array for update
$array['user_settings'][$i]['user_setting_uuid'] = $row['user_setting_uuid'];
$array['user_settings'][$i]['user_uuid'] = $user_uuid;
$array['user_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['user_settings'][$i]['user_setting_category'] = 'domain';
$array['user_settings'][$i]['user_setting_subcategory'] = 'language';
$array['user_settings'][$i]['user_setting_name'] = 'code';
$array['user_settings'][$i]['user_setting_value'] = $user_language;
$array['user_settings'][$i]['user_setting_enabled'] = 'true';
$i++;
}
}
}
unset($sql, $prep_statement, $row);
//check to see if user time zone is set
$sql = "select user_setting_uuid, user_setting_value from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['user_setting_uuid'] == '' && $user_time_zone != '') {
//add user setting to array for insert
$array['user_settings'][$i]['user_setting_uuid'] = uuid();
$array['user_settings'][$i]['user_uuid'] = $user_uuid;
$array['user_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['user_settings'][$i]['user_setting_category'] = 'domain';
$array['user_settings'][$i]['user_setting_subcategory'] = 'time_zone';
$array['user_settings'][$i]['user_setting_name'] = 'name';
$array['user_settings'][$i]['user_setting_value'] = $user_time_zone;
$array['user_settings'][$i]['user_setting_enabled'] = 'true';
$i++;
}
else {
if ($row['user_setting_value'] == '' || $user_time_zone == '') {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
//add user setting to array for update
$array['user_settings'][$i]['user_setting_uuid'] = $row['user_setting_uuid'];
$array['user_settings'][$i]['user_uuid'] = $user_uuid;
$array['user_settings'][$i]['domain_uuid'] = $domain_uuid;
$array['user_settings'][$i]['user_setting_category'] = 'domain';
$array['user_settings'][$i]['user_setting_subcategory'] = 'time_zone';
$array['user_settings'][$i]['user_setting_name'] = 'name';
$array['user_settings'][$i]['user_setting_value'] = $user_time_zone;
$array['user_settings'][$i]['user_setting_enabled'] = 'true';
$i++;
}
}
}
//assign the user to the group
if ((permission_exists('user_add') || permission_exists('user_edit')) && $_REQUEST["group_uuid_name"] != '') {
$group_data = explode('|', $group_uuid_name);
$group_uuid = $group_data[0];
$group_name = $group_data[1];
//only a superadmin can add other superadmins or admins, admins can only add other admins
switch ($group_name) {
case "superadmin": if (!if_group("superadmin")) { break; }
case "admin": if (!if_group("superadmin") && !if_group("admin")) { break; }
default: //add group user to array for insert
$array['group_users'][$n]['group_user_uuid'] = uuid();
$array['group_users'][$n]['domain_uuid'] = $domain_uuid;
$array['group_users'][$n]['group_name'] = $group_name;
$array['group_users'][$n]['group_uuid'] = $group_uuid;
$array['group_users'][$n]['user_uuid'] = $user_uuid;
$n++;
}
}
//update domain, if changed
if ((permission_exists('user_add') || permission_exists('user_edit')) && permission_exists('user_domain')) {
//adjust group user records
$sql = "select group_user_uuid from v_group_users ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
//add group user to array for update
$array['group_users'][$n]['group_user_uuid'] = $row['group_user_uuid'];
$array['group_users'][$n]['domain_uuid'] = $domain_uuid;
$n++;
}
}
unset($sql, $prep_statement, $result, $row);
//adjust user setting records
$sql = "select user_setting_uuid from v_user_settings ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
//add user setting to array for update
$array['user_settings'][$i]['user_setting_uuid'] = $row['user_setting_uuid'];
$array['user_settings'][$i]['domain_uuid'] = $domain_uuid;
$i++;
}
}
unset($sql, $prep_statement, $result, $row);
//unassign any foreign domain groups
$sql = "delete from v_group_users where ";
$sql .= "domain_uuid = '".$domain_uuid."' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$sql .= "and group_uuid not in (";
$sql .= " select group_uuid from v_groups where domain_uuid = '".$domain_uuid."' or domain_uuid is null ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
}
//add contact to array for insert
if ($action == 'add' && permission_exists('user_add') && permission_exists('contact_add')) {
$contact_uuid = uuid();
$array['contacts'][$c]['domain_uuid'] = $domain_uuid;
$array['contacts'][$c]['contact_uuid'] = $contact_uuid;
$array['contacts'][$c]['contact_type'] = 'user';
$array['contacts'][$c]['contact_organization'] = $contact_organization;
$array['contacts'][$c]['contact_name_given'] = $contact_name_given;
$array['contacts'][$c]['contact_name_family'] = $contact_name_family;
$array['contacts'][$c]['contact_nickname'] = $username;
$c++;
if (permission_exists('contact_email_add')) {
$contact_email_uuid = uuid();
$array['contact_emails'][$c]['contact_email_uuid'] = $contact_email_uuid;
$array['contact_emails'][$c]['domain_uuid'] = $domain_uuid;
$array['contact_emails'][$c]['contact_uuid'] = $contact_uuid;
$array['contact_emails'][$c]['email_address'] = $user_email;
$array['contact_emails'][$c]['email_primary'] = '1';
$c++;
}
}
//add user setting to array for update
$array['users'][$x]['user_uuid'] = $user_uuid;
$array['users'][$x]['domain_uuid'] = $domain_uuid;
if ($username != '' && $username != $username_old) {
$array['users'][$x]['username'] = $username;
}
if ($password != '' && $password == $password_confirm) {
$salt = uuid();
$array['users'][$x]['password'] = md5($salt.$password);
$array['users'][$x]['salt'] = $salt;
}
$array['users'][$x]['user_status'] = $user_status;
if (permission_exists('user_add') || permission_exists('user_edit')) {
$array['users'][$x]['api_key'] = ($api_key != '') ? $api_key : null;
$array['users'][$x]['user_enabled'] = $user_enabled;
$array['users'][$x]['contact_uuid'] = ($contact_uuid != '') ? $contact_uuid : null;
if ($action == 'add') {
$array['users'][$x]['add_user'] = $_SESSION["user"]["username"];
$array['users'][$x]['add_date'] = date("Y-m-d H:i:s.uO");
}
}
$x++;
//if call center installed
if (
$action == 'edit' &&
permission_exists('user_edit') &&
$username != $username_old &&
file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")
) {
//update call center agent table
$sql = "select call_center_agent_uuid from v_call_center_agents ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and agent_name = '".$username_old."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$a = 0;
foreach ($result as $row) {
$array['call_center_agents'][$a]['call_center_agent_uuid'] = $row['call_center_agent_uuid'];
$array['call_center_agents'][$a]['agent_name'] = $username;
$a++;
}
}
unset($sql, $prep_statement, $result);
//update call center tiers table
$sql = "select call_center_tier_uuid from v_call_center_tiers ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and agent_name = '".$username_old."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
$t = 0;
foreach ($result as $row) {
$array['call_center_tiers'][$t]['call_center_tier_uuid'] = $row['call_center_tier_uuid'];
$array['call_center_tiers'][$t]['agent_name'] = $username;
$t++;
}
}
unset($sql, $prep_statement, $result);
}
//add the user_edit permission
$p = new permissions;
$p->add("user_setting_add", "temp");
$p->add("user_setting_edit", "temp");
$p->add("user_edit", "temp");
//save the data
$orm = new orm;
$orm->app_name = 'users';
$orm->app_uuid = '112124b3-95c2-5352-7e9d-d14c0b88f207';
$orm->save($array);
//$message = $orm->message;
//remove the temporary permission
$p->delete("user_setting_add", "temp");
$p->delete("user_setting_edit", "temp");
$p->delete("user_edit", "temp");
//if call center installed
if (
$action == 'edit' &&
permission_exists('user_edit') &&
$username != $username_old &&
file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")
) {
//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['domains'][$domain_uuid]['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['domains'][$domain_uuid]['domain_name']." Waiting";
$response = event_socket_request($fp, $cmd);
}
//redirect the browser
$_SESSION["message"] = $text['message-update'];
if ($_REQUEST['action'] == $text['button-add'] || !permission_exists('user_edit')) {
header("Location: user_edit.php?id=".$user_uuid);
}
else {
header("Location: users.php");
}
return;
}
//pre-populate the form
if ($action == 'edit') {
//get user data
$sql = "select * from v_users where user_uuid = '".$user_uuid."' ";
if (!permission_exists('user_all')) {
$sql .= "and domain_uuid = '".$domain_uuid."' ";
}
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_NAMED);
if (is_array($row) && sizeof($row) > 0) {
$domain_uuid = $row["domain_uuid"];
$user_uuid = $row["user_uuid"];
$username = $row["username"];
$password = $row["password"];
$api_key = $row["api_key"];
$user_enabled = $row["user_enabled"];
$contact_uuid = $row["contact_uuid"];
$user_status = $row["user_status"];
}
else {
header("Location: user_edit.php?id=".$_SESSION['user_uuid']);
exit;
}
unset($sql, $prep_statement, $row);
//get user settings
$sql = "select * from v_user_settings ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$sql .= "and user_setting_enabled = 'true' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
$name = $row['user_setting_name'];
$category = $row['user_setting_category'];
$subcategory = $row['user_setting_subcategory'];
if (strlen($subcategory) == 0) {
//$$category[$name] = $row['domain_setting_value'];
$user_settings[$category][$name] = $row['user_setting_value'];
}
else {
$user_settings[$category][$subcategory][$name] = $row['user_setting_value'];
}
}
}
}
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-user_edit'];
//show the content
echo "<script>\n";
echo " function compare_passwords() {\n";
echo " if (document.getElementById('password') === document.activeElement || document.getElementById('password_confirm') === document.activeElement) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " if ($('#password').val() != $('#password_confirm').val()) {\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " $('#password').addClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').addClass('formfld_highlight_bad');\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').addClass('formfld_highlight_good');\n";
echo " $('#password_confirm').addClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
$req['length'] = $_SESSION['security']['password_length']['numeric'];
$req['number'] = ($_SESSION['security']['password_number']['boolean'] == 'true') ? true : false;
$req['lowercase'] = ($_SESSION['security']['password_lowercase']['boolean'] == 'true') ? true : false;
$req['uppercase'] = ($_SESSION['security']['password_uppercase']['boolean'] == 'true') ? true : false;
$req['special'] = ($_SESSION['security']['password_special']['boolean'] == 'true') ? true : false;
echo " function check_password_strength(pwd) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " var msg_errors = [];\n";
if (is_numeric($req['length']) && $req['length'] != 0) {
echo " var re = /.{".$req['length'].",}/;\n"; //length
echo " if (!re.test(pwd)) { msg_errors.push('".$req['length']."+ ".$text['label-characters']."'); }\n";
}
if ($req['number']) {
echo " var re = /(?=.*[\d])/;\n"; //number
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-numbers']."'); }\n";
}
if ($req['lowercase']) {
echo " var re = /(?=.*[a-z])/;\n"; //lowercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-lowercase_letters']."'); }\n";
}
if ($req['uppercase']) {
echo " var re = /(?=.*[A-Z])/;\n"; //uppercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-uppercase_letters']."'); }\n";
}
if ($req['special']) {
echo " var re = /(?=.*[\W])/;\n"; //special
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-special_characters']."'); }\n";
}
echo " if (msg_errors.length > 0) {\n";
echo " var msg = '".$text['message-password_requirements'].": ' + msg_errors.join(', ');\n";
echo " display_message(msg, 'negative', '6000');\n";
echo " return false;\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " function show_strenth_meter() {\n";
echo " $('#pwstrength_progress').slideDown();\n";
echo " }\n";
echo "</script>\n";
echo "<form name='frm' id='frm' method='post'>\n";
echo "<input type='hidden' name='action' id='action' value=''>\n";
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
echo "<td align='left' width='90%' valign='top' nowrap><b>".$text['header-user_edit']."</b></td>\n";
echo "<td align='right' nowrap>\n";
if (permission_exists('user_add') || permission_exists('user_edit')) {
echo " <input type='button' class='btn' onclick=\"window.location='users.php'\" value='".$text['button-back']."'>";
}
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; submit_form();\">";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo " ".$text['description-user_edit']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
echo " <tr>";
echo " <td width='30%' class='vncellreq' valign='top'>".$text['label-username']."</td>";
echo " <td width='70%' class='vtable'>";
if (permission_exists("user_edit")) {
echo " <input type='text' class='formfld' name='username' id='username' value='".$username."' required='required'>\n";
}
else {
echo " ".$username."\n";
echo " <input type='hidden' name='username' id='username' value='".$username."'>\n";
}
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell".(($action == 'add') ? 'req' : null)."' valign='top'>".$text['label-password']."</td>";
echo " <td class='vtable'>";
echo " <input style='display: none;' type='password'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password' id='password' value='' onkeypress='show_strenth_meter();' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " <div id='pwstrength_progress' class='pwstrength_progress'></div>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell".(($action == 'add') ? 'req' : null)."' valign='top'>".$text['label-confirm_password']."</td>";
echo " <td class='vtable'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password_confirm' id='password_confirm' value='' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " </td>";
echo " </tr>";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-user_language']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='user_language' name='user_language' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
//get all language codes from database
$sql = "select * from v_languages order by language asc";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$language_codes[$row["code"]] = $row["language"];
}
unset($prep_statement, $result, $row);
foreach ($_SESSION['app']['languages'] as $code) {
$selected = ($code == $user_settings['domain']['language']['code']) ? "selected='selected'" : null;
echo " <option value='".$code."' ".$selected.">".$language_codes[$code]." [".$code."]</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-user_language']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\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";
echo " <option value=''></option>\n";
//$list = DateTimeZone::listAbbreviations();
$time_zone_identifiers = DateTimeZone::listIdentifiers();
$previous_category = '';
$x = 0;
foreach ($time_zone_identifiers as $key => $row) {
$time_zone = explode("/", $row);
$category = $time_zone[0];
if ($category != $previous_category) {
if ($x > 0) {
echo " </optgroup>\n";
}
echo " <optgroup label='".$category."'>\n";
}
if ($row == $user_settings['domain']['time_zone']['name']) {
echo " <option value='".$row."' selected='selected'>".$row."</option>\n";
}
else {
echo " <option value='".$row."'>".$row."</option>\n";
}
$previous_category = $category;
$x++;
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-time_zone']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
if ($_SESSION['user_status_display'] != "false") {
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\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+".$username."@".$_SESSION['domains'][$domain_uuid]['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";
echo " <option value='Available' ".(($user_status == "Available") ? "selected='selected'" : null).">".$text['option-available']."</option>\n";
echo " <option value='Available (On Demand)' ".(($user_status == "Available (On Demand)") ? "selected='selected'" : null).">".$text['option-available_on_demand']."</option>\n";
echo " <option value='Logged Out' ".(($user_status == "Logged Out") ? "selected='selected'" : null).">".$text['option-logged_out']."</option>\n";
echo " <option value='On Break' ".(($user_status == "On Break") ? "selected='selected'" : null).">".$text['option-on_break']."</option>\n";
echo " <option value='Do Not Disturb' ".(($user_status == "Do Not Disturb") ? "selected='selected'" : null).">".$text['option-do_not_disturb']."</option>\n";
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-status']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
}
if ($action == 'edit' && permission_exists("user_edit")) {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-contact']."</td>";
echo " <td class='vtable'>\n";
$sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts ";
$sql .= " where domain_uuid = '".$domain_uuid."' ";
$sql .= " order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
echo "<select name=\"contact_uuid\" id=\"contact_uuid\" class=\"formfld\">\n";
echo "<option value=\"\"></option>\n";
foreach($result as $row) {
$contact_name = array();
if ($row['contact_organization'] != '') { $contact_name[] = $row['contact_organization']; }
if ($row['contact_name_family'] != '') { $contact_name[] = $row['contact_name_family']; }
if ($row['contact_name_given'] != '') { $contact_name[] = $row['contact_name_given']; }
if ($row['contact_name_family'] == '' && $row['contact_name_family'] == '' && $row['contact_nickname'] != '') { $contact_name[] = $row['contact_nickname']; }
echo "<option value='".$row['contact_uuid']."' ".(($row['contact_uuid'] == $contact_uuid) ? "selected='selected'" : null).">".implode(', ', $contact_name)."</option>\n";
}
unset($sql, $result, $row_count);
echo "</select>\n";
echo "<br />\n";
echo $text['description-contact']."\n";
if (strlen($contact_uuid) > 0) {
echo " <a href=\"".PROJECT_PATH."/app/contacts/contact_edit.php?id=$contact_uuid\">".$text['description-contact_view']."</a>\n";
}
echo " </td>";
echo " </tr>";
}
else if ($action == 'add' && permission_exists("user_add")) {
echo " <tr>";
echo " <td class='vncellreq'>".$text['label-email']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='user_email' value='".$user_email."'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-first_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_name_given' value='".$contact_name_given."'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-last_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_name_family' value='".$contact_name_family."'></td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell'>".$text['label-company_name']."</td>";
echo " <td class='vtable'><input type='text' class='formfld' name='contact_organization' value='".$contact_organization."'></td>";
echo " </tr>";
}
if ((permission_exists("user_add") && $action == 'add') || (permission_exists("user_edit") && $action == 'edit')) {
echo " <tr>";
echo " <td class='vncellreq' valign='top'>".$text['label-group'.(($action == 'edit') ? 's' : null)]."</td>";
echo " <td class='vtable'>";
$sql = "select ";
$sql .= " gu.*, g.domain_uuid as group_domain_uuid ";
$sql .= "from ";
$sql .= " v_group_users as gu, ";
$sql .= " v_groups as g ";
$sql .= "where ";
$sql .= " gu.group_uuid = g.group_uuid ";
$sql .= " and (";
$sql .= " g.domain_uuid = :domain_uuid ";
$sql .= " or g.domain_uuid is null ";
$sql .= " ) ";
$sql .= " and gu.domain_uuid = :domain_uuid ";
$sql .= " and gu.user_uuid = :user_uuid ";
$sql .= "order by ";
$sql .= " g.domain_uuid desc, ";
$sql .= " g.group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
$prep_statement->bindParam(':user_uuid', $user_uuid);
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if ($result_count > 0) {
echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
foreach($result as $field) {
if (strlen($field['group_name']) > 0) {
echo "<tr>\n";
echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
echo " </td>\n";
if ($result_count > 1) {
if (permission_exists('group_member_delete') || if_group("superadmin")) {
echo " <td class='list_control_icons' style='width: 25px;'>\n";
echo " <a href='user_edit.php?id=".$user_uuid."&domain_uuid=".$domain_uuid."&group_uuid=".$field['group_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
echo " </td>\n";
}
}
echo "</tr>\n";
$assigned_groups[] = $field['group_uuid'];
}
}
echo "</table>\n";
}
unset($sql, $prep_statement, $result, $result_count);
$sql = "select * from v_groups ";
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
if (sizeof($assigned_groups) > 0) {
$sql .= "and group_uuid not in ('".implode("','",$assigned_groups)."') ";
}
$sql .= "order by domain_uuid desc, group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if ($result_count > 0) {
if (isset($assigned_groups)) { echo "<br />\n"; }
echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
echo " <option value=''></option>\n";
foreach($result as $field) {
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins
if ( !isset($assigned_groups) || (isset($assigned_groups) && !in_array($field["group_uuid"], $assigned_groups)) ) {
echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
}
}
echo "</select>";
if ($action == 'edit') {
echo "<input type='button' class='btn' value=\"".$text['button-add']."\" onclick=\"document.getElementById('action').value = '".$text['button-add']."'; submit_form();\">\n";
}
}
unset($sql, $prep_statement, $result);
echo " </td>";
echo " </tr>";
if (permission_exists('user_domain')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
foreach ($_SESSION['domains'] as $row) {
echo " <option value='".$row['domain_uuid']."' ".(($row['domain_uuid'] == $domain_uuid) ? "selected='selected'" : null).">".$row['domain_name']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_name']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else {
echo "<input type='hidden' name='domain_uuid' value='".$domain_uuid."'>";
}
if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/api/app_config.php')) {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-api_key']."</td>";
echo " <td class='vtable'>\n";
echo " <input type=\"text\" class='formfld' name=\"api_key\" id='api_key' value=\"".$api_key."\" >";
echo " <input type='button' class='btn' value='".$text['button-generate']."' onclick=\"getElementById('api_key').value='".uuid()."';\">";
if (strlen($text['description-api_key']) > 0) {
echo " <br />".$text['description-api_key']."<br />\n";
}
echo " </td>";
echo " </tr>";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\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='true'>".$text['option-true']."</option>\n";
echo " <option value='false' ".(($user_enabled != "true") ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else {
echo "<input type='hidden' name='domain_uuid' value='".$domain_uuid."'>";
}
echo " <tr>";
echo " <td colspan='2' align='right'>";
if ($action == 'edit') {
echo " <input type='hidden' name='id' value=\"$user_uuid\">";
if (permission_exists("user_edit")) {
echo " <input type='hidden' name='username_old' value=\"$username\">";
}
}
echo " <br>";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; if (check_password_strength(document.getElementById('password').value)) { submit_form(); }\">";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
echo "<script>\n";
//capture enter key to submit form
echo " $(window).keypress(function(event){\n";
echo " if (event.which == 13) { submit_form(); }\n";
echo " });\n";
// convert password fields to text
echo " function submit_form() {\n";
echo " $('input:password').css('visibility','hidden');\n";
echo " $('input:password').attr({type:'text'});\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
if (permission_exists("user_edit") && permission_exists('user_setting_view') && $action == 'edit') {
require "user_settings.php";
}
//include the footer
require_once "resources/footer.php";
?>

View File

@ -64,7 +64,7 @@
$_SESSION["message_mood"] = "negative";
}
header("Location: usersupdate.php?id=".check_str($_REQUEST["user_uuid"]));
header("Location: user_edit.php?id=".check_str($_REQUEST["user_uuid"]));
exit;
?>

View File

@ -324,7 +324,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if ($action == "add") {
$_SESSION["message"] = $text['message-add'];
}
header("Location: usersupdate.php?id=".$user_uuid);
header("Location: user_edit.php?id=".$user_uuid);
return;
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
@ -373,7 +373,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
echo "</b></td>\n";
echo "<td width='70%' align='right' valign='top'>";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='usersupdate.php?id=$user_uuid'\" value='".$text['button-back']."'>";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='user_edit.php?id=$user_uuid'\" value='".$text['button-back']."'>";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
echo "</td>\n";
echo "</tr>\n";

View File

@ -53,7 +53,7 @@
unset($sql);
$_SESSION["message"] = $text['message-update'];
header("Location: usersupdate.php?id=".$user_uuid);
header("Location: user_edit.php?id=".$user_uuid);
exit;
}
}

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2015
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -25,9 +25,10 @@
*/
//includes
require_once "root.php";
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists("user_view") || if_group("superadmin")) {
@ -38,8 +39,13 @@
exit;
}
//additional includes
require_once "resources/paging.php";
//add multi-lingual support
$language = new text;
$text = $language->get();
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-user_manager'];
//set the variables
$order_by = check_str($_GET["order_by"]);
@ -145,11 +151,11 @@
echo "<td align='right' nowrap='nowrap'>";
if (permission_exists('user_all')) {
if ($_GET['showall'] == 'true') {
echo "<input type='button' class='btn' value='".$text['button-back']."' onclick=\"window.location='index.php';\">\n";
echo "<input type='button' class='btn' value='".$text['button-back']."' onclick=\"window.location='users.php';\">\n";
echo "<input type='hidden' name='showall' value='true'>";
}
else {
echo "<input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='index.php?showall=true';\">\n";
echo "<input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='users.php?showall=true';\">\n";
}
}
echo "<input type='text' class='txt' style='width: 150px; margin-right: 3px;' name='search_value' value=\"".$search_value."\">";
@ -184,7 +190,7 @@
echo "<td class='list_control_icons'>";
if (permission_exists('user_add')) {
if ($_SESSION['limit']['users']['numeric'] == '' || ($_SESSION['limit']['users']['numeric'] != '' && $total_users < $_SESSION['limit']['users']['numeric'])) {
echo "<a href='signup.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
echo "<a href='user_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo "</td>\n";
@ -195,14 +201,14 @@
if (if_superadmin($superadmins, $row['user_uuid']) && !if_group("superadmin")) {
//hide
} else {
$tr_link = (permission_exists('user_edit')) ? "href='usersupdate.php?id=".$row['user_uuid']."'" : null;
$tr_link = (permission_exists('user_edit')) ? "href='user_edit.php?id=".$row['user_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
if (permission_exists('user_all') && $_GET['showall'] == 'true') {
echo " <td valign='top' class='".$row_style[$c]."'>".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."</td>\n";
}
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('user_edit')) {
echo "<a href='usersupdate.php?id=".$row['user_uuid']."'>".$row['username']."</a>";
echo "<a href='user_edit.php?id=".$row['user_uuid']."'>".$row['username']."</a>";
}
else {
echo $row['username'];
@ -223,11 +229,11 @@
echo "&nbsp;</td>\n";
echo " <td valign='top' align='right' class='tr_link_void'>";
if (permission_exists('user_edit')) {
echo "<a href='usersupdate.php?id=".$row['user_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
echo "<a href='user_edit.php?id=".$row['user_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('user_delete')) {
if ($_SESSION["user"]["user_uuid"] != $row['user_uuid']) {
echo "<a href='userdelete.php?id=".$row['user_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
echo "<a href='user_delete.php?id=".$row['user_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
}
else {
echo "<span onclick=\"alert('".$text['message-cannot_delete_own_account']."');\">".str_replace("list_control_icon", "list_control_icon_disabled", $v_link_label_delete)."</span>";
@ -248,4 +254,8 @@
echo $paging_controls."\n";
echo "<br /><br />\n";
//include the footer
include "resources/footer.php";
?>

View File

@ -1,823 +0,0 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2013
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists("user_add") ||
permission_exists("user_edit") ||
permission_exists("user_delete") ||
if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get data from the db
if (strlen($_REQUEST["id"]) > 0) {
$user_uuid = $_REQUEST["id"];
}
//required to be a superadmin to update an account that is a member of the superadmin group
$superadmins = superadmin_list($db);
if (if_superadmin($superadmins, $user_uuid)) {
if (!if_group("superadmin")) {
echo "access denied";
exit;
}
}
//delete the group from the user
if ($_GET["a"] == "delete" && permission_exists("user_delete")) {
//set the variables
$group_uuid = check_str($_GET["group_uuid"]);
//delete the group from the users
$sql = "delete from v_group_users where 1 = 1 ";
$sql .= "and group_uuid = '".$group_uuid."' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
//redirect the user
$_SESSION["message"] = $text['message-update'];
header("Location: usersupdate.php?id=".$user_uuid);
return;
}
//get the user settings
$sql = "select * from v_user_settings ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$sql .= "and user_setting_enabled = 'true' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
$name = $row['user_setting_name'];
$category = $row['user_setting_category'];
$subcategory = $row['user_setting_subcategory'];
if (strlen($subcategory) == 0) {
//$$category[$name] = $row['domain_setting_value'];
$user_settings[$category][$name] = $row['user_setting_value'];
}
else {
$user_settings[$category][$subcategory][$name] = $row['user_setting_value'];
}
}
}
if (count($_POST) > 0 && $_POST["persistform"] != "1") {
//get the HTTP values and set as variables
$user_uuid = $_REQUEST["id"];
$domain_uuid = check_str($_POST["domain_uuid"]);
$username_old = check_str($_POST["username_old"]);
$username = check_str($_POST["username"]);
$password = check_str($_POST["password"]);
$password_confirm = check_str($_POST["password_confirm"]);
$user_status = check_str($_POST["user_status"]);
$user_language = check_str($_POST["user_language"]);
$user_time_zone = check_str($_POST["user_time_zone"]);
$contact_uuid = check_str($_POST["contact_uuid"]);
$group_member = check_str($_POST["group_member"]);
$user_enabled = check_str($_POST["user_enabled"]);
$api_key = check_str($_POST["api_key"]);
//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 != $password_confirm) { $msg_error = $text['message-password_mismatch']; }
if ($msg_error != '') {
$_SESSION["message"] = $msg_error;
$_SESSION["message_mood"] = 'negative';
header("Location: usersupdate.php?id=".$user_uuid);
exit;
}
if (!check_password_strength($password, $text)) {
header("Location: usersupdate.php?id=".$user_uuid);
exit;
}
//check to see if user language is set
$sql = "select count(*) as num_rows from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$user_setting_uuid = uuid();
$sql = "insert into v_user_settings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "user_setting_uuid, ";
$sql .= "user_setting_category, ";
$sql .= "user_setting_subcategory, ";
$sql .= "user_setting_name, ";
$sql .= "user_setting_value, ";
$sql .= "user_setting_enabled, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$domain_uuid."', ";
$sql .= "'".$user_setting_uuid."', ";
$sql .= "'domain', ";
$sql .= "'language', ";
$sql .= "'code', ";
$sql .= "'".$user_language."', ";
$sql .= "'true', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
$db->exec(check_sql($sql));
}
else {
if (strlen($user_language) == 0) {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
$sql = "update v_user_settings set ";
$sql .= "user_setting_value = '".$user_language."', ";
$sql .= "user_setting_enabled = 'true' ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'language' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
}
}
}
//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' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$user_setting_uuid = uuid();
$sql = "insert into v_user_settings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "user_setting_uuid, ";
$sql .= "user_setting_category, ";
$sql .= "user_setting_subcategory, ";
$sql .= "user_setting_name, ";
$sql .= "user_setting_value, ";
$sql .= "user_setting_enabled, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$domain_uuid."', ";
$sql .= "'".$user_setting_uuid."', ";
$sql .= "'domain', ";
$sql .= "'time_zone', ";
$sql .= "'name', ";
$sql .= "'".$user_time_zone."', ";
$sql .= "'true', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
else {
if (strlen($user_time_zone) == 0) {
$sql = "delete from v_user_settings ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
else {
$sql = "update v_user_settings set ";
$sql .= "user_setting_value = '".$user_time_zone."', ";
$sql .= "user_setting_enabled = 'true' ";
$sql .= "where user_setting_category = 'domain' ";
$sql .= "and user_setting_subcategory = 'time_zone' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
}
}
//assign the user to the group
if (strlen($_REQUEST["group_uuid_name"]) > 0) {
$group_data = explode('|', $_REQUEST["group_uuid_name"]);
$group_uuid = $group_data[0];
$group_name = $group_data[1];
$sql_insert = "insert into v_group_users ";
$sql_insert .= "(";
$sql_insert .= "group_user_uuid, ";
$sql_insert .= "domain_uuid, ";
$sql_insert .= "group_name, ";
$sql_insert .= "group_uuid, ";
$sql_insert .= "user_uuid ";
$sql_insert .= ") ";
$sql_insert .= "values ";
$sql_insert .= "( ";
$sql_insert .= "'".uuid()."', ";
$sql_insert .= "'".$domain_uuid."', ";
$sql_insert .= "'".$group_name."', ";
$sql_insert .= "'".$group_uuid."', ";
$sql_insert .= "'".$user_uuid."' ";
$sql_insert .= ")";
//only a superadmin can add other superadmins or admins, admins can only add other admins
switch ($group_name) {
case "superadmin" :
if (!if_group("superadmin")) { break; }
case "admin" :
if (!if_group("superadmin") && !if_group("admin")) { break; }
default :
$db->exec($sql_insert);
}
}
//change domain_uuid in group users and user settings tables, and unassign any foreign domain groups
if (permission_exists('user_domain')) {
$sql = "update v_group_users set ";
$sql .= "domain_uuid = '".$domain_uuid."' ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
$sql = "update v_user_settings set ";
$sql .= "domain_uuid = '".$domain_uuid."' ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
$sql = "delete from v_group_users where ";
$sql .= "domain_uuid = '".$domain_uuid."' ";
$sql .= "and user_uuid = '".$user_uuid."' ";
$sql .= "and group_uuid not in (";
$sql .= " select group_uuid from v_groups where domain_uuid = '".$domain_uuid."' or domain_uuid is null ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
}
//sql update
$sql = "update v_users set ";
if (permission_exists('user_domain')) {
$sql .= "domain_uuid = '".$domain_uuid."', ";
}
if (strlen($username) > 0 && $username != $username_old) {
$sql .= "username = '".$username."', ";
}
if (strlen($password) > 0 && $password_confirm == $password) {
//salt used with the password to create a one way hash
$salt = uuid();
//set the password
$sql .= "password = '".md5($salt.$password)."', ";
$sql .= "salt = '".$salt."', ";
}
if (strlen($api_key) > 0) {
$sql .= "api_key = '".$api_key."', ";
}
else {
$sql .= "api_key = null, ";
}
$sql .= "user_status = '".$user_status."', ";
$sql .= "user_enabled = '".$user_enabled."', ";
if (strlen($contact_uuid) == 0) {
$sql .= "contact_uuid = null ";
}
else {
$sql .= "contact_uuid = '".$contact_uuid."' ";
}
$sql .= "where ";
if (!permission_exists('user_domain')) {
$sql .= "domain_uuid = '".$domain_uuid."' and ";
}
$sql .= "user_uuid = '".$user_uuid."' ";
$db->exec(check_sql($sql));
// if call center installed
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
// 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['domains'][$domain_uuid]['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['domains'][$domain_uuid]['domain_name']." Waiting";
$response = event_socket_request($fp, $cmd);
}
//redirect the browser
$_SESSION["message"] = $text['message-update'];
if ($_REQUEST['action'] == $text['button-add']) {
header("Location: usersupdate.php?id=".$user_uuid);
}
else {
header("Location: index.php");
}
return;
}
//pre-populate the form
$sql = "select * from v_users ";
$sql .= "where user_uuid = '".$user_uuid."' ";
if (!permission_exists('user_all')) {
$sql .= "and domain_uuid = '".$domain_uuid."' ";
}
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$domain_uuid = $row["domain_uuid"];
$user_uuid = $row["user_uuid"];
$username = $row["username"];
$password = $row["password"];
$api_key = $row["api_key"];
$user_enabled = $row["user_enabled"];
$contact_uuid = $row["contact_uuid"];
$user_status = $row["user_status"];
}
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-user_edit'];
//show the content
$table_width ='width="100%"';
echo "<script>\n";
echo " function compare_passwords() {\n";
echo " if (document.getElementById('password') === document.activeElement || document.getElementById('password_confirm') === document.activeElement) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " if ($('#password').val() != $('#password_confirm').val()) {\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " $('#password').addClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').addClass('formfld_highlight_bad');\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').addClass('formfld_highlight_good');\n";
echo " $('#password_confirm').addClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " $('#password').removeClass('formfld_highlight_bad');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_bad');\n";
echo " $('#password').removeClass('formfld_highlight_good');\n";
echo " $('#password_confirm').removeClass('formfld_highlight_good');\n";
echo " }\n";
echo " }\n";
$req['length'] = $_SESSION['security']['password_length']['numeric'];
$req['number'] = ($_SESSION['security']['password_number']['boolean'] == 'true') ? true : false;
$req['lowercase'] = ($_SESSION['security']['password_lowercase']['boolean'] == 'true') ? true : false;
$req['uppercase'] = ($_SESSION['security']['password_uppercase']['boolean'] == 'true') ? true : false;
$req['special'] = ($_SESSION['security']['password_special']['boolean'] == 'true') ? true : false;
echo " function check_password_strength(pwd) {\n";
echo " if ($('#password').val() != '' || $('#password_confirm').val() != '') {\n";
echo " var msg_errors = [];\n";
if (is_numeric($req['length']) && $req['length'] != 0) {
echo " var re = /.{".$req['length'].",}/;\n"; //length
echo " if (!re.test(pwd)) { msg_errors.push('".$req['length']."+ ".$text['label-characters']."'); }\n";
}
if ($req['number']) {
echo " var re = /(?=.*[\d])/;\n"; //number
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-numbers']."'); }\n";
}
if ($req['lowercase']) {
echo " var re = /(?=.*[a-z])/;\n"; //lowercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-lowercase_letters']."'); }\n";
}
if ($req['uppercase']) {
echo " var re = /(?=.*[A-Z])/;\n"; //uppercase
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-uppercase_letters']."'); }\n";
}
if ($req['special']) {
echo " var re = /(?=.*[\W])/;\n"; //special
echo " if (!re.test(pwd)) { msg_errors.push('1+ ".$text['label-special_characters']."'); }\n";
}
echo " if (msg_errors.length > 0) {\n";
echo " var msg = '".$text['message-password_requirements'].": ' + msg_errors.join(', ');\n";
echo " display_message(msg, 'negative', '6000');\n";
echo " return false;\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " return true;\n";
echo " }\n";
echo " }\n";
echo " function show_strenth_meter() {\n";
echo " $('#pwstrength_progress').slideDown();\n";
echo " }\n";
echo "</script>\n";
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<input type='hidden' name='action' id='action' value=''>\n";
echo "<table $table_width cellpadding='0' cellspacing='0' border='0'>";
echo "<td align='left' width='90%' nowrap><b>".$text['header-user_edit']."</b></td>\n";
echo "<td align='right' nowrap>\n";
echo " <input type='button' class='btn' onclick=\"window.location='index.php'\" value='".$text['button-back']."'>";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; submit_form();\">";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo " ".$text['description-user_edit']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br />\n";
echo "<table $table_width cellpadding='0' cellspacing='0' border='0'>";
echo "<tr>\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' valign='top'>".$text['label-username']."</td>";
echo " <td width='70%' class='vtable'>";
if (if_group("admin") || if_group("superadmin")) {
echo " <input type='text' class='formfld' name='username' id='username' value='".$username."' required='required'>";
}
else {
echo " ".$username;
}
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-password']."</td>";
echo " <td class='vtable'>";
echo " <input style='display: none;' type='password'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password' id='password' value='' onkeypress='show_strenth_meter();' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " <div id='pwstrength_progress' class='pwstrength_progress'></div>";
echo " </td>";
echo " </tr>";
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-confirm_password']."</td>";
echo " <td class='vtable'>";
echo " <input type='password' autocomplete='off' class='formfld' name='password_confirm' id='password_confirm' value='' onfocus='compare_passwords();' onkeyup='compare_passwords();' onblur='compare_passwords();'>";
echo " </td>";
echo " </tr>";
if (permission_exists('user_domain')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
foreach ($_SESSION['domains'] as $row) {
echo " <option value='".$row['domain_uuid']."' ".(($row['domain_uuid'] == $domain_uuid) ? "selected='selected'" : null).">".$row['domain_name']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_name']."\n";
echo "</td>\n";
echo "</tr>\n";
}
else {
echo "<input type='hidden' name='domain_uuid' value='".$domain_uuid."'>";
}
echo " <tr>";
echo " <td class='vncellreq' valign='top'>".$text['label-groups']."</td>";
echo " <td class='vtable'>";
$sql = "select ";
$sql .= " gu.*, g.domain_uuid as group_domain_uuid ";
$sql .= "from ";
$sql .= " v_group_users as gu, ";
$sql .= " v_groups as g ";
$sql .= "where ";
$sql .= " gu.group_uuid = g.group_uuid ";
$sql .= " and (";
$sql .= " g.domain_uuid = :domain_uuid ";
$sql .= " or g.domain_uuid is null ";
$sql .= " ) ";
$sql .= " and gu.domain_uuid = :domain_uuid ";
$sql .= " and gu.user_uuid = :user_uuid ";
$sql .= "order by ";
$sql .= " g.domain_uuid desc, ";
$sql .= " g.group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
$prep_statement->bindParam(':user_uuid', $user_uuid);
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if ($result_count > 0) {
echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
foreach($result as $field) {
if (strlen($field['group_name']) > 0) {
echo "<tr>\n";
echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
echo " </td>\n";
if ($result_count > 1) {
if (permission_exists('group_member_delete') || if_group("superadmin")) {
echo " <td class='list_control_icons' style='width: 25px;'>\n";
echo " <a href='usersupdate.php?id=".$user_uuid."&domain_uuid=".$domain_uuid."&group_uuid=".$field['group_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
echo " </td>\n";
}
}
echo "</tr>\n";
$assigned_groups[] = $field['group_uuid'];
}
}
echo "</table>\n";
}
unset($sql, $prep_statement, $result, $result_count);
$sql = "select * from v_groups ";
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
if (sizeof($assigned_groups) > 0) {
$sql .= "and group_uuid not in ('".implode("','",$assigned_groups)."') ";
}
$sql .= "order by domain_uuid desc, group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if ($result_count > 0) {
if (isset($assigned_groups)) { echo "<br />\n"; }
echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
echo " <option value=''></option>\n";
foreach($result as $field) {
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins
if ( !isset($assigned_groups) || (isset($assigned_groups) && !in_array($field["group_uuid"], $assigned_groups)) ) {
echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
}
}
echo "</select>";
echo "<input type='button' class='btn' value=\"".$text['button-add']."\" onclick=\"document.getElementById('action').value = '".$text['button-add']."'; submit_form();\">\n";
}
unset($sql, $prep_statement, $result);
echo " </td>";
echo " </tr>";
echo "</table>";
echo "<br>";
echo "<br>";
echo "<table $table_width cellpadding='0' cellspacing='0'>";
echo " <tr>\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' valign='top'>".$text['label-contact']."</td>";
echo " <td width='70%' class='vtable'>\n";
$sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family, contact_nickname from v_contacts ";
$sql .= " where domain_uuid = '".$domain_uuid."' ";
$sql .= " order by contact_organization desc, contact_name_family asc, contact_name_given asc, contact_nickname asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql);
echo "<select name=\"contact_uuid\" id=\"contact_uuid\" class=\"formfld\">\n";
echo "<option value=\"\"></option>\n";
foreach($result as $row) {
$contact_name = array();
if ($row['contact_organization'] != '') { $contact_name[] = $row['contact_organization']; }
if ($row['contact_name_family'] != '') { $contact_name[] = $row['contact_name_family']; }
if ($row['contact_name_given'] != '') { $contact_name[] = $row['contact_name_given']; }
if ($row['contact_name_family'] == '' && $row['contact_name_family'] == '' && $row['contact_nickname'] != '') { $contact_name[] = $row['contact_nickname']; }
echo "<option value='".$row['contact_uuid']."' ".(($row['contact_uuid'] == $contact_uuid) ? "selected='selected'" : null).">".implode(', ', $contact_name)."</option>\n";
}
unset($sql, $result, $row_count);
echo "</select>\n";
echo "<br />\n";
echo $text['description-contact']."\n";
if (strlen($contact_uuid) > 0) {
echo " <a href=\"".PROJECT_PATH."/app/contacts/contact_edit.php?id=$contact_uuid\">".$text['description-contact_view']."</a>\n";
}
echo " </td>";
echo " </tr>";
if ($_SESSION['user_status_display'] == "false") {
//hide the user_status when it is set to false
}
else {
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\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+".$username."@".$_SESSION['domains'][$domain_uuid]['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";
echo " <option value='Available' ".(($user_status == "Available") ? "selected='selected'" : null).">".$text['option-available']."</option>\n";
echo " <option value='Available (On Demand)' ".(($user_status == "Available (On Demand)") ? "selected='selected'" : null).">".$text['option-available_on_demand']."</option>\n";
echo " <option value='Logged Out' ".(($user_status == "Logged Out") ? "selected='selected'" : null).">".$text['option-logged_out']."</option>\n";
echo " <option value='On Break' ".(($user_status == "On Break") ? "selected='selected'" : null).">".$text['option-on_break']."</option>\n";
echo " <option value='Do Not Disturb' ".(($user_status == "Do Not Disturb") ? "selected='selected'" : null).">".$text['option-do_not_disturb']."</option>\n";
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-status']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
}
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\n";
echo " ".$text['label-user_language']."\n";
echo " </td>\n";
echo " <td class=\"vtable\" align='left'>\n";
echo " <select id='user_language' name='user_language' class='formfld' style=''>\n";
echo " <option value=''></option>\n";
//get all language codes from database
$sql = "select * from v_languages order by language asc";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$language_codes[$row["code"]] = $row["language"];
}
unset($prep_statement, $result, $row);
foreach ($_SESSION['app']['languages'] as $code) {
$selected = ($code == $user_settings['domain']['language']['code']) ? "selected='selected'" : null;
echo " <option value='".$code."' ".$selected.">".$language_codes[$code]." [".$code."]</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-user_language']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td width='20%' class=\"vncell\" valign='top'>\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";
echo " <option value=''></option>\n";
//$list = DateTimeZone::listAbbreviations();
$time_zone_identifiers = DateTimeZone::listIdentifiers();
$previous_category = '';
$x = 0;
foreach ($time_zone_identifiers as $key => $row) {
$time_zone = explode("/", $row);
$category = $time_zone[0];
if ($category != $previous_category) {
if ($x > 0) {
echo " </optgroup>\n";
}
echo " <optgroup label='".$category."'>\n";
}
if ($row == $user_settings['domain']['time_zone']['name']) {
echo " <option value='".$row."' selected='selected'>".$row."</option>\n";
}
else {
echo " <option value='".$row."'>".$row."</option>\n";
}
$previous_category = $category;
$x++;
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-time_zone']."<br />\n";
echo " </td>\n";
echo " </tr>\n";
if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/api/app_config.php')) {
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-api_key']."</td>";
echo " <td class='vtable'>\n";
echo " <input type=\"text\" class='formfld' name=\"api_key\" id='api_key' value=\"".$api_key."\" >";
echo " <input type='button' class='btn' value='".$text['button-generate']."' onclick=\"getElementById('api_key').value='".uuid()."';\">";
if (strlen($text['description-api_key']) > 0) {
echo " <br />".$text['description-api_key']."<br />\n";
}
echo " </td>";
echo " </tr>";
}
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\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='true'>".$text['option-true']."</option>\n";
echo " <option value='false' ".(($user_enabled != "true") ? "selected='selected'" : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-enabled']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>";
echo " <td colspan='2' align='right'>";
echo " <input type='hidden' name='id' value=\"$user_uuid\">";
echo " <input type='hidden' name='username_old' value=\"$username\">";
echo " <br>";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"document.getElementById('action').value = '".$text['button-save']."'; if (check_password_strength(document.getElementById('password').value)) { submit_form(); }\">";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
echo "<script>\n";
//capture enter key to submit form
echo " $(window).keypress(function(event){\n";
echo " if (event.which == 13) { submit_form(); }\n";
echo " });\n";
// convert password fields to text
echo " function submit_form() {\n";
echo " $('input:password').css('visibility','hidden');\n";
echo " $('input:password').attr({type:'text'});\n";
echo " $('form#frm').submit();\n";
echo " }\n";
echo "</script>\n";
if (permission_exists('user_setting_view')) {
require "user_settings.php";
}
//include the footer
require_once "resources/footer.php";
?>