tags */ function debugPrint ($var, $file = '') { if ($file === true) $file = '/tmp/logDebug'; if (strlen($file) > 0) { $f = fopen($file, "a"); ob_start(); echo date("Y/m/d H:i:s") . "\n"; print_r($var); echo "\n\n"; $output = ob_get_clean(); fprintf($f,"%s",$output); fclose($f); } else { echo "
";print_r($var);echo "
"; } } function f2str($function, $params) { ob_start(); call_user_func_array($function, $params); return ob_get_clean(); } /** * Prints an array of fields in a popup menu of a form. * * Based on choose_from_menu() from Moodle * * @param array Array with dropdown values. Example: $fields["value"] = "label" * @param string Select form name * @param variant Current selected value. Can be a single value or an * array of selected values (in combination with multiple) * @param string Javascript onChange code. * @param string Label when nothing is selected. * @param variant Value when nothing is selected * @param bool Whether to return an output string or echo now (optional, echo by default). * @param bool Set the input to allow multiple selections (optional, single selection by default). * @param bool Whether to sort the options or not (optional, unsorted by default). * * @return string HTML code if return parameter is true. */ function print_select_style ($fields, $name, $selected = '', $style='', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false) { $output = "\n"; static $idcounter = array (); //If duplicate names exist, it will start numbering. Otherwise it won't if (isset ($idcounter[$name])) { $idcounter[$name]++; } else { $idcounter[$name] = 0; } $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $attributes = ""; if (!empty ($script)) { $attributes .= ' onchange="'.$script.'"'; } if (!empty ($multiple)) { $attributes .= ' multiple="multiple" size="10"'; } if (!empty ($class)) { $attributes .= ' class="'.$class.'"'; } if (!empty ($disabled)) { $attributes .= ' disabled="disabled"'; } $output .= '"; if ($return) return $output; echo $output; } /** * Prints the groups of user of fields in a popup menu of a form. * * @param string User id * @param string The privilege to evaluate * @param boolean $returnAllGroup Flag the return group, by default true. * @param boolean $returnAllColumns Flag to return all columns of groups. * @param array Array with dropdown values. Example: $fields["value"] = "label" * @param string Select form name * @param variant Current selected value. Can be a single value or an * array of selected values (in combination with multiple) * @param string Javascript onChange code. * @param string Label when nothing is selected. * @param variant Value when nothing is selected * @param bool Whether to return an output string or echo now (optional, echo by default). * @param bool Set the input to allow multiple selections (optional, single selection by default). * @param bool Whether to sort the options or not (optional, unsorted by default). * @param string $style The string of style. * @param integer $id_group The id of node that must do not show the children and own. * * @return string HTML code if return parameter is true. */ function print_select_groups($id_user = false, $privilege = "AR", $returnAllGroup = true, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false, $id_group = false) { global $config; $user_groups = get_user_groups ($id_user, $privilege, $returnAllGroup, true); if ($id_group !== false) { $childrens = get_childrens($id_group); foreach ($childrens as $child) { unset($user_groups[$child['id_grupo']]); } unset($user_groups[$id_group]); } $user_groups_tree = get_user_groups_tree_recursive($user_groups); $fields = array(); foreach ($user_groups_tree as $group) { if (isset($config['text_char_long'])) { $groupName = printTruncateText($group['nombre'], $config['text_char_long'], false, true, false); } else { $groupName = $group['nombre']; } $fields[$group['id_grupo']] = str_repeat("    ", $group['deep']) . $groupName; } $output = print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, false, $class, $disabled, $style, $option_style); if ($return) { return $output; } } /** * Prints an array of fields in a popup menu of a form. * * Based on choose_from_menu() from Moodle * * @param array Array with dropdown values. Example: $fields["value"] = "label" * @param string Select form name * @param variant Current selected value. Can be a single value or an * array of selected values (in combination with multiple) * @param string Javascript onChange code. * @param string Label when nothing is selected. * @param variant Value when nothing is selected * @param bool Whether to return an output string or echo now (optional, echo by default). * @param bool Set the input to allow multiple selections (optional, single selection by default). * @param bool Whether to sort the options or not (optional, unsorted by default). * @param string $style The string of style. * * @return string HTML code if return parameter is true. */ function print_select ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = 0, $return = false, $multiple = false, $sort = true, $class = '', $disabled = false, $style = false, $option_style = false) { $output = "\n"; static $idcounter = array (); //If duplicate names exist, it will start numbering. Otherwise it won't if (isset ($idcounter[$name])) { $idcounter[$name]++; } else { $idcounter[$name] = 0; } $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $attributes = ""; if (!empty ($script)) { $attributes .= ' onchange="'.$script.'"'; } if (!empty ($multiple)) { $attributes .= ' multiple="multiple" size="10"'; } if (!empty ($class)) { $attributes .= ' class="'.$class.'"'; } if (!empty ($disabled)) { $attributes .= ' disabled="disabled"'; } if ($style === false) { $styleText = 'style="max-width: 180px"'; } else { $styleText = 'style="max-width: 180px; ' .$style . '"'; } $output .= '"; if ($return) return $output; echo $output; } /** * Prints an array of fields in a popup menu of a form based on a SQL query. * The first and second columns of the query will be used. * * The element will have an id like: "password-$value". Based on choose_from_menu() from Moodle. * * @param string $sql SQL sentence, the first field will be the identifier of the option. * The second field will be the shown value in the dropdown. * @param string $name Select form name * @param string $selected Current selected value. * @param string $script Javascript onChange code. * @param string $nothing Label when nothing is selected. * @param string $nothing_value Value when nothing is selected * @param bool $return Whether to return an output string or echo now (optional, echo by default). * @param bool $multiple Whether to allow multiple selections or not. Single by default * @param bool $sort Whether to sort the options or not. Sorted by default. * @param bool $disabled if it's true, disable the select. * @param string $style The string of style. * * @return string HTML code if return parameter is true. */ function print_select_from_sql ($sql, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $return = false, $multiple = false, $sort = true, $disabled = false, $style = false) { global $config; $fields = array (); $result = get_db_all_rows_sql ($sql); if ($result === false) $result = array (); foreach ($result as $row) { $id = array_shift($row); $value = array_shift($row); if (isset($config['text_char_long'])) { $fields[$id] = printTruncateText($value, $config['text_char_long'], false, true, false); } else { $fields[$id] = $value; } } return print_select ($fields, $name, $selected, $script, $nothing, $nothing_value, $return, $multiple, $sort,'',$disabled, $style); } /** * Render a pair of select for times and text box for set the time more fine. * * @param array Array with dropdown values. Example: $fields["value"] = "label" * @param string Select form name * @param variant Current selected value. Can be a single value or an * array of selected values (in combination with multiple) * @param string Javascript onChange (select) code. * @param string Label when nothing is selected. * @param variant Value when nothing is selected * @param integer $size Size of the input. * @param bool Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_extended_select_for_time ($fields, $name, $selected = '', $script = '', $nothing = '', $nothing_value = '0', $size = false, $return = false, $select_style = false) { if (($selected !== false) && (!isset($fields[$selected]))) { $fields[$selected] = human_time_description_raw($selected,true); } ob_start(); print_select ($fields, $name . '_select', $selected,"javascript: $('#text-" . $name . "').val($('#" . $name . "_select').val());" . $script, $nothing, $nothing_value, false, false, false, '', false, $select_style); print_input_text ($name, $selected, '', $size); $returnString = ob_get_clean(); if ($return) return $returnString; else echo $returnString; } /** * Render an input text element. Extended version, use print_input_text() to simplify. * * @param string $name Input name. * @param string $value Input value. * @param string $id Input HTML id. * @param string $alt Do not use, invalid for text and password. Use print_input_image * @param int $size Size of the input. * @param int $maxlength Maximum length allowed. * @param bool $disabled Disable the button (optional, button enabled by default). * @param string $script JavaScript to attach to this . (TODO This parameter don't use...and I don't know reason) * @param mixed $attributes Attributes to add to this tag. Should be an array for correction. * @param bool $return Whether to return an output string or echo now (optional, echo by default). * @param bool $password Whether it is a password input or not. Not password by default. * * @return string HTML code if return parameter is true. */ function print_input_text_extended ($name, $value, $id, $alt, $size, $maxlength, $disabled, $script, $attributes, $return = false, $password = false) { static $idcounter = 0; if ($maxlength == 0) $maxlength = 255; if ($size == 0) $size = 10; ++$idcounter; $valid_attrs = array ("accept", "disabled", "maxlength", "name", "readonly", "size", "value", "accesskey", "class", "dir", "id", "lang", "style", "tabindex", "title", "xml:lang", "onfocus", "onblur", "onselect", "onchange", "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmousemove", "onmouseout", "onkeypress", "onkeydown", "onkeyup"); $output = ' $attr_value) { if (! in_array ($attribute, $valid_attrs)) { continue; } $output .= $attribute.'="'.$attr_value.'" '; } } else { $output .= trim ($attributes)." "; $attributes = array (); } //Attributes specified by function call $attrs = array ("name" => "unnamed", "value" => "", "id" => "text-".sprintf ('%04d', $idcounter), "size" => "", "maxlength" => ""); foreach ($attrs as $attribute => $default) { if (array_key_exists ($attribute, $attributes)) { continue; } //If the attribute was already processed, skip /* * Remember, this next code have a $$ that for example there is a var as * $a = 'john' then $$a is a var $john . * * In this case is use for example for $name and $atribute = 'name' . * */ /* Exact operator because we want to show "0" on the value */ if ($$attribute !== '') { $output .= $attribute.'="'.$$attribute.'" '; } elseif ($default != '') { $output .= $attribute.'="'.$default.'" '; } } $output .= '/>'; if (!$return) echo $output; return $output; } /** * Render an input password element. * * The element will have an id like: "password-$name" * * @param string $name Input name. * @param string $value Input value. * @param string $alt Alternative HTML string (optional). * @param int $size Size of the input (optional). * @param int $maxlength Maximum length allowed (optional). * @param bool $return Whether to return an output string or echo now (optional, echo by default). * @param bool $disabled Disable the button (optional, button enabled by default). * * @return string HTML code if return parameter is true. */ function print_input_password ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false) { $output = print_input_text_extended ($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', '', true, true); if ($return) return $output; echo $output; } /** * Render an input text element. * * The element will have an id like: "text-$name" * * @param string $name Input name. * @param string $value Input value. * @param string $alt Alternative HTML string (invalid - not used). * @param int $size Size of the input (optional). * @param int $maxlength Maximum length allowed (optional). * @param bool $return Whether to return an output string or echo now (optional, echo by default). * @param bool $disabled Disable the button (optional, button enabled by default). * * @return string HTML code if return parameter is true. */ function print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false) { if ($maxlength == 0) $maxlength = 255; if ($size == 0) $size = 10; return print_input_text_extended ($name, $value, 'text-'.$name, '', $size, $maxlength, $disabled, '', '', $return); } /** * Render an input image element. * * The element will have an id like: "image-$name" * * @param string $name Input name. * @param string $src Image source. * @param string $value Input value. * @param string $style HTML style property. * @param bool $return Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_input_image ($name, $src, $value, $style = '', $return = false, $options = false) { global $config; static $idcounter = 0; ++$idcounter; /* Checks if user's skin is available */ $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $skin_path = enterprise_hook('get_image_skin_path',array($src)); if ($skin_path) $src = $skin_path; } // path to image $src = $config["homeurl"] . '/' . $src; $output = ''; if ($return) return $output; echo $output; } /** * Render an input hidden element. * * The element will have an id like: "hidden-$name" * * @param string $name Input name. * @param string $value Input value. * @param bool $return Whether to return an output string or echo now (optional, echo by default). * @param string $class Set the class of input. * * @return string HTML code if return parameter is true. */ function print_input_hidden ($name, $value, $return = false, $class = false) { if ($class !== false) { $classText = 'class="' . $class . '"'; } else { $classText = ''; } $output = ''; if ($return) return $output; echo $output; } /** * Render an submit input button element. * * The element will have an id like: "submit-$name" * * @param string $label Input label. * @param string $name Input name. * @param bool $disabled Whether to disable by default or not. Enabled by default. * @param array $attributes Additional HTML attributes. * @param bool $return Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_submit_button ($label = 'OK', $name = '', $disabled = false, $attributes = '', $return = false) { if (!$name) { $name="unnamed"; } if (is_array ($attributes)) { $attr_array = $attributes; $attributes = ''; foreach ($attr_array as $attribute => $value) { $attributes .= $attribute.'="'.$value.'" '; } } $output = ''; //$output .= safe_input ($value); $output .= ($value); $output .= ''; if ($return) return $output; echo $output; } /** * Print a nicely formatted table. Code taken from moodle. * * @param object Object with several properties: * $table->head - An array of heading names. * $table->head_colspan - An array of colspans of each head column. * $table->align - An array of column alignments * $table->valign - An array of column alignments * $table->size - An array of column sizes * $table->wrap - An array of "nowrap"s or nothing * $table->style - An array of personalized style for each column. * $table->rowstyle - An array of personalized style of each row. * $table->rowclass - An array of personalized classes of each row (odd-evens classes will be ignored). * $table->colspan - An array of colspans of each column. * $table->rowspan - An array of rowspans of each column. * $table->data[] - An array of arrays containing the data. * $table->width - A percentage of the page * $table->border - Border of the table. * $table->tablealign - Align the whole table (float left or right) * $table->cellpadding - Padding on each cell * $table->cellspacing - Spacing between cells * $table->class - CSS table class * $table->id - Table ID (useful in JavaScript) * $table->headclass[] - An array of classes for each heading * $table->title - Title of the table is a single string that will be on top of the table in the head spanning the whole table * $table->titlestyle - Title style * $table->titleclass - Title class * $table->styleTable - Table style * @param bool Whether to return an output string or echo now * * @return string HTML code if return parameter is true. */ function print_table (&$table, $return = false) { $output = ''; static $table_count = 0; $table_count++; if (isset ($table->align)) { foreach ($table->align as $key => $aa) { if ($aa) { $align[$key] = ' text-align:'. $aa.';'; } else { $align[$key] = ''; } } } if (isset ($table->valign)) { foreach ($table->valign as $key => $aa) { if ($aa) { $valign[$key] = ' vertical-align:'. $aa.';'; } else { $valign[$key] = ''; } } } if (isset ($table->size)) { foreach ($table->size as $key => $ss) { if ($ss) { $size[$key] = ' width:'. $ss .';'; } else { $size[$key] = ''; } } } if (isset ($table->style)) { foreach ($table->style as $key => $st) { if ($st) { $style[$key] = ' '. $st .';'; } else { $style[$key] = ''; } } } $styleTable = ''; if (isset ($table->styleTable)) { $styleTable = $table->styleTable; } if (isset ($table->rowstyle)) { foreach ($table->rowstyle as $key => $st) { $rowstyle[$key] = ' '. $st .';'; } } if (isset ($table->rowclass)) { foreach ($table->rowclass as $key => $class) { $rowclass[$key] = $class; } } if (isset ($table->colspan)) { foreach ($table->colspan as $keyrow => $cspan) { foreach ($cspan as $key => $span) { $colspan[$keyrow][$key] = ' colspan="'.$span.'"'; } } } if (isset ($table->rowspan)) { foreach ($table->rowspan as $keyrow => $rspan) { foreach ($rspan as $key => $span) { $rowspan[$keyrow][$key] = ' rowspan="'.$span.'"'; } } } if (empty ($table->width)) { //$table->width = '80%'; } if (empty ($table->border)) { $table->border = '0'; } if (empty ($table->tablealign) || $table->tablealign != 'left' || $table->tablealign != 'right') { $table->tablealign = ''; } else { $table->tablealign = 'style="float:'.$table->tablealign.';"'; //Align is deprecated. Use float instead } if (!isset ($table->cellpadding)) { $table->cellpadding = '4'; } if (!isset ($table->cellspacing)) { $table->cellspacing = '4'; } if (empty ($table->class)) { $table->class = 'databox'; } if (empty ($table->titlestyle)) { $table->titlestyle = 'text-align:center;'; } $tableid = empty ($table->id) ? 'table'.$table_count : $table->id; if (!empty($table->width)) { $output .= 'tablealign; } else { $output .= '
tablealign; } $output .= ' cellpadding="'.$table->cellpadding.'" cellspacing="'.$table->cellspacing.'"'; $output .= ' border="'.$table->border.'" class="'.$table->class.'" id="'.$tableid.'">'; $countcols = 0; if (!empty ($table->head)) { $countcols = count ($table->head); $output .= ''; if (isset ($table->title)) { $output .= ''; } foreach ($table->head as $key => $heading) { if (!isset ($size[$key])) { $size[$key] = ''; } if (!isset ($align[$key])) { $align[$key] = ''; } if (!isset ($table->headclass[$key])) { $table->headclass[$key] = 'header c'.$key; } if (isset ($table->head_colspan[$key])) { $headColspan = 'colspan = "' . $table->head_colspan[$key] . '"'; } else $headColspan = ''; $output .= ''; } $output .= ''."\n"; } $output .= ''."\n"; if (!empty ($table->data)) { $oddeven = 1; foreach ($table->data as $keyrow => $row) { if (!isset ($rowstyle[$keyrow])) { $rowstyle[$keyrow] = ''; } $oddeven = $oddeven ? 0 : 1; $class = 'datos'.($oddeven ? "" : "2"); if (isset ($rowclass[$keyrow])) { $class = $rowclass[$keyrow]; } $output .= ''."\n"; /* Special separator rows */ if ($row == 'hr' and $countcols) { $output .= ''; continue; } /* It's a normal row */ foreach ($row as $key => $item) { if (!isset ($size[$key])) { $size[$key] = ''; } if (!isset ($colspan[$keyrow][$key])) { $colspan[$keyrow][$key] = ''; } if (!isset ($rowspan[$keyrow][$key])) { $rowspan[$keyrow][$key] = ''; } if (!isset ($align[$key])) { $align[$key] = ''; } if (!isset ($valign[$key])) { $valign[$key] = ''; } if (!isset ($wrap[$key])) { $wrap[$key] = ''; } if (!isset ($style[$key])) { $style[$key] = ''; } $output .= ''."\n"; } $output .= ''."\n"; } } $output .= '
titlestyle)) { $output .= ' style="'.$table->titlestyle.'"'; } if (isset ($table->titleclass)) { $output .= ' class="'.$table->titleclass.'"'; } $output .= '>'.$table->title.'
'. $heading .'
'. $item .'
'."\n"; if ($return) return $output; echo $output; } /** * Render a radio button input. Extended version, use print_radio_button() to simplify. * * @param string Input name. * @param string Input value. * @param string Set the button to be marked (optional, unmarked by default). * @param bool Disable the button (optional, button enabled by default). * @param string Script to execute when onClick event is triggered (optional). * @param string Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). * @param bool Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_radio_button_extended ($name, $value, $label, $checkedvalue, $disabled, $script, $attributes, $return = false) { static $idcounter = 0; $output = ''; $output = ''. $label .'' . "\n"; } if ($return) return $output; echo $output; } /** * Render a radio button input. * * @param string Input name. * @param string Input value. * @param string Label to add after the radio button (optional). * @param string Checked and selected value, the button will be selected if it matches $value (optional). * @param bool Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_radio_button ($name, $value, $label = '', $checkedvalue = '', $return = false) { $output = print_radio_button_extended ($name, $value, $label, $checkedvalue, false, '', '', true); if ($return) return $output; echo $output; } /** * Render a checkbox button input. Extended version, use print_checkbox() to simplify. * * @param string Input name. * @param string Input value. * @param string Set the button to be marked (optional, unmarked by default). * @param bool Disable the button (optional, button enabled by default). * @param string Script to execute when onClick event is triggered (optional). * @param string Optional HTML attributes. It's a free string which will be inserted into the HTML tag, use it carefully (optional). * @param bool Whether to return an output string or echo now (optional, echo by default). * * @return string HTML code if return parameter is true. */ function print_checkbox_extended ($name, $value, $checked, $disabled, $script, $attributes, $return = false) { static $idcounter = array (); //If duplicate names exist, it will start numbering. Otherwise it won't if (isset ($idcounter[$name])) { $idcounter[$name]++; } else { $idcounter[$name] = 0; } $id = preg_replace('/[^a-z0-9\:\;\-\_]/i', '', $name.($idcounter[$name] ? $idcounter[$name] : '')); $output = ''). * * @return string HTML code if return parameter is true. */ function print_image ($src, $return = false, $options = false, $return_src = false) { global $config; /* Checks if user's skin is available */ $isFunctionSkins = enterprise_include_once ('include/functions_skins.php'); if ($isFunctionSkins !== ENTERPRISE_NOT_HOOK) { $skin_path = enterprise_hook('get_image_skin_path',array($src)); if ($skin_path) $src = $skin_path; } // path to image $src = $config["homeurl"] . '/' . $src; // Only return src field of image if ($return_src){ if (!$return){ echo safe_input($src); return; } return safe_input($src); } $output = ''; if (!$return) { echo $output; } return $output; } /** * Render an input text element. Extended version, use print_input_text() to simplify. * * @param string Input name. * @param bool Whether to return an output string or echo now (optional, echo by default). * @param array An array with optional HTML parameters. * Key size: HTML size attribute. * Key disabled: Whether to disable the input or not. * Key class: HTML class */ function print_input_file ($name, $return = false, $options = false) { $output = ''; $output .= ''; $output .= $text; $output .= ''; if ($options) { if (isset ($options['html'])) $output .= $options['html']; } if ($return) return $output; echo $output; } /** * Convert a html color like #FF00FF into the rgb values like (255,0,255). * * @param string color in format #FFFFFF, FFFFFF, #FFF or FFF */ function html2rgb($htmlcolor) { if ($htmlcolor[0] == '#') { $htmlcolor = substr($htmlcolor, 1); } if (strlen($htmlcolor) == 6) { $r = hexdec($htmlcolor[0].$htmlcolor[1]); $g = hexdec($htmlcolor[2].$htmlcolor[3]); $b = hexdec($htmlcolor[4].$htmlcolor[5]); return array($r, $g, $b); } elseif (strlen($htmlcolor) == 3) { $r = hexdec($htmlcolor[0].$htmlcolor[0]); $g = hexdec($htmlcolor[1].$htmlcolor[1]); $b = hexdec($htmlcolor[2].$htmlcolor[2]); return array($r, $g, $b); } else { 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; } } ?>