コード例 #1
0
function gravarPermissoes()
{
    include '../dao/ConnectionHolder.php';
    $idUsuario = $_POST["idUsuario"];
    if (!$idUsuario) {
        finalize("idUsuario não fornecido!");
    }
    $idList = $_POST["list"];
    if (!$idList) {
        finalize("Lista de permissões vazia!");
    }
    try {
        $connection = ConnectionHolder::getConnection();
        // PROBLEMA!!
        // O postgres não trabalha com o conceito de transação, commit e rollback,
        // ao invés disso, deve ser enviada uma query, sendo todo o script sql,
        // e será executado todo, ou nada.
        // Fonte: http://stackoverflow.com/questions/9704557/php-pgsql-driver-and-autocommit
        // Apaga as permissoes existentes para o usuário
        $query = "DELETE FROM permissoes WHERE idusuario = " . $idUsuario . "; ";
        // Insere as operações recebidas por POST
        foreach ($idList as $id) {
            $query .= "INSERT INTO permissoes (idoperacaomodulo, idusuario) " . "VALUES (" . $id . ", " . $idUsuario . "); ";
        }
        $resultSet = pg_query($connection, $query);
        if (!$resultSet) {
            finalize("Query error");
        }
        done();
    } catch (Exception $e) {
        finalize("Exception: " . $e->getMessage());
    }
}
コード例 #2
0
function getUsuarioPorId()
{
    include '../dao/Usuarios.php';
    include '../dao/UsuariosDAO.php';
    $usuariosDAO = new UsuariosDAO();
    $idUsuario = $_POST["idUsuario"];
    $usuarios = $usuariosDAO->selectRegistro($idUsuario);
    if (!$usuarios) {
        finalize("Usuário não encontrado!");
    }
    $json['success'] = 1;
    $json['data'] = array("id" => $usuarios->getId(), "login" => $usuarios->getLogin(), "nome" => $usuarios->getNome(), "email" => $usuarios->getEmail(), "ativo" => $usuarios->isAtivo(), "senha" => $usuarios->getSenha());
    echo json_encode($json);
}
コード例 #3
0
ファイル: cadastrocrmAPI.php プロジェクト: RMCampos/Projerp
function getCRMPorId()
{
    include '../dao/Cliforn.php';
    include '../dao/ClifornDAO.php';
    $clifornDAO = new ClifornDAO();
    $id = $_POST["idCRM"];
    $cliforn = $clifornDAO->selectRegistro($id);
    if (!$cliforn) {
        finalize("Cliente/Fornecedor não encontrado!");
    }
    $json['success'] = 1;
    $json['data'] = array("id" => $cliforn->getId(), "tipo" => $cliforn->getTipo(), "nome" => $cliforn->getNome(), "sexo" => $cliforn->getSexo(), "datanascimento" => $cliforn->getDatanascimento(), "cpf" => $cliforn->getCpf(), "rg" => $cliforn->getRg(), "razaosocial" => $cliforn->getRazaosocial(), "fantasia" => $cliforn->getFantasia(), "cnpj" => $cliforn->getCnpj(), "ie" => $cliforn->getIe(), "ativo" => $cliforn->isAtivo());
    echo json_encode($json);
}
コード例 #4
0
ファイル: indexAPI.php プロジェクト: RMCampos/Projerp
function verificarLogin()
{
    include '../dao/Usuarios.php';
    include '../dao/UsuariosDAO.php';
    $login = $_POST["login"];
    $senha = $_POST["senha"];
    $usuariosDAO = new UsuariosDAO();
    $usuarios = $usuariosDAO->selectRegistroPorLogin($login);
    if (!$usuarios) {
        finalize(NULL);
    }
    if (strcmp($usuarios->getSenha(), $senha) != 0) {
        finalize(NULL);
    }
    iniciarSessao($usuarios);
    done();
}
コード例 #5
0
ファイル: setup.php プロジェクト: hatyuki/php-ClassTrigger
function done_testing()
{
    global $t;
    $funcs = get_defined_functions();
    $initialize = false;
    $finalize = false;
    if (in_array('initialize', $funcs['user'])) {
        $initialize = true;
    }
    if (in_array('finalize', $funcs['user'])) {
        $finalize = true;
    }
    if (in_array('build', $funcs['user'])) {
        build($t);
    }
    foreach ($funcs['user'] as $func) {
        # 予約された function
        if (in_array($func, array('build', 'destroy', 'initialize', 'finalize', 'done_testing'))) {
            continue;
        }
        # _function( ) は skip
        if (preg_match('/^_/', $func)) {
            continue;
        }
        if ($initialize) {
            initialize($t);
        }
        try {
            $t->diag("in function '{$func}'");
            $func($t);
        } catch (Exception $e) {
            $t->diag($e->getMessage() . " at {$func}( )");
            $t->fail();
        }
        if ($finalize) {
            finalize($t);
        }
    }
    if (in_array('destroy', $funcs['user'])) {
        destroy($t);
    }
}
コード例 #6
0
ファイル: gerenciarcrmAPI.php プロジェクト: RMCampos/Projerp
function buscarPermissoesCRM()
{
    include '../dao/Operacaomodulos.php';
    include '../dao/OperacaomodulosDAO.php';
    include '../dao/Permissoes.php';
    include '../dao/PermissoesDAO.php';
    $operacaomodulosDAO = new OperacaomodulosDAO();
    $permissoesDAO = new PermissoesDAO();
    // Buscar as operações do módulo id=2 (CRM)
    $operacoesList = $operacaomodulosDAO->selectListaRegistrosPorModulo(1);
    if (!$operacoesList) {
        finalize(NULL);
    }
    $list['success'] = 1;
    $list['data'] = array();
    foreach ($operacoesList as $op) {
        $permissoes = $permissoesDAO->selectRegistro($op->getIdoperacaomodulo(), $_SESSION["id"]);
        if (!$permissoes) {
            continue;
        }
        $list['data'][] = $op->getDescricao();
    }
    echo json_encode($list);
}
コード例 #7
0
ファイル: config.php プロジェクト: dingdong2310/g5_theme
<?php

/* config.js */
$params->PageBgColor = $params->PageBgColor ? $params->PageBgColor : "#d7d7d7";
$slideshow_css = '$CssPath$style.css';
$thumbs = (object) array('margin' => 3, 'padding' => 4);
array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/bullet.png'));
array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/arrows.png'));
array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/play.png'));
array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/pause.png'));
if ($params->ShowTooltips) {
    $params->ThumbWidthHalf = round($params->ThumbWidth / 2);
    array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/triangle-' . $params->TooltipPos . '.png', 'dest' => '$ImgPath$triangle.png'));
    array_push($files, (object) array('src' => 'backgnd/' . $params->TemplateName . '/style-tooltip.css', 'dest' => $slideshow_css, 'filters' => array('params')));
}
// call this function at the end of each template
finalize();
コード例 #8
0
ファイル: baseAPI.php プロジェクト: RMCampos/Projerp
<?php

$json['data'] = array();
if (!isset($_POST) || !isset($_POST["operacao"])) {
    finalize("Access denied!");
}
session_start();
if (isset($_SESSION["id"])) {
    DEFINE("ID_USUARIO", $_SESSION["id"]);
}
function finalize($message)
{
    if (!$message) {
        $message = "No message suplied!";
    }
    $json['success'] = 0;
    $json['message'] = $message;
    echo json_encode($json);
    exit;
}
function done()
{
    $json['success'] = 1;
    $json['data'] = array();
    echo json_encode($json);
    exit;
}
function iniciarSessao($usuarios)
{
    $_SESSION['id'] = $usuarios->getId();
    $_SESSION['login'] = $usuarios->getLogin();