From: hickert Date: Wed, 29 Sep 2010 09:03:37 +0000 (+0000) Subject: Updated device handling X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=84a25eb9e1d9191921c59fb86faf8285c4377516;p=gosa.git Updated device handling - git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19843 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc b/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc index 4775ed0d6..86f09f792 100644 --- a/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc +++ b/gosa-plugins/goto/admin/systems/goto/Device/DeviceTab.inc @@ -6,32 +6,49 @@ class DeviceTab extends tabs { // Prepare object DN $baseobject= $this->by_object['Device']; - $uuid = preg_replace('/,/', '\,', $baseobject->deviceUUID); + $uuid = $baseobject->deviceUUID; + $orig_uuid = $baseobject->orig_deviceUUID; + $rdn = get_ou('Device','DeviceRDN'); - if(empty($uuid)){ - $cn = preg_replace('/,/', '\,', $baseobject->cn); - $cn = preg_replace('/"/', '\"', $cn); - $this->dn= "cn=".$cn.",".$rdn.$baseobject->base; - }else{ - $this->dn= "deviceUUID=".$uuid.",".$rdn.$baseobject->base; - } - $baseobject->dn= $this->dn; + $cn = preg_replace('/,/', '\,', $baseobject->cn); + $cn = preg_replace('/"/', '\"', $cn); - // 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); + $dnCn = "cn=".$cn.",".$rdn.$baseobject->base; + $dnUuid= "deviceUUID=".$uuid.",".$rdn.$baseobject->base; + + // Save object using the 'cn' in the dn and then move it to 'uuid'; + $moveToUUID = FALSE; + if(!empty($uuid) && empty($orig_uuid) && $baseobject->orig_dn != "new"){ + $moveToUUID = TRUE; } + // Detect target dn + $this->dn = (empty($uuid)) ? $dnCn : $dnUuid; + + if($moveToUUID) $this->dn = $dnCn; + // Populate values foreach ($this->by_object as $key => $obj){ $this->by_object[$key]->dn= $this->dn; $this->by_object[$key]->cn= $baseobject->cn; } + // 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); + } + // Save now tabs::save(TRUE); + + if($moveToUUID){ + $this->dn = (empty($uuid)) ? $dnCn : $dnUuid; + $baseobject->update_acls($baseobject->orig_dn,$this->dn); + $baseobject->move($baseobject->orig_dn,$this->dn); + } + } } diff --git a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc b/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc index 7995b8b7c..8f54646bc 100644 --- a/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc +++ b/gosa-plugins/goto/admin/systems/goto/Device/class_Device.inc @@ -55,6 +55,8 @@ class Device extends plugin $this->baseSelector->setSubmitButton(false); $this->baseSelector->setHeight(300); $this->baseSelector->update(true); + + $this->orig_deviceUUID = $this->deviceUUID; } @@ -94,7 +96,7 @@ class Device extends plugin // 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))); } @@ -129,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"); } @@ -243,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