forked from Wavyzz/dolibarr
Mise au norme modele script
This commit is contained in:
@@ -45,10 +45,13 @@ require_once(DOL_DOCUMENT_ROOT."/../dev/skeletons/skeleton_class.class.php");
|
|||||||
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||||
|
|
||||||
|
|
||||||
// Parameters
|
// Main
|
||||||
$version='$Revision$';
|
$version='$Revision$';
|
||||||
|
@set_time_limit(0);
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
$langs->load("main");
|
||||||
|
|
||||||
|
|
||||||
print "***** $script_file ($version) *****\n";
|
print "***** $script_file ($version) *****\n";
|
||||||
|
|
||||||
|
|||||||
@@ -36,24 +36,45 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Main
|
||||||
|
$version='$Revision$';
|
||||||
|
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
||||||
|
@set_time_limit(0);
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
require_once($path."../../htdocs/master.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||||
|
|
||||||
|
$langs->load("main");
|
||||||
|
|
||||||
|
|
||||||
|
print "***** $script_file ($version) *****\n";
|
||||||
|
|
||||||
if (! isset($argv[1]) || ! $argv[1]) {
|
if (! isset($argv[1]) || ! $argv[1]) {
|
||||||
print "Usage: $script_file now\n";
|
print "Usage: $script_file now\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$now=$argv[1];
|
$now=$argv[1];
|
||||||
|
|
||||||
// Recupere env dolibarr
|
print "\n";
|
||||||
$version='$Revision$';
|
print "----- Synchronize all records from Dolibarr database:\n";
|
||||||
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
print "host=".$conf->db->host."\n";
|
||||||
|
print "port=".$conf->db->port."\n";
|
||||||
require_once($path."../../htdocs/master.inc.php");
|
print "login=".$conf->db->user."\n";
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
|
print "pass=".eregi_replace('.','*',$conf->db->pass)."\n";
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
print "database=".$conf->db->name."\n";
|
||||||
|
print "\n";
|
||||||
$error=0;
|
print "----- To LDAP database:\n";
|
||||||
|
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||||
|
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||||
print "***** $script_file ($version) *****\n";
|
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||||
|
print "pass=".eregi_replace('.','*',$conf->global->LDAP_ADMIN_PASS)."\n";
|
||||||
|
print "DN target=".$conf->global->LDAP_MEMBER_DN."\n";
|
||||||
|
print "\n";
|
||||||
|
print "Press a key to confirm...\n";
|
||||||
|
$input = trim(fgets(STDIN));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (! $conf->global->LDAP_MEMBER_ACTIVE)
|
if (! $conf->global->LDAP_MEMBER_ACTIVE)
|
||||||
@@ -84,7 +105,7 @@ if ($resql)
|
|||||||
$member = new Adherent($db);
|
$member = new Adherent($db);
|
||||||
$member->fetch($obj->rowid);
|
$member->fetch($obj->rowid);
|
||||||
|
|
||||||
print $langs->trans("UpdateMember")." rowid=".$member->id." ".$member->fullname;
|
print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->fullname;
|
||||||
|
|
||||||
$info=$member->_load_ldap_info();
|
$info=$member->_load_ldap_info();
|
||||||
$dn=$member->_load_ldap_dn($info);
|
$dn=$member->_load_ldap_dn($info);
|
||||||
@@ -92,12 +113,12 @@ if ($resql)
|
|||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
print " - ".$langs->trans("OK");
|
print " - ".$langs->transnoentities("OK");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
print " - ".$langs->trans("KO").' - '.$ldap->error;
|
print " - ".$langs->transnoentities("KO").' - '.$ldap->error;
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
|
|
||||||
|
|||||||
@@ -36,29 +36,49 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($argv[1]) || ! is_numeric($argv[1])) {
|
|
||||||
print "Usage: $script_file id_member_type\n";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$typeid=$argv[1];
|
|
||||||
|
|
||||||
// Recupere env dolibarr
|
// Main
|
||||||
$version='$Revision$';
|
$version='$Revision$';
|
||||||
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
|
||||||
|
@set_time_limit(0);
|
||||||
|
$error=0;
|
||||||
|
|
||||||
require_once($path."../../htdocs/master.inc.php");
|
require_once($path."../../htdocs/master.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
|
||||||
|
|
||||||
$error=0;
|
$langs->load("main");
|
||||||
|
|
||||||
|
|
||||||
if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];
|
if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2];
|
||||||
|
|
||||||
print "***** $script_file ($version) *****\n";
|
print "***** $script_file ($version) *****\n";
|
||||||
print 'DN='.$conf->global->LDAP_MEMBER_DN."\n";
|
|
||||||
|
if (! isset($argv[1]) || ! is_numeric($argv[1])) {
|
||||||
|
print "Usage: $script_file id_member_type\n";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$typeid=$argv[1];
|
||||||
|
|
||||||
|
print "\n";
|
||||||
|
print "----- Synchronize all records from LDAP database:\n";
|
||||||
|
print "host=".$conf->global->LDAP_SERVER_HOST."\n";
|
||||||
|
print "port=".$conf->global->LDAP_SERVER_PORT."\n";
|
||||||
|
print "login=".$conf->global->LDAP_ADMIN_DN."\n";
|
||||||
|
print "pass=".eregi_replace('.','*',$conf->global->LDAP_ADMIN_PASS)."\n";
|
||||||
|
print "DN to extract=".$conf->global->LDAP_MEMBER_DN."\n";
|
||||||
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
|
print 'Filter=('.$conf->global->LDAP_KEY_MEMBERS.'=*)'."\n";
|
||||||
|
print "----- To Dolibarr database:\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->pass)."\n";
|
||||||
|
print "database=".$conf->db->name."\n";
|
||||||
|
print "\n";
|
||||||
|
print "Press a key to confirm...\n";
|
||||||
|
$input = trim(fgets(STDIN));
|
||||||
|
|
||||||
|
|
||||||
if (! $conf->global->LDAP_MEMBER_DN)
|
if (! $conf->global->LDAP_MEMBER_DN)
|
||||||
{
|
{
|
||||||
@@ -169,11 +189,11 @@ if ($result >= 0)
|
|||||||
$member->typeid=$typeid;
|
$member->typeid=$typeid;
|
||||||
|
|
||||||
// Creation membre
|
// Creation membre
|
||||||
print $langs->trans("MemberCreate").' no '.$key.': '.$member->fullname;
|
print $langs->trans("MemberCreate").' # '.$key.': '.$member->fullname;
|
||||||
$member_id=$member->create();
|
$member_id=$member->create();
|
||||||
if ($member_id > 0)
|
if ($member_id > 0)
|
||||||
{
|
{
|
||||||
print ' --> '.$member_id;
|
print ' --> Created member id='.$member_id.' login='.$member->login;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -210,12 +230,12 @@ if ($result >= 0)
|
|||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
print $langs->trans("NoErrorCommitIsDone")."\n";
|
print $langs->transnoentities("NoErrorCommitIsDone")."\n";
|
||||||
$db->commit();
|
$db->commit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $langs->trans("SommeErrorWereFoundRollbackIsDone",$error)."\n";
|
print $langs->transnoentities("ErrorSomeErrorWereFoundRollbackIsDone",$error)."\n";
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user