Code

Updated sudo
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 Apr 2008 07:13:43 +0000 (07:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 Apr 2008 07:13:43 +0000 (07:13 +0000)
-DSpecial handling for default entries

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10266 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/sudo/admin/sudo/class_divListSudo.inc
gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
gosa-plugins/sudo/admin/sudo/generic.tpl

index a02d5a24c6b1ed9a0729ceee82142742b2b90b39..fa135f12031adc3c1ba9abfbccf85aeac2c23a2c 100644 (file)
@@ -167,6 +167,12 @@ class divListSudo extends MultiSelectWindow
       }
 
       $display = $val['cn'][0].$desc;
+     
+      /* Highlight default entry */ 
+      if(preg_match("/^default$/i",$val['cn'][0])){
+        $display = "<b>$display</b>";
+      }
+
       $field1 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
           "attach" => "style='width:20px;'");
       $field2 = array("string" => sprintf($userimg,$val['dn']), 
index 807315c952c845fd6e9bb6ae32d9ce20803ffec6..7af22e569453f9572b2cfd7d5dc95c457bb8c2de 100644 (file)
@@ -43,7 +43,7 @@ class sudo extends plugin
   var $attributes    = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunAs","accessTo","trustModel");
 
   var $is_account = TRUE;
-
+  var $is_default = FALSE;
   var $dialog;
 
   /*! \brief  Returns to the base department for sudo roles.
@@ -114,6 +114,10 @@ class sudo extends plugin
 
     }
 
+    if(preg_match("/^default$/i",$this->cn)){
+      $this->is_default = TRUE;
+    }
+
     /* Get global filter config */
     if (!session::is_set("sysfilter")){
       $ui= get_userinfo();
@@ -318,6 +322,7 @@ class sudo extends plugin
      *********************/
 
     $smarty = get_smarty();
+    $smarty->assign("is_default",$this->is_default);
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
       $smarty->assign($attr."ACL",$this->getacl($attr));
@@ -499,6 +504,27 @@ class sudo extends plugin
   function check()
   {
     $message = plugin::check();
+
+    /* Is a name given? */
+    if(empty($this->cn)){
+      $message[] = msgPool::required(_("Name"));
+    }
+
+    /* Check name */
+    if(!preg_match("/^[a-z]*$/i",$this->cn)){
+      $message[] = msgPool::invalid(_("Name"),$this->cn,"/[a-z]/i");
+    }
+
+    /* Check if this entry will cause duplicated ldap entries */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->get_sudoers_ou($this->config));
+    $ldap->search("(&(objectClass=sudoRole)(cn=".$this->cn."))");
+    while($attrs = $ldap->fetch()){
+      if($attrs['dn'] != $this->dn){
+        $message[] = msgPool::duplicated(_("Name"));
+      }
+    }
+
     return ($message);
   }
 
index 08450eefa75899376ac628f2d492878f62c7b9a0..d437576122d7120c5a5b7c827921cd824f80e7a0 100644 (file)
@@ -1,7 +1,35 @@
+{if $is_default}
+
+<h2>{t}Sudo generic{/t} - {t}Global defaults{/t}</h2>
+<table> 
+ <tr>
+  <td>
+   {t}Name{/t}
+  </td>
+  <td>
+   {render acl=$cnACL}
+   <input type="text" name="cn" value="{$cn}">
+   {/render}
+  </td>
+ </tr>
+ <tr>
+  <td>
+   {t}Description{/t}
+  </td>
+  <td>
+   {render acl=$descriptionACL}
+   <input type="text" name="description" value="{$description}">
+   {/render}
+  </td>
+ </tr>
+</table>
+
+{else}
+
 <table style="width: 90%;">
  <tr>
   <td style="vertical-align:top;width:50%">
-   <h2>Sudo generic</h2>
+   <h2>{t}Sudo generic{/t}</h2>
    <table> 
     <tr>
      <td>
   </td>
  </tr>
 </table>
+{/if}