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 ""; }
/** * create First Config for all graphs *@return nothing **/ function createFirstConfig() { $reports = array(); $inc_dir = GLPI_ROOT . "/plugins/mreporting/inc"; //parse inc dir to search report classes $classes = PluginMreportingCommon::parseAllClasses($inc_dir); foreach ($classes as $classname) { if (!class_exists($classname)) { $class_filedir = GLPI_ROOT . "/plugins/mreporting/inc/" . strtolower(str_replace('PluginMreporting', '', $classname)) . ".class.php"; require_once $class_filedir; } $functions = get_class_methods($classname); // We check if a config function exists in class foreach ($functions as $funct_name) { if ($funct_name == 'preconfig') { // If a preconfig exists we construct the class $classConfig = true; $classObject = new $classname(); } } foreach ($functions as $funct_name) { $ex_func = preg_split('/(?<=\\w)(?=[A-Z])/', $funct_name); if ($ex_func[0] != 'report') { continue; } $input = array(); if ($classConfig) { // If a preconfig exists in class we do it $input = $classObject->preconfig($funct_name, $classname, $this); } else { // Else we get the default preconfig $input = $this->preconfig($funct_name, $classname); } $input["firstconfig"] = 1; unset($input["id"]); $newid = $this->add($input); } } }