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; }
<?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) {