index c852f48bf4c903b7b28303a4a3a6ce56f80d91eb..588a9e0bef73c33fd103395fa4d766b48527dd65 100644 (file)
unset($this->saved_attributes[$index]);
continue;
}
- if (isset($this->saved_attributes[$index][0]) && $this->saved_attributes[$index]["count"] == 1){
- $tmp= $this->saved_attributes[$index][0];
- unset($this->saved_attributes[$index]);
- $this->saved_attributes[$index]= $tmp;
- continue;
- }
+ if (isset($this->saved_attributes[$index][0])){
+ if(!isset($this->saved_attributes[$index]["count"])){
+ $this->saved_attributes[$index]["count"] = count($this->saved_attributes[$index]);
+ }
+ if($this->saved_attributes[$index]["count"] == 1){
+ $tmp= $this->saved_attributes[$index][0];
+ unset($this->saved_attributes[$index]);
+ $this->saved_attributes[$index]= $tmp;
+ continue;
+ }
+ }
unset($this->saved_attributes["$index"]["count"]);
}
if(isset($this->attrs['gosaUnitTag'])){
}
/* Adapt from template, using 'dn' */
- function adapt_from_template($dn)
+ function adapt_from_template($dn, $skip= array())
{
/* Include global link_info */
$ldap= $this->config->get_ldap_link();
/* Walk through attributes */
foreach ($this->attributes as $val){
+ /* Skip the ones in skip list */
+ if (in_array($val, $skip)){
+ continue;
+ }
+
if (isset($this->attrs["$val"][0])){
/* If attribute is set, replace dynamic parts:
if ($command != ""){
- /* Additional attributes */
- foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name( |$)/", "$value ", $command);
- }
-
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
+ $add_attrs[$attr] = $this->$attr;
}
}
- $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+ $add_attrs['dn']=$this->dn;
+
+ $tmp = array();
+ foreach($add_attrs as $name => $value){
+ $tmp[$name] = strlen($name);
+ }
+ arsort($tmp);
+
+ /* Additional attributes */
+ foreach ($tmp as $name => $len){
+ $value = $add_attrs[$name];
+ $command= preg_replace("/%$name/", "$value", $command);
+ }
if (check_command($command)){
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
exec($command);
} else {
- $message[]= msgPool::cmdnotfound("POSTCREATE", get_class($this));
+ $message= msgPool::cmdnotfound("POSTCREATE", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
if ($command != ""){
- /* Additional attributes */
- foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name( |$)/", "$value ", $command);
- }
-
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
+ $add_attrs[$attr] = $this->$attr;
}
}
- $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+ $add_attrs['dn']=$this->dn;
- if (check_command($command)){
- @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
- $command, "Execute");
+ $tmp = array();
+ foreach($add_attrs as $name => $value){
+ $tmp[$name] = strlen($name);
+ }
+ arsort($tmp);
+
+ /* Additional attributes */
+ foreach ($tmp as $name => $len){
+ $value = $add_attrs[$name];
+ $command= preg_replace("/%$name/", "$value", $command);
+ }
+ if (check_command($command)){
+ @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,$command, "Execute");
exec($command);
} else {
- $message[]= msgPool::cmdnotfound("POSTMODIFY", get_class($this));
+ $message= msgPool::cmdnotfound("POSTMODIFY", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
$command= $this->config->search(get_class($this), "POSTREMOVE",array('menu','tabs'));
if ($command != ""){
- /* Additional attributes */
- foreach ($add_attrs as $name => $value){
- $command= preg_replace("/%$name( |$)/", "$value ", $command);
- }
-
/* Walk through attribute list */
foreach ($this->attributes as $attr){
if (!is_array($this->$attr)){
- $command= preg_replace("/%$attr( |$)/", $this->$attr." ", $command);
+ $add_attrs[$attr] = $this->$attr;
}
}
- $command= preg_replace("/%dn( |$)/", $this->dn." ", $command);
+ $add_attrs['dn']=$this->dn;
+
+ $tmp = array();
+ foreach($add_attrs as $name => $value){
+ $tmp[$name] = strlen($name);
+ }
+ arsort($tmp);
+
+ /* Additional attributes */
+ foreach ($tmp as $name => $len){
+ $value = $add_attrs[$name];
+ $command= preg_replace("/%$name/", "$value", $command);
+ }
if (check_command($command)){
@DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
exec($command);
} else {
- $message[]= msgPool::cmdnotfound("POSTREMOVE", get_class($this));
+ $message= msgPool::cmdnotfound("POSTREMOVE", get_class($this));
msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
}
}
foreach ($this->config->adepartments as $key => $ntag){
/* This one is bigger than our dn, its not relevant... */
- if ($len <= strlen($key)){
+ if ($len < strlen($key)){
continue;
}
$password = $tmp['SNAPSHOT_PASSWORD'];
$snapldapbase = $tmp['SNAPSHOT_BASE'];
- $ldap_to = new ldapMultipelxer(new LDAP($user,$password, $server));
+ $ldap_to = new ldapMultiplexer(new LDAP($user,$password, $server));
$ldap_to -> cd($snapldapbase);
if (!$ldap_to->success()){
$data = gzuncompress($ldap_to->get_attribute($dn,'gosaSnapshotData'));
/* Import the given data */
+ $err = "";
$ldap->import_complete_ldif($data,$err,false,false);
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, "", get_class()));