Ejemplo n.º 1
0
function get_credentials($idalm_user)
{
    //Recorro Arreglo de tablas para chequear permisos
    $alm_user = new alm_userTable();
    $alm_user->readEnv();
    $alm_table = new alm_tableTable();
    $alm_table->readEnv();
    $alm_table_data = $alm_table->readData();
    $alm_user_record = $alm_user->readRecord($idalm_user);
    $alm_tables = "/^(alm_table|alm_user|alm_access|alm_role|alm_column)\$/";
    if ($alm_table_data) {
        foreach ($alm_table_data as $table) {
            switch ($alm_user_record['idalm_role']) {
                case '':
                    // Si no hay role por defecto, revisar personalizacion
                    $alm_access = new alm_accessTable();
                    $credentials = $alm_access->readDataFilter("alm_access.idalm_user='******' AND alm_access.idalm_table='" . $table['idalm_table'] . "' AND alm_access.idalm_role!='deny'");
                    if (is_array($credentials)) {
                        $arrayCredentials[$table['idalm_table']] = $credentials[0]['idalm_role'];
                    }
                    break;
                case 'full':
                    // total
                    $arrayCredentials[$table['idalm_table']] = 'full';
                    break;
                case 'edit':
                    // edicion
                    if (!preg_match($alm_tables, $table['idalm_table'])) {
                        $arrayCredentials[$table['idalm_table']] = 'edit';
                    }
                    break;
                case 'delete':
                    // Correccion, solo borrar
                    if (!preg_match($alm_tables, $table['idalm_table'])) {
                        $arrayCredentials[$table['idalm_table']] = 'delete';
                    }
                    break;
                case 'read':
                    // Guest, read-only...
                    if (!preg_match($alm_tables, $table['idalm_table'])) {
                        $arrayCredentials[$table['idalm_table']] = 'read';
                    }
                    break;
                case 'deny':
                    // No access
                    # Nothing to do...
                    break;
            }
        }
    }
    return $arrayCredentials;
}
Ejemplo n.º 2
0
 if ($type == 'pgsql') {
     $sqlcmd = "SELECT relname FROM pg_class WHERE  pg_class.relkind = 'r' AND pg_class.relname LIKE 'alm_%'";
 } elseif ($type == 'mysql') {
     $sqlcmd = "SHOW TABLES LIKE 'alm_%'";
 }
 $var = $data->getList($sqlcmd);
 if (count($var) >= 5) {
     $output .= '<br/>Tablas de almidon ya existen. Re-generando solo meta-datos.<br/>';
     $data->execSql("DELETE FROM alm_access");
     $data->execSql("DELETE FROM alm_column");
     $data->execSql("DELETE FROM alm_table");
 } else {
     $data->execSql($alm_sqlcmd);
     $output = "BD Almidonizada!<br/>Codigo SQL aplicado:<br/><pre>{$alm_sqlcmd}</pre><br/>";
 }
 $alm_table = new alm_tableTable();
 $alm_column = new alm_columnTable();
 # Nota: no hay soporte para TableDoubleKey yet...
 $rank = 1;
 $output .= "Re-generando: ";
 foreach ($tables as $key) {
     $keyTable = $key . 'Table';
     $data = new $keyTable();
     $alm_column->execSql("DELETE FROM alm_column WHERE idalm_table='{$key}'");
     $alm_table->deleteRecord($key);
     $alm_table->request['idalm_table'] = $key;
     $alm_table->request['pkey'] = $data->key;
     $alm_table->request['alm_table'] = $data->title;
     $alm_table->request['orden'] = $data->order;
     $alm_table->request['rank'] = $rank;
     if (isset($data->hidden)) {
Ejemplo n.º 3
0
<?php

$alm_table = new alm_tableTable();
$alm_column = new alm_columnTable();
$table_data = $alm_table->readData();
if (!isset($output)) {
    $output = '';
}
foreach ($table_data as $table_datum) {
    $output .= "class " . $table_datum['idalm_table'] . "Table extends Table {\n";
    $output .= "  function " . $table_datum['idalm_table'] . "Table() {\n";
    $output .= "    \$this->Table('" . $table_datum['idalm_table'] . "');\n";
    $hidden = $table_datum['hidden'] == 't' ? 'true' : 'false';
    if ($hidden === 'true') {
        $output .= "    \$this->hidden = " . $hidden . ";\n";
    }
    if (!empty($table_datum['parent'])) {
        $output .= "    \$this->parent ='" . $table_datum['parent'] . "';\n";
    }
    if (!empty($table_datum['child'])) {
        $output .= "    \$this->child ='" . $table_datum['child'] . "';\n";
    }
    if (!empty($table_datum['restrictby'])) {
        $output .= "    if (\$_SESSION['idalm_role'] !== 'full') \$this->filter = \"" . $table_datum['idalm_table'] . '.' . $table_datum['restrictby'] . "='\".\$_SESSION['idalm_user'].\"'\";\n";
    }
    $output .= "    \$this->title ='" . $table_datum['alm_table'] . "';\n";
    if (!empty($table_datum['orden'])) {
        $output .= "    \$this->order ='" . $table_datum['orden'] . "';\n";
    }
    $data = $alm_column->readDataFilter("alm_column.idalm_table='" . $table_datum['idalm_table'] . "'");
    if ($data) {