Code

Added acls to nagios account
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 3 Aug 2006 04:02:48 +0000 (04:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 3 Aug 2006 04:02:48 +0000 (04:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4368 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 3809cb58a33b5c18751fe490a7facab21e47b587..51a522cb2798c72cd13c369d3ca834dade9a69ef 100644 (file)
@@ -82,9 +82,13 @@ class nagiosAccount extends plugin
     $display= "";
 
     /* Do we need to flip is_account state? */
-    if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
-    }
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }    
 
     /* Do we represent a valid account? */
     if (!$this->is_account && $this->parent == NULL){
@@ -106,10 +110,16 @@ class nagiosAccount extends plugin
       }
     }
 
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
+    foreach($tmp['plProvidedAcls'] as $acl => $desc){
+      $smarty->assign($acl."ACL",$this->getacl($acl,$SkipWrite));
+    }
+
     /* Assign attributes an ACL to smarty */
     foreach($this->attributes as $val) { 
       $smarty->assign("$val", $this->$val);
-      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
       if(in_array($val,$this->is_chk_box)){
         if($this->$val == "checked"){
           $smarty->assign($val."CHK", " checked ");
@@ -191,10 +201,12 @@ class nagiosAccount extends plugin
 
       /* Specialhandling for checkboxes */
       foreach($this->is_chk_box as $val){
-        if(isset($_POST[$val])){
-          $this->$val = "checked";
-        }else{
-          $this->$val = "unchecked";
+        if($this->acl_is_writeable($val)){
+          if(isset($_POST[$val])){
+            $this->$val = "checked";
+          }else{
+            $this->$val = "unchecked";
+          }
         }
       }
     }
index e707ebfd3c8bdae4f9cfa369f4f00cae1caaaf07..a3373c24207a266b70d00c8489349d82d1f90c0b 100644 (file)
@@ -54,16 +54,6 @@ if (!$remove_lock){
     $_SESSION['edit']= TRUE;
   }
 
-  /* Adjust acl's to mode */
-  if (isset($_SESSION['edit'])){
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $nagiosAccount->acl= get_module_permission($acl, "nagiosAccount", $ui->dn);
-  } else {
-    $acl= get_permissions ($ui->dn, $ui->subtreeACL);
-    $editacl= get_module_permission($acl, "nagiosAccount", $ui->dn);
-    $nagiosAccount->acl= "#none#";
-  }
-
   /* save changes to LDAP and disable edit mode */
   if (isset($_POST['edit_finish'])){
 
@@ -74,7 +64,6 @@ if (!$remove_lock){
     if (count ($message) == 0){
       $nagiosAccount->save ();
       gosa_log ("User/nagios object'".$ui->dn."' has been saved");
-      $nagiosAccount->acl= "#none#";
       del_lock ($ui->dn);
       sess_del ('edit');
 
@@ -109,11 +98,11 @@ if (!$remove_lock){
     } else {
       $info= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/openlock.png').
              "\"> ".$ui->dn."&nbsp;";
-      if (isset($editacl) && $editacl != "#none#"){
-        $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
-            "\"> "._("Click the 'Edit' button below to change informations in this dialog");
-        $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
-      }
+
+      echo "FIXME : user -> nagios, 102 Only display edit button if there is at least one attribute editable.";
+      $info.= "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lamp.png').
+        "\"> "._("Click the 'Edit' button below to change informations in this dialog");
+      $display.= "<input type=submit name=\"edit\" value=\""._("Edit")."\">\n";
 
       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
     }
index cb6262148d5a87000c1785aba33b6e5ff262d07d..555a228b9fedda18741ae050aaf3fdee10d1c873 100644 (file)
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="0" border="0">
  <tr>
   <td style="width:50%; vertical-align:top;">
-   <h2><img class="center" alt="" align="middle" src="images/rightarrow.png" />&nbsp;{t}Nagios Account{/t}</h2>
+   <h2>
+    <img class="center" alt="" align="middle" src="images/rightarrow.png" />&nbsp;{t}Nagios Account{/t}</h2>
    <table summary="">
     <tr>
      <td><label for="NagiosAlias">{t}Alias{/t}</label>{$must}</td>
-     <td><input id="NagiosAlias" name="NagiosAlias" size=25 maxlength=65 {$NagiosAliasACL} value="{$NagiosAlias}"></td>
+     <td>
+{render acl=$NagiosAliasACL}
+      <input id="NagiosAlias" name="NagiosAlias" size=25 maxlength=65 value="{$NagiosAlias}">
+{/render}
+     </td>
     </tr>
 
     <tr>
      <td><label for="NagiosMail">{t}Mail address{/t}</label>{$must}</td>
-     <td><input id="NagiosMail" name="NagiosMail" size=25 maxlength=65 {$NagiosMailACL} value="{$NagiosMail}"></td>
+     <td>
+{render acl=$NagiosMailACL}
+      <input id="NagiosMail" name="NagiosMail" size=25 maxlength=65 value="{$NagiosMail}">
+{/render}
+     </td>
     </tr>
 
-       <tr>
-       <td><label for="HostNotificationPeriod">{t}Host notification period{/t}</label>{$must}</td>
-       <td><select name="HostNotificationPeriod" id="HostNotificationPeriod" {$HostNotificationPeriodACL}>
-       {html_options options=$HostNotificationPeriodValues values=$HostNotificationPeriodValues selected=$HostNotificationPeriod }
-       </select>
-       </td>
-       </tr>
+    <tr>
+     <td>
+      <label for="HostNotificationPeriod">{t}Host notification period{/t}</label>{$must}
+     </td>
+     <td>
+{render acl=$HostNotificationPeriodACL}
+      <select name="HostNotificationPeriod" id="HostNotificationPeriod">
+       {html_options options=$HostNotificationPeriodValues values=$HostNotificationPeriodValues selected=$HostNotificationPeriod }
+      </select>
+{/render}
+     </td>
+    </tr>
 
-       <tr>
-       <td><label for="ServiceNotificationPeriod">{t}Service notification period{/t}</label>{$must}</td>
-       <td><select name="ServiceNotificationPeriod" id="ServiceNotificationPeriod" {$ServiceNotificationPeriodACL}>
-       {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" {$ServiceNotificationOptionsACL}>
-       {html_options options=$ServiceNotificationOptionsValues values=$ServiceNotificationOptionsValues selected=$ServiceNotificationOptions}
-       </select>
-       </td>
-       </tr>
+    <tr>
+     <td>
+      <label for="ServiceNotificationPeriod">{t}Service notification period{/t}</label>{$must}
+     </td>
+     <td>
+{render acl=$ServiceNotificationPeriodACL}
+      <select name="ServiceNotificationPeriod" id="ServiceNotificationPeriod">
+       {html_options options=$ServiceNotificationPeriodValues values=$ServiceNotificationPeriodValues selected=$ServiceNotificationPeriod}
+      </select>
+{/render}
+     </td>
+    </tr>
 
+    <tr>
+     <td>
+      <label for="ServiceNotificationOptions">{t}Service notification options{/t}</label>{$must}
+     </td>
+     <td>
+{render acl=$ServiceNotificationOptionsACL}
+      <select name="ServiceNotificationOptions" id="ServiceNotificationOptions">
+       {html_options options=$ServiceNotificationOptionsValues values=$ServiceNotificationOptionsValues selected=$ServiceNotificationOptions}
+      </select>
+{/render}
+     </td>
+    </tr>
 
-       <tr>
-       <td><label for="HostNotificationOptions">{t}Host notification options{/t}</label>{$must}</td>
-       <td><select name="HostNotificationOptions" id="HostNotificationOptions" {$HostNotificationOptionsACL}>
-       {html_options options=$HostNotificationOptionsValues values=$HostNotificationOptionsValues selected=$HostNotificationOptions }
-       </select>
-       </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>
+     <td>
+      <label for="HostNotificationOptions">{t}Host notification options{/t}</label>{$must}
+     </td>
+     <td>
+{render acl=$HostNotificationOptionsACL}
+      <select name="HostNotificationOptions" id="HostNotificationOptions">
+       {html_options options=$HostNotificationOptionsValues values=$HostNotificationOptionsValues selected=$HostNotificationOptions }
+      </select>
+{/render}
+     </td>
     </tr>
 
     <tr>
-     <td><label for="ServiceNotificationCommands">{t}Service notification commands{/t}</label></td>
-     <td><input id="ServiceNotificationCommands" disabled name="ServiceNotificationCommands" size=25 maxlength=65  value="{$ServiceNotificationCommands}"></td>
+     <td>
+      <label for="NagiosPager">{t}Pager{/t}</label>
+     </td>
+     <td>
+{render acl=$NagiosPagerACL}
+      <input id="NagiosPager" name="NagiosPager" size=25 maxlength=65 value="{$NagiosPager}">
+{/render}
+     </td>
     </tr>
+
     <tr>
-     <td><label for="HostNotificationCommands">{t}Host notification commands{/t}</label></td>
-     <td><input id="HostNotificationCommands" disabled name="HostNotificationCommands" size=25 maxlength=65  value="{$HostNotificationCommands}"></td>
+     <td>
+      <label for="ServiceNotificationCommands">{t}Service notification commands{/t}</label>
+     </td>
+     <td>
+{render acl=$ServiceNotificationCommandsACL}
+      <input id="ServiceNotificationCommands" disabled name="ServiceNotificationCommands" size=25 maxlength=65  value="{$ServiceNotificationCommands}">
+{/render}
+     </td>
     </tr>
-</table>
-</td>
+    <tr>
+     <td>
+      <label for="HostNotificationCommands">{t}Host notification commands{/t}</label>
+     </td>
+     <td>
+{render acl=$HostNotificationCommandsACL}
+      <input id="HostNotificationCommands" disabled name="HostNotificationCommands" size=25 maxlength=65  value="{$HostNotificationCommands}">
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
   <td style="border-left:1px solid #A0A0A0">
    &nbsp;
   </td>
-<td style="width:100%; vertical-align:top;">
-   <h2><img class="center" alt="" align="middle" src="images/rightarrow.png" />&nbsp;{t}Nagios authentification{/t}</h2>
+  <td style="width:100%; vertical-align:top;">
+   <h2> 
+    <img class="center" alt="" align="middle" src="images/rightarrow.png" />&nbsp;{t}Nagios authentification{/t}
+   </h2>
    <table summary="">
-       <tr><td><input type="checkbox" name="AuthorizedSystemInformation" value="1" {$AuthorizedSystemInformationACL}  
-{$AuthorizedSystemInformationCHK}>{t}view system informations{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedConfigurationInformation" {$AuthorizedConfigurationInformationACL} value="1" 
-{$AuthorizedConfigurationInformationCHK}>{t}view configuration information{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedSystemCommands" {$AuthorizedSystemCommandsACL} value="1" 
-{$AuthorizedSystemCommandsCHK}>{t}trigger system commands{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedAllServices" {$AuthorizedAllServicesACL} value="1" 
-{$AuthorizedAllServicesCHK}>{t}view all services{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedAllHosts" {$AuthorizedAllHostsACL} value="1" 
-{$AuthorizedAllHostsCHK}>{t}view all hosts{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedAllServiceCommands" {$AuthorizedAllServiceCommandsACL} value="1" {$AuthorizedAllServiceCommandsCHK}>{t}trigger all service commands{/t}</td></tr>
-       
-       <tr><td><input type="checkbox" name="AuthorizedAllHostCommands" {$AuthorizedAllHostCommandsACL} value="1" 
-{$AuthorizedAllHostCommandsCHK}>{t}trigger all host commands{/t}</td></tr>
-
+    <tr>
+     <td>
+{render acl=$AuthorizedSystemInformationACL}
+      <input type="checkbox" name="AuthorizedSystemInformation" value="1" {$AuthorizedSystemInformationACL}  
+       $AuthorizedSystemInformationCHK}>{t}view system informations{/t}
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td>
+{render acl=$AuthorizedConfigurationInformationACL}
+      <input type="checkbox" name="AuthorizedConfigurationInformation" {$AuthorizedConfigurationInformationACL} value="1" 
+       {$AuthorizedConfigurationInformationCHK}>{t}view configuration information{/t}
+{/render}
+     </td>
+    </tr>
+       
+    <tr>
+     <td>
+{render acl=$AuthorizedSystemCommandsACL}
+      <input type="checkbox" name="AuthorizedSystemCommands" {$AuthorizedSystemCommandsACL} value="1" 
+       {$AuthorizedSystemCommandsCHK}>{t}trigger system commands{/t}
+{/render}
+     </td>
+    </tr>
+       
+    <tr>
+     <td>
+{render acl=$AuthorizedAllServicesACL}
+      <input type="checkbox" name="AuthorizedAllServices" value="1" 
+       {$AuthorizedAllServicesCHK}>{t}view all services{/t}
+{/render}
+     </td>
+    </tr>
+       
+    <tr>
+     <td>
+{render acl=$AuthorizedAllHostsACL}
+      <input type="checkbox" name="AuthorizedAllHosts" value="1" 
+       {$AuthorizedAllHostsCHK}>{t}view all hosts{/t}
+{/render}
+     </td> 
+    </tr>
+       
+    <tr>
+     <td>
+{render acl=$AuthorizedAllServiceCommandsACL}
+      <input type="checkbox" name="AuthorizedAllServiceCommands" value="1" 
+       {$AuthorizedAllServiceCommandsCHK}>{t}trigger all service commands{/t}
+{/render}
+     </td>
+    </tr>
+       
+    <tr>
+     <td>
+{render acl=$AuthorizedAllHostCommandsACL}
+      <input type="checkbox" name="AuthorizedAllHostCommands" value="1" 
+       {$AuthorizedAllHostCommandsCHK}>{t}trigger all host commands{/t}
+{/render}
+     </td>
+    </tr>
    </table>
-</td>
-
+  </td>
+ </tr>
 </table>
 
 <input type="hidden" name="nagiosTab" value="nagiosTab">