Code

Updated a couple of values
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_printGeneric.inc
index d2febbb8d6d8efb0a44a244770267c8323fe63df..46aa1f1f8b472dda1934e45113d3b409b57a2fcb 100644 (file)
@@ -15,6 +15,8 @@ class printgeneric extends plugin
   var $gotoPrinterPPD   = "";
   var $initial_PPD      = "";
   var $orig_dn          = "";
+  var $orig_cn          = "";
+  var $orig_base        = "";
 
   var $UserMember       ="";
   var $UserMembers      =array();
@@ -122,14 +124,13 @@ class printgeneric extends plugin
       /* $this->members contains all members */
       $this->member[$type]=array();
 
-      if (isset($this->attrs[$attr]['count'])) {
-        unset($this->attrs[$attr]['count']);
-      }
-
       if(isset($this->attrs[$attr])){
-        foreach($this->attrs[$attr] as $mem){
+        $ldap->cd($this->config->current['BASE']) ;
+        for($i = 0 ;  $i < $this->attrs[$attr]['count']; $i++){
+        
+          $mem = $this->attrs[$attr][$i];
           if(preg_match("/Group/",$type)){
-            $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description"));
+            $ldap->search("(&(|(objectClass=posixGroup)(objectClass=gosaGroupOfNames))(cn=".$mem."))",array("cn","description"));
             if($ldap->count()){
               $entry = $ldap->fetch();
               $this->member[$type][$entry['cn'][0]]=$entry;
@@ -144,6 +145,8 @@ class printgeneric extends plugin
         }
       }
     }
+    $this->orig_cn    = $this->cn;
+    $this->orig_base  = $this->base;
   }
 
   function set_acl_base($base)
@@ -310,14 +313,14 @@ class printgeneric extends plugin
 
     /* Do we represent a valid printer? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
         msgPool::noValidExtension(_("printer"))."</b>";
       return($display);
     }
 
     /* If this is a WS / Terminal depending printer, display account state button */
     if(!preg_match("/^Printer$/i",$this->BelongsTo)){
-      if((empty($this->cn)) && ($this->dn != "new")){
+      if($this->cn == "" && ($this->dn != "new")){
         $display= $this->show_enable_header(_("Add printer extension"),
             msgPool::featuresDisabled(_("printer"))._("You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template."),TRUE,TRUE);
         $this->is_account= false;
@@ -498,9 +501,8 @@ class printgeneric extends plugin
 
     /* Parse selected ppd file */
     $config = session::get('config');
-    if((isset($config->data['MAIN']['PPD_PATH']))&&(is_dir($config->data['MAIN']['PPD_PATH']))){
-
-      $path = $config->data['MAIN']['PPD_PATH'];
+    if ($config->get_cfg_value("ppdPath") != ""){
+      $path = $config->get_cfg_value("ppdPath");
       if(!preg_match("/\/$/",$path)){
         $path = $path."/";
       }
@@ -664,7 +666,7 @@ class printgeneric extends plugin
     $dn= "cn=".$this->cn.get_ou('printerou').",".$this->base;
 
     /* must: cn */
-    if(($this->BelongsTo == "Printer") && (empty($this->cn))){
+    if(($this->BelongsTo == "Printer") && $this->cn == ""){
       $message[]= msgPool::required(_("Name"));
     }
 
@@ -696,6 +698,14 @@ class printgeneric extends plugin
       }
     }
 
+    /* Check if we are allowed to create or move this object
+     */
+    if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+      $message[] = msgPool::permCreate();
+    }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+      $message[] = msgPool::permMove();
+    }
+
     return ($message);
   }
 
@@ -767,7 +777,7 @@ class printgeneric extends plugin
    
     /* Get servername */
     $server = $_SERVER['SERVER_NAME'];
-    if(TESTS::is_ip($server)){  
+    if(tests::is_ip($server)){  
       $server_name = gethostbyaddr($server);
     }else{
       $server_name = gethostbyaddr(gethostbyname($server));