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
-216
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";
-23
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();
}
}
?>
-253
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.";
+20 -16
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";
?>
-490
View File
@@ -1,490 +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-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permisions
if (permission_exists('group_permissions') || if_group("superadmin")) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//include the header
$document['title'] = $text['title-group_permissions'];
require_once "resources/header.php";
//include paging
require_once "resources/paging.php";
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x=0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
//if there are no permissions listed in v_group_permissions then set the default permissions
$sql = "select count(*) as count from v_group_permissions ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$group_permission_count = $row["count"];
break; //limit to 1 row
}
unset ($prep_statement);
if ($group_permission_count == 0) {
//no permissions found add the defaults
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
foreach ($row['groups'] as $group) {
//add the record
$sql = "insert into v_group_permissions ";
$sql .= "(";
$sql .= "group_permission_uuid, ";
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".$row['name']."', ";
$sql .= "'".$group."' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
}
}
}
//get the group uuid, lookup domain uuid (if any) and name
$group_uuid = check_str($_REQUEST['group_uuid']);
$sql = "select domain_uuid, group_name from v_groups ";
$sql .= "where group_uuid = '".$group_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"];
$group_name = $row["group_name"];
break; //limit to 1 row
}
unset ($prep_statement);
//get the permissions assigned to this group
$sql = " select * from v_group_permissions ";
$sql .= "where group_name = '$group_name' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$permission_name = $row["permission_name"];
$permissions_db[$permission_name] = "true";
}
//show the db checklist
//echo "<pre>";
//print_r($permissions_db);
//echo "</pre>";
//list all the permissions in the database
foreach($apps as $app) {
if (isset($app['permissions'])) foreach ($app['permissions'] as $row) {
if ($permissions_db[$row['name']] == "true") {
$permissions_db_checklist[$row['name']] = "true";
}
else {
$permissions_db_checklist[$row['name']] = "false";
}
}
}
//show the db checklist
//echo "<pre>";
//print_r($permissions_db_checklist);
//echo "</pre>";
//process the http post
if (count($_POST)>0) {
foreach($_POST['permissions_form'] as $permission) {
$permissions_form[$permission] = "true";
}
//list all the permissions
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
if ($permissions_form[$row['name']] == "true") {
$permissions_form_checklist[$row['name']] = "true";
}
else {
$permissions_form_checklist[$row['name']] = "false";
}
}
}
//show the form db checklist
//echo "<pre>";
//print_r($permissions_form_checklist);
//echo "</pre>";
//list all the permissions
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
$permission = $row['name'];
if ($permissions_db_checklist[$permission] == "true" && $permissions_form_checklist[$permission] == "true") {
//matched do nothing
}
if ($permissions_db_checklist[$permission] == "false" && $permissions_form_checklist[$permission] == "false") {
//matched do nothing
}
if ($permissions_db_checklist[$permission] == "true" && $permissions_form_checklist[$permission] == "false") {
//delete the record
$sql = "delete from v_group_permissions ";
$sql .= "where group_name = '$group_name' ";
$sql .= "and permission_name = '$permission' ";
$db->exec(check_sql($sql));
unset($sql);
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
if ($row['name'] == $permission) {
$sql = "delete from v_menu_item_groups ";
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
$sql .= "and group_name = '$group_name' ";
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$db->exec(check_sql($sql));
unset($sql);
$sql = " select menu_item_parent_uuid from v_menu_items ";
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$menu_item_parent_uuid = $row["menu_item_parent_uuid"];
}
unset ($prep_statement);
$sql = " select * from v_menu_items as i, v_menu_item_groups as g ";
$sql .= "where i.menu_item_uuid = g.menu_item_uuid ";
$sql .= "and i.menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$sql .= "and i.menu_item_parent_uuid = '$menu_item_parent_uuid' ";
$sql .= "and g.group_name = '$group_name' ";
$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) {
$sql = "delete from v_menu_item_groups ";
$sql .= "where menu_item_uuid = '$menu_item_parent_uuid' ";
$sql .= "and group_name = '$group_name' ";
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$db->exec(check_sql($sql));
unset($sql);
}
unset ($prep_statement);
}
}
}
//set the permission to false in the permissions_db_checklist
$permissions_db_checklist[$permission] = "false";
}
if ($permissions_db_checklist[$permission] == "false" && $permissions_form_checklist[$permission] == "true") {
//add the record
$sql = "insert into v_group_permissions ";
$sql .= "(";
$sql .= "group_permission_uuid, ";
if ($domain_uuid != '') {
$sql .= "domain_uuid, ";
}
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
if ($domain_uuid != '') {
$sql .= "'".$domain_uuid."', ";
}
$sql .= "'$permission', ";
$sql .= "'$group_name' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
foreach($apps as $app) {
foreach ($app['permissions'] as $row) {
if ($row['name'] == $permission) {
$sql = "insert into v_menu_item_groups ";
$sql .= "(";
$sql .= "menu_uuid, ";
$sql .= "menu_item_uuid, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'b4750c3f-2a86-b00d-b7d0-345c14eca286', ";
$sql .= "'".$row['menu']['uuid']."', ";
$sql .= "'$group_name' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
$sql = " select menu_item_parent_uuid from v_menu_items ";
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$menu_item_parent_uuid = $row["menu_item_parent_uuid"];
}
unset ($prep_statement);
$sql = " select * from v_menu_item_groups ";
$sql .= "where menu_item_uuid = '$menu_item_parent_uuid' ";
$sql .= "and group_name = '$group_name' ";
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
$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) {
$sql = "insert into v_menu_item_groups ";
$sql .= "(";
$sql .= "menu_uuid, ";
$sql .= "menu_item_uuid, ";
$sql .= "group_name ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'b4750c3f-2a86-b00d-b7d0-345c14eca286', ";
$sql .= "'$menu_item_parent_uuid', ";
$sql .= "'$group_name' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
unset ($prep_statement);
}
}
}
//set the permission to true in the permissions_db_checklist
$permissions_db_checklist[$permission] = "true";
}
}
}
$_SESSION["message"] = $text['message-update'];
header("Location: groups.php");
return;
}
//copy group javascript
echo "<script language='javascript' type='text/javascript'>\n";
echo " function copy_group() {\n";
echo " var new_group_name;\n";
echo " var new_group_desc;\n";
echo " new_group_name = prompt('".$text['message-new_group_name']."');\n";
echo " if (new_group_name != null) {\n";
echo " new_group_desc = prompt('".$text['message-new_group_description']."');\n";
echo " if (new_group_desc != null) {\n";
echo " window.location = 'permissions_copy.php?group_name=".$group_name."&new_group_name=' + new_group_name + '&new_group_desc=' + new_group_desc;\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo "\n";
echo " $( document ).ready(function() {\n";
echo " $('#group_permission_search').focus();\n";
echo " });\n";
echo "</script>\n";
//prevent enter key submit on search field
echo "<script language='javascript' type='text/javascript'>\n";
echo " $(document).ready(function() {\n";
echo " $('#group_permission_search').keydown(function(event){\n";
echo " if (event.keyCode == 13) {\n";
echo " event.preventDefault();\n";
echo " return false;\n";
echo " }\n";
echo " });\n";
echo " });\n";
echo "</script>\n";
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo "<input type='hidden' name='domain_uuid' value='".$domain_uuid."'>\n";
echo "<table cellpadding='0' cellspacing='0' width='100%' border='0'>\n";
echo " <tr>\n";
echo " <td width='50%' align=\"left\" nowrap=\"nowrap\" valign='top'>";
echo " <b>".$text['header-group_permissions'].$group_name."</b>";
echo " <br><br>";
echo " </td>\n";
echo " <td width='50%' align=\"right\" valign='top'>\n";
echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='groups.php'\" value='".$text['button-back']."'> ";
echo " <input type='text' id='group_permission_search' class='formfld' style='min-width: 150px; width:150px; max-width: 150px;' placeholder=\"".$text['label-search']."\" onkeyup='permission_search();'>\n";
echo " <input type='button' class='btn' alt='".$text['button-copy']."' onclick='copy_group();' value='".$text['button-copy']."'>";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align=\"left\" colspan='2'>\n";
echo " ".$text['description-group_permissions']."\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br /><br />\n";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//list all the permissions
foreach($apps as $app_index => $app) {
//hide apps for which there are no permissions
if (!is_array($app['permissions']) || sizeof($app['permissions']) == 0) { continue; }
$app_name = $app['name'];
$description = $app['description']['en-us'];
//used to hide apps, even if permissions don't exist
$array_apps_unique[] = str_replace(' ','_',strtolower($app['name']));
echo "<div id='app_".str_replace(' ','_',strtolower($app['name']))."'>";
echo "<b>".$app_name."</b><br />\n";
if ($description != '') { echo $description."<br />\n"; }
echo "<br>";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <th style='text-align: center; padding: 0 7px;'><input type='checkbox' id='check_toggle_".$app_index."' onclick=\"check_toggle('".$app_index."', this.checked);\"></th>\n";
echo " <th width='30%'>".$text['label-permission_permissions']."</th>\n";
echo " <th width='70%'>".$text['label-permission_description']."</th>\n";
echo " <tr>\n";
foreach ($app['permissions'] as $permission_index => $row) {
$checked = ($permissions_db_checklist[$row['name']] == "true") ? "checked='checked'" : null;
echo "<tr id='permission_".$row['name']."'>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' name='permissions_form[]' id='perm_".$app_index."_".$permission_index."' ".$checked." value='".$row['name']."'></td>\n";
echo " <td valign='top' nowrap='nowrap' class='".$row_style[$c]."' onclick=\"(document.getElementById('perm_".$app_index."_".$permission_index."').checked) ? document.getElementById('perm_".$app_index."_".$permission_index."').checked = false : document.getElementById('perm_".$app_index."_".$permission_index."').checked = true;\">".$row['name']."</td>\n";
echo " <td valign='top' class='row_stylebg' onclick=\"(document.getElementById('perm_".$app_index."_".$permission_index."').checked) ? document.getElementById('perm_".$app_index."_".$permission_index."').checked = false : document.getElementById('perm_".$app_index."_".$permission_index."').checked = true;\">".$row['description']."&nbsp;</td>\n";
echo "</tr>\n";
$c = ($c == 0) ? 1 : 0;
//populate search/filter arrays
$array_apps[] = str_replace(' ','_',strtolower($app['name']));
$array_apps_original[] = $app['name'];
$array_permissions[] = $row['name'];
$array_descriptions[] = str_replace('"','\"',$row['description']);
$app_permissions[$app_index][] = "perm_".$app_index."_".$permission_index;
}
echo " <tr>\n";
echo " <td colspan='3' align='right' style='padding-top: 15px;'><input type='submit' name='submit' class='btn' value='".$text['button-save']."'></td>\n";
echo " </tr>\n";
echo "</table>";
echo "</div>\n\n";
} //end foreach
echo "<br>";
unset($sql, $result, $row_count);
echo "</form>\n";
//check or uncheck all category checkboxes
echo "<script>\n";
echo "function check_toggle(app_index, toggle_state) {\n";
echo " switch (app_index) {\n";
foreach ($app_permissions as $app_index => $app_permission_ids) {
echo " case '".$app_index."':\n";
foreach ($app_permission_ids as $app_permission_id) {
echo " document.getElementById('".$app_permission_id."').checked = toggle_state;\n";
}
echo " break;\n";
}
echo " }\n";
echo "}\n";
echo "</script>\n";
//setting search script
echo "<script>\n";
echo " var apps_unique = new Array(\"".implode('","', $array_apps_unique)."\");\n";
echo " var apps = new Array(\"".implode('","', $array_apps)."\");\n";
echo " var apps_original = new Array(\"".implode('","', $array_apps_original)."\");\n";
echo " var permissions = new Array(\"".implode('","', $array_permissions)."\");\n";
echo " var descriptions = new Array(\"".implode('","', $array_descriptions)."\");\n";
echo "\n";
echo " function permission_search() {\n";
echo " var criteria = $('#group_permission_search').val();\n";
echo " if (criteria.length >= 2) {\n";
echo " for (var x = 0; x < apps_unique.length; x++) {\n";
echo " document.getElementById('app_'+apps_unique[x]).style.display = 'none';\n";
echo " }\n";
echo " for (var x = 0; x < permissions.length; x++) {\n";
echo " if (\n";
echo " apps_original[x].toLowerCase().match(criteria.toLowerCase()) ||\n";
echo " permissions[x].toLowerCase().match(criteria.toLowerCase()) ||\n";
echo " descriptions[x].toLowerCase().match(criteria.toLowerCase())\n";
echo " ) {\n";
echo " document.getElementById('app_'+apps[x]).style.display = '';\n";
echo " document.getElementById('permission_'+permissions[x]).style.display = '';\n";
echo " }\n";
echo " else {\n";
echo " document.getElementById('permission_'+permissions[x]).style.display = 'none';\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo " else {\n";
echo " for (var x = 0; x < permissions.length; x++) {\n";
echo " document.getElementById('app_'+apps[x]).style.display = '';\n";
echo " document.getElementById('permission_'+permissions[x]).style.display = '';\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo "\n";
echo "</script>\n";
//show the footer
require_once "resources/footer.php";
?>
-184
View File
@@ -1,184 +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-2014
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('group_add')) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the http values and set them as variables
if (count($_POST) > 0) {
//set the variables
$group_name = check_str($_POST["group_name"]);
if (permission_exists('group_domain')) {
$domain_uuid = check_str($_POST["domain_uuid"]);
}
else {
$domain_uuid = $_SESSION['domain_uuid'];
}
$group_description = check_str($_POST["group_description"]);
//check for global/domain duplicates
$sql = "select count(*) as num_rows from v_groups where ";
$sql .= "group_name = '".$group_name."' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$group_exists = ($row['num_rows'] > 0) ? true : false;
}
else {
$group_exists = false;
}
unset($sql, $prep_statement, $row);
//insert group
if (!$group_exists) {
$sql = "insert into v_groups ";
$sql .= "(";
$sql .= "group_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "group_name, ";
$sql .= "group_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= (($domain_uuid != '') ? "'".$domain_uuid."'" : "null").", ";
$sql .= "'".$group_name."', ";
$sql .= "'".$group_description."' ";
$sql .= ")";
if (!$db->exec($sql)) {
//echo $db->errorCode() . "<br>";
$info = $db->errorInfo();
echo "<pre>".print_r($info, true)."</pre>";
exit;
// $info[0] == $db->errorCode() unified error code
// $info[1] is the driver specific error code
// $info[2] is the driver specific error string
}
$_SESSION["message"] = $text['message-add'];
header("Location: groups.php");
}
else {
$_SESSION['message_mood'] = 'negative';
$_SESSION["message"] = $text['message-group_exists'];
header("Location: groupadd.php");
}
//redirect the user
return;
}
//include the header
include "resources/header.php";
$document['title'] = $text['title-group_add'];
//show the content
echo "<form name='login' method='post' action=''>\n";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' valign='top'>\n";
echo " <b>".$text['header-group_add']."</b>\n";
echo " <br><br>\n";
echo " ".$text['description-group_add']."\n";
echo " </td>\n";
echo " <td align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='groups.php'\" value='".$text['button-back']."'> ";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br>";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncellreq'>\n";
echo $text['label-group_name']."\n";
echo "</td>\n";
echo "<td width='70%' align='left' class='vtable'>\n";
echo " <input type='text' class='formfld' name='group_name'>\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('group_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";
echo " <option value='' ".((strlen($domain_uuid) == 0) ? "selected='selected'" : null).">".$text['option-global']."</option>\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";
}
echo "<tr>\n";
echo "<td class='vncell'>\n";
echo $text['label-group_description']."\n";
echo "</td>\n";
echo "<td align='left' class='vtable'>\n";
echo "<textarea name='group_description' class='formfld' style='width: 250px; height: 50px;'></textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan='2' align='right'>\n";
echo " <br />";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><br>";
echo "</form>";
//include the footer
include "resources/footer.php";
?>
-98
View File
@@ -1,98 +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 (permission_exists('group_delete') || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the http value and set as a variable
$group_uuid = check_str($_GET["id"]);
//validate the uuid
if (is_uuid($group_uuid)) {
//get the group from v_groups
$sql = "select domain_uuid, group_name from v_groups ";
$sql .= "where group_uuid = '".$group_uuid."' ";
if (!permission_exists('group_domain')) {
$sql .= "and (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null); ";
}
$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"];
$group_name = $row["group_name"];
}
unset ($prep_statement);
//delete the group users
$sql = "delete from v_group_users ";
$sql .= "where group_uuid = '".$group_uuid."' ";
if (!$db->exec($sql)) {
$error = $db->errorInfo();
print_r($error);
}
//delete the group permissions
if (strlen($group_name) > 0) {
$sql = "delete from v_group_permissions ";
$sql .= "where group_name = '".$group_name."' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
if (!$db->exec($sql)) {
$error = $db->errorInfo();
print_r($error);
}
}
//delete the group
$sql = "delete from v_groups ";
$sql .= "where group_uuid = '".$group_uuid."' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
if (!$db->exec($sql)) {
$error = $db->errorInfo();
print_r($error);
}
}
//redirect the user
$_SESSION["message"] = $text['message-delete'];
header("Location: groups.php");
?>
-314
View File
@@ -1,314 +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-2014
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('group_edit')) {
//access allowed
}
else {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//process update
if (count($_POST) > 0) {
//set the variables
$group_uuid = check_str($_POST['group_uuid']);
$group_name = check_str($_POST['group_name']);
$group_name_previous = check_str($_POST['group_name_previous']);
$domain_uuid = check_str($_POST["domain_uuid"]);
$domain_uuid_previous = check_str($_POST["domain_uuid_previous"]);
$group_description = check_str($_POST["group_description"]);
//check for global/domain duplicates
$sql = "select count(*) as num_rows from v_groups where ";
$sql .= "group_name = '".$group_name."' ";
$sql .= "and group_uuid <> '".$group_uuid."' ";
$sql .= "and domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ");
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$group_exists = ($row['num_rows'] > 0) ? true : false;
}
else {
$group_exists = false;
}
unset($sql, $prep_statement, $row);
//update group
if (!$group_exists) {
$sql = "update v_groups ";
$sql .= "set ";
$sql .= "group_name = '".$group_name."', ";
$sql .= "domain_uuid = ".(($domain_uuid != '') ? "'".$domain_uuid."'" : "null").", ";
$sql .= "group_description = '".$group_description."' ";
$sql .= "where group_uuid = '".$group_uuid."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
echo "<pre>".print_r($error, true)."</pre>";
exit;
}
//group changed from global to domain-specific
if ($domain_uuid_previous == '' && $domain_uuid != '') {
//remove any users assigned to the group from the old domain
$sql = "delete from v_group_users where group_uuid = '".$group_uuid."' and domain_uuid <> '".$domain_uuid."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//update permissions to use new domain uuid
$sql = "update v_group_permissions set domain_uuid = '".$domain_uuid."' where group_name = '".$group_name_previous."' and domain_uuid is null ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name
if ($group_name != $group_name_previous && $group_name != '') {
//change group name in group users
$sql = "update v_group_users set group_name = '".$group_name."' where group_uuid = '".$group_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name in permissions
$sql = "update v_group_permissions set group_name = '".$group_name."' where domain_uuid = '".$domain_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
}
}
//group changed from one domain to another
else if ($domain_uuid_previous != '' && $domain_uuid != '' && $domain_uuid_previous != $domain_uuid) {
//remove any users assigned to the group from the old domain
$sql = "delete from v_group_users where group_uuid = '".$group_uuid."' and domain_uuid = '".$domain_uuid_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//update permissions to use new domain uuid
$sql = "update v_group_permissions set domain_uuid = '".$domain_uuid."' where group_name = '".$group_name_previous."' and domain_uuid = '".$domain_uuid_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name
if ($group_name != $group_name_previous && $group_name != '') {
//change group name in group users
$sql = "update v_group_users set group_name = '".$group_name."' where group_uuid = '".$group_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name in permissions
$sql = "update v_group_permissions set group_name = '".$group_name."' where domain_uuid = '".$domain_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
}
}
//group changed from domain-specific to global
else if ($domain_uuid_previous != '' && $domain_uuid == '') {
//change group name
if ($group_name != $group_name_previous && $group_name != '') {
//change group name in group users
$sql = "update v_group_users set group_name = '".$group_name."' where group_uuid = '".$group_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name in permissions
$sql = "update v_group_permissions set group_name = '".$group_name."' where domain_uuid = '".$domain_uuid_previous."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
}
//update permissions to not use a domain uuid
$sql = "update v_group_permissions set domain_uuid = null where group_name = '".$group_name."' and domain_uuid = '".$domain_uuid_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
}
//domain didn't change, but name may still
else {
//change group name
if ($group_name != $group_name_previous && $group_name != '') {
//change group name in group users
$sql = "update v_group_users set group_name = '".$group_name."' where group_uuid = '".$group_uuid."' and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
//change group name in permissions
$sql = "update v_group_permissions set group_name = '".$group_name."' where domain_uuid ".(($domain_uuid != '') ? " = '".$domain_uuid."' " : " is null ")." and group_name = '".$group_name_previous."' ";
if (!$db->exec(check_sql($sql))) {
$error = $db->errorInfo();
//echo "<pre>".print_r($error, true)."</pre>"; exit;
}
}
}
$_SESSION["message"] = $text['message-update'];
header("Location: groups.php");
}
else {
$_SESSION['message_mood'] = 'negative';
$_SESSION["message"] = $text['message-group_exists'];
header("Location: groupedit.php?id=".$group_uuid);
}
//redirect the user
return;
}
//pre-populate the form
$group_uuid = check_str($_REQUEST['id']);
if ($group_uuid != '') {
$sql = "select * from v_groups where ";
$sql .= "group_uuid = '".$group_uuid."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$group_name = $row['group_name'];
$domain_uuid = $row['domain_uuid'];
$group_description = $row['group_description'];
}
}
//include the header
include "resources/header.php";
$document['title'] = $text['title-group_edit'];
//copy group javascript
echo "<script language='javascript' type='text/javascript'>\n";
echo " function copy_group() {\n";
echo " var new_group_name;\n";
echo " var new_group_desc;\n";
echo " new_group_name = prompt('".$text['message-new_group_name']."');\n";
echo " if (new_group_name != null) {\n";
echo " new_group_desc = prompt('".$text['message-new_group_description']."');\n";
echo " if (new_group_desc != null) {\n";
echo " window.location = 'permissions_copy.php?group_name=".$group_name."&new_group_name=' + new_group_name + '&new_group_desc=' + new_group_desc;\n";
echo " }\n";
echo " }\n";
echo " }\n";
echo "</script>\n";
//show the content
echo "<form name='login' method='post' action=''>\n";
echo "<input type='hidden' name='group_uuid' value='".$group_uuid."'>\n";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' valign='top'>\n";
echo " <b>".$text['header-group_edit']."</b>\n";
echo " <br><br>\n";
echo " ".$text['description-group_edit']."\n";
echo " </td>\n";
echo " <td align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='groups.php'\" value='".$text['button-back']."'> ";
echo " <input type='button' class='btn' alt='".$text['button-copy']."' onclick='copy_group();' value='".$text['button-copy']."'>";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br>";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='30%' class='vncellreq' valign='top'>\n";
echo $text['label-group_name']."\n";
echo "</td>\n";
echo "<td width='70%' align='left' class='vtable'>\n";
echo " <input type='hidden' name='group_name_previous' value=\"".$group_name."\">\n";
echo " <input type='text' class='formfld' name='group_name' value=\"".$group_name."\">\n";
echo "</td>\n";
echo "</tr>\n";
if (permission_exists('group_domain')) {
echo "<tr>\n";
echo "<td class='vncell' valign='top'>\n";
echo " ".$text['label-domain']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input type='hidden' name='domain_uuid_previous' value='".$domain_uuid."'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
echo " <option value='' ".((strlen($domain_uuid) == 0) ? "selected='selected'" : null).">".$text['option-global']."</option>\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>\n";
echo "<td class='vncell' valign='top'>\n";
echo $text['label-group_description']."\n";
echo "</td>\n";
echo "<td align='left' class='vtable' valign='top'>\n";
echo " <textarea name='group_description' class='formfld' style='width: 250px; height: 50px;'>".$group_description."</textarea>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td colspan='2' align='right'>\n";
echo " <br />";
echo " <input type='submit' class='btn' value=\"".$text['button-save']."\">\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<br><br>";
echo "</form>";
//include the footer
include "resources/footer.php";
?>
-87
View File
@@ -1,87 +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('group_member_add') || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//requires a superadmin to add a user to the superadmin group
if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") {
echo "access denied";
return;
}
//get the http values and set them as variables
$domain_uuid = check_str($_POST["domain_uuid"]);
$group_uuid = check_str($_POST["group_uuid"]);
$group_name = check_str($_POST["group_name"]);
$user_uuid = check_str($_POST["user_uuid"]);
//add the user to the group
if (is_uuid($user_uuid) && is_uuid($group_uuid) && strlen($group_name) > 0) {
$sql = "insert into v_group_users ";
$sql .= "(";
$sql .= "group_user_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "group_uuid, ";
$sql .= "group_name, ";
$sql .= "user_uuid ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".$domain_uuid."', ";
$sql .= "'".$group_uuid."', ";
$sql .= "'".$group_name."', ";
$sql .= "'".$user_uuid."' ";
$sql .= ")";
if (!$db->exec($sql)) {
$info = $db->errorInfo();
echo "<pre>".print_r($info, true)."</pre>";
exit;
}
else {
//log the success
//$log_type = 'group'; $log_status='add'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." added to group: ".$group_name;
//log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]);
}
}
//redirect the user
$_SESSION["message"] = $text['message-update'];
header("Location: groupmembers.php?group_uuid=".$group_uuid."&group_name=".$group_name);
?>
-70
View File
@@ -1,70 +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('group_member_delete') || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//requires a superadmin to delete superadmin group
if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") {
echo "access denied";
return;
}
//get the http values and set them as variables
$group_name = check_str($_GET["group_name"]);
$user_uuid = check_str($_GET["user_uuid"]);
$group_uuid = check_str($_GET["group_uuid"]);
//delete the group membership
$sql_delete = "delete from v_group_users ";
$sql_delete .= "where user_uuid = '".$user_uuid."' ";
$sql_delete .= "and group_uuid = '".$group_uuid."' ";
if (!$db->exec($sql_delete)) {
$info = $db->errorInfo();
echo "<pre>".print_r($info, true)."</pre>";
exit;
}
else {
//$log_type = 'group'; $log_status='remove'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." removed from group: ".$group_name;
//log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]);
}
//redirect the user
$_SESSION["message"] = $text['message-delete'];
header("Location: groupmembers.php?group_uuid=".$group_uuid."&group_name=".$group_name);
?>
-191
View File
@@ -1,191 +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('group_members_view') || if_group("superadmin")) {
//access allowed
}
else {
echo "access denied";
return;
}
//requires a superadmin to view members of the superadmin group
if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") {
echo "access denied";
return;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//get the group uuid, lookup domain uuid (if any) and name
$group_uuid = check_str($_REQUEST['group_uuid']);
$sql = "select domain_uuid, group_name from v_groups ";
$sql .= "where group_uuid = '".$group_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"];
$group_name = $row["group_name"];
break; //limit to 1 row
}
unset ($prep_statement);
//define the if group members function
function is_group_member($group_uuid, $user_uuid) {
global $db, $domain_uuid;
$sql = "select * from v_group_users ";
$sql .= "where user_uuid = '".$user_uuid."' ";
$sql .= "and group_uuid = '".$group_uuid."' ";
$sql .= "and domain_uuid = '".(($domain_uuid != '') ? $domain_uuid : $_SESSION['domain_uuid'])."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) == 0) { return true; } else { return false; }
unset ($sql, $prep_statement);
}
//$exampledatareturned = example("apples", 1);
//get the the users array
if (permission_exists('group_member_add')) {
$sql = "select * from v_users where ";
if ($domain_uuid != '') {
$sql .= "domain_uuid = '".$domain_uuid."' ";
}
else {
$sql .= "domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
$sql .= "order by username ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
}
//get the groups users
$sql = "select u.user_uuid, u.username, gu.group_user_uuid, gu.domain_uuid, gu.group_uuid ";
$sql .= "from v_group_users as gu, v_users as u, v_domains as d ";
$sql .= "where gu.user_uuid = u.user_uuid ";
$sql .= "and gu.domain_uuid = d.domain_uuid ";
if ($domain_uuid != '') {
$sql .= "and gu.domain_uuid = '".$domain_uuid."' ";
}
if (!permission_exists('user_all')) {
$sql .= "and u.domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
$sql .= "and gu.group_uuid = '".$group_uuid."' ";
$sql .= "order by d.domain_name asc, u.username asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//include the header
require_once "resources/header.php";
$document['title'] = $text['title-group_members'];
//show the content
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo " <tr>\n";
echo " <td width='100%' align='left' valign='top'>\n";
echo " <b>".$text['header-group_members'].$group_name."</b>\n";
echo " </td>\n";
echo " <td align='right' nowrap='nowrap' valign='middle'>\n";
echo " <input type='button' class='btn' style='margin-right: 15px;' alt='".$text['button-back']."' onclick=\"window.location='groups.php'\" value='".$text['button-back']."'>";
echo " </td>";
if (permission_exists('group_member_add')) {
echo " <td align='right' nowrap='nowrap' valign='top'>\n";
echo " <form method='post' action='groupmemberadd.php'>";
echo " <select name='user_uuid' style='width: 200px;' class='formfld'>\n";
echo " <option value=''></option>\n";
foreach($users as $field) {
if (is_group_member($group_uuid, $field['user_uuid'])) {
echo " <option value='".$field['user_uuid']."'>".$field['username']."</option>\n";
}
}
unset($sql, $users);
echo " </select>";
echo " <input type='hidden' name='domain_uuid' value='".(($domain_uuid != '') ? $domain_uuid : $_SESSION['domain_uuid'])."'>";
echo " <input type='hidden' name='group_uuid' value='".$group_uuid."'>";
echo " <input type='hidden' name='group_name' value='".$group_name."'>";
echo " <input type='submit' class='btn' value='".$text['button-add_member']."'>";
echo " </form>";
echo " </td>\n";
}
echo " </tr>\n";
echo "</table>\n";
echo "<br>";
$echo = "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
$echo .= "<tr>\n";
if (permission_exists('user_all')) {
$echo .= "<th width='30%' align='left' nowrap>".$text['label-domain']."</th>\n";
}
$echo .= " <th align='left' nowrap>".$text['label-username']."</th>\n";
$echo .= " <td width='25' align='right' nowrap>&nbsp;</td>\n";
$echo .= "</tr>\n";
$count = 0;
foreach ($result as &$row) {
$group_user_uuid = $row["group_user_uuid"];
$username = $row["username"];
$user_uuid = $row["user_uuid"];
$domain_uuid = $row["domain_uuid"];
$group_uuid = $row["group_uuid"];
$echo .= "<tr>";
if (permission_exists('user_all')) {
$echo .= "<td align='left' class='".$row_style[$c]."' nowrap>".$_SESSION['domains'][$domain_uuid]['domain_name']."</td>\n";
}
$echo .= "<td align='left' class='".$row_style[$c]."' nowrap>".$username."</td>\n";
$echo .= "<td class='list_control_icons' style='width: 25px;'>";
if (permission_exists('group_member_delete')) {
$echo .= "<a href='groupmemberdelete.php?user_uuid=".$user_uuid."&group_name=".$group_name."&group_uuid=".$group_uuid."' onclick=\"return confirm('".$text['confirm-delete']."')\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
}
$echo .= "</td>\n";
$echo .= "</tr>\n";
$c = ($c) ? 0 : 1;
$group_users[] = $row["user_uuid"];
$count++;
}
$echo .= "</table>\n";
$echo .= "<br /><br />";
echo $echo;
//include the footer
require_once "resources/footer.php";
?>
-234
View File
@@ -1,234 +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-2014
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 the 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();
//show the header
require_once "resources/header.php";
$document['title'] = $text['title-group_manager'];
if (isset($_REQUEST["change"])) {
//get the values from the HTTP POST and save them as PHP variables
$change = check_str($_REQUEST["change"]);
$group_uuid = check_str($_REQUEST["group_uuid"]);
$group_name = check_str($_REQUEST["group_name"]);
$sql = "update v_groups set group_protected = '".$change."' ";
$sql .= "where group_uuid = '".$group_uuid."' ";
if (!permission_exists('group_domain')) {
$sql .= "and (";
$sql .= " domain_uuid = '".$domain_uuid."' ";
$sql .= " or domain_uuid is null ";
$sql .= ") ";
}
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-update'];
}
//get the groups
$sql = "select * from v_groups ";
if (!(permission_exists('group_all') && $_GET['showall'] == 'true')) {
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "or domain_uuid is null ";
}
$sql .= "order by domain_uuid desc, group_name asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$groups = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statement);
//$system_groups = array('superadmin','admin','user','public','agent');
$system_groups = array();
//get group counts
$sql = "select group_uuid, count(user_uuid) as group_count from v_group_users ";
if (!permission_exists('user_all')) {
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
}
$sql .= "group by group_uuid ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as $row) {
$group_counts[$row['group_uuid']] = $row['group_count'];
}
unset($sql, $prep_statement, $result, $row);
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
echo "<tr>";
echo "<td width='50%' valign='top'>";
echo " <b>".$text['header-group_manager']."</b>";
echo " <br><br>";
echo "</td>";
echo "<td width='50%' align='right' valign='top'>";
if (permission_exists('group_all')) {
if ($_GET['showall'] != 'true') {
echo "<input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='groups.php?showall=true';\">\n";
}
}
if (permission_exists('user_view')) {
echo " <input type='button' class='btn' onclick=\"window.location='index.php'\" value='".$text['header-user_manager']."'>";
}
if (permission_exists('group_edit')) {
echo " <input type='button' class='btn' alt='".$text['button-restore']."' onclick=\"window.location='permissions_default.php'\" value='".$text['button-restore']."'>";
}
echo "</td>\n";
echo "</tr>";
echo "</table>";
echo "<br>";
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
$echo = "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
$echo .= "<tr>\n";
if (permission_exists('group_all') && $_GET['showall'] == 'true') {
$echo .= " <th nowrap>".$text['label-domain']."</th>\n";
}
$echo .= " <th nowrap>".$text['label-group_name']."</th>\n";
$echo .= " <th nowrap>".$text['label-group_tools']."</th>\n";
$echo .= " <th style='text-align: center;' nowrap>".$text['label-group_protected']."</th>\n";
$echo .= " <th nowrap>".$text['label-group_description']."</th>\n";
$echo .= " <td class='list_control_icons' style='width: 25px;'>";
if (permission_exists('group_add')) {
$echo .= "<a href='groupadd.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
$echo .= " </td>\n";
$echo .= "</tr>\n";
$count = 0;
foreach ($groups as &$row) {
$domain_uuid = $row['domain_uuid'];
$group_uuid = $row["group_uuid"];
$group_name = $row["group_name"];
$group_protected = $row["group_protected"];
$group_description = $row["group_description"];
if (strlen($group_name) == 0) { $group_name = "&nbsp;"; }
if (strlen($group_description) == 0) { $group_description = "&nbsp;"; }
$group_description = wordwrap($group_description, 50, "<br />\n");
if (!if_group("superadmin") && $group_name == "superadmin") {
//hide the superadmin group from non superadmin's
}
else {
if (permission_exists('group_edit') && !($domain_uuid == '' && in_array($group_name, $system_groups))) {
$tr_link = (permission_exists('group_edit')) ? "href='groupedit.php?id=".$group_uuid."'" : null;
}
else {
unset($tr_link);
}
$echo .= "<tr ".$tr_link.">\n";
if (permission_exists('group_all') && $_GET['showall'] == 'true') {
$echo .= "<td class='".$row_style[$c]."' nowrap>";
$echo .= ($domain_uuid != '') ? $_SESSION['domains'][$domain_uuid]['domain_name'] : "<i>".$text['label-global']."</i>";
$echo .= "</td>\n";
}
$echo .= "<td class='".$row_style[$c]."' nowrap>";
if (permission_exists('group_edit') && !($domain_uuid == '' && in_array($group_name, $system_groups))) {
$echo .= "<a href='groupedit.php?id=".$group_uuid."'>".(($domain_uuid == '' && $_GET['showall'] != 'true') ? "<i>".$group_name."</i>" : $group_name)."</a>";
}
else {
$echo .= ($domain_uuid == '' && $_GET['showall'] != 'true') ? "<i>".$group_name."</i>" : $group_name;
}
$echo .= "</td>\n";
$echo .= "<td class='".$row_style[$c]." tr_link_void' nowrap>\n";
if (permission_exists('group_add') || if_group("superadmin")) {
$echo .= "<a class='' href='group_permissions.php?group_uuid=".$group_uuid."' title='".$text['label-group_permissions']."'>".$text['label-group_permissions']."</a>&nbsp;&nbsp;&nbsp;";
}
if (permission_exists('group_member_view') || if_group("superadmin")) {
$echo .= "<a class='' href='groupmembers.php?group_uuid=".$group_uuid."&group_name=".$group_name."' title='".$text['label-group_members']."'>".$text['label-group_members']."</a>";
if (sizeof($group_counts) > 0 && $group_counts[$group_uuid] > 0) {
$echo .= " <span style='font-size: 80%;'>(".$group_counts[$group_uuid].")</span>";
}
}
$echo .= "</td>\n";
$echo .= "<td class='".$row_style[$c]." tr_link_void' style='padding: 0px; text-align: center;' align='center' nowrap>\n";
$echo .= " <input type='checkbox' name='group_protected' ".(($group_protected == "true") ? "checked='checked'" : null)." value='".(($group_protected == "true") ? 'false' : 'true')."' onchange=\"window.location='".PROJECT_PATH."/core/users/groups.php?change=".(($group_protected == "true") ? 'false' : 'true')."&group_uuid=".$group_uuid."&group_name=".$group_name.(($_GET['showall'] == 'true') ? "&showall=true" : null)."';\">\n";
$echo .= "</td>\n";
$echo .= "<td class='row_stylebg' nowrap>".$group_description."</td>\n";
$echo .= "<td class='list_control_icons' style='width: 25px;'>";
if (permission_exists('group_edit')) {
if (!($domain_uuid == '' && in_array($group_name, $system_groups))) {
$echo .= "<a href='groupedit.php?id=".$group_uuid."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>";
}
else {
$echo .= "<span onclick=\"alert('".$text['message-default_system_group']."');\" alt='".$text['button-edit']."'>".str_replace("list_control_icon", "list_control_icon_disabled", $v_link_label_edit)."</span>";
}
}
if (permission_exists('group_delete')) {
if (!($domain_uuid == '' && in_array($group_name, $system_groups))) {
$echo .= "<a href='groupdelete.php?id=".$group_uuid."' onclick=\"return confirm('".$text['confirm-delete']."')\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
}
else {
$echo .= "<span onclick=\"alert('".$text['message-default_system_group']."');\" alt='".$text['button-delete']."'>".str_replace("list_control_icon", "list_control_icon_disabled", $v_link_label_delete)."</span>";
}
}
$echo .= "</td>\n";
$echo .= "</tr>\n";
}
$c = ($c) ? 0 : 1;
$count++;
}
$echo .= "<tr>\n";
$echo .= "<td colspan='".((permission_exists('group_all') && $_GET['showall'] == 'true') ? 5 : 4)."'>&nbsp;</td>";
$echo .= "<td class='list_control_icons' style='width: 25px;'>";
if (permission_exists('group_add')) {
$echo .= "<a href='groupadd.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
$echo .= "</td>\n";
$echo .= "</tr>\n";
$echo .= "</table>\n";
$echo .= "<br>";
if ($count > 0) {
echo $echo;
}
//show the footer
require_once "resources/footer.php";
?>
-55
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";
?>
-124
View File
@@ -1,124 +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):
Sérgio Reis <uc@wavecom.pt>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('extension_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//include paging
require_once "resources/paging.php";
//set the http get/post variable(s) to a php variable
if (isset($_REQUEST["group_name"]) && isset($_REQUEST["new_group_name"])) {
//get HTTP values and set as variables
$group_name = check_str($_REQUEST["group_name"]);
$new_group_name = check_str($_REQUEST["new_group_name"]);
$new_group_desc = check_str($_REQUEST["new_group_desc"]);
//get the groups data
$sql = "select * from v_groups ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "or domain_uuid is null ";
$sql .= "and group_name = '".$group_name."' ";
$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"];
$group_name = $row["group_name"];
}
unset ($prep_statement);
//create new group
$group_uuid = uuid();
$sql = "insert into v_groups ";
$sql .= "( ";
$sql .= "group_uuid, ";
$sql .= "group_name, ";
$sql .= "group_description ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".$group_uuid."', ";
$sql .= "'".$new_group_name."', ";
$sql .= "'".$new_group_desc."' ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
//get the group permissions data
$sql = "select * from v_group_permissions ";
$sql .= "where group_name = '".$group_name."' ";
$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"];
$permission_name = $row["permission_name"];
$group_name = $row["group_name"];
//copy the group permissions
$group_permission_uuid = uuid();
$sql = "insert into v_group_permissions ";
$sql .= "( ";
$sql .= "group_permission_uuid, ";
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".$group_permission_uuid."', ";
$sql .= "'".$permission_name."', ";
$sql .= "'".$new_group_name."' ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
}
unset ($prep_statement);
//redirect the user
$_SESSION["message"] = $text['message-copy'];
}
//redirect
header("Location: groups.php");
?>
-59
View File
@@ -1,59 +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-2014
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//check permisions
if (!$included) {
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('group_edit')) {
//access granted
}
else {
echo "access denied";
return;
}
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//permission restore default
require_once "core/users/resources/classes/permission.php";
$permission = new permission;
$permission->db = $db;
$permission->restore();
//redirect the users
if (!$included) {
//show a message to the user
$_SESSION["message"] = $text['message-restore'];
header("Location: groups.php");
return;
}
?>
-133
View File
@@ -1,133 +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>
Copyright (C) 2013
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//define the permission class
class permission {
//delete the permissions
function delete() {
//set the variables
$db = $this->db;
//get unprotected groups and their domain uuids (if any)
$sql = "select group_name, domain_uuid from v_groups where group_protected <> 'true' ";
$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) {
foreach($result as $row) {
$unprotected_groups[$row['group_name']] = $row['domain_uuid'];
}
}
unset ($prep_statement, $sql, $result, $result_count);
//delete unprotected group permissions
if (is_array($unprotected_groups) && sizeof($unprotected_groups) > 0) {
foreach ($unprotected_groups as $unprotected_group_name => $unprotected_domain_uuid) {
$sql = "delete from v_group_permissions where ";
$sql .= "group_name = '".$unprotected_group_name."' ";
$sql .= "and domain_uuid ".(($unprotected_domain_uuid != '') ? " = '".$unprotected_domain_uuid."' " : " is null ");
if (false === $db->exec($sql)) {
//echo $db->errorCode() . "<br>";
$info = $db->errorInfo();
print_r($info);
// $info[0] == $db->errorCode() unified error code
// $info[1] is the driver specific error code
// $info[2] is the driver specific error string
}
}
}
}
//restore the permissions
function restore() {
//set the variables
$db = $this->db;
//delete the group permisisons
$this->delete();
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x=0;
foreach ($config_list as &$config_path) {
include($config_path);
$x++;
}
//restore default permissions
foreach($apps as $row) {
foreach ($row['permissions'] as $permission) {
//set the variables
if ($permission['groups']) {
foreach ($permission['groups'] as $group) {
//check group protection
$sql = "select * from v_groups ";
$sql .= "where group_name = '".$group."' ";
$sql .= "and group_protected = 'true'";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset ($prep_statement);
if (count($result) == 0) {
//if the item uuid is not currently in the db then add it
$sql = "select * from v_group_permissions ";
$sql .= "where permission_name = '".$permission['name']."' ";
$sql .= "and group_name = '$group' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset ($prep_statement);
if (count($result) == 0) {
//insert the default permissions into the database
$sql = "insert into v_group_permissions ";
$sql .= "(";
$sql .= "group_permission_uuid, ";
$sql .= "permission_name, ";
$sql .= "group_name ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".uuid()."', ";
$sql .= "'".$permission['name']."', ";
$sql .= "'".$group."' ";
$sql .= ");";
$db->exec(check_sql($sql));
unset($sql);
} // if count
} // if prepared statement
} // if count
} // if prepared statement
} // foreach group permission
} // if permission
} // foreach permission
} // foreach app
} // function
} // class
?>
-376
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";
?>
@@ -103,6 +103,6 @@
//redirect the user
$_SESSION["message"] = $text['message-delete'];
header("Location: index.php");
header("Location: users.php");
?>
+947
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";
?>
+1 -1
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;
?>
+2 -2
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";
+1 -1
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;
}
}
+21 -11
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";
?>
-823
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";
?>