Subversion Repositories slis

Rev

Rev 5301 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?PHP
/* $Id: monitor_check_list.php 1 2004-12-21 09:09:43Z xav $

This script has been written by Xavier LANGLOIS
Copyright (C) 2004 Xavier LANGLOIS <xavier.l@iwall.fr>

This script is released under GNU Public Licence (GPL)
http://www.gnu.org/licenses/gpl.html

This script is part of the SLIS Project initiated by
the CARMI-Internet (Academie de Grenoble - France 38).

SLIS : Serveur de communications Linux pour l'Internet Scolaire.
Copyright (C) 1998-2001 Bruno Bzeznik

--------------------------------------------------------------*/


// level = 1
// right = manage_check
// name = Monitor check list
// desc = Monitor check list

include_once("general.php");
include_once("gui/Form.php");
include_once("gui/FormField.php");
include_once("gui/OptionField.php");
include_once("gui/HiddenField.php");
include_once("gui/CheckboxField.php");
include_once("gui/Table.php");
include_once("gui/LinkField.php");
include_once("gui/LineField.php");
include_once("gui/HelpButton.php");
include_once("gui/Button.php");
include_once("gui/ButtonForm.php");

include_once("objects/AccessHistory.php");
include_once("objects/Monitor_check.php");
include_once("objects/Monitor_global.php");
include_once("objects/Monitor_list.php");
include_once("objects/VersionSlis.php");

/*if ($new)    {
        html_redirect("monitor_check_edit.php");
}*/


if (!$slim_user->has_right("manage_check")) {
        html_error ("Operation not allowed");
        exit();
}

global $with_record_count;
$with_record_count = &$_SESSION['with_record_count'];

global $with_check_version;
$with_check_version = &$_SESSION['with_check_version'];

$save_user_config = false;

if (isset($_GET["with_record_count"])){
  $with_record_count= $_GET["with_record_count"];
  $save_user_config = true;
}
if (isset($_GET["with_check_version"])){
  $with_check_version= $_GET["with_check_version"];
  $save_user_config = true;
}

if ($save_user_config) {
        // save the config_slim of the user in DB
        $config =  $_SESSION['config_slim'];
        $config['with_record_count']=$with_record_count;
        $config['with_check_version']=$with_check_version;

        $slim_user->config_slim = base64_encode(wddx_serialize_value($config));
        $slim_user->modify();
       
}



print html_header($slis->name);

if ($slim_user->has_right("manage_check")) {

        if ($slis_name) {
                $checks = $Monitor_list->select("slis_name='$slis_name'");
               
                foreach($checks as $check) {
                        if ($cond) $cond.=" and ";
                        $cond.= "id_check!=$check->id_check";
                }
                $cond.= " and priority!=0 and priority!=100 ";
                $notusesd = $Monitor_check->select($cond,"priority");
               
                $mcs = $Monitor_check->select($cond, "priority,name");
               
                $table = new Table(1);
                $table->set_title("Monitor check");
                $table->add_field(new Field("priority", "Priorit√©"));
                $table->add_field(new Field("", "Nom","","get_slis_link"));
                $table->add_field(new Field("comment", "Commentaire"));
                print $table->build_code($notusesd);   
               
        } else {
       
                $cond="";
                $mcs = array();
                if (isset($with_check_version) && $with_check_version != "") {
                    $mcs = $Monitor_check->select_by_version($with_check_version,$cond,"priority,name");
                }
                else {
                    $mcs = $Monitor_check->select($cond, "priority,name");
                }
               
                $table = new Table(1);
    $table->set_no_i8n();      
                if (isset($with_check_version) && $with_check_version != "") {
                    $title = __("Monitor checks for the version: ") . $with_check_version;
                }
                else {
                    $title = __("Monitor checks for all versions");
                }
                $table->set_title($title);
               
       
                $table->add_field(new Field("priority", "Priorit√©"));
                $table->add_field(new LinkField("name", "Nom","","","getLink_1","",""));
                $table->add_field(new Field("comment", "Commentaire"));
               
                $table->add_field(new Field("", "by default","","is_default"));
               
                if ($with_record_count=="yes") {
                        $table->add_field(new Field("", "Record count","","getRecordCount"));
                }
               
                $table->add_field(new Field("min_age", "Min age"));
                $table->add_field(new Field("min_record", "Min record"));
                $table->add_field(new Field("max_age", "Max age"));
                $table->add_field(new Field("max_record", "Max record"));

                $vs = $VersionSlis->select("");
                print "<p>\n";
                $link = html_link("?with_check_version=","All Versions");
                if (!isset($with_check_version) || $with_check_version == "") {
                  print "<b>".$link."</b>";
                } else {
                  print $link;
                }
                foreach($vs as $v) {
                    print " | ";
                    $link = html_link("?with_check_version=".$v->version_name,$v->version_name);
                    if (isset($with_check_version) && $with_check_version == $v->version_name) {
                      print "<b>".$link."</b>";
                    } else {
                      print $link;
                    }
                }
                print "</p>\n";

                print $table->build_code($mcs);
       
                $button_form = new ButtonForm(new Button("New script", "new"),"monitor_check_edit.php");
                print "<p>\n";
                print $button_form->build_code();
               
                if ($with_record_count=="yes") {
                        echo html_link("?with_record_count=no",__("Hide record counts") );
                } else {
                        echo html_link("?with_record_count=yes",__("Show record counts") );
                }
       
                print "<HR>\n";
               
                $mgs = $Monitor_global->select("", "name");
                $table = new Table(1);
                $table->set_title("Global monitor check");
        //      $table->add_field(new Field("priority", "Priorite"));
                $table->add_field(new LinkField("name", "Nom","","","getLink_1","",""));
                $table->add_field(new Field("comment", "Commentaire"));
                print $table->build_code($mgs);
       
                $button_form = new ButtonForm(new Button("New script", "new"),"monitor_global_edit.php");
                print "<p>\n";
                print $button_form->build_code();
        }
               
} else {
        html_error ("Operation not allowed");
}


print html_footer();

?>