Code

Fixed printer acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Sep 2006 05:57:56 +0000 (05:57 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Sep 2006 05:57:56 +0000 (05:57 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4588 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/tabs_printers.inc
plugins/personal/environment/class_environment.inc

index 803ea881eee9dc08180f6c7327a1a60c5c332b60..ee40925c0800f33cfe8d4e378984cc9ffd2470b4 100644 (file)
@@ -840,7 +840,7 @@ class printgeneric extends plugin
       return(FALSE);
     }
 
-    if(!$this->acl_is_writeable($type)){
+    if(!$this->acl_is_writeable("gotoUserPrinter")){
       print_red(sprintf(_("You are not allowed to add the given object '%s' to the list of members of '%s'."),$dn,$this->dn));
       return(FALSE);
     }
@@ -854,22 +854,38 @@ class printgeneric extends plugin
 
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($dn);
-    $ldap->cat($dn,array("cn","uid"));
+    $ldap->cat($dn,array($var));
     if($ldap->count()){
 
       $attrs = $ldap->fetch();
-      $name = $attrs[$var][0];
-  
-      /* Check if this uid/cn is already assigned to any permission */
-      foreach($types as $ctype){
-        if(isset(  $this->member[$ctype][$name])){
-          print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0]));
-          return(FALSE);
+
+      if(isset($attrs[$var][0])){
+        $name = $attrs[$var][0];
+
+        /* Check if this uid/cn is already assigned to any permission */
+        foreach($types as $ctype){
+
+          /* If we want to add a user, only check user/userAdmin members */
+          if((preg_match("/user/i",$type)) && (!preg_match("/user/i",$ctype))){
+            continue;
+          }
+
+          /* If we want to add a group, only check groups/adminGroups .. */
+          if((preg_match("/group/i",$type)) && (!preg_match("/group/i",$ctype))){
+            continue;
+          }
+
+          if(isset(  $this->member[$ctype][$name])){
+            print_red(sprintf(_("Can't add '%s' to the list of members, it is already used."),$attrs[$var][0]));
+            return(FALSE);
+          }
         }
-      }
 
-      /* Everything is fine. So add the given object to members */
-      $this->member[$type][$attrs[$var][0]] = $attrs ;
+        /* Everything is fine. So add the given object to members */
+        $this->member[$type][$attrs[$var][0]] = $attrs ;
+      }else{
+        print_a($attrs);
+      }
     }else{
       print_red(sprintf(_("Can't add '%s' to list of members, it is not reachable."),$dn));
       return(FALSE);
index cf1360ecfbaf0f3ed680c59df969e312769436de..2c264234e377fc88542a3e3c6caf0b64a56ab9cb 100644 (file)
@@ -3,7 +3,7 @@
 class printtabs extends tabs
 {
 
-  function printtabs($config, $data, $dn)
+  function printtabs($config, $data, $dn,$category)
   {
     /* Save dn */
     $this->dn= $dn;
@@ -14,10 +14,12 @@ class printtabs extends tabs
         $this->by_name[$tab['CLASS']]= $tab['NAME'];
         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn,$this);
         $this->by_object[$tab['CLASS']]->parent= &$this;
+        $this->by_object[$tab['CLASS']]->set_acl_category($category);
       }else{
         $this->by_name[$tab['CLASS']]= $tab['NAME'];
         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn);
         $this->by_object[$tab['CLASS']]->parent= &$this;
+        $this->by_object[$tab['CLASS']]->set_acl_category($category);
       }
       /* Initialize current */
       if ($this->current == ""){
index 79bc8679a8446c57379fede19d37722317f46e00..f0cee0e46106c67082dd7364c5c7cedea32d567d 100644 (file)
@@ -749,7 +749,16 @@ class environment extends plugin
         $tmp2= $this->dialog->getPrinter(true);
 
         foreach($tmp as $pname){
-        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn']);
+        $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer");
+        $printerObj->set_acl_base($tmp2[$pname]['dn']);
+
+        if($this->is_group){
+          if($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){
+            $this->gotoPrinter[$pname]=$tmp2[$pname];
+            $this->gotoPrinter[$pname]['mode']="user";
+            $this->add_del_printer_member_was_called = true;
+          }
+        }else{
           if($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
             $this->gotoPrinter[$pname]=$tmp2[$pname];
             $this->gotoPrinter[$pname]['mode']="user";
@@ -757,6 +766,8 @@ class environment extends plugin
           }
         }
 
+        }
+
         $this->is_dialog=false;
         unset($this->dialog);
         $this->dialog   =NULL;