Code

Added servrepository acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Dec 2006 11:29:49 +0000 (11:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 1 Dec 2006 11:29:49 +0000 (11:29 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5286 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servRepository.inc
plugins/admin/systems/servRepository.tpl

index 98c8bcb928e214ce7e102fcee965466e8f120876..2277e4793883f43f4564f932ff09ee9ba9cbe98d 100644 (file)
@@ -26,6 +26,10 @@ class servrepository extends plugin
   {
     plugin::plugin ($config, $dn, $parent);
 
+    $ui = get_userinfo();
+    $tmp= get_permissions ($this->dn, $ui->subtreeACL);
+    $this->acl= get_module_permission($tmp, "FAIclass", $this->dn);
+    
     $this->repositories = array();
     if(isset($this->attrs['FAIrepository'])){
       for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
@@ -106,18 +110,20 @@ class servrepository extends plugin
        ADD / EDIT Repository
        Dialog Handling
      */
+      
+    $allow_edit = chkacl($this->acl,"FAIclass") == "";
 
     $once = false;
     if(isset($_POST['servRepository'])){
       foreach($_POST as $name => $value){
 
-        if(preg_match("/AddRepository/",$name)){
+        if(preg_match("/AddRepository/",$name) && !$once && $allow_edit){
           $once = true;
           $this->dialog = new servRepositorySetup($this->config,$this->dn);
           $this->dialog->acl = $this->acl;
         }
 
-        if((preg_match("/^delete_/",$name))&&(!$once)){
+        if((preg_match("/^delete_/",$name))&&(!$once) && $allow_edit){
           $once = true;
           $value = preg_replace("/delete_/","",$name);
           $value = base64_decode(preg_replace("/_.*$/","",$value));
@@ -150,7 +156,7 @@ class servrepository extends plugin
           }
         }
 
-        if((preg_match("/^edit_/",$name))&&(!$once)){
+        if((preg_match("/^edit_/",$name))&&(!$once) && $allow_edit){
           $value = preg_replace("/edit_/","",$name);
           $value = base64_decode(preg_replace("/_.$/","",$value));
 
@@ -192,7 +198,7 @@ class servrepository extends plugin
         }
       }
     }
-    if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id']))){
+    if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id'])) && $allow_edit){
       $obj = $this->repositories[base64_decode($_GET['id'])];
       $obj['initialy_was'] = $obj['Release'];
       $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
@@ -261,23 +267,32 @@ class servrepository extends plugin
     foreach($this->repositories as $name => $reps){
 
       $str = " ";
-
       if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){
-    
 
       foreach($reps['Sections'] as $sec){
         $str.=$sec." ";  
       }    
-  
+
+      if($allow_edit){
+        $link_str = sprintf($link,base64_encode($name),$name);
+        $sections = sprintf($link,base64_encode($name),_("Sections")." :".$str);
+        $options  = preg_replace("/%s/",base64_encode($name),$edit.$delete);
+      }else{
+        $link_str = $name;
+        $sections = _("Sections")." :".$str;
+        $options  = "";
+      }
+    
       $divlist->AddEntry(array(
-                              array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
-                              array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
-                              array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
-                              ));
+                              array("string"=>$link_str,"attach"=>"style='width:80px;'"),
+                              array("string"=>$sections),
+                              array("string"=>$options,"attach"=>"style='border-right:0px;width:55px;text-align:right;'")));
       }
     }
  
     $smarty -> assign("Repositories",$divlist->DrawList());
+    $smarty -> assign("FAIclassACL",chkacl($this->acl,"FAIclass"));
 
     $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE));
     return($display);
@@ -324,6 +339,9 @@ class servrepository extends plugin
   /* Save to LDAP */
   function save()
   {
+   
+    /* Skip if not allowed */ 
+    if(preg_match("/disabled/",chkacl($this->acl,"FAIclass"))) return;
     plugin::save();
 
     $arr = array();
index 8213703a2d3249193e7c0e53b7009f9da1c20742..fe738b9a68c3e35ba32fcb92b9fa077d941ac2c7 100644 (file)
@@ -8,7 +8,9 @@
   </div>
   <div class="contentboxb">
        <div style='background:#F0F0F9;padding:5px;'>
-<input type="image" src="images/fai_new_packages.png" title="{t}Add repository{/t}" name="AddRepository">
+{if $FAIclassACL == ""}
+       <input type="image" src="images/fai_new_packages.png" title="{t}Add repository{/t}" name="AddRepository">
+{/if}
        </div>
 </div>
 <div style='height:4px;'></div>