Code

Invalid repository settings fixed.
[gosa.git] / plugins / admin / systems / class_printGeneric.inc
index 61a0e71e3c1b17fdaeeced50bccd68cbb8b2a300..dea5899fdd2f1881f367cf2c323c6eaa12630a83 100644 (file)
@@ -30,7 +30,9 @@ class printgeneric extends plugin
   var $AdminMember      ="";
   var $AdminMembers     =array();
   var $AdminMemberKeys  =array();
-  
+
+  var $is_terminalBased = false; 
   var $member           =array();
   var $strings          = "";
   var $type             = "";
@@ -50,6 +52,7 @@ class printgeneric extends plugin
       $ui= get_userinfo();
       $this->base= dn2base($ui->dn);
       $this->cn= "";
+      $this->is_terminal = true;
     } else {
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
@@ -59,11 +62,11 @@ class printgeneric extends plugin
      * in case of gotoTerminal it is called from a terminal tab
      * else it is a standalone printer
      */
-    if((in_array("gotoWorkstation",$this->attrs['objectClass']))){
+    if((isset($this->attrs['objectClass']))&&(in_array("gotoWorkstation",$this->attrs['objectClass']))){
       $this->is_terminal = "true";   
       $this->dn   = preg_replace("/ou=workstation/","ou=printer",$this->dn);
       $this->type = "station";
-    }elseif((in_array("gotoTerminal",$this->attrs['objectClass']))){
+    }elseif((isset($this->attrs['objectClass']))&&(in_array("gotoTerminal",$this->attrs['objectClass']))){
       $this->type = "terminal";
       $this->is_terminal = "true";
       $this->dn   = preg_replace("/ou=terminal/","ou=printer",$this->dn);
@@ -120,6 +123,18 @@ class printgeneric extends plugin
         }
       }
     }
+  
+    $ldap->search("(&(cn=".$this->cn.")(|(objectClass=gotoTerminal)(objectClass=gotoWorkstation)))",array("cn","objectClass"));
+    if($attrs = $ldap->fetch()){
+      if(in_array("gotoTerminal",$attrs['objectClass'])){
+        $this->is_terminalBased = "Terminal";
+      }else{
+        $this->is_terminalBased = "Workstation";
+      }
+    }
+
+
+
   }
 
   function execute()
@@ -148,23 +163,37 @@ class printgeneric extends plugin
     }
 
     if($this->is_terminal){
-      if ($this->is_account){
-        if($this->type=="station"){
-          $display= $this->show_header(_("Remove printer extension"),
-              _("This workstation has printer extension enabled. You can disable it by clicking below."));
+      if(empty($this->cn)){
+        if(!in_array("gotoPrinter",$this->objectclasses)){
+          $display= $this->show_header(_("Add printer extension"),
+              _("This workstation has printer extension disabled. 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;
+          return $display;
         }else{
-          $display= $this->show_header(_("Remove printer extension"),
-              _("This terminal has printer extension enabled. You can disable it by clicking below."));
+          $smarty->assign("is_terminal","false");
+          $skip = true;
         }
-      }else{
-        if($this->type=="station"){
-          $display= $this->show_header(_("Add printer extension"),
-              _("This workstation has printer extension disabled. You can enable it by clicking below."));
+      }
+
+      if(!isset($skip)){
+        if (($this->is_account)){
+          if($this->type=="station"){
+            $display= $this->show_header(_("Remove printer extension"),
+                _("This workstation has printer extension enabled.You can disable it by clicking below."));
+          }else{
+            $display= $this->show_header(_("Remove printer extension"),
+                _("This terminal has printer extension enabled. You can disable it by clicking below."));
+          }
         }else{
-          $display= $this->show_header(_("Add printer extension"),
-              _("This terminal has printer extension disabled. You can enable it by clicking below."));
-        }  
-        return ($display);
+          if($this->type=="station"){
+            $display= $this->show_header(_("Add printer extension"),
+                _("This workstation has printer extension disabled. You can enable it by clicking below."));
+          }else{
+            $display= $this->show_header(_("Add printer extension"),
+                _("This terminal has printer extension disabled. You can enable it by clicking below."));
+          }  
+          return ($display);
+        }
       }
     }
 
@@ -185,7 +214,7 @@ class printgeneric extends plugin
       $smarty->assign($attr."ACL", chkacl($this->acl, $attr));
       $smarty->assign("$attr", $this->$attr);
     }
-    
+
     if(isset($_POST['AddUser'])){
       $this->dialog = new selectUserToPrinterDialog($this->config, get_userinfo(),"AddUser");
     }
@@ -221,7 +250,7 @@ class printgeneric extends plugin
       }
 
     }
-    
+
     if(isset($_POST['ClosePPD'])){
       unset($this->dialog);
       $this->dialog=NULL;
@@ -299,7 +328,16 @@ class printgeneric extends plugin
 
     asort($userlist);
     asort($adminlist);
-
+    if($this->is_terminalBased){
+      if($this->is_terminalBased == "Terminal"){
+        $smarty->assign("desc"    ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+      }else{
+        $smarty->assign("desc"    ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
+      }
+      $smarty->assign("cnACL"    ," disabled ");
+    }else{
+      $smarty->assign("desc"    ,"");
+    }
     $smarty->assign("UserMember"    ,$this->UserMember);
     $smarty->assign("UserMembers"   ,$userlist);
     $smarty->assign("UserMemberKeys",array_flip($userlist));