Changeset 6691
- Timestamp:
- 10/02/08 11:38:23 (2 months ago)
- Location:
- trunk/centreon/www/include/monitoring/downtime
- Files:
-
- 4 modified
-
AddHostDowntime.php (modified) (1 diff)
-
AddSvcDowntime.php (modified) (1 diff)
-
template/downtime.ihtml (modified) (2 diffs)
-
viewDowntime.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/centreon/www/include/monitoring/downtime/AddHostDowntime.php
r6646 r6691 18 18 if (!isset($oreon)) 19 19 exit(); 20 21 $actions = false; 22 $actions = verifyActionsACLofUser("host_schedule_downtime"); 23 $GroupListofUser = getGroupListofUser($pearDB); 20 24 21 # Init 22 $LCA_error = 0; 23 if (!$is_admin){ 24 $lcaHostByName = getLcaHostByName($pearDB); 25 } 26 27 if (isset($_GET["host_name"])){ 28 $host_id = getMyHostID($_GET["host_name"]); 29 if (!isset($lcaHostByName["LcaHost"] [$_GET["host_name"]]) && !$is_admin) 30 $LCA_error = 1; 31 $host_name = $_GET["host_name"]; 32 } else 33 $host_name = NULL; 34 35 if ($LCA_error) 25 if ($actions == true || count($GroupListofUser) == 0) { 26 # Init 27 $LCA_error = 0; 28 if (!$is_admin){ 29 $lcaHostByName = getLcaHostByName($pearDB); 30 } 31 32 if (isset($_GET["host_name"])){ 33 $host_id = getMyHostID($_GET["host_name"]); 34 if (!isset($lcaHostByName["LcaHost"] [$_GET["host_name"]]) && !$is_admin) 35 $LCA_error = 1; 36 $host_name = $_GET["host_name"]; 37 } else 38 $host_name = NULL; 39 40 if ($LCA_error) 41 require_once("./alt_error.php"); 42 else { 43 $data = array("host_id" => getMyHostID($host_name), "start" => date("Y/m/d G:i" , time() + 120), "end" => date("Y/m/d G:i", time() + 7320)); 44 45 # 46 ## Database retrieve information for differents elements list we need on the page 47 # 48 49 $hosts = array(""=>""); 50 $DBRESULT =& $pearDB->query("SELECT host_id, host_name, host_template_model_htm_id FROM `host` WHERE host_register = '1' ORDER BY host_name"); 51 if (PEAR::isError($DBRESULT)) 52 print "AddHostDowntime - RQ 1 : Mysql Error : ".$DBRESULT->getMessage(); 53 while ($host =& $DBRESULT->fetchRow()){ 54 if (!$host["host_name"]) 55 $host["host_name"] = getMyHostName($host["host_template_model_htm_id"]); 56 if (isset($lcaHostByName["LcaHost"][$host["host_name"]]) || $is_admin) 57 $hosts[$host["host_id"]]= $host["host_name"]; 58 } 59 $DBRESULT->free(); 60 61 $debug = 0; 62 $attrsTextI = array("size"=>"3"); 63 $attrsText = array("size"=>"30"); 64 $attrsTextarea = array("rows"=>"7", "cols"=>"100"); 65 66 # 67 ## Form begin 68 # 69 70 $form = new HTML_QuickForm('Form', 'post', "?p=".$p); 71 if ($o == "ah") 72 $form->addElement('header', 'title', _("Add a Host downtime")); 73 # 74 ## Indicator basic information 75 # 76 77 $redirect =& $form->addElement('hidden', 'o'); 78 $redirect->setValue($o); 79 80 $selHost =& $form->addElement('select', 'host_id', _("Host Name"), $hosts); 81 $form->addElement('checkbox', 'persistant', _("Fixed")); 82 $form->addElement('text', 'start', _("Start Time"), $attrsText); 83 $form->addElement('text', 'end', _("End Time"), $attrsText); 84 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea); 85 86 $form->addRule('host_id', _("Required Field"), 'required'); 87 $form->addRule('end', _("Required Field"), 'required'); 88 $form->addRule('start', _("Required Field"), 'required'); 89 $form->addRule('comment', _("Required Field"), 'required'); 90 91 $form->setDefaults($data); 92 $subA =& $form->addElement('submit', 'submitA', _("Save")); 93 $res =& $form->addElement('reset', 'reset', _("Reset")); 94 95 if ((isset($_POST["submitA"]) && $_POST["submitA"]) && $form->validate()) { 96 if (!isset($_POST["persistant"])) 97 $_POST["persistant"] = 0; 98 if (!isset($_POST["comment"])) 99 $_POST["comment"] = 0; 100 AddHostDowntime($_POST["host_id"], $_POST["comment"], $_POST["start"], $_POST["end"], $_POST["persistant"]); 101 require_once("viewDowntime.php"); 102 } else { 103 # Smarty template Init 104 $tpl = new Smarty(); 105 $tpl = initSmartyTpl($path, $tpl, "template/"); 106 107 #Apply a template definition 108 $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); 109 $renderer->setRequiredTemplate('{$label} <font color="red" size="1">*</font>'); 110 $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}'); 111 $form->accept($renderer); 112 $tpl->assign('form', $renderer->toArray()); 113 $tpl->assign('o', $o); 114 $tpl->display("AddHostDowntime.ihtml"); 115 } 116 } 117 } else { 36 118 require_once("./alt_error.php"); 37 else {38 $data = array("host_id" => getMyHostID($host_name), "start" => date("Y/m/d G:i" , time() + 120), "end" => date("Y/m/d G:i", time() + 7320));39 40 #41 ## Database retrieve information for differents elements list we need on the page42 #43 44 $hosts = array(""=>"");45 $DBRESULT =& $pearDB->query("SELECT host_id, host_name, host_template_model_htm_id FROM `host` WHERE host_register = '1' ORDER BY host_name");46 if (PEAR::isError($DBRESULT))47 print "AddHostDowntime - RQ 1 : Mysql Error : ".$DBRESULT->getMessage();48 while ($host =& $DBRESULT->fetchRow()){49 if (!$host["host_name"])50 $host["host_name"] = getMyHostName($host["host_template_model_htm_id"]);51 if (isset($lcaHostByName["LcaHost"][$host["host_name"]]) || $is_admin)52 $hosts[$host["host_id"]]= $host["host_name"];53 }54 $DBRESULT->free();55 56 $debug = 0;57 $attrsTextI = array("size"=>"3");58 $attrsText = array("size"=>"30");59 $attrsTextarea = array("rows"=>"7", "cols"=>"100");60 61 #62 ## Form begin63 #64 65 $form = new HTML_QuickForm('Form', 'post', "?p=".$p);66 if ($o == "ah")67 $form->addElement('header', 'title', _("Add a Host downtime"));68 #69 ## Indicator basic information70 #71 72 $redirect =& $form->addElement('hidden', 'o');73 $redirect->setValue($o);74 75 $selHost =& $form->addElement('select', 'host_id', _("Host Name"), $hosts);76 $form->addElement('checkbox', 'persistant', _("Fixed"));77 $form->addElement('text', 'start', _("Start Time"), $attrsText);78 $form->addElement('text', 'end', _("End Time"), $attrsText);79 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea);80 81 $form->addRule('host_id', _("Required Field"), 'required');82 $form->addRule('end', _("Required Field"), 'required');83 $form->addRule('start', _("Required Field"), 'required');84 $form->addRule('comment', _("Required Field"), 'required');85 86 $form->setDefaults($data);87 $subA =& $form->addElement('submit', 'submitA', _("Save"));88 $res =& $form->addElement('reset', 'reset', _("Reset"));89 90 if ((isset($_POST["submitA"]) && $_POST["submitA"]) && $form->validate()) {91 if (!isset($_POST["persistant"]))92 $_POST["persistant"] = 0;93 if (!isset($_POST["comment"]))94 $_POST["comment"] = 0;95 AddHostDowntime($_POST["host_id"], $_POST["comment"], $_POST["start"], $_POST["end"], $_POST["persistant"]);96 require_once("viewDowntime.php");97 } else {98 # Smarty template Init99 $tpl = new Smarty();100 $tpl = initSmartyTpl($path, $tpl, "template/");101 102 #Apply a template definition103 $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);104 $renderer->setRequiredTemplate('{$label} <font color="red" size="1">*</font>');105 $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}');106 $form->accept($renderer);107 $tpl->assign('form', $renderer->toArray());108 $tpl->assign('o', $o);109 $tpl->display("AddHostDowntime.ihtml");110 }111 119 } 112 120 ?> -
trunk/centreon/www/include/monitoring/downtime/AddSvcDowntime.php
r6646 r6691 18 18 if (!isset($oreon)) 19 19 exit(); 20 21 $actions = false; 22 $actions = verifyActionsACLofUser("service_schedule_downtime"); 23 $GroupListofUser = getGroupListofUser($pearDB); 20 24 21 $LCA_error = 0; 22 if (!$is_admin){ 23 $lcaHostByName = getLcaHostByName($pearDB); 24 } 25 if ($actions == true || count($GroupListofUser) == 0) { 26 $LCA_error = 0; 27 if (!$is_admin){ 28 $lcaHostByName = getLcaHostByName($pearDB); 29 } 30 31 isset($_GET["host_id"]) ? $cG = $_GET["host_id"] : $cG = NULL; 32 isset($_POST["host_id"]) ? $cP = $_POST["host_id"] : $cP = NULL; 33 $cG ? $host_id = $cG : $host_id = $cP; 25 34 26 isset($_GET["host_id"]) ? $cG = $_GET["host_id"] : $cG = NULL; 27 isset($_POST["host_id"]) ? $cP = $_POST["host_id"] : $cP = NULL; 28 $cG ? $host_id = $cG : $host_id = $cP; 29 30 $svc_description = NULL; 31 32 if (isset($_GET["host_name"]) && isset($_GET["service_description"])){ 33 $host_id = getMyHostID($_GET["host_name"]); 34 if (!isset($lcaHostByName["LcaHost"][$_GET["host_name"]]) && !$is_admin) 35 $LCA_error = 1; 36 $service_id = getMyServiceID($_GET["service_description"], $host_id); 37 $host_name = $_GET["host_name"]; 38 $svc_description = $_GET["service_description"]; 39 } else 40 $host_name = NULL; 41 42 if ($LCA_error) 35 $svc_description = NULL; 36 37 if (isset($_GET["host_name"]) && isset($_GET["service_description"])){ 38 $host_id = getMyHostID($_GET["host_name"]); 39 if (!isset($lcaHostByName["LcaHost"][$_GET["host_name"]]) && !$is_admin) 40 $LCA_error = 1; 41 $service_id = getMyServiceID($_GET["service_description"], $host_id); 42 $host_name = $_GET["host_name"]; 43 $svc_description = $_GET["service_description"]; 44 } else 45 $host_name = NULL; 46 47 if ($LCA_error) 48 require_once("./alt_error.php"); 49 else { 50 $data = array("host_id" => $host_id, "service_id" => getMyServiceID($svc_description, $host_id),"start" => date("Y/m/d G:i" , time() + 120), "end" => date("Y/m/d G:i", time() + 7320)); 51 52 # 53 ## Database retrieve information for differents elements list we need on the page 54 # 55 $hosts = array(""=>""); 56 $DBRESULT =& $pearDB->query("SELECT host_id, host_name, host_template_model_htm_id FROM `host` WHERE host_register = '1' ORDER BY host_name"); 57 if (PEAR::isError($DBRESULT)) 58 print "AddSvcDonwtime RQ 1 - Mysql Error : ".$DBRESULT->getMessage(); 59 while ($host =& $DBRESULT->fetchRow()){ 60 if (!$host["host_name"]) 61 $host["host_name"] = getMyHostName($host["host_template_model_htm_id"]); 62 if (isset($lcaHostByName["LcaHost"][$host["host_name"]]) || $is_admin) 63 $hosts[$host["host_id"]]= $host["host_name"]; 64 } 65 $DBRESULT->free(); 66 67 $services = array(); 68 if (isset($host_id)) 69 $services = getMyHostServices($host_id); 70 71 $debug = 0; 72 $attrsTextI = array("size"=>"3"); 73 $attrsText = array("size"=>"30"); 74 $attrsTextarea = array("rows"=>"7", "cols"=>"100"); 75 76 # 77 ## Form begin 78 # 79 80 $form = new HTML_QuickForm('Form', 'post', "?p=".$p); 81 $form->addElement('header', 'title', _("Add a Service downtime")); 82 83 # 84 ## Indicator basic information 85 # 86 87 $redirect =& $form->addElement('hidden', 'o'); 88 $redirect->setValue($o); 89 90 $selHost =& $form->addElement('select', 'host_id', _("Host Name"), $hosts, array("onChange" =>"this.form.submit();")); 91 $selSv =& $form->addElement('select', 'service_id', _("Services"), $services); 92 $form->addElement('checkbox', 'persistant', _("Fixed")); 93 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea); 94 95 $form->addElement('text', 'start', _("Start Time"), $attrsText); 96 $form->addElement('text', 'end', _("End Time"), $attrsText); 97 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea); 98 99 $form->addRule('host_id', _("Required Field"), 'required'); 100 $form->addRule('service_id', _("Required Field"), 'required'); 101 $form->addRule('end', _("Required Field"), 'required'); 102 $form->addRule('start', _("Required Field"), 'required'); 103 $form->addRule('comment', _("Required Field"), 'required'); 104 105 $form->setDefaults($data); 106 107 $subA =& $form->addElement('submit', 'submitA', _("Save")); 108 $res =& $form->addElement('reset', 'reset', _("Reset")); 109 110 if ((isset($_POST["submitA"]) && $_POST["submitA"]) && $form->validate()) { 111 if (!isset($_POST["persistant"])) 112 $_POST["persistant"] = 0; 113 if (!isset($_POST["comment"])) 114 $_POST["comment"] = 0; 115 AddSvcDowntime($_POST["host_id"], $_POST["service_id"], $_POST["comment"], $_POST["start"], $_POST["end"], $_POST["persistant"]); 116 require_once("viewDowntime.php"); 117 } else { 118 # Smarty template Init 119 $tpl = new Smarty(); 120 $tpl = initSmartyTpl($path, $tpl, "template/"); 121 122 #Apply a template definition 123 $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl); 124 $renderer->setRequiredTemplate('{$label} <font color="red" size="1">*</font>'); 125 $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}'); 126 $form->accept($renderer); 127 $tpl->assign('form', $renderer->toArray()); 128 $tpl->assign('o', $o); 129 $tpl->display("AddSvcDowntime.ihtml"); 130 } 131 } 132 } else { 43 133 require_once("./alt_error.php"); 44 else {45 $data = array("host_id" => $host_id, "service_id" => getMyServiceID($svc_description, $host_id),"start" => date("Y/m/d G:i" , time() + 120), "end" => date("Y/m/d G:i", time() + 7320));46 47 #48 ## Database retrieve information for differents elements list we need on the page49 #50 $hosts = array(""=>"");51 $DBRESULT =& $pearDB->query("SELECT host_id, host_name, host_template_model_htm_id FROM `host` WHERE host_register = '1' ORDER BY host_name");52 if (PEAR::isError($DBRESULT))53 print "AddSvcDonwtime RQ 1 - Mysql Error : ".$DBRESULT->getMessage();54 while ($host =& $DBRESULT->fetchRow()){55 if (!$host["host_name"])56 $host["host_name"] = getMyHostName($host["host_template_model_htm_id"]);57 if (isset($lcaHostByName["LcaHost"][$host["host_name"]]) || $is_admin)58 $hosts[$host["host_id"]]= $host["host_name"];59 }60 $DBRESULT->free();61 62 $services = array();63 if (isset($host_id))64 $services = getMyHostServices($host_id);65 66 $debug = 0;67 $attrsTextI = array("size"=>"3");68 $attrsText = array("size"=>"30");69 $attrsTextarea = array("rows"=>"7", "cols"=>"100");70 71 #72 ## Form begin73 #74 75 $form = new HTML_QuickForm('Form', 'post', "?p=".$p);76 $form->addElement('header', 'title', _("Add a Service downtime"));77 78 #79 ## Indicator basic information80 #81 82 $redirect =& $form->addElement('hidden', 'o');83 $redirect->setValue($o);84 85 $selHost =& $form->addElement('select', 'host_id', _("Host Name"), $hosts, array("onChange" =>"this.form.submit();"));86 $selSv =& $form->addElement('select', 'service_id', _("Services"), $services);87 $form->addElement('checkbox', 'persistant', _("Fixed"));88 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea);89 90 $form->addElement('text', 'start', _("Start Time"), $attrsText);91 $form->addElement('text', 'end', _("End Time"), $attrsText);92 $form->addElement('textarea', 'comment', _("Comments"), $attrsTextarea);93 94 $form->addRule('host_id', _("Required Field"), 'required');95 $form->addRule('service_id', _("Required Field"), 'required');96 $form->addRule('end', _("Required Field"), 'required');97 $form->addRule('start', _("Required Field"), 'required');98 $form->addRule('comment', _("Required Field"), 'required');99 100 $form->setDefaults($data);101 102 $subA =& $form->addElement('submit', 'submitA', _("Save"));103 $res =& $form->addElement('reset', 'reset', _("Reset"));104 105 if ((isset($_POST["submitA"]) && $_POST["submitA"]) && $form->validate()) {106 if (!isset($_POST["persistant"]))107 $_POST["persistant"] = 0;108 if (!isset($_POST["comment"]))109 $_POST["comment"] = 0;110 AddSvcDowntime($_POST["host_id"], $_POST["service_id"], $_POST["comment"], $_POST["start"], $_POST["end"], $_POST["persistant"]);111 require_once("viewDowntime.php");112 } else {113 # Smarty template Init114 $tpl = new Smarty();115 $tpl = initSmartyTpl($path, $tpl, "template/");116 117 #Apply a template definition118 $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);119 $renderer->setRequiredTemplate('{$label} <font color="red" size="1">*</font>');120 $renderer->setErrorTemplate('<font color="red">{$error}</font><br />{$html}');121 $form->accept($renderer);122 $tpl->assign('form', $renderer->toArray());123 $tpl->assign('o', $o);124 $tpl->display("AddSvcDowntime.ihtml");125 }126 134 } 127 135 ?> -
trunk/centreon/www/include/monitoring/downtime/template/downtime.ihtml
r6646 r6691 2 2 <form action="" method='GET'> 3 3 <hidden name="p" value='{$p}'> 4 <table class="ListTable"><tr class='ListHeader'><td> <img src='./img/icones/16x16/warning.gif'> {$dtm_host_downtime}</td>{if !$nb_downtime_host}<td align='right'> <a href="{$msgh.addL}">{$msgh.addT}</a></td>{/if}</tr></table><br />4 <table class="ListTable"><tr class='ListHeader'><td> <img src='./img/icones/16x16/warning.gif'> {$dtm_host_downtime}</td>{if !$nb_downtime_host}<td align='right'>{if $msgh}<a href="{$msgh.addL}">{$msgh.addT}</a>{/if}</td>{/if}</tr></table><br /> 5 5 {if $nb_downtime_host} 6 6 <table class="ListTable"> … … 39 39 </form> 40 40 <br> 41 <table class="ListTable"><tr class='ListHeader'><td> <img src='./img/icones/16x16/warning.gif'> {$dtm_service_downtime}</td>{if !$nb_downtime_svc}<td align='right'> <a href="{$msgs.addL}">{$msgs.addT}</a></td>{/if}</tr></table><br />41 <table class="ListTable"><tr class='ListHeader'><td> <img src='./img/icones/16x16/warning.gif'> {$dtm_service_downtime}</td>{if !$nb_downtime_svc}<td align='right'>{if $msgs}<a href="{$msgs.addL}">{$msgs.addT}</a></td>{/if}</tr></table><br />{/if} 42 42 {if $nb_downtime_svc} 43 43 <form action="" method='GET'> -
trunk/centreon/www/include/monitoring/downtime/viewDowntime.php
r6646 r6691 18 18 if (!isset($oreon)) 19 19 exit(); 20 21 /* 22 * ACL Actions 23 */ 24 $GroupListofUser = array(); 25 $GroupListofUser = getGroupListofUser($pearDB); 26 27 $allActions = false; 28 if(count($GroupListofUser) > 0 && isUserAdmin($pearDB) == 1) { 29 $authorized_actions = array(); 30 $authorized_actions = getActionsACLList($GroupListofUser); 31 } 32 else { 33 $allActions = true; 34 } 20 35 21 36 /* … … 104 119 $form->setDefaults($tab); 105 120 121 if(isset($authorized_actions) && $allActions == false){ 122 foreach($authorized_actions as $action_name) { 123 if($action_name == "host_schedule_downtime") $tpl->assign('msgh', array ("addL"=>"?p=".$p."&o=ah", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); 124 if($action_name == "service_schedule_downtime") $tpl->assign('msgs', array ("addL"=>"?p=".$p."&o=as", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); 125 } 126 } else { 106 127 $tpl->assign('msgh', array ("addL"=>"?p=".$p."&o=ah", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); 107 128 $tpl->assign('msgs', array ("addL"=>"?p=".$p."&o=as", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?"))); 129 } 130 108 131 $tpl->assign("p", $p); 109 132
