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