Code

Updated registered device plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 15 Sep 2010 13:49:52 +0000 (13:49 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 15 Sep 2010 13:49:52 +0000 (13:49 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19689 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/admin/systems/goto/devices/class_registeredDevice.inc
gosa-plugins/goto/admin/systems/goto/devices/registeredDevice.tpl
gosa-plugins/goto/admin/systems/goto/devices/registeredDeviceTab.inc

index c947f5b5e17bf051393f3dbfada3dc407bbba132..52d1bcc971c9d1ca8eb5278c90ecff4eb55a7f5f 100644 (file)
@@ -8,6 +8,28 @@ class registeredDevice extends plugin
     public $attributes = array("cn","serialNumber","seeAlso","owner","ou","o",
             "l","description","manager","deviceUUID","deviceStatus");
 
+    public $cn = "";
+    public $serialNumber = "";
+    public $seeAlso = "";
+    public $owner = "";
+    public $ou = "";
+    public $o = "";
+    public $l = "";
+    public $description = "";
+    public $manager = "";
+    public $deviceUUID = "";
+    public $deviceStatus = "";
+
+    public $base = "";
+    public $orig_dn ="";
+
+    function __construct(&$config, $dn)
+    {
+        plugin::plugin($config, $dn);
+        $this->base = $this->config->current['BASE'];
+        $this->orig_dn = $this->dn;
+    }
+
     function execute()
     {
         plugin::execute();    
@@ -26,7 +48,13 @@ class registeredDevice extends plugin
         $ldap=$this->config->get_ldap_link();
         $ldap->cd($this->config->current['BASE']);
         $ldap->cd($this->dn);
-        $ldap->modify($this->attrs);
+        
+        if($this->initially_was_account){
+            $ldap->modify($this->attrs);
+        }else{
+            $ldap->add($this->attrs);
+        }
+        echo $ldap->get_error();
     }
 
 
index af1561f46447222c634ccd1e40c914517c1531b7..6ab332f4b125b296f197ae322f3b75302128cbe9 100644 (file)
@@ -1,13 +1,13 @@
 <h3>{t}Registered device{/t}</h3>
 
-<br> <input type="text" name="cn" value="{$cn}">
-<br> <input type="text" name="serialNumber" value="{$serialNumber}">
-<br> <input type="text" name="seeAlso" value="{$seeAlso}">
-<br> <input type="text" name="owner" value="{$owner}">
-<br> <input type="text" name="ou" value="{$ou}">
-<br> <input type="text" name="o" value="{$o}">
-<br> <input type="text" name="l" value="{$l}">
-<br> <input type="text" name="description" value="{$description}">
-<br> <input type="text" name="manager" value="{$manager}">
-<br> <input type="text" name="deviceUUID" value="{$deviceUUID}">
-<br> <input type="text" name="deviceStatus" value="{$deviceStatus}">
+<br>Name: <input type="text" name="cn" value="{$cn}">
+<br>Serial number <input type="text" name="serialNumber" value="{$serialNumber}">
+<br>See also <input type="text" name="seeAlso" value="{$seeAlso}">
+<br>Owner <input type="text" name="owner" value="{$owner}">
+<br>Organizational unit <input type="text" name="ou" value="{$ou}">
+<br>Organization <input type="text" name="o" value="{$o}">
+<br>Location <input type="text" name="l" value="{$l}">
+<br>Description <input type="text" name="description" value="{$description}">
+<br>Manager <input type="text" name="manager" value="{$manager}">
+<br>UUid <input type="text" name="deviceUUID" value="{$deviceUUID}">
+<br>Status <input type="text" name="deviceStatus" value="{$deviceStatus}">
index 14e8fc483a8658eb42b049f328adb58d73d7d0eb..fa902b0dd3fbf15b3cfdac42bc6c223ad19a384a 100644 (file)
@@ -2,7 +2,33 @@
 
 class registeredDeviceTab extends tabs
 {
-}
 
+    
+    
+    function save($ignore_account= FALSE)
+    {
+        // Prepare object DN
+        $baseobject= $this->by_object['registeredDevice'];
+        $cn      = preg_replace('/,/', '\,', $baseobject->cn);
+        $cn      = preg_replace('/"/', '\"', $cn);
+        $this->dn= "cn=".$cn.",ou=systems,".$baseobject->base;
+        $baseobject->dn= $this->dn;
+
+        // Object moved?
+        if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
+            $baseobject->update_acls($baseobject->orig_dn,$this->dn);
+            $baseobject->move($baseobject->orig_dn,$this->dn);
+        }
+
+        // Populate values 
+        foreach ($this->by_object as $key => $obj){
+            $this->by_object[$key]->dn= $this->dn;
+            $this->by_object[$key]->cn= $baseobject->cn;
+        }
+
+        // Save now
+        tabs::save(TRUE);
+    }
+}
 
 ?>