Browse Source

colocar uma parametro para que a busca na função ExisteRegistro seja todas as organizações ou apenas organizações correspondentes

1.9-pjsip
bruno 1 month ago
parent
commit
40db6cf100
  1. 4
      include/util/funcoesApl.php
  2. 4
      seguranca/usuarioCad.php

4
include/util/funcoesApl.php

@ -3040,13 +3040,13 @@ function RegistroInc($db, $query) {
return $dados[0];
}
function ExisteRegistro($db, $table, $where, $id, $queryParam = null) {
function ExisteRegistro($db, $table, $where, $id, $queryParam = null, $all_org_id = False) {
$org_id = GetOrganizacao();
$compl = "";
$join = "";
if ($table == 'pbx_usuarios') {
$join = "a INNER JOIN pbx_organizacao_usuarios b ON b.id_usuario = a.id ";
$compl = ($where == "email" ? " " : " id_organizacao = $org_id AND");
$compl = ($all_org_id == true ? " " : " id_organizacao = $org_id AND");
}
$query = "SELECT count(*) FROM $table $join WHERE $compl $where = '$id' ";

4
seguranca/usuarioCad.php

@ -52,11 +52,11 @@ if (isset($_GET["idUser"]) && $_GET["idUser"] == 0) {
$msg = "alert('Informe a senha');";
} else if (($_POST["btGravar"] != "Alterar") && ExisteRegistro($dbcon, "pbx_usuarios", "apelido", (strtolower($_POST["userLogin"])))) {
$msg = "alert('Login já cadastrado!');";
} else if (($_POST["btGravar"] != "Alterar") && ExisteRegistro($dbcon, "pbx_usuarios", "matricula", ($_POST["userMatriculaH"]))) {
} else if (($_POST["btGravar"] != "Alterar") && ExisteRegistro($dbcon, "pbx_usuarios", "matricula", ($_POST["userMatriculaH"]), null, true)) {
$msg = "alert('Matrícula já cadastrada!');";
} else if ($_POST["userEmail"] && !is_email($_POST["userEmail"])) {
$msg = "alert('Email Inválido!');";
} else if (ExisteRegistro($dbcon, "pbx_usuarios", "email", (strtolower($_POST["userEmail"])), ($idUser ? "a.id <> {$idUser}" : ''))) {
} else if (ExisteRegistro($dbcon, "pbx_usuarios", "email", (strtolower($_POST["userEmail"])), ($idUser ? "a.id <> {$idUser}" : ''), true)) {
$msg = "alert('O e-mail informado já foi registrado!');";
} else if ($_POST["userExpiraSenha"] < 0) {
$msg = "alert('O tempo de expiração deve ser maior ou igual 0 'zero');";

Loading…
Cancel
Save