diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 368accd39b..b36785329c 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -13,6 +13,8 @@ require_once 'include/functions_messages.php'; require_once 'include/functions_servers.php'; require_once 'include/functions_notifications.php'; +require_once 'include/ajax/order_interpreter.php'; +ui_require_css_file('order_interpreter'); // Check permissions // Global errors/warnings checking. @@ -120,8 +122,13 @@ if ($config['menu_type'] == 'classic') { } $search_bar .= 'onfocus="javascript: if (fieldKeyWordEmpty) $(\'#keywords\').val(\'\');" - onkeyup="javascript: fieldKeyWordEmpty = false;" class="search_input" />'; + onkeyup="showinterpreter()" class="search_input" />'; + $search_bar .= ''; // $search_bar .= 'onClick="javascript: document.quicksearch.submit()"'; $search_bar .= ""; $search_bar .= ''; @@ -630,7 +637,14 @@ if ($config['menu_type'] == 'classic') { var fixed_header = ; var new_chat = ; - + + function showinterpreter(){ + if( $('#keywords').val() === ''){ + $('#result_order').hide(); + }else { + $('#result_order').show(); + } + } /** * Loads modal from AJAX to add feedback. */ diff --git a/pandora_console/include/ajax/order_interpreter.php b/pandora_console/include/ajax/order_interpreter.php new file mode 100644 index 0000000000..5edc8913f3 --- /dev/null +++ b/pandora_console/include/ajax/order_interpreter.php @@ -0,0 +1,62 @@ +ajaxMethod($method) === true) { + $order_interpreter->{$method}(); + } else { + $order_interpreter->error('Unavailable method.'); + } +} else { + $order_interpreter->error('Method not found. ['.$method.']'); +} + + +// Stop any execution. +exit; diff --git a/pandora_console/include/class/OrderInterpreter.class.php b/pandora_console/include/class/OrderInterpreter.class.php new file mode 100644 index 0000000000..92474d617e --- /dev/null +++ b/pandora_console/include/class/OrderInterpreter.class.php @@ -0,0 +1,157 @@ + $msg] + ); + } + + + /** + * Checks if target method is available to be called using AJAX. + * + * @param string $method Target method. + * + * @return boolean True allowed, false not. + */ + public function ajaxMethod($method) + { + global $config; + + // Check access. + check_login(); + + return in_array($method, $this->AJAXMethods); + } + + + /** + * Constructor. + * + * @param boolean $must_run Must run or not. + * @param string $ajax_controller Controller. + * + * @return object + * @throws Exception On error. + */ + public function __construct( + $ajax_controller='include/ajax/order_interpreter' + ) { + $this->ajaxController = $ajax_controller; + $this->pages_name = [ + 0 => __('Agent view'), + 1 => __('Agent Management'), + 2 => __('Manage Agents'), + 3 => __('Manage Policies'), + ]; + $this->pages_url = [ + 0 => ui_get_full_url(), + 1 => ui_get_full_url(), + 2 => ui_get_full_url(), + 3 => ui_get_full_url(), + ]; + + } + + + /** + * Method to print order interpreted on header search input. + * + * @return void + */ + public function getResult() + { + // Take value from input search. + $text = get_parameter('text', ''); + + foreach ($this->pages_name as $key => $value) { + if (preg_match('/'.$text.'/', $value)) { + echo 'pene gordo'; + } + } + + return; + + } + + + /** + * Load JS content. + * function that enables the functions to the buttons when its action is + * completed. + * Assign the url of each button. + * + * @return string HTML code for javascript functionality. + */ + public function loadJS() + { + ob_start(); + ?> + +