From: cajus Date: Thu, 26 May 2005 16:12:06 +0000 (+0000) Subject: Code layout fixes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c12a16de7d2173a0e41723101c08eb463d6c8a9f;p=gosa.git Code layout fixes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@471 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 74020d3c9..84eb21c1d 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -627,74 +627,71 @@ class LDAP{ /* Every block must begin with a dn */ if($dn != "dn") { - $error= sprintf(_("This is not a valid DN: '%s'. A block for import should begin with 'dn: ...' in line %s"), - $line, $current_line); + $error= sprintf(_("This is not a valid DN: '%s'. A block for import should begin with 'dn: ...' in line %s"), $line, $current_line); return -2; } - - - // Should we use Modify instead of Add - $usemodify = false; - // Delete before insert - $usermdir = false; - + /* Should we use Modify instead of Add */ + $usemodify= false; + /* Delete before insert */ + $usermdir= false; /* The dn address already exists! */ if (($this->dn_exists($value))&&((!$overwrite)&&(!$cleanup))) { + $error= sprintf(_("The dn: '%s' (from line %s) already exists in the LDAP database."), $line, $current_line); return ALREADY_EXISTING_ENTRY; - } - elseif(($this->dn_exists($value))&&($cleanup)){ - ;//Delete first, then add + + } elseif(($this->dn_exists($value))&&($cleanup)){ + + /* Delete first, then add */ $usermdir = true; - } - elseif(($this->dn_exists($value))&&($overwrite)) { - ;//Modify instead of Add + + } elseif(($this->dn_exists($value))&&($overwrite)) { + + /* Modify instead of Add */ $usemodify = true; } - /* If we can't Import, return with a file error */ if(!$this->import_single_entry($single,$usemodify,$usermdir) ) { $error= sprintf(_("Error while importing dn: '%s', please check your LDIF from line %s on!"), $line, $current_line); return UNKNOWN_TOKEN_IN_LDIF_FILE; } - } + return (INSERT_OK); } + /* Imports a single entry */ function import_single_entry($str_attr,$modify,$delete) { - - - if($this->reconnect) $this->connect(); $ret = false; + $rows= split("\n",$str_attr); + $data= false; - $rows = split("\n",$str_attr); - $data = false; foreach($rows as $row) { /* Check if we use Linenumbers (when import_complete_ldif is called we use Linenumbers) Linenumbers are use like this 123#attribute : value */ if(!empty($row)) { if((strpos($row,"#")!=FALSE)&&(strpos($row,"#")cd($data['dn']); /* Delete existing entry */ - if($delete) - $this->rmdir($data['dn']); - + if($delete){ + $this->rmdir($data['dn']); + } /* Create missing trees */ $this->create_missing_trees($data['dn']); unset($data['dn']); /* If entry exists use modify */ - if(!$modify) + if(!$modify){ $ret = $this->add($data); - else + } else { $ret = $this->modify($data); - - - + } } return($ret); @@ -751,17 +746,15 @@ class LDAP{ foreach($lines as $line) { /* continue if theres a comment */ - if(substr(trim($line),0,1)=="#") - continue; + if(substr(trim($line),0,1)=="#"){ + continue; + } $line= str_replace ("\t\t","\t",$line); $line= str_replace ("\t" ,"," ,$line); - print $line; - - + echo $line; $cells = split(",",$line ) ; - #print_a($cells); $linet= str_replace ("\t\t",",",$line); $cells = split("\t",$line); $count = count($cells);