From 4b174a29b07eb1e9c95307252de0767dd0b2f064 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 30 Jan 2013 13:53:02 +0000 Subject: [PATCH] 2013-01-30 Miguel de Dios * godmode/agentes/planned_downtime.list.php, include/db/oracle.php, include/Image/image_functions.php, operation/events/events.build_table.php, operation/messages/message_edit.php, operation/users/user_edit.php, operation/tree.php: improved the source style. * include/constants.php: added constants for the subtype of modules. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7550 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 10 +++ .../godmode/agentes/planned_downtime.list.php | 2 +- .../include/Image/image_functions.php | 4 +- pandora_console/include/constants.php | 9 ++- pandora_console/include/db/oracle.php | 75 ++++++++++--------- .../operation/events/events.build_table.php | 2 +- .../operation/messages/message_edit.php | 6 +- pandora_console/operation/tree.php | 19 +++-- pandora_console/operation/users/user_edit.php | 23 +++--- 9 files changed, 85 insertions(+), 65 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index fa1fabd275..15e321551d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2013-01-30 Miguel de Dios + + * godmode/agentes/planned_downtime.list.php, include/db/oracle.php, + include/Image/image_functions.php, + operation/events/events.build_table.php, + operation/messages/message_edit.php, operation/users/user_edit.php, + operation/tree.php: improved the source style. + + * include/constants.php: added constants for the subtype of modules. + 2013-01-30 Sergio Martin * godmode/events/event_responses.editor.php: Little fix diff --git a/pandora_console/godmode/agentes/planned_downtime.list.php b/pandora_console/godmode/agentes/planned_downtime.list.php index 5e65c9e8d9..f1a5d50c2f 100755 --- a/pandora_console/godmode/agentes/planned_downtime.list.php +++ b/pandora_console/godmode/agentes/planned_downtime.list.php @@ -153,7 +153,7 @@ else { $data[5] .= " "; } $data[5] .= " (" . $downtime['periodically_time_from']; - $data[5] .= "-" . $downtime['periodically_time_to'] . ")"; + $data[5] .= "-" . $downtime['periodically_time_to'] . ")"; break; case 'monthly': $data[5] = __('Monthly:'); diff --git a/pandora_console/include/Image/image_functions.php b/pandora_console/include/Image/image_functions.php index d7b9afbd61..8974fa6d41 100644 --- a/pandora_console/include/Image/image_functions.php +++ b/pandora_console/include/Image/image_functions.php @@ -1,7 +1,7 @@ +/* Id Module (more use in component)*/ +define ('MODULE_WMI', 6); +define ('MODULE_NETWORK', 2); +define ('MODULE_PLUGIN', 4); +define ('MODULE_WEB', 7); +?> \ No newline at end of file diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index 7929a33519..2d2c47fab4 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -590,14 +590,14 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi } if ($i == $max) { $query .= ' ) '; - } + } $i++; continue; } else if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; - + if ($i < $max) { $query .= ' '.$join.' '; } @@ -621,12 +621,12 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi $query .= sprintf ("%s IN ('%s')", $field, implode ("', '", $value)); } else { - if ($value[0] == ">"){ + if ($value[0] == ">") { $value = substr($value,1,strlen($value)-1); $query .= sprintf ("%s > '%s'", $field, $value); } - else if ($value[0] == "<"){ - if ($value[1] == ">"){ + else if ($value[0] == "<") { + if ($value[1] == ">") { $value = substr($value,2,strlen($value)-2); $query .= sprintf ("%s <> '%s'", $field, $value); } @@ -707,11 +707,11 @@ function oracle_db_format_array_where_clause_sql ($values, $join = 'AND', $prefi **/ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { $fields = array (); - + if (! is_array ($values) || empty($sql)) { return ''; } - + $query = ''; $limit = ''; $offset = ''; @@ -736,7 +736,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { else if (isset ($values['offset'])) { unset ($values['offset']); } - + if (isset ($values['order'])) { if (is_array($values['order'])) { if (!isset($values['order']['order'])) { @@ -755,19 +755,19 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { } unset ($values['order']); } - + if (isset ($values['group'])) { $group = sprintf (' GROUP BY %s', $values['group']); unset ($values['group']); } - + $i = 1; $max = count ($values); foreach ($values as $field => $value) { if ($i == 1) { $query .= ' ( '; } - + if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; @@ -778,7 +778,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { $i++; continue; } - + if (is_null ($value)) { $query .= sprintf ("%s IS NULL", $field); } @@ -867,10 +867,10 @@ function oracle_db_get_value_sql($sql, $dbconnection = false) { function oracle_db_get_row_sql ($sql, $search_history_db = false) { $sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2"; $result = oracle_db_get_all_rows_sql($sql, $search_history_db); - + if($result === false) return false; - + return $result[0]; } @@ -904,11 +904,11 @@ function oracle_db_get_row_filter ($table, $filter, $fields = false, $where_join } else { if (is_array ($fields)) - $fields = implode (',', $fields); + $fields = implode (',', $fields); else if (! is_string ($fields)) - return false; + return false; } - + if (is_array ($filter)) $filter = db_format_array_where_clause_sql ($filter, $where_join, ' WHERE '); else if (is_string ($filter)) @@ -917,7 +917,7 @@ function oracle_db_get_row_filter ($table, $filter, $fields = false, $where_join $filter = ''; $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); - + return db_get_row_sql ($sql); } @@ -956,7 +956,7 @@ function oracle_db_get_all_rows_filter ($table, $filter = array(), $fields = fal elseif (!is_string($fields)) { return false; } - + //TODO: Validate and clean filter options if (is_array ($filter)) { $filter = db_format_array_where_clause_sql ($filter, $where_join, ' WHERE '); @@ -967,9 +967,9 @@ function oracle_db_get_all_rows_filter ($table, $filter = array(), $fields = fal else { $filter = ''; } - + $sql = sprintf ('SELECT %s FROM %s %s', $fields, $table, $filter); - + if ($returnSQL) return $sql; else @@ -984,7 +984,7 @@ function oracle_db_get_all_rows_filter ($table, $filter = array(), $fields = fal */ function oracle_db_get_num_rows ($sql) { global $config; - + $type = explode(' ',strtoupper(trim($sql))); if ($type[0] == 'SELECT'){ $sql = "SELECT count(*) as NUM FROM (" . $sql . ")"; @@ -1000,7 +1000,7 @@ function oracle_db_get_num_rows ($sql) { } oci_free_statement($query); - + return $rows; } @@ -1024,10 +1024,10 @@ function oracle_db_get_all_rows_field_filter ($table, $field, $condition, $order else { $sql = sprintf ("SELECT * FROM %s WHERE %s = '%s'", $table, $field, $condition); } - + if ($order_field != "") $sql .= sprintf (" ORDER BY %s", $order_field); - + return db_get_all_rows_sql ($sql); } @@ -1045,10 +1045,10 @@ function oracle_db_get_all_fields_in_table ($table, $field = '', $condition = '' if ($condition != '') { $sql .= sprintf (" WHERE %s = '%s'", $field, $condition); } - + if ($order_field != "") $sql .= sprintf (" ORDER BY %s", $order_field); - + return db_get_all_rows_sql ($sql); } @@ -1077,7 +1077,7 @@ function oracle_db_get_all_fields_in_table ($table, $field = '', $condition = '' */ function oracle_db_format_array_to_update_sql ($values) { $fields = array (); - + foreach ($values as $field => $value) { if (is_numeric($field)) { array_push ($fields, $value); @@ -1086,7 +1086,7 @@ function oracle_db_format_array_to_update_sql ($values) { else if ($field[0] == "`") { $field = str_replace('`', '', $field); } - + if ($value === NULL) { $sql = sprintf ("%s = NULL", $field); } @@ -1110,7 +1110,7 @@ function oracle_db_format_array_to_update_sql ($values) { } array_push ($fields, $sql); } - + return implode (", ", $fields); } @@ -1142,7 +1142,7 @@ function oracle_db_process_sql_update($table, $values, $where = false, $where_jo $query = sprintf ("UPDATE %s SET %s", $table, db_format_array_to_update_sql ($values)); - + if ($where) { if (is_string ($where)) { // No clean, the caller should make sure all input is clean, this is a raw function @@ -1188,9 +1188,9 @@ function oracle_db_process_sql_delete($table, $where, $where_join = 'AND') { if (empty ($where)) /* Should avoid any mistake that lead to deleting all data */ return false; - + $query = sprintf ("DELETE FROM %s WHERE ", $table); - + if ($where) { if (is_string ($where)) { /* FIXME: Should we clean the string for sanity? @@ -1201,7 +1201,7 @@ function oracle_db_process_sql_delete($table, $where, $where_join = 'AND') { $query .= db_format_array_where_clause_sql ($where, $where_join); } } - + return db_process_sql ($query); } @@ -1209,9 +1209,9 @@ function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND') if (empty ($where)) /* Should avoid any mistake that lead to deleting all data */ return false; - + $query = sprintf ("DELETE FROM %s WHERE ", $table); - + if ($where) { if (is_string ($where)) { /* FIXME: Should we clean the string for sanity? @@ -1222,8 +1222,9 @@ function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND') $query .= db_format_array_where_clause_sql ($where, $where_join); } } - + $result = ''; + return db_process_sql ($query, "affected_rows", '', true, $result, false); } diff --git a/pandora_console/operation/events/events.build_table.php b/pandora_console/operation/events/events.build_table.php index 2128fb7a4c..2f606a71b3 100644 --- a/pandora_console/operation/events/events.build_table.php +++ b/pandora_console/operation/events/events.build_table.php @@ -289,7 +289,7 @@ foreach ($result as $event) { $data[$i] = ''; $data[$i] .= $event["agent_name"]; $data[$i] .= ""; - } + } else { $data[$i] .= ui_print_agent_name ($event["id_agente"], true); } diff --git a/pandora_console/operation/messages/message_edit.php b/pandora_console/operation/messages/message_edit.php index 84412e7970..d0487ea7e0 100644 --- a/pandora_console/operation/messages/message_edit.php +++ b/pandora_console/operation/messages/message_edit.php @@ -82,8 +82,8 @@ if ($read_message) { $table->data[2][0] = __('Subject'); $table->data[2][1] = html_print_input_text_extended ("subject", $message["subject"], 'text-subject', '', 50, 70, true, false, '', 'readonly'); - - $order = array("\r\n", "\n", "\r"); + + $order = array("\r\n", "\n", "\r"); $replace = '
'; $parsed_message = str_replace($order, $replace, $message["mensaje"]); @@ -124,7 +124,7 @@ if ($read_message) { // Create message (destination user) if (($new_msg) && (!empty ($dst_user)) && (!$reply)) { $return = messages_create_message ($config["id_user"], $dst_user, $subject, $message); - + $user_name = get_user_fullname ($dst_user); if (!$user_name) { $user_name = $dst_user; diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index ad2a73e1d7..1461bcebf8 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -561,8 +561,8 @@ if (! defined ('METACONSOLE')) { $img_style = array ("class" => "top", "width" => 16); $activeTab = get_parameter('tab','group'); $group_tab = array('text' => "" - . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", - 'active' => $activeTab == "group"); + . html_print_image ("images/group.png", true, array ("title" => __('Groups'))) . "", + 'active' => $activeTab == "group"); $tags_tab = array('text' => "" . html_print_image ("images/tag_red.png", true, array ("title" => __('Tags'))) . "", 'active' => $activeTab == "tag"); $subsections = array('group' => $group_tab, 'tag' => $tags_tab); @@ -586,7 +586,8 @@ if(tags_has_user_acl_tags()) { echo "
"; if (! defined ('METACONSOLE')) { echo '