Code

Nagios (delete, add and modify account) -> OK
authorguiguidoc <guiguidoc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 15:30:27 +0000 (15:30 +0000)
committerguiguidoc <guiguidoc@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Oct 2005 15:30:27 +0000 (15:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1490 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/nagios/class_nagiosAccount.inc
plugins/personal/nagios/main.inc
plugins/personal/nagios/nagios.tpl

index 25466ed4079c793acb5f4022e8c76de5ce9fd476..bdf59f93a2a32fba87bc1570f9f77fa9e9aa456b 100644 (file)
@@ -3,6 +3,7 @@
 /*! \brief   mail plugin
   \author  Guillame Delecourt <guillaume@opensides.be>
   \author  Benoit Mortier <benoit.mortier@opensides.be>
+  \author  Vincent Seynhaeve <vincent@opensides.be>  
   \version 1.00
   \date    25.09.2005
 
@@ -49,7 +50,7 @@ class nagiosAccount extends plugin
       "AuthorizedSystemCommands", "AuthorizedAllHostCommands", "AuthorizedAllServiceCommands",
       "AuthorizedConfigurationInformation", "AuthorizedSystemInformation");
 
-  var $objectclasses= array("nagiosContact");
+  var $objectclasses= array("nagiosContact","nagiosAuth");
 
   /* constructor, if 'dn' is set, the node loads the given
        'dn' from LDAP */
@@ -69,7 +70,7 @@ class nagiosAccount extends plugin
     /* Load templating engine */
     $smarty= get_smarty();
     $display= "";
-            
+
          /* Do we need to flip is_account state? */
          if (isset($_POST['modify_state'])){
            $this->is_account= !$this->is_account;
@@ -104,6 +105,12 @@ class nagiosAccount extends plugin
     $smarty->assign("$val", $this->$val);
     $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
     }
+    $smarty->assign('ServiceNotificationOptionsValues',array("d,u,r,v" ,"d,u,r" ,"d,u"));
+    $smarty->assign('HostNotificationOptionsValues',array("w,u,c,r" ,"w,u,c" ,"c,w"));
+
+
+    $smarty->assign('ServiceNotificationPeriodValues',array("24x7" ,"24x5" ,"8x5"));
+    $smarty->assign('HostNotificationPeriodValues',array("24x7" ,"24x5" ,"8x5"));
 
        $display.= $smarty->fetch (get_template_path('nagios.tpl', TRUE, dirname(__FILE__)));
            return ($display);
@@ -122,8 +129,21 @@ class nagiosAccount extends plugin
     //$method= new $this->method($this->config);
     //$id= $method->uattrib;
     //$method->fixAttributesOnStore($this);
-                
 
+       $check="unchecked";
+       if(isset($_POST['AuthorizedSystemInformation'])){$check="checked";}$this->attrs['AuthorizedSystemInformation']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedConfigurationInformation'])){$check="checked";}$this->attrs['AuthorizedConfigurationInformation']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedSystemCommands'])){$check="checked";}$this->attrs['AuthorizedSystemCommands']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedAllServices'])){$check="checked";}$this->attrs['AuthorizedAllServices']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedAllHosts'])){$check="checked";}$this->attrs['AuthorizedAllHosts']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedAllServiceCommands'])){$check="checked";}$this->attrs['AuthorizedAllServiceCommands']=$check;
+       $check="unchecked";
+       if(isset($_POST['AuthorizedAllHostCommands'])){$check="checked";}$this->attrs['AuthorizedAllHostCommands']=$check;
          /* Write back to ldap */
          $ldap->cd($this->dn);
          $ldap->modify($this->attrs);
@@ -142,6 +162,25 @@ class nagiosAccount extends plugin
 
   function check()
   {
+    $message= array();
+    $ldap= $this->config->get_ldap_link();
+    /* must: mail */
+    if ($this->NagiosAlias == ""){
+      $message[]= _("The required field 'NagiosAlias' is not set.");
+    }
+    if ($this->NagiosMail == ""){
+      $message[]= _("The required field 'NagiosMail' is not set.");
+    }
+    if ($this->is_template){
+      if (!is_email($this->NagiosMail, TRUE)){
+        $message[]= _("Please enter a valid email address in 'NagiosMail' field.");
+      }
+    } else {
+      if (!is_email($this->NagiosMail)){
+        $message[]= _("Please enter a valid email address in 'NagiosMail' field.");
+      }
+    }
+       return($message);
   }
   
   function save_object()
@@ -167,8 +206,8 @@ class nagiosAccount extends plugin
     plugin::remove_from_parent();
 
     /* Adapt attributes if needed */
-    $method= new $this->method($this->config);
-    $method->fixAttributesOnRemove($this);
+//     $method= new $this->method($this->config);
+//     $method->fixAttributesOnRemove($this);
     
 
     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
index 23983ec637176ac38d1a58cda02b5ec9cac2fa46..a2c3489c7e34e35dcf10895f0a70d129acb40a17 100644 (file)
@@ -73,7 +73,7 @@ if (!$remove_lock){
     /* No errors, save object */
     if (count ($message) == 0){
       $nagiosAccount->save ();
-      gosa_log ("User/mail object'".$ui->dn."' has been saved");
+      gosa_log ("User/nagios object'".$ui->dn."' has been saved");
       $nagiosAccount->acl= "#none#";
       del_lock ($ui->dn);
       sess_del ('edit');
index 7bc1891deb489474872f930436b52ff19fda937c..737b2d7285a3eff89af1b7bc2f6780bbed314d27 100644 (file)
@@ -1,6 +1,6 @@
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
  <tr>
-  <td style="width:50%; vertical-align:top;">
+  <td style="width:40%; vertical-align:top;">
    <h2><img alt="" align="middle" src="images/rightarrow.png"> {t}Nagios Account{/t}</h2>
    <table summary="">
     <tr>
@@ -9,46 +9,78 @@
     </tr>
 
     <tr>
-     <td><LABEL for="NagiosEmail">{t}email{/t}</LABEL>{$must}</td>
-     <td><input id="NagiosEmail" name="NagiosEmail" size=25 maxlength=65 {$NagiosEmailACL} value="{$NagiosEmail}"></td>
+     <td><LABEL for="NagiosMail">{t}email{/t}</LABEL>{$must}</td>
+     <td><input id="NagiosMail" name="NagiosMail" size=25 maxlength=65 {$NagiosMailACL} value="{$NagiosMail}"></td>
     </tr>
 
-    <tr>
-     <td><LABEL for="NagiosPager">{t}pager{/t}</LABEL></td>
-     <td><input id="NagiosPager" name="NagiosPager" size=25 maxlength=65 {$NagiosPagerACL} value="{$NagiosPager}"></td>
-    </tr>
+       <tr>
+       <td><LABEL for="HostNotificationPeriod">{t}Host Notification Period{/t}</LABEL>{$must}</td>
+       <td><select name="HostNotificationPeriod" id="HostNotificationPeriod">
+       {html_options options=$HostNotificationPeriodValues values=$HostNotificationPeriodValues selected=$HostNotificationPeriod }
+       </select>
+       </td>
+       </tr>
 
-    <tr>
-     <td><LABEL for="ServiceNotificationPeriod">{t}Service Notification Period{/t}</LABEL>{$must}</td>
-     <td><input id="ServiceNotificationPeriod" name="ServiceNotificationPeriod" size=25 maxlength=65 {$ServiceNotificationPeriodACL} value="{$ServiceNotificationPeriod}"></td>
-    </tr>
+       <tr>
+       <td><LABEL for="ServiceNotificationPeriod">{t}Service Notification Period{/t}</LABEL>{$must}</td>
+       <td><select name="ServiceNotificationPeriod" id="ServiceNotificationPeriod">
+       {html_options options=$ServiceNotificationPeriodValues values=$ServiceNotificationPeriodValues selected=$ServiceNotificationPeriod}
+       </select>
+       </td>
+       </tr>
+       <tr>
+       <td><LABEL for="ServiceNotificationOptions">{t}Service Notification Options{/t}</LABEL>{$must}</td>
+       <td><select name="ServiceNotificationOptions" id="ServiceNotificationOptions">
+       {html_options options=$ServiceNotificationOptionsValues values=$ServiceNotificationOptionsValues selected=$ServiceNotificationOptions}
+       </select>
+       </td>
+       </tr>
 
-    <tr>
-     <td><LABEL for="ServiceNotificationOptions">{t}Service Notification Options{/t}</LABEL>{$must}</td>
-     <td><input id="ServiceNotificationOptions" name="ServiceNotificationOptions" size=25 maxlength=65 {$ServiceNotificationOptionsACL} value="{$ServiceNotificationOptions}"></td>
-    </tr>
 
+       <tr>
+       <td><LABEL for="HostNotificationOptions">{t}Host Notification Options{/t}</LABEL>{$must}</td>
+       <td><select name="HostNotificationOptions" id="HostNotificationOptions">
+       {html_options options=$HostNotificationOptionsValues values=$HostNotificationOptionsValues selected=$HostNotificationOptions }
+       </select>
+       </td>
+       </tr>
     <tr>
-     <td><LABEL for="ServiceNotificationCommands">{t}Service Notification Commands{/t}</LABEL>{$must}</td>
-     <td><input id="ServiceNotificationCommands" name="ServiceNotificationCommands" size=25 maxlength=65 {$ServiceNotificationCommandsACL} value="{$ServiceNotificationCommands}"></td>
+     <td><LABEL for="NagiosPager">{t}pager{/t}</LABEL></td>
+     <td><input id="NagiosPager" name="NagiosPager" size=25 maxlength=65 {$NagiosPagerACL} value="{$NagiosPager}"></td>
     </tr>
 
     <tr>
-     <td><LABEL for="HostNotificationPeriod">{t}Host Notification Period{/t}</LABEL>{$must}</td>
-     <td><input id="HostNotificationPeriod" name="HostNotificationPeriod" size=25 maxlength=65 {$HostNotificationPeriodACL} value="{$HostNotificationPeriod}"></td>
+     <td><LABEL for="ServiceNotificationCommands">{t}Service Notification Commands{/t}</LABEL></td>
+     <td><input id="ServiceNotificationCommands" disabled name="ServiceNotificationCommands" size=25 maxlength=65 {$ServiceNotificationCommandsACL} value="{$ServiceNotificationCommands}"></td>
     </tr>
-
     <tr>
-     <td><LABEL for="HostNotificationOptions">{t}Host Notification Options{/t}</LABEL>{$must}</td>
-     <td><input id="HostNotificationOptions" name="HostNotificationOptions" size=25 maxlength=65 {$HostNotificationOptionsACL} value="{$HostNotificationOptions}"></td>
+     <td><LABEL for="HostNotificationCommands">{t}Host Notification Commands{/t}</LABEL></td>
+     <td><input id="HostNotificationCommands" disabled name="HostNotificationCommands" size=25 maxlength=65 {$HostNotificationCommandsACL} value="{$HostNotificationCommands}"></td>
     </tr>
+</table>
+</td>
+  <td style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+<td style="width:100%; vertical-align:top;">
+   <h2><img alt="" align="middle" src="images/rightarrow.png"> {t}Nagios Auth{/t}</h2>
+   <table summary="">
+       <input type="checkbox" name="AuthorizedSystemInformation" value="{$AuthorizedSystemInformation}"  {$AuthorizedSystemInformation}>{t}authorized_for_system_information{/t}<br />
+       
+       <input type="checkbox" name="AuthorizedConfigurationInformation" {$AuthorizedConfigurationInformationACL} value="{$AuthorizedConfigurationInformation}" {$AuthorizedConfigurationInformation}>authorized_for_configuration_information<br />
+       
+       <input type="checkbox" name="AuthorizedSystemCommands" {$AuthorizedSystemCommandsACL} value="{$AuthorizedSystemCommands}" {$AuthorizedSystemCommands}>authorized_for_system_commands<br />
+       
+       <input type="checkbox" name="AuthorizedAllServices" {$AuthorizedAllServicesACL} value="{$AuthorizedAllServices}" {$AuthorizedAllServices}>authorized_for_all_services<br />
+       
+       <input type="checkbox" name="AuthorizedAllHosts" {$AuthorizedAllHostsACL} value="{$AuthorizedAllHosts}" {$AuthorizedAllHosts}>authorized_for_all_hosts<br />
+       
+       <input type="checkbox" name="AuthorizedAllServiceCommands" {$AuthorizedAllServiceCommandsACL} value="{$AuthorizedAllServiceCommands}" {$AuthorizedAllServiceCommands}>authorized_for_all_service_commands<br />
+       
+       <input type="checkbox" name="AuthorizedAllHostCommands" {$AuthorizedAllHostCommandsACL} value="{$AuthorizedAllHostCommands}" {$AuthorizedAllHostCommands}>authorized_for_all_host_commands<br />
 
-    <tr>
-     <td><LABEL for="HostNotificationCommands">{t}Host Notification Period{/t}</LABEL>{$must}</td>
-     <td><input id="HostNotificationCommands" name="HostNotificationCommands" size=25 maxlength=65 {$HostNotificationCommandsACL} value="{$HostNotificationCommands}"></td>
-    </tr>
-       </table>
-  
+   </table>
+</td>
 
 </table>