cvs: pear /DB_ldap ldap.php

From: Date: Mon, 11 Feb 2002 12:59:37 +0000
Subject: cvs: pear /DB_ldap ldap.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2385@lists.php.net to get a copy of this message
mj Mon Feb 11 07:59:37 2002 EDT Modified files: /pear/DB_ldap ldap.php Log: * Fix some indenting. Index: pear/DB_ldap/ldap.php diff -u pear/DB_ldap/ldap.php:1.8 pear/DB_ldap/ldap.php:1.9 --- pear/DB_ldap/ldap.php:1.8 Tue Jan 22 08:25:39 2002 +++ pear/DB_ldap/ldap.php Mon Feb 11 07:59:37 2002 @@ -23,7 +23,7 @@ // - Piotr Roszatycki <Piotr_Roszatycki@netia.net.pl> // DB_ldap::base() method, support for LDAP sequences, various fixes // -// $Id: ldap.php,v 1.8 2002/01/22 13:25:39 ludoo Exp $ +// $Id: ldap.php,v 1.9 2002/02/11 12:59:37 mj Exp $ // require_once 'DB/common.php'; @@ -449,14 +449,14 @@ return $this->raiseError(); } } else { - # If first argument is an array, it contains the entry with DN. - if (is_array($filter)) { - $entry = $filter; - $filter = $entry["dn"]; - } else { - $entry = array(); - } - unset($entry["dn"]); + # If first argument is an array, it contains the entry with DN. + if (is_array($filter)) { + $entry = $filter; + $filter = $entry["dn"]; + } else { + $entry = array(); + } + unset($entry["dn"]); $attribute = ''; $value = ''; $newrdn = ''; @@ -782,54 +782,55 @@ { $repeat = 0; do { - // Get the sequence entry - $this->base($seq_name); + // Get the sequence entry + $this->base($seq_name); $this->pushErrorHandling(PEAR_ERROR_RETURN); - $data = $this->getRow("objectClass=*"); + $data = $this->getRow("objectClass=*"); $this->popErrorHandling(); - if (DB::isError($data)) { - // DB_ldap doesn't use DB_ERROR_NOT_FOUND - if ($ondemand && $repeat == 0 - && $data->getCode() == DB_ERROR) { - // Try to create sequence and repeat - $repeat = 1; - $data = $this->createSequence($seq_name); + if (DB::isError($data)) { + // DB_ldap doesn't use DB_ERROR_NOT_FOUND + if ($ondemand && $repeat == 0 + && $data->getCode() == DB_ERROR) { + // Try to create sequence and repeat + $repeat = 1; + $data = $this->createSequence($seq_name); + if (DB::isError($data)) { + return $this->raiseError($data); + } + } else { + // Other error + return $this->raiseError($data); + } + } else { + // Increment sequence value + $data["cn"]++; + // Unique identificator of transaction + $seq_unique = mt_rand(); + $data["uid"] = $seq_unique; + // Modify the LDAP entry + $this->pushErrorHandling(PEAR_ERROR_RETURN); + $data = $this->simpleQuery($data, 'modify'); + $this->popErrorHandling(); if (DB::isError($data)) { - return $this->raiseError($data); + return $this->raiseError($data); + } + // Get the entry and check if it contains our unique value + $this->base($seq_name); + $data = $this->getRow("objectClass=*"); + if (DB::isError($data)) { + return $this->raiseError($data); + } + if ($data["uid"] != $seq_unique) { + // It is not our entry. Wait a little time and repeat + sleep(1); + $repeat = 1; + } else { + $repeat = 0; } - } else { - // Other error - return $this->raiseError($data); - } - } else { - // Increment sequence value - $data["cn"]++; - // Unique identificator of transaction - $seq_unique = mt_rand(); - $data["uid"] = $seq_unique; - // Modify the LDAP entry - $this->pushErrorHandling(PEAR_ERROR_RETURN); - $data = $this->simpleQuery($data, 'modify'); - $this->popErrorHandling(); - if (DB::isError($data)) { - return $this->raiseError($data); - } - // Get the entry and check if it contains our unique value - $this->base($seq_name); - $data = $this->getRow("objectClass=*"); - if (DB::isError($data)) { - return $this->raiseError($data); } - if ($data["uid"] != $seq_unique) { - // It is not our entry. Wait a little time and repeat - sleep(1); - $repeat = 1; - } else { - $repeat = 0; - } - } } while ($repeat); + if (DB::isError($data)) { return $data; } @@ -860,20 +861,20 @@ */ function createSequence($seq_name) { - // Extract $seq_id from DN - ereg("^([^,]*),", $seq_name, $regs); - $seq_id = $regs[1]; - - // Create the sequence entry - $data = array( - dn => $seq_name, - objectclass => array("top", "extensibleObject"), - sn => $seq_id, - cn => 0, - uid => 0 - ); + // Extract $seq_id from DN + ereg("^([^,]*),", $seq_name, $regs); + $seq_id = $regs[1]; + + // Create the sequence entry + $data = array( + dn => $seq_name, + objectclass => array("top", "extensibleObject"), + sn => $seq_id, + cn => 0, + uid => 0 + ); - // Add the LDAP entry + // Add the LDAP entry $this->pushErrorHandling(PEAR_ERROR_RETURN); $data = $this->simpleQuery($data, 'add'); $this->popErrorHandling(); @@ -889,10 +890,10 @@ */ function dropSequence($seq_name) { - // Delete the sequence entry - $data = array( - dn => $seq_name, - ); + // Delete the sequence entry + $data = array( + dn => $seq_name, + ); $this->pushErrorHandling(PEAR_ERROR_RETURN); $data = $this->simpleQuery($data, 'delete'); $this->popErrorHandling();

« previous php.pear.cvs (#2385) next »