Exemplo n.º 1
0
if (!isset($_GET["preconfig"])) {
    $_GET["preconfig"] = -1;
}
$config = new PluginMreportingConfig();
if (isset($_POST["add"])) {
    Session::checkRight("config", "w");
    $newID = $config->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        Session::checkRight("config", "w");
        $config->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            Session::checkRight("config", "w");
            $config->delete($_POST, 1);
            Html::redirect("./config.form.php");
        } else {
            Html::header(__("Setup"), '', "plugins", "mreporting", "config");
            //Link from graph
            if (isset($_GET["name"]) && isset($_GET["classname"])) {
                if ($config->getFromDBByFunctionAndClassname($_GET["name"], $_GET["classname"])) {
                    $_GET["id"] = $config->fields['id'];
                }
            }
            $config->showForm($_GET["id"]);
            Html::footer();
        }
    }
}
Exemplo n.º 2
0
 /**
  * Get all reports from parsing class
  *
  * @params
  */
 function getAllReports($with_url = true, $params = array())
 {
     global $LANG;
     $reports = array();
     $inc_dir = GLPI_ROOT . "/plugins/mreporting/inc";
     $pics_dir = "../pics";
     //parse inc dir to search report classes
     $classes = self::parseAllClasses($inc_dir);
     sort($classes);
     if (isset($params['classname']) && !empty($params['classname'])) {
         $classes = array();
         $classes[] = $params['classname'];
     }
     //construct array to list classes and functions
     foreach ($classes as $classname) {
         $i = 0;
         //scn = short class name
         $scn = str_replace('PluginMreporting', '', $classname);
         if (isset($LANG['plugin_mreporting'][$scn]['title'])) {
             $title = $LANG['plugin_mreporting'][$scn]['title'];
             $functions = get_class_methods($classname);
             foreach ($functions as $f_name) {
                 $ex_func = preg_split('/(?<=\\w)(?=[A-Z])/', $f_name);
                 if ($ex_func[0] != 'report') {
                     continue;
                 }
                 if (isset($LANG['plugin_mreporting'][$scn][$f_name])) {
                     $gtype = strtolower($ex_func[1]);
                     $title_func = $LANG['plugin_mreporting'][$scn][$f_name]['title'];
                     $category_func = '';
                     if (isset($LANG['plugin_mreporting'][$scn][$f_name]['category'])) {
                         $category_func = $LANG['plugin_mreporting'][$scn][$f_name]['category'];
                     }
                     if (isset($LANG['plugin_mreporting'][$scn][$f_name]['desc'])) {
                         $des_func = $LANG['plugin_mreporting'][$scn][$f_name]['desc'];
                     }
                     $url_graph = "graph.php?short_classname={$scn}" . "&amp;f_name={$f_name}&amp;gtype={$gtype}";
                     $min_url_graph = "front/graph.php?short_classname={$scn}" . "&amp;f_name={$f_name}&amp;gtype={$gtype}";
                     $reports[$classname]['title'] = $title;
                     $reports[$classname]['functions'][$i]['function'] = $f_name;
                     $reports[$classname]['functions'][$i]['title'] = $title_func;
                     $reports[$classname]['functions'][$i]['desc'] = $des_func;
                     $reports[$classname]['functions'][$i]['category_func'] = $category_func;
                     $reports[$classname]['functions'][$i]['pic'] = $pics_dir . "/chart-{$gtype}.png";
                     $reports[$classname]['functions'][$i]['gtype'] = $gtype;
                     $reports[$classname]['functions'][$i]['short_classname'] = $scn;
                     $reports[$classname]['functions'][$i]['is_active'] = false;
                     $config = new PluginMreportingConfig();
                     if ($config->getFromDBByFunctionAndClassname($f_name, $classname)) {
                         if ($config->fields['is_active'] == 1) {
                             $reports[$classname]['functions'][$i]['is_active'] = true;
                         }
                     }
                     if ($with_url) {
                         $reports[$classname]['functions'][$i]['url_graph'] = $url_graph;
                         $reports[$classname]['functions'][$i]['min_url_graph'] = $min_url_graph;
                     }
                     $i++;
                 }
             }
         }
     }
     return $reports;
 }