From 7957ca1e07adaf8c2a545d12a59fd48c84bed3a3 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 3 Nov 2010 17:45:39 +0000 Subject: [PATCH] 2010-11-03 Miguel de Dios * include/functions_html.php: added the function "print_autocomplete_modules". This function is same to magic-select box for agents instead this for modules. * include/javascript/jquery.ui.datepicker.js, include/javascript/jquery.ui.droppable.js: fixed end of lines that it haven't semicolon end char. * include/ajax/module.php: fix version of file that responds to ajax request for the magic-select box for modules. * include/functions_ui.php: in function "format_alert_row" use new call for the "isAlertInPolicy2". * include/functions_db.php: added in function "get_agent_modules" for the parameter $filter, the posibility to search with the "like" mysql operator. * images/lightning_blue.png: blue lighting for new magic-select box agents. * godmode/agentes/configurar_agente.php: cleaned source code style. * godmode/alerts/alert_list.list.php: use new call for the "isAlertInPolicy2". And fixed the column align for policies and actions. * godmode/reporting/reporting_builder.list_items.php: erased old source code lines comments. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3509 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 29 +++++ .../godmode/agentes/configurar_agente.php | 2 +- .../godmode/alerts/alert_list.list.php | 11 +- .../reporting_builder.list_items.php | 9 -- pandora_console/images/lightning_blue.png | Bin 0 -> 628 bytes pandora_console/include/ajax/module.php | 33 +++++ pandora_console/include/functions_db.php | 19 ++- pandora_console/include/functions_html.php | 116 ++++++++++++++++++ pandora_console/include/functions_ui.php | 6 +- .../javascript/jquery.ui.datepicker.js | 2 +- .../include/javascript/jquery.ui.droppable.js | 2 +- 11 files changed, 206 insertions(+), 23 deletions(-) create mode 100644 pandora_console/images/lightning_blue.png create mode 100644 pandora_console/include/ajax/module.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2502d79f05..6b8be99f9d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,32 @@ +2010-11-03 Miguel de Dios + + * include/functions_html.php: added the function + "print_autocomplete_modules". This function is same to magic-select box for + agents instead this for modules. + + * include/javascript/jquery.ui.datepicker.js, + include/javascript/jquery.ui.droppable.js: fixed end of lines that it + haven't semicolon end char. + + * include/ajax/module.php: fix version of file that responds to ajax + request for the magic-select box for modules. + + * include/functions_ui.php: in function "format_alert_row" use new call + for the "isAlertInPolicy2". + + * include/functions_db.php: added in function "get_agent_modules" for the + parameter $filter, the posibility to search with the "like" mysql operator. + + * images/lightning_blue.png: blue lighting for new magic-select box agents. + + * godmode/agentes/configurar_agente.php: cleaned source code style. + + * godmode/alerts/alert_list.list.php: use new call for the + "isAlertInPolicy2". And fixed the column align for policies and actions. + + * godmode/reporting/reporting_builder.list_items.php: erased old source + code lines comments. + 2010-11-03 Sancho Lerena * pandoradb_data.sql: Updated build diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 65315267a7..c616536425 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -721,7 +721,7 @@ if ($create_module) { // MODULE DELETION // ================= -if ($delete_module){ // DELETE agent module ! +if ($delete_module) { // DELETE agent module ! $id_borrar_modulo = (int) get_parameter_get ("delete_module",0); $module_data = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_borrar_modulo); $id_grupo = (int) dame_id_grupo ($id_agente); diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 929f0221e0..9084a902c0 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -334,8 +334,11 @@ $table->valign[6] = 'middle'; $table->valign[7] = 'middle'; $table->valign[8] = 'middle'; $table->align[2] = 'center'; +if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { + $table->align[5] = 'center'; +} $table->align[4] = 'center'; -$table->align[6] = 'center'; +$table->align[6] = 'left'; $table->align[7] = 'center'; $table->align[8] = 'center'; @@ -403,14 +406,14 @@ foreach ($simple_alerts as $alert) { $data[4] .= ""; if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - $policyInfo = isAlertInPolicy($alert['id_agent_module'], $alert['id_alert_template'], false); + $policyInfo = isAlertInPolicy2($alert['id'], false); if ($policyInfo === false) $data[5] = ''; else { $img = 'images/policies.png'; - $data[5] = '' . - print_image($img,true, array('title' => $policyInfo['name_policy'])) . + $data[5] = '' . + print_image($img,true, array('title' => $policyInfo['name'])) . ''; } } diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index eaba75a5e6..3a521436ea 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -216,8 +216,6 @@ foreach ($items as $item) { $row[4] = human_time_description_raw($item['period']); - //. ' ' . __("Type at least two


characters to search") . '
'; - if ($item['description'] == '') { $row[5] = '-'; } @@ -225,13 +223,6 @@ foreach ($items as $item) { $row[5] = printTruncateText($item['description'], 25, true, true); } -// if ($item['id_gs'] == null) { -// $row[5] = '-'; -// } -// else { -// $row[5] = get_db_value_filter('name', 'tgraph', array('id_graph' => $item['id_gs'])); -// } - $row[6] = ''; $row[6] .= ' '; $row[6] .= ''; diff --git a/pandora_console/images/lightning_blue.png b/pandora_console/images/lightning_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..a5bf418d384d5b9238a6072a8aa3f358a9330d7b GIT binary patch literal 628 zcmV-)0*n2LP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igk) z5-2h#faFI200Hz#L_t(I%Z-yiYg9oL#ea8Zvb!%)1ho<3`dAQBD1q(lY^*{cXd?(J z`Uz~TMX>e*1PfcMNF=66XCnx93X0L}#wbzN#EoX(pPhRxqRWy*%`MN&Idks4XT;1n zNX@LYn*eiZ{pBz&!vZ(jAD?WhP60#_rtqlUTCDtdjzhuS8sa}Nu2QGci*D|HF2OutH{aCrk?I14~BSgr5z`dnmdB9 zr4a|1^8|rbmS^8oOW-^(4a^U3LoT=4R}UH4Rd|Lm^0qYk;G5Jarf@W|4 O0000 $filter) + $other_filter)); + + if ($modules === false) $modules = array(); + $modules = array_unique($modules); + + foreach ($modules as $module) { + echo $module . "\n"; + } +} +?> \ No newline at end of file diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 9591112260..6b2fb945fa 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -663,7 +663,8 @@ function get_agent_modules ($id_agent, $details = false, $filter = false, $index if ($where != '') { $where .= ' AND '; - } else { + } + else { $where .= ' WHERE '; } @@ -674,17 +675,27 @@ function get_agent_modules ($id_agent, $details = false, $filter = false, $index if (is_array ($filter)) { $fields = array (); foreach ($filter as $field => $value) { - array_push ($fields, $field.'="'.$value.'"'); + if ($value[0] == '%') { + array_push ($fields, $field.' LIKE "'.$value.'"'); + } + else if (substr($value, -1) == '%') { + array_push ($fields, $field.' LIKE "'.$value.'"'); + } + else { + array_push ($fields, $field.' = "'.$value.'"'); + } } $where .= implode (' AND ', $fields); - } else { + } + else { $where .= $filter; } } if (empty ($details)) { $details = "nombre"; - } else { + } + else { $details = safe_input ($details); } diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 586b2eb6a5..b30025ba3e 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1241,4 +1241,120 @@ function html2rgb($htmlcolor) return false; } } + +/** + * Print a magic-ajax control to select the module. + * + * @param string $name The name of ajax control, by default is "module". + * @param string $default The default value to show in the ajax control. + * @param array $id_agents The array list of id agents as array(1,2,3), by default is false and the function use all agents (if the ACL desactive). + * @param bool $ACL Filter the agents by the ACL list of user. + * @param string $scriptResult The source code of script to call, by default is + * empty. And the example is: + * function (e, data, formatted) { + * ... + * } + * + * And the formatted is the select item as string. + * + * @param array $filter Other filter of modules. + * @param bool $return If it is true return a string with the output instead to echo the output. + * + * @return mixed If the $return is true, return the output as string. + */ +function print_autocomplete_modules($name = 'module', $default = '', $id_agents = false, $ACL = true, $scriptResult = '', $filter = array(), $return = false) { + global $config; + + if ($id_agents === false) { + $groups = array(); + if ($ACL) { + $groups = get_user_groups($config['id_user'], "AW", false); + $groups = array_keys($groups); + + $agents = get_db_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN (' . implode(',', $groups) . ')'); + } + else { + $agents = get_db_all_rows_sql('SELECT id_agente FROM tagente'); + } + + if ($agents === false) $agents = array(); + + $id_agents = array(); + foreach ($agents as $agent) { + $id_agents[] = $agent['id_agente']; + } + } + else { + if ($ACL) { + $groups = get_user_groups($config['id_user'], "AW", false); + $groups = array_keys($groups); + + $agents = get_db_all_rows_sql('SELECT id_agente FROM tagente WHERE id_grupo IN (' . implode(',', $groups) . ')'); + + if ($agents === false) $agents = array(); + + $id_agentsACL = array(); + foreach ($agents as $agent) { + if (array_search($agent['id_agente'], $id_agents) !== false) { + $id_agentsACL[] = $agent['id_agente']; + } + } + + $id_agents = $id_agentsACL; + } + } + + ob_start(); + + require_jquery_file ('autocomplete'); + + ?> + + 'background: url(images/lightning_blue.png) no-repeat right;')); + echo ' ' . __("Type at least two characters to search the module.") . ''; + + $output = ob_get_clean(); + + if ($return) { + return $output; + } + else { + echo $output; + } +} ?> diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 96dc0fc1f9..6e74d2f142 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -431,14 +431,14 @@ function format_alert_row ($alert, $compound = false, $agent = true, $url = '') $data = array (); if (($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) && (!$compound)) { - $policyInfo = isAlertInPolicy($alert['id_agent_module'], $alert['id_alert_template'], false); + $policyInfo = isAlertInPolicy2($alert['id'], false); if ($policyInfo === false) $data[$index['policy']] = ''; else { $img = 'images/policies.png'; - $data[$index['policy']] = '' . - print_image($img,true, array('title' => $policyInfo['name_policy'])) . + $data[$index['policy']] = '' . + print_image($img,true, array('title' => $policyInfo['name'])) . ''; } } diff --git a/pandora_console/include/javascript/jquery.ui.datepicker.js b/pandora_console/include/javascript/jquery.ui.datepicker.js index d650b41c4d..a692541d94 100644 --- a/pandora_console/include/javascript/jquery.ui.datepicker.js +++ b/pandora_console/include/javascript/jquery.ui.datepicker.js @@ -1,2 +1,2 @@ -(function($){function Datepicker(){this.debug=false;this._nextId=0;this._inst=[];this._curInst=null;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this.regional=[];this.regional[""]={clearText:"Clear",clearStatus:"Erase the current date",closeText:"Close",closeStatus:"Close without change",prevText:"<Prev",prevStatus:"Show the previous month",nextText:"Next>",nextStatus:"Show the next month",currentText:"Today",currentStatus:"Show the current month",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],monthStatus:"Show a different month",yearStatus:"Show a different year",weekHeader:"Wk",weekStatus:"Week of the year",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dayStatus:"Set DD as first week day",dateStatus:"Select DD, M d",dateFormat:"yy-mm-dd",firstDay:0,initStatus:"Select a date",isRTL:false};this._defaults={showOn:"focus",showAnim:"show",defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,closeAtTop:true,mandatory:false,hideIfNoPrevNext:false,changeMonth:true,changeYear:true,yearRange:"-10:+10",changeFirstDay:true,showOtherMonths:false,showWeeks:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",showStatus:false,statusForDate:this.dateStatus,minDate:null,maxDate:null,speed:"normal",beforeShowDay:null,beforeShow:null,onSelect:null,onClose:null,numberOfMonths:1,stepMonths:1,rangeSelect:false,rangeSeparator:" - "};$.extend(this._defaults,this.regional[""]);this._datepickerDiv=$('
')}$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",log:function(){if(this.debug){console.log.apply("",arguments)}},_register:function(inst){var id=this._nextId++;this._inst[id]=inst;return id},_getInst:function(id){return this._inst[id]||id},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase();var instSettings=(inlineSettings?$.extend(settings||{},inlineSettings||{}):settings);if(nodeName=="input"){var inst=(inst&&!inlineSettings?inst:new DatepickerInstance(instSettings,false));this._connectDatepicker(target,inst)}else{if(nodeName=="div"||nodeName=="span"){var inst=new DatepickerInstance(instSettings,true);this._inlineDatepicker(target,inst)}}},_destroyDatepicker:function(target){var nodeName=target.nodeName.toLowerCase();var calId=target._calId;target._calId=null;var $target=$(target);if(nodeName=="input"){$target.siblings(".ui-datepicker-append").replaceWith("").end().siblings(".ui-datepicker-trigger").replaceWith("").end().removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress);var wrapper=$target.parents(".ui-datepicker-wrap");if(wrapper){wrapper.replaceWith(wrapper.html())}}else{if(nodeName=="div"||nodeName=="span"){$target.removeClass(this.markerClassName).empty()}}if($("input[_calId="+calId+"]").length==0){this._inst[calId]=null}},_enableDatepicker:function(target){target.disabled=false;$(target).siblings("button.ui-datepicker-trigger").each(function(){this.disabled=false}).end().siblings("img.ui-datepicker-trigger").css({opacity:"1.0",cursor:""});this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value)})},_disableDatepicker:function(target){target.disabled=true;$(target).siblings("button.ui-datepicker-trigger").each(function(){this.disabled=true}).end().siblings("img.ui-datepicker-trigger").css({opacity:"0.5",cursor:"default"});this._disabledInputs=$.map($.datepicker._disabledInputs,function(value){return(value==target?null:value)});this._disabledInputs[$.datepicker._disabledInputs.length]=target},_isDisabledDatepicker:function(target){if(!target){return false}for(var i=0;i-1);},_connectDatepicker:function(target,inst){var input=$(target);if(input.is("."+this.markerClassName)){return }var appendText=inst._get("appendText");var isRTL=inst._get("isRTL");if(appendText){if(isRTL){input.before(''+appendText)}else{input.after(''+appendText);}}var showOn=inst._get("showOn");if(showOn=="focus"||showOn=="both"){input.focus(this._showDatepicker)}if(showOn=="button"||showOn=="both"){input.wrap('');var buttonText=inst._get("buttonText");var buttonImage=inst._get("buttonImage");var trigger=$(inst._get("buttonImageOnly")?$("").addClass("ui-datepicker-trigger").attr({src:buttonImage,alt:buttonText,title:buttonText}):$("