From: hickert Date: Thu, 29 Jul 2010 09:04:19 +0000 (+0000) Subject: Updated csv import X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a6560059830ba3f996b5bbddc9df4191b8086a8c;p=gosa.git Updated csv import -Fixed problems using templates git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6@19204 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc index c720903ce..fb0c41db2 100644 --- a/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc +++ b/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc @@ -169,29 +169,27 @@ class csvimport extends plugin $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], 'new'); $keys = array_keys($dat); - /* Set all submitted vars */ - if(is_array($keys)) + if(is_array($keys)){ foreach($keys as $key) { if($key != "status"){ $this->usertab->$key = $dat[$key]; + foreach($this->usertab->by_object as $pname => $plugin){ + if(isset($this->usertab->by_object[$pname]->$key)){ + $this->usertab->by_object[$pname]->$key = $dat[$key]; + } + } } } + } - /* Initialize template */ + // Adapt template values. if($this->csvinfo['tplid']!=0){ - $this->usertab->adapt_from_template($this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']); - $this->usertab->save_object(); - } else { - - /* Reset vars */ - if(is_array($keys)) - foreach($keys as $key) { - if($key != "status"){ - $this->usertab->by_object['user']->$key = $dat[$key]; - } - } - } + $tpl_dn = $this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']; + $this->usertab->adapt_from_template($tpl_dn,array("uid","cn","givenName","sn")); + $tpl_base = preg_replace("/^[^,]+,".preg_quote(get_people_ou(), '/i')."/", '', $tpl_dn); + $this->usertab->by_object['user']->base= $tpl_base; + } // Setting user Password if((isset($dat['userPassword']))&&(!empty($dat['userPassword']))){