Code

Updated a couple of messages
[gosa.git] / gosa-plugins / goto / admin / systems / goto / Device / class_Device.inc
index a6a8a42fa46e7bd40fb12855a792fcbc467c0d31..7308ae53d80ddc722e6ffdd68d1958154052242e 100644 (file)
@@ -40,8 +40,23 @@ class Device extends plugin
     function __construct(&$config, $dn)
     {
         plugin::plugin($config, $dn);
-        $this->base = $this->config->current['BASE'];
         $this->orig_dn = $this->dn;
+
+        // Initialize the object base 
+        if ($this->dn == "new"){
+            $ui= get_userinfo();
+            $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn);
+        } else {
+            $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("Device", "DeviceRDN"), '/')."/i", "", $this->dn);
+        }
+
+        // Prepare the base selector
+        $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
+        $this->baseSelector->setSubmitButton(false);
+        $this->baseSelector->setHeight(300);
+        $this->baseSelector->update(true);
+
+        $this->orig_deviceUUID = $this->deviceUUID;
     }
 
     
@@ -77,9 +92,11 @@ class Device extends plugin
         // Assign just user names instead of the complete dn.
         $smarty->assign("owner_name", $this->getUserName($this->owner));
         $smarty->assign("manager_name", $this->getUserName($this->manager));
+        $smarty->assign("base", $this->baseSelector->render());
 
+        // Assign attribute values 
         foreach($this->attributes as $attr){
-            $smarty->assign($attr, $this->$attr);
+            $smarty->assign($attr, set_post($this->$attr));
         }
         return($smarty->fetch(get_template_path('goto/Device/Device.tpl', TRUE)));
     }
@@ -114,7 +131,7 @@ class Device extends plugin
         }
 
         // Check mac-address
-        if (!empty($this->ipHostNumber) && !tests::is_ip($this->macAddress)){
+        if (!empty($this->macAddress) && !tests::is_mac($this->macAddress)){
             $message[]= msgPool::invalid(_("MAC address"), "", "", "00:0C:7F:31:33:F1");
         }
  
@@ -193,6 +210,18 @@ class Device extends plugin
       
         // Regenerate a new uuid 
         if(isset($_POST['reloadUUID']))  $this->deviceUUID = $this->genFakeUuid();
+
+        // Update the base 
+        if ($this->acl_is_moveable($this->base)){
+            if (!$this->baseSelector->update()) {
+                msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
+            }
+            if ($this->base != $this->baseSelector->getBase()) {
+                $this->base= $this->baseSelector->getBase();
+                $this->is_modified= TRUE;
+            }
+        }
+
     }
 
 
@@ -216,6 +245,7 @@ class Device extends plugin
         $this->cleanup();
         $ldap=$this->config->get_ldap_link();
         $ldap->cd($this->config->current['BASE']);
+        $ldap->create_missing_trees(preg_replace("/^[^,]*+,/","",$this->dn));
         $ldap->cd($this->dn);
 
         // Perform action modify/create
@@ -248,11 +278,15 @@ class Device extends plugin
                     "plDepends"     => array(),
                     "plPriority"    => 1,
                     "plSection"     => array("administration"),
-                    "plCategory"    => array(
+                    "plCategory"    => 
+                    array(
                         "Device" => array( 
                             "description"  => _("Device"),
-                            "objectClass"  => "Device")),
-                    "plProvidedAcls" => array(
+                            "objectClass"  => "Device")
+                        ),
+                    "plProvidedAcls" => 
+                    array(
+                        "base" => _("Base"),
                         "cn" => _("Name"),
                         "serialNumber" => _("Serial number"),
                         "seeAlso" => _("See also"),
@@ -262,14 +296,28 @@ class Device extends plugin
                         "l" => _("Location"),
                         "description" => _("Description"),
                         "manager" => _("Manager"),
-                        "deviceUUID" => _("Uuid"),
+                        "deviceUUID" => _("UUID"),
                         "deviceStatus" => _("Status"),
                         "deviceType" => _("Type"),
                         "macAddress" => _("MAC address"),
                         "ipHostNumber" => _("IP address")
-                        )
-                        )
-                        );
+                        ),
+            "plProperties" =>
+                array(
+                        array(
+                            "name"          => "DeviceRDN",
+                            "type"          => "rdn",
+                            "default"       => "ou=devices,ou=systems,",
+                            "description"   => _("RDN for device storage."),
+                            "check"         => "gosaProperty::isRdn",
+                            "migrate"       => "migrate_deviceRDN",
+                            "group"         => "plugin",
+                            "mandatory"     => FALSE
+                            ),
+
+                     )
+                )
+                );
     }
 }