Code

Updated device naming
[gosa.git] / gosa-plugins / goto / admin / systems / goto / Device / DeviceTab.inc
1 <?php
3 class DeviceTab extends tabs
4 {
5     function save($ignore_account= FALSE)
6     {
7         // Prepare object DN
8         $baseobject= $this->by_object['Device'];
9         $uuid = $baseobject->deviceUUID;
10         $orig_uuid = $baseobject->orig_deviceUUID;
13         $rdn = get_ou('Device','DeviceRDN');
14         $cn      = preg_replace('/,/', '\,', $baseobject->cn);
15         $cn      = preg_replace('/"/', '\"', $cn);
17         $dnCn = "cn=".$cn.",".$rdn.$baseobject->base;
18         $dnUuid= "deviceUUID=".$uuid.",".$rdn.$baseobject->base;
20         // Save object using the 'cn' in the dn and then move it to 'uuid';
21         $moveToUUID = FALSE;
22         if(!empty($uuid) && empty($orig_uuid) && $baseobject->orig_dn != "new"){
23             $moveToUUID = TRUE;
24         }
26         // Detect target dn
27         $this->dn = (empty($uuid)) ? $dnCn : $dnUuid;
29         if($moveToUUID) $this->dn = $dnCn;
31         // Populate values 
32         foreach ($this->by_object as $key => $obj){
33             $this->by_object[$key]->dn= $this->dn;
34             $this->by_object[$key]->cn= $baseobject->cn;
35         }
37         // Object moved?
38         if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
39             $baseobject->update_acls($baseobject->orig_dn,$this->dn);
40             $baseobject->move($baseobject->orig_dn,$this->dn);
41             $baseobject->orig_dn = $this->dn;
42         }
44         // Save now
45         tabs::save(TRUE);
47         if($moveToUUID){
48             $this->dn = (empty($uuid)) ? $dnCn : $dnUuid;
49             $baseobject->update_acls($baseobject->orig_dn,$this->dn);
50             $baseobject->move($baseobject->orig_dn,$this->dn);
51         }
53     }
54 }
56 ?>