2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
* godmode/menu.php, include/db/oracle.php, include/db/mysql.php, include/functions_categories.php, include/functions_db.php, include/functions_menu.php: improved the code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7544 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6af7ae4956
commit
b3184d23af
|
@ -1,3 +1,9 @@
|
||||||
|
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* godmode/menu.php, include/db/oracle.php, include/db/mysql.php,
|
||||||
|
include/functions_categories.php, include/functions_db.php,
|
||||||
|
include/functions_menu.php: improved the code style.
|
||||||
|
|
||||||
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
|
2013-01-29 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* godmode/reporting/visual_console_builder.wizard.php,
|
* godmode/reporting/visual_console_builder.wizard.php,
|
||||||
|
|
|
@ -266,7 +266,7 @@ if (check_acl ($config['id_user'], 0, "PM")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if was displayed inside other menu
|
//Check if was displayed inside other menu
|
||||||
if ($extension['godmode_menu']["fatherId"] == '') {
|
if ($extension['godmode_menu']["fatherId"] == '') {
|
||||||
$sub[$extmenu["sec2"]]["text"] = $extmenu["name"];
|
$sub[$extmenu["sec2"]]["text"] = $extmenu["name"];
|
||||||
$sub[$extmenu["sec2"]]["refr"] = 0;
|
$sub[$extmenu["sec2"]]["refr"] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ function mysql_db_get_row ($table, $field_search, $condition, $fields = false) {
|
||||||
$fields, $table, $field_search, $condition);
|
$fields, $table, $field_search, $condition);
|
||||||
}
|
}
|
||||||
$result = db_get_all_rows_sql ($sql);
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -179,9 +179,11 @@ function mysql_db_get_row ($table, $field_search, $condition, $fields = false) {
|
||||||
*/
|
*/
|
||||||
function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
|
function mysql_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
|
||||||
if ($order_field != "") {
|
if ($order_field != "") {
|
||||||
return db_get_all_rows_sql ("SELECT * FROM `".$table."` ORDER BY ".$order_field . " " . $order);
|
return db_get_all_rows_sql ("SELECT *
|
||||||
|
FROM `".$table."`
|
||||||
|
ORDER BY ".$order_field . " " . $order);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return db_get_all_rows_sql ("SELECT * FROM `".$table."`");
|
return db_get_all_rows_sql ("SELECT * FROM `".$table."`");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +207,7 @@ function mysql_db_process_sql_insert($table, $values) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = (array) $values;
|
$values = (array) $values;
|
||||||
|
|
||||||
$query = sprintf ("INSERT INTO `%s` ", $table);
|
$query = sprintf ("INSERT INTO `%s` ", $table);
|
||||||
$fields = array ();
|
$fields = array ();
|
||||||
$values_str = '';
|
$values_str = '';
|
||||||
|
@ -570,7 +572,7 @@ function mysql_db_format_array_where_clause_sql ($values, $join = 'AND', $prefix
|
||||||
* @return the first value of the first row of a table result from query.
|
* @return the first value of the first row of a table result from query.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function mysql_db_get_value_sql($sql, $dbconnection = false) {
|
function mysql_db_get_value_sql($sql, $dbconnection = false) {
|
||||||
$sql .= " LIMIT 1";
|
$sql .= " LIMIT 1";
|
||||||
$result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection);
|
$result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection);
|
||||||
|
|
||||||
|
|
|
@ -212,10 +212,10 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
global $sql_cache;
|
global $sql_cache;
|
||||||
|
|
||||||
$retval = array();
|
$retval = array();
|
||||||
|
|
||||||
if ($sql == '')
|
if ($sql == '')
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ($cache && ! empty ($sql_cache[$sql])) {
|
if ($cache && ! empty ($sql_cache[$sql])) {
|
||||||
$retval = $sql_cache[$sql];
|
$retval = $sql_cache[$sql];
|
||||||
$sql_cache['saved']++;
|
$sql_cache['saved']++;
|
||||||
|
@ -226,19 +226,19 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
$parse_query = explode(' ',trim(preg_replace('/\s\s+/',' ',$sql)));
|
$parse_query = explode(' ',trim(preg_replace('/\s\s+/',' ',$sql)));
|
||||||
$table_name = preg_replace('/\((\w*|,\w*)*\)|\(\w*|,\w*/','',preg_replace('/\s/','',$parse_query[2]));
|
$table_name = preg_replace('/\((\w*|,\w*)*\)|\(\w*|,\w*/','',preg_replace('/\s/','',$parse_query[2]));
|
||||||
$type = explode(' ',strtoupper(trim($sql)));
|
$type = explode(' ',strtoupper(trim($sql)));
|
||||||
|
|
||||||
$start = microtime (true);
|
$start = microtime (true);
|
||||||
if ($dbconnection !== '') {
|
if ($dbconnection !== '') {
|
||||||
if ($type[0] == 'INSERT'){
|
if ($type[0] == 'INSERT') {
|
||||||
$query = oci_parse($dbconnection, 'begin insert_id(:table_name, :sql, :out); end;');
|
$query = oci_parse($dbconnection, 'begin insert_id(:table_name, :sql, :out); end;');
|
||||||
}
|
}
|
||||||
// Prevent execution of insert_id stored procedure
|
// Prevent execution of insert_id stored procedure
|
||||||
else if ($type[0] == '/INSERT'){
|
else if ($type[0] == '/INSERT') {
|
||||||
$query = oci_parse($dbconnection, substr($sql,1));
|
$query = oci_parse($dbconnection, substr($sql,1));
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$query = oci_parse($dbconnection, $sql);
|
$query = oci_parse($dbconnection, $sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($type[0] == 'INSERT'){
|
if ($type[0] == 'INSERT'){
|
||||||
|
@ -258,15 +258,15 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
oci_bind_by_name($query,":sql", $sql, 1000);
|
oci_bind_by_name($query,":sql", $sql, 1000);
|
||||||
oci_bind_by_name($query,":out", $id, 32);
|
oci_bind_by_name($query,":out", $id, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$autocommit){
|
if (!$autocommit) {
|
||||||
$result = oci_execute($query, OCI_NO_AUTO_COMMIT);
|
$result = oci_execute($query, OCI_NO_AUTO_COMMIT);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$result = oci_execute($query);
|
$result = oci_execute($query);
|
||||||
}
|
}
|
||||||
$time = microtime (true) - $start;
|
$time = microtime (true) - $start;
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$backtrace = debug_backtrace ();
|
$backtrace = debug_backtrace ();
|
||||||
$e = oci_error($query);
|
$e = oci_error($query);
|
||||||
|
@ -295,8 +295,8 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
$result = $rows;
|
$result = $rows;
|
||||||
}
|
}
|
||||||
db_add_database_debug_trace ($sql, $result, $rows,
|
db_add_database_debug_trace ($sql, $result, $rows,
|
||||||
array ('time' => $time));
|
array ('time' => $time));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else { //The query IS a select.
|
else { //The query IS a select.
|
||||||
|
@ -304,7 +304,7 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
while ($row = oci_fetch_assoc($query)) {
|
while ($row = oci_fetch_assoc($query)) {
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$result_temp = array();
|
$result_temp = array();
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$column_type = oci_field_type($query, $key);
|
$column_type = oci_field_type($query, $key);
|
||||||
// Support for Clob fields larger than 4000bytes
|
// Support for Clob fields larger than 4000bytes
|
||||||
//if ($sql == 'SELECT * FROM tgrupo ORDER BY dbms_lob.substr(nombre,4000,1) ASC') echo $i .' '.$column_type.' '.$key.'<br>';
|
//if ($sql == 'SELECT * FROM tgrupo ORDER BY dbms_lob.substr(nombre,4000,1) ASC') echo $i .' '.$column_type.' '.$key.'<br>';
|
||||||
|
@ -319,7 +319,7 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
else {
|
else {
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result_temp[strtolower($key)] = $value;
|
$result_temp[strtolower($key)] = $value;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ function oracle_db_process_sql($sql, $rettype = "affected_rows", $dbconnection =
|
||||||
*/
|
*/
|
||||||
function oracle_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
|
function oracle_db_get_all_rows_in_table($table, $order_field = "", $order = 'ASC') {
|
||||||
if ($order_field != "") {
|
if ($order_field != "") {
|
||||||
|
|
||||||
// Clob fields are not allowed in ORDER BY statements, they need cast to varchar2 datatype
|
// Clob fields are not allowed in ORDER BY statements, they need cast to varchar2 datatype
|
||||||
$type = db_get_value_filter ('data_type', 'user_tab_columns', array ('table_name' => strtoupper($table), 'column_name' => strtoupper($order_field)), 'AND');
|
$type = db_get_value_filter ('data_type', 'user_tab_columns', array ('table_name' => strtoupper($table), 'column_name' => strtoupper($order_field)), 'AND');
|
||||||
if ($type == 'CLOB') {
|
if ($type == 'CLOB') {
|
||||||
|
@ -363,7 +363,7 @@ function oracle_db_get_all_rows_in_table($table, $order_field = "", $order = 'AS
|
||||||
return db_get_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY ' . $order_field . ' ' . $order);
|
return db_get_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY ' . $order_field . ' ' . $order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return db_get_all_rows_sql ('SELECT * FROM ' . $table);
|
return db_get_all_rows_sql ('SELECT * FROM ' . $table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -387,13 +387,13 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$values = (array) $values;
|
$values = (array) $values;
|
||||||
|
|
||||||
$query = sprintf ('INSERT INTO %s ', $table);
|
$query = sprintf ('INSERT INTO %s ', $table);
|
||||||
$fields = array ();
|
$fields = array ();
|
||||||
$values_str = '';
|
$values_str = '';
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$max = count ($values);
|
$max = count ($values);
|
||||||
foreach ($values as $field => $value) {
|
foreach ($values as $field => $value) {
|
||||||
array_push ($fields, $field);
|
array_push ($fields, $field);
|
||||||
|
|
||||||
if (is_null ($value)) {
|
if (is_null ($value)) {
|
||||||
|
@ -422,7 +422,7 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) {
|
||||||
|
|
||||||
$query .= ' VALUES (' . $values_str . ')';
|
$query .= ' VALUES (' . $values_str . ')';
|
||||||
$status = '';
|
$status = '';
|
||||||
|
|
||||||
return db_process_sql($query, 'insert_id', '', true, $status, $autocommit);
|
return db_process_sql($query, 'insert_id', '', true, $status, $autocommit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,7 +813,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
|
||||||
$query .= sprintf ("%s = '%s'", $field, $value);
|
$query .= sprintf ("%s = '%s'", $field, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($i < $max) {
|
if ($i < $max) {
|
||||||
$query .= ' '.$join.' ';
|
$query .= ' '.$join.' ';
|
||||||
}
|
}
|
||||||
|
@ -822,16 +822,16 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $pre_query.$sql.$query.$limit.$group.$order.$post_query;
|
$result = $pre_query.$sql.$query.$limit.$group.$order.$post_query;
|
||||||
if ($return){
|
if ($return) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$result = oracle_db_process_sql($result);
|
$result = oracle_db_process_sql($result);
|
||||||
if ($result !== false){
|
if ($result !== false) {
|
||||||
for ($i=0; $i < count($result); $i++) {
|
for ($i=0; $i < count($result); $i++) {
|
||||||
unset($result[$i]['RNUM']);
|
unset($result[$i]['RNUM']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -846,13 +846,13 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
|
||||||
* @return the first value of the first row of a table result from query.
|
* @return the first value of the first row of a table result from query.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function oracle_db_get_value_sql($sql, $dbconnection = false) {
|
function oracle_db_get_value_sql($sql, $dbconnection = false) {
|
||||||
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
|
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
|
||||||
$result = oracle_db_get_all_rows_sql ($sql, false, true, $dbconnection);
|
$result = oracle_db_get_all_rows_sql ($sql, false, true, $dbconnection);
|
||||||
|
|
||||||
if($result === false)
|
if($result === false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
foreach ($result[0] as $f)
|
foreach ($result[0] as $f)
|
||||||
return $f;
|
return $f;
|
||||||
}
|
}
|
||||||
|
@ -1240,37 +1240,37 @@ function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND')
|
||||||
*/
|
*/
|
||||||
function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($new == true){
|
if ($new == true){
|
||||||
$result = oci_parse($config['dbconnection'], $sql);
|
$result = oci_parse($config['dbconnection'], $sql);
|
||||||
oci_execute($result);
|
oci_execute($result);
|
||||||
}
|
}
|
||||||
$row = oci_fetch_assoc($result);
|
$row = oci_fetch_assoc($result);
|
||||||
|
|
||||||
$result_temp = array();
|
$result_temp = array();
|
||||||
if ($row) {
|
if ($row) {
|
||||||
foreach ($row as $key => $value){
|
foreach ($row as $key => $value){
|
||||||
$column_type = oci_field_type($result, $key);
|
$column_type = oci_field_type($result, $key);
|
||||||
// Support for Clob field larger than 4000bytes
|
// Support for Clob field larger than 4000bytes
|
||||||
if ($column_type == 'CLOB') {
|
if ($column_type == 'CLOB') {
|
||||||
$column_name = oci_field_name($result, $key);
|
$column_name = oci_field_name($result, $key);
|
||||||
$column_name = oci_field_name($result, $key);
|
$column_name = oci_field_name($result, $key);
|
||||||
// protect against a NULL CLOB
|
// protect against a NULL CLOB
|
||||||
if (is_object($row[$column_name])) {
|
if (is_object($row[$column_name])) {
|
||||||
$clob_data = $row[$column_name]->load();
|
$clob_data = $row[$column_name]->load();
|
||||||
$row[$column_name]->free();
|
$row[$column_name]->free();
|
||||||
$value = $clob_data;
|
$value = $clob_data;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$value = '';
|
$value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result_temp[strtolower($key)] = $value;
|
$result_temp[strtolower($key)] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$row){
|
if (!$row){
|
||||||
oci_free_statement($result);
|
oci_free_statement($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return $row;
|
// return $row;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
*
|
*
|
||||||
* @return bool True or false if something goes wrong.
|
* @return bool True or false if something goes wrong.
|
||||||
*/
|
*/
|
||||||
function categories_delete_category ($id_category){
|
function categories_delete_category ($id_category) {
|
||||||
// Change the elements of this category to "without category"
|
// Change the elements of this category to "without category"
|
||||||
db_process_sql_update('tagente_modulo', array('id_category' => 0), array('id_category' => $id_category));
|
db_process_sql_update('tagente_modulo', array('id_category' => 0), array('id_category' => $id_category));
|
||||||
db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category));
|
db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category));
|
||||||
|
@ -44,7 +44,7 @@ function categories_delete_category ($id_category){
|
||||||
*
|
*
|
||||||
* @return mixed Int with the tag's count.
|
* @return mixed Int with the tag's count.
|
||||||
*/
|
*/
|
||||||
function categories_get_category_count(){
|
function categories_get_category_count() {
|
||||||
return (int)db_get_value('count(*)', 'tcategory');
|
return (int)db_get_value('count(*)', 'tcategory');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ function db_pandora_audit($accion, $descripcion, $user_id = false, $ip = false,
|
||||||
$accion = io_safe_input($accion);
|
$accion = io_safe_input($accion);
|
||||||
$descripcion = io_safe_input($descripcion);
|
$descripcion = io_safe_input($descripcion);
|
||||||
|
|
||||||
switch ($config['dbtype']){
|
switch ($config['dbtype']) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
$values = array('id_usuario' => $id,
|
$values = array('id_usuario' => $id,
|
||||||
|
|
|
@ -507,7 +507,7 @@ function menu_get_sec_pages($sec,$menu_hash = false) {
|
||||||
*
|
*
|
||||||
* @return true if the page is in section, false otherwise
|
* @return true if the page is in section, false otherwise
|
||||||
*/
|
*/
|
||||||
function menu_sec2_in_sec($sec,$sec2) {
|
function menu_sec2_in_sec($sec,$sec2) {
|
||||||
$sec2_array = menu_get_sec_pages($sec);
|
$sec2_array = menu_get_sec_pages($sec);
|
||||||
|
|
||||||
// If this value has various parameters, we only get the first
|
// If this value has various parameters, we only get the first
|
||||||
|
|
Loading…
Reference in New Issue