Code

Added devices
[gosa.git] / gosa-plugins / systems / admin / systems / class_componentGeneric.inc
index dbd26c814ced2f56530ce1c165686396a2739638..b3ff77e38c4df28568bca1ea8d2d5cb9496def74 100644 (file)
@@ -31,6 +31,8 @@ class componentGeneric extends plugin
   var $cn= "";
   var $description= "";
   var $orig_dn= "";
+  var $orig_cn= "";
+  var $orig_base= "";
 
   /* attribute list for save action */
   var $attributes= array("cn", "description");
@@ -48,11 +50,14 @@ class componentGeneric extends plugin
       $this->base= dn2base($ui->dn);
       $this->cn= "";
     } else {
-      $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+      $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("componentRDN"), '/')."/i", "", $this->dn);
     }
     $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, true);
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
+
+    $this->orig_base = $this->base;
+    $this->orig_cn = $this->cn;
   }
 
 
@@ -68,8 +73,8 @@ class componentGeneric extends plugin
 
     /* Do we represent a valid phone? */
     if (!$this->is_account && $this->parent === NULL){
-      $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
-        _("This 'dn' has no network features.")."</b>";
+      $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
+        msgPool::noValidExtension(_("component"))."</b>";
       return($display);
     }
 
@@ -198,7 +203,7 @@ class componentGeneric extends plugin
     $message= plugin::check();
     $message= array_merge($message,$this->netConfigDNS->check());
 
-    $this->dn= "cn=".$this->cn.",".get_ou('componentou').$this->base;
+    $this->dn= "cn=".$this->cn.",".get_ou('componentRDN').$this->base;
 
     if ($this->cn == "" ){
       $message[]= msgPool::required(_("Component name"));
@@ -227,7 +232,7 @@ class componentGeneric extends plugin
           if(preg_match("/cn=dhcp,/",$attrs['dn'])){
             continue;
           }
-          if ($attrs['dn'] != $this->orig_dn){
+          if ($attrs['dn'] != $this->orig_dn && preg_match("/".preg_quote(get_ou("componentRDN"), '/')."/i",$attrs['dn'])){
             $message[]= msgPool::duplicated(_("Component name"));
             break;
           }
@@ -235,6 +240,14 @@ class componentGeneric 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);
   }
 
@@ -274,10 +287,6 @@ class componentGeneric extends plugin
       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
       
     } else {
-      if ($this->orig_dn != $this->dn){
-        $this->move($this->orig_dn, $this->dn);
-      }
-
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
@@ -308,7 +317,8 @@ class componentGeneric extends plugin
           "plProvidedAcls"=> array(
             "cn"                  => _("Name"),
             "base"                => _("Base"),
-            "description"         => _("Description"))
+            "description"         => _("Description"),
+            "userPassword"      => _("Root password"))
           ));
   }
 
@@ -345,6 +355,13 @@ class componentGeneric extends plugin
       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
     }
   }
+
+
+  function is_modal_dialog()
+  {
+    return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
+  }
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: