Example #1
0
function plugin_mreporting_giveItem($type, $ID, $data, $num)
{
    global $LANG;
    $searchopt =& Search::getOptions($type);
    $table = $searchopt[$ID]["table"];
    $field = $searchopt[$ID]["field"];
    $output_type = Search::HTML_OUTPUT;
    if (isset($_GET['display_type'])) {
        $output_type = $_GET['display_type'];
    }
    switch ($type) {
        case 'PluginMreportingConfig':
            switch ($table . '.' . $field) {
                case "glpi_plugin_mreporting_configs.show_label":
                    $out = ' ';
                    if (!empty($data["ITEM_{$num}"])) {
                        $out = PluginMreportingConfig::getLabelTypeName($data["ITEM_{$num}"]);
                    }
                    return $out;
                    break;
                case "glpi_plugin_mreporting_configs.name":
                    $out = ' ';
                    if (!empty($data["ITEM_{$num}"])) {
                        $title_func = '';
                        $short_classname = '';
                        $f_name = '';
                        $inc_dir = GLPI_ROOT . "/plugins/mreporting/inc";
                        //parse inc dir to search report classes
                        $classes = PluginMreportingCommon::parseAllClasses($inc_dir);
                        foreach ($classes as $classname) {
                            $functions = get_class_methods($classname);
                            foreach ($functions as $funct_name) {
                                $ex_func = preg_split('/(?<=\\w)(?=[A-Z])/', $funct_name);
                                if ($ex_func[0] != 'report') {
                                    continue;
                                }
                                $gtype = strtolower($ex_func[1]);
                                if ($data["ITEM_{$num}"] == $funct_name) {
                                    if (!empty($classname) && !empty($funct_name)) {
                                        $short_classname = str_replace('PluginMreporting', '', $classname);
                                        if (isset($LANG['plugin_mreporting'][$short_classname][$funct_name]['title'])) {
                                            $title_func = $LANG['plugin_mreporting'][$short_classname][$funct_name]['title'];
                                        }
                                    }
                                }
                            }
                        }
                        $out = "<a href='config.form.php?id=" . $data["id"] . "'>" . $data["ITEM_{$num}"] . "</a> (" . $title_func . ")";
                    }
                    return $out;
                    break;
            }
            return "";
            break;
    }
    return "";
}