2
0
forked from Wavyzz/dolibarr

Fix: minor bugs

Qual: Remove deprecated file
This commit is contained in:
Laurent Destailleur
2009-04-20 15:29:09 +00:00
parent 9a601dd546
commit 9f01a861dd
3 changed files with 37 additions and 156 deletions

View File

@@ -1,122 +0,0 @@
#!/usr/bin/env python
#
# Glasnost
# By: Odile B<>nassy <obenassy@entrouvert.com>
# Thierry Dulieu <tdulieu@easter-eggs.com>
# Fr<46>d<EFBFBD>ric P<>ters <fpeters@theridion.com>
# Benjamin Poussin <poussin@codelutin.com>
# Emmanuel Raviart <eraviart@entrouvert.com>
# Emmanuel Saracco <esaracco@easter-eggs.com>
#
# Copyright (C) 2000, 2001 Easter-eggs & Emmanuel Raviart
# Copyright (C) 2002 Odile B<>nassy, Code Lutin, Thierry Dulieu, Easter-eggs,
# Entr'ouvert, Fr<46>d<EFBFBD>ric P<>ters, Benjamin Poussin, Emmanuel Raviart,
# Emmanuel Saracco & Th<54>ridion
# Copyright (C) 2003 Odile B<>nassy, Code Lutin, Thierry Dulieu, Easter-eggs,
# Entr'ouvert, Ouvaton, Fr<46>d<EFBFBD>ric P<>ters, Benjamin Poussin, Rodolphe
# Qui<75>deville, Emmanuel Raviart, Emmanuel Saracco, Th<54>ridion & Vecam
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
__doc__ = """Sample showing how to handle people with XML-RPC"""
__version__ = '$Revision$'[11:-2]
import xmlrpclib # Requires Python >= 2.2.
# Every calls to a Glasnost server is handled by a Glasnost XML-RPC gateway.
glasnostServerName = 'localhost' ### YOU MAY NEED TO CHANGE THIS!!!
glasnostGatewayPort = 8001
# The login & password of a Glasnost user who has the rights to add people to
# the server.
login = 'login' ### CHANGE THIS!!!
password = 'password' ### CHANGE THIS!!!
# Each Glasnost server is uniquely identified by its server id.
authenticationServerId = 'glasnost://%s/authentication' % glasnostServerName
peopleServerId = 'glasnost://%s/people' % glasnostServerName
# This sample application doesn't need an application token.
applicationToken = ''
# First, establish a connection to the gateway.
gateway = xmlrpclib.ServerProxy('http://%s:%d' % (
glasnostServerName, glasnostGatewayPort))
# Call the authentication server to give him your login & password and to
# receive a user id and token.
userId, userToken = gateway.callGateway(
authenticationServerId,
'getUserIdAndToken',
[authenticationServerId, applicationToken, login, password])
print 'Login = %s' % login
print 'User ID = %s' % userId
print 'User Token = %s' % userToken
# Create a new person.
# Note: The attributes of people are described in shared/common/PeopleCommon.py
person = {
# Don't touch the next two lines.
'__thingCategory__': 'object',
'__thingName__': 'Person',
'firstName': 'John',
'lastName': 'Doe',
'login': 'jdoe',
'email': 'root@localhost', ### CHANGE THIS!!!
}
# Call the method addObject of the people server.
# Note: The available functions of the people server are defined in the class
# PeopleServer, which is defined in servers/PeopleServer/PeopleServer.py.
# The class PeopleServer inherits from the class ObjectsServer, which is
# defined in shared/server/ObjectsServer.py
personId = gateway.callGateway(
peopleServerId,
'addObject' ,
[peopleServerId, applicationToken, userToken, person])
print 'Person created with id = %s' % personId
# Give a person id and get its infos.
person = gateway.callGateway(
peopleServerId,
'getObject' ,
[peopleServerId, applicationToken, userToken, personId])
print 'Got a new person = %s' % person
# Change the nickname of that person.
person['nickname'] = 'jd'
gateway.callGateway(
peopleServerId,
'modifyObject' ,
[peopleServerId, applicationToken, userToken, person])
# Get the new infos of the person.
person = gateway.callGateway(
peopleServerId,
'getObject' ,
[peopleServerId, applicationToken, userToken, personId])
print 'Got a modified person = %s' % person
# Remove the person.
gateway.callGateway(
peopleServerId,
'deleteObject' ,
[peopleServerId, applicationToken, userToken, personId])
print 'Person deleted'

View File

@@ -18,14 +18,14 @@
*/
/**
\file scripts/adherents/sync_member_dolibarr2ldap.php
\ingroup ldap adherent
\brief Script de mise a jour des adherents dans LDAP depuis base Dolibarr
*/
* \file scripts/adherents/sync_member_dolibarr2ldap.php
* \ingroup ldap adherent
* \brief Script de mise a jour des adherents dans LDAP depuis base Dolibarr
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
$script_file=__FILE__;
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -50,7 +50,7 @@ $langs->load("main");
print "***** $script_file ($version) *****\n";
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";
print "Usage: $script_file now\n";
exit;
}
$now=$argv[1];
@@ -63,6 +63,7 @@ print "type=".$conf->db->type."\n";
print "host=".$conf->db->host."\n";
print "port=".$conf->db->port."\n";
print "login=".$conf->db->user."\n";
//print "pass=".eregi_replace('.','*',$conf->db->password)."\n"; // Not defined for security reasons
print "database=".$conf->db->name."\n";
print "\n";
print "----- To LDAP database:\n";
@@ -83,7 +84,7 @@ $input = trim(fgets(STDIN));
if (! $conf->global->LDAP_MEMBER_ACTIVE)
{
print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
exit 1;
exit 1;
}
*/
@@ -102,7 +103,7 @@ if ($resql)
while ($i < $num)
{
$ldap->error="";
$obj = $db->fetch_object($resql);
$member = new Adherent($db);
@@ -118,12 +119,12 @@ if ($resql)
dol_print_error($db,$member->error);
exit;
}
print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->fullname;
$info=$member->_load_ldap_info();
$dn=$member->_load_ldap_dn($info);
$result=$ldap->update($dn,$info,$user);
if ($result > 0)
{
@@ -138,7 +139,7 @@ if ($resql)
$i++;
}
$ldap->unbind();
$ldap->close();
}

View File

@@ -1,6 +1,6 @@
<?PHP
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,14 +20,14 @@
*/
/**
\file scripts/adherents/sync_member_ldap2dolibarr.php
\ingroup ldap adherent
\brief Script de mise a jour des adherents dans Dolibarr depuis LDAP
*/
* \file scripts/adherents/sync_member_ldap2dolibarr.php
* \ingroup ldap adherent
* \brief Script de mise a jour des adherents dans Dolibarr depuis LDAP
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
$script_file=__FILE__;
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
if (substr($sapi_type, 0, 3) == 'cgi') {
@@ -40,6 +40,7 @@ $version='$Revision$';
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
@set_time_limit(0);
$error=0;
$forcecommit=1;
require_once($path."../../htdocs/master.inc.php");
@@ -56,7 +57,7 @@ if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];
print "***** $script_file ($version) *****\n";
if (! isset($argv[1]) || ! is_numeric($argv[1])) {
print "Usage: $script_file id_member_type\n";
print "Usage: $script_file id_member_type\n";
exit;
}
$typeid=$argv[1];
@@ -88,7 +89,7 @@ $input = trim(fgets(STDIN));
if (! $conf->global->LDAP_MEMBER_DN)
{
print $langs->trans("Error").': '.$langs->trans("LDAP setup for members not defined inside Dolibarr");
exit(1);
exit(1);
}
@@ -133,10 +134,10 @@ if ($result >= 0)
{
$justthese=array();
// On d<>sactive la synchro Dolibarr vers LDAP
$conf->global->LDAP_MEMBER_ACTIVE=0;
// Liste des champs a r<>cup<75>rer de LDAP
$required_fields = array(
$conf->global->LDAP_FIELD_FULLNAME,
@@ -169,13 +170,13 @@ if ($result >= 0)
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
$ldaprecords = $ldap->getRecords('*',$conf->global->LDAP_MEMBER_DN, $conf->global->LDAP_KEY_MEMBERS, $required_fields, 0);
if (is_array($ldaprecords))
{
$db->begin();
// Warning $ldapuser a une cl<63> en minuscule
// Warning $ldapuser has a key in lowercase
foreach ($ldaprecords as $key => $ldapuser)
{
$member = new Adherent($db);
@@ -221,9 +222,9 @@ if ($result >= 0)
$member->typeid=$typeid;
// Creation membre
print $langs->trans("MemberCreate").' # '.$key.': fullname='.$member->fullname;
print $langs->transnoentities("MemberCreate").' # '.$key.': login='.$member->login.', fullname='.$member->fullname;
print ', datec='.$member->datec;
$member_id=$member->create();
$member_id=$member->create($user);
if ($member_id > 0)
{
print ' --> Created member id='.$member_id.' login='.$member->login;
@@ -236,7 +237,7 @@ if ($result >= 0)
print "\n";
//print_r($member);
$datefirst='';
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)
{
@@ -264,8 +265,8 @@ if ($result >= 0)
}
}
// Insertion premi<6D>re adh<64>sion
// Insert first subscription
if ($datefirst)
{
// Cree premiere cotisation et met a jour datefin dans adherent
@@ -273,19 +274,20 @@ if ($result >= 0)
$crowid=$member->cotisation($datefirst, $pricefirst, 0);
}
// Insertion derni<6E>re adh<64>sion
// Insert last subscription
if ($datelast)
{
// Cree derniere cotisation et met a jour datefin dans adherent
//print "yy".dol_print_date($datelast)."\n";
$crowid=$member->cotisation($datelast, $pricelast, 0);
}
}
if (! $error)
if (! $error || $forcecommit)
{
print $langs->transnoentities("NoErrorCommitIsDone")."\n";
if (! $error) print $langs->transnoentities("NoErrorCommitIsDone")."\n";
else print $langs->transnoentities("ErrorButCommitIsDone")."\n";
$db->commit();
}
else
@@ -305,7 +307,7 @@ else
dol_print_error('',$ldap->error);
$error++;
}
return $error;