clean triggers
This commit is contained in:
parent
66fbddb892
commit
360ea91be5
@ -81,7 +81,7 @@ abstract class DolibarrTriggers
|
|||||||
const VERSION_EXPERIMENTAL = 'experimental';
|
const VERSION_EXPERIMENTAL = 'experimental';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string module is dolibarr
|
* @var string module is dolibarr ready
|
||||||
*/
|
*/
|
||||||
const VERSION_DOLIBARR = 'dolibarr';
|
const VERSION_DOLIBARR = 'dolibarr';
|
||||||
|
|
||||||
|
|||||||
@ -31,11 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceLogevents extends DolibarrTriggers
|
class InterfaceLogevents extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler
|
|
||||||
*/
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@ -32,11 +32,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
|
|
||||||
class InterfaceWorkflowManager extends DolibarrTriggers
|
class InterfaceWorkflowManager extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler
|
|
||||||
*/
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@ -34,11 +34,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceActionsAuto extends DolibarrTriggers
|
class InterfaceActionsAuto extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler
|
|
||||||
*/
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@ -30,11 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceActionsBlockedLog extends DolibarrTriggers
|
class InterfaceActionsBlockedLog extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler
|
|
||||||
*/
|
|
||||||
protected $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|||||||
@ -31,19 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceLdapsynchro extends DolibarrTriggers
|
class InterfaceLdapsynchro extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
public $family = 'ldap';
|
/**
|
||||||
public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
/**
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
* Version of the trigger
|
$this->family = "ldap";
|
||||||
* @var string
|
$this->description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
|
||||||
*/
|
// 'development', 'experimental', 'dolibarr' or version
|
||||||
public $version = self::VERSION_DOLIBARR;
|
$this->version = self::VERSION_DOLIBARR;
|
||||||
|
$this->picto = 'technic';
|
||||||
/**
|
}
|
||||||
* @var string Image of the trigger
|
|
||||||
*/
|
|
||||||
public $picto = 'technic';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
@ -61,8 +64,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing
|
if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing
|
||||||
if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing
|
if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing
|
||||||
|
|
||||||
if (!function_exists('ldap_connect'))
|
if (!function_exists('ldap_connect')) {
|
||||||
{
|
|
||||||
dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
|
dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -73,16 +75,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$result = 0;
|
$result = 0;
|
||||||
|
|
||||||
// Users
|
// Users
|
||||||
if ($action == 'USER_CREATE')
|
if ($action == 'USER_CREATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -91,18 +90,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USER_MODIFY')
|
} elseif ($action == 'USER_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -114,8 +109,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,18 +123,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USER_NEW_PASSWORD')
|
} elseif ($action == 'USER_NEW_PASSWORD') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -152,8 +142,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,19 +154,15 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USER_ENABLEDISABLE')
|
} elseif ($action == 'USER_ENABLEDISABLE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
} elseif ($action == 'USER_DELETE')
|
} elseif ($action == 'USER_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -186,20 +171,16 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USER_SETINGROUP')
|
} elseif ($action == 'USER_SETINGROUP') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
// Must edit $object->newgroupid
|
// Must edit $object->newgroupid
|
||||||
$usergroup = new UserGroup($this->db);
|
$usergroup = new UserGroup($this->db);
|
||||||
if ($object->newgroupid > 0)
|
if ($object->newgroupid > 0) {
|
||||||
{
|
|
||||||
$usergroup->fetch($object->newgroupid);
|
$usergroup->fetch($object->newgroupid);
|
||||||
|
|
||||||
$oldinfo = $usergroup->_load_ldap_info();
|
$oldinfo = $usergroup->_load_ldap_info();
|
||||||
@ -209,8 +190,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
|
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,20 +203,16 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USER_REMOVEFROMGROUP')
|
} elseif ($action == 'USER_REMOVEFROMGROUP') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
// Must edit $object->newgroupid
|
// Must edit $object->newgroupid
|
||||||
$usergroup = new UserGroup($this->db);
|
$usergroup = new UserGroup($this->db);
|
||||||
if ($object->oldgroupid > 0)
|
if ($object->oldgroupid > 0) {
|
||||||
{
|
|
||||||
$usergroup->fetch($object->oldgroupid);
|
$usergroup->fetch($object->oldgroupid);
|
||||||
|
|
||||||
$oldinfo = $usergroup->_load_ldap_info();
|
$oldinfo = $usergroup->_load_ldap_info();
|
||||||
@ -246,8 +222,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
|
$container = $usergroup->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,16 +238,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Groupes
|
// Groupes
|
||||||
elseif ($action == 'USERGROUP_CREATE')
|
elseif ($action == 'USERGROUP_CREATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -286,18 +258,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USERGROUP_MODIFY')
|
} elseif ($action == 'USERGROUP_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -309,8 +277,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,16 +289,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'USERGROUP_DELETE')
|
} elseif ($action == 'USERGROUP_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
|
if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -343,16 +307,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Contacts
|
// Contacts
|
||||||
elseif ($action == 'CONTACT_CREATE')
|
elseif ($action == 'CONTACT_CREATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
|
if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -361,18 +322,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'CONTACT_MODIFY')
|
} elseif ($action == 'CONTACT_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
|
if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -384,8 +341,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,16 +353,13 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'CONTACT_DELETE')
|
} elseif ($action == 'CONTACT_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
|
if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -418,26 +371,21 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
elseif ($action == 'MEMBER_CREATE')
|
elseif ($action == 'MEMBER_CREATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result = $ldap->add($dn, $info, $user);
|
$result = $ldap->add($dn, $info, $user);
|
||||||
|
|
||||||
// For member type
|
// For member type
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
if ($object->typeid > 0) {
|
||||||
if ($object->typeid > 0)
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||||
$membertype = new AdherentType($this->db);
|
$membertype = new AdherentType($this->db);
|
||||||
$membertype->fetch($object->typeid);
|
$membertype->fetch($object->typeid);
|
||||||
@ -450,8 +398,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $membertype->_load_ldap_dn($oldinfo, 1);
|
$container = $membertype->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,19 +412,15 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_VALIDATE')
|
} elseif ($action == 'MEMBER_VALIDATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
// If status field is setup to be synchronized
|
// If status field is setup to be synchronized
|
||||||
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
|
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
$olddn = $dn; // We know olddn=dn as we change only status
|
$olddn = $dn; // We know olddn=dn as we change only status
|
||||||
@ -488,23 +431,19 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_SUBSCRIPTION')
|
} elseif ($action == 'MEMBER_SUBSCRIPTION') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
// If subscriptions fields are setup to be synchronized
|
// If subscriptions fields are setup to be synchronized
|
||||||
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
|
if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
|
||||||
|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
|
|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
|
||||||
|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
|
|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
|
||||||
|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
|
|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
|
||||||
|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
|
|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
$olddn = $dn; // We know olddn=dn as we change only subscriptions
|
$olddn = $dn; // We know olddn=dn as we change only subscriptions
|
||||||
@ -515,18 +454,14 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_MODIFY')
|
} elseif ($action == 'MEMBER_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -538,8 +473,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,8 +485,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
|
$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
|
||||||
|
|
||||||
// For member type
|
// For member type
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -569,8 +502,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $newmembertype->_load_ldap_dn($oldinfo, 1);
|
$container = $newmembertype->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$newmembertype->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$newmembertype->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,8 +511,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
|
|
||||||
$result = $ldap->update($dn, $info, $user, $olddn);
|
$result = $ldap->update($dn, $info, $user, $olddn);
|
||||||
|
|
||||||
if ($object->oldcopy->typeid != $object->typeid)
|
if ($object->oldcopy->typeid != $object->typeid) {
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Remove member in old member type
|
* Remove member in old member type
|
||||||
*/
|
*/
|
||||||
@ -595,8 +526,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $oldmembertype->_load_ldap_dn($oldinfo, 1);
|
$container = $oldmembertype->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$oldmembertype->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$oldmembertype->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,24 +538,19 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_NEW_PASSWORD')
|
} elseif ($action == 'MEMBER_NEW_PASSWORD') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
// If password field is setup to be synchronized
|
// If password field is setup to be synchronized
|
||||||
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
|
if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
$olddn = $dn; // We know olddn=dn as we change only password
|
$olddn = $dn; // We know olddn=dn as we change only password
|
||||||
@ -633,25 +558,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$result = $ldap->update($dn, $info, $user, $olddn);
|
$result = $ldap->update($dn, $info, $user, $olddn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_RESILIATE')
|
} elseif ($action == 'MEMBER_RESILIATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
// If status field is setup to be synchronized
|
// If status field is setup to be synchronized
|
||||||
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
|
if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
$olddn = $dn; // We know olddn=dn as we change only status
|
$olddn = $dn; // We know olddn=dn as we change only status
|
||||||
@ -659,32 +579,26 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$result = $ldap->update($dn, $info, $user, $olddn);
|
$result = $ldap->update($dn, $info, $user, $olddn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_DELETE')
|
} elseif ($action == 'MEMBER_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result = $ldap->delete($dn);
|
$result = $ldap->delete($dn);
|
||||||
|
|
||||||
// For member type
|
// For member type
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
if ($object->typeid > 0) {
|
||||||
if ($object->typeid > 0)
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -701,8 +615,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $membertype->_load_ldap_dn($oldinfo, 1);
|
$container = $membertype->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -714,24 +627,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Members types
|
// Members types
|
||||||
elseif ($action == 'MEMBER_TYPE_CREATE')
|
elseif ($action == 'MEMBER_TYPE_CREATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
@ -743,23 +652,18 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$result = $ldap->add($dn, $info, $user);
|
$result = $ldap->add($dn, $info, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_TYPE_MODIFY')
|
} elseif ($action == 'MEMBER_TYPE_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (empty($object->oldcopy) || !is_object($object->oldcopy)) {
|
||||||
if (empty($object->oldcopy) || !is_object($object->oldcopy))
|
|
||||||
{
|
|
||||||
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = clone $object;
|
||||||
}
|
}
|
||||||
@ -773,8 +677,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
|
||||||
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
|
||||||
$records = $ldap->search($container, $search);
|
$records = $ldap->search($container, $search);
|
||||||
if (count($records) && $records['count'] == 0)
|
if (count($records) && $records['count'] == 0) {
|
||||||
{
|
|
||||||
$olddn = '';
|
$olddn = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -790,24 +693,20 @@ class InterfaceLdapsynchro extends DolibarrTriggers
|
|||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'MEMBER_TYPE_DELETE')
|
} elseif ($action == 'MEMBER_TYPE_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
|
if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') {
|
||||||
{
|
|
||||||
$ldap = new Ldap();
|
$ldap = new Ldap();
|
||||||
$result = $ldap->connect_bind();
|
$result = $ldap->connect_bind();
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$info = $object->_load_ldap_info();
|
$info = $object->_load_ldap_info();
|
||||||
$dn = $object->_load_ldap_dn($info);
|
$dn = $object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result = $ldap->delete($dn);
|
$result = $ldap->delete($dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
$this->errors[] = "ErrorLDAP ".$ldap->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,19 +29,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
public $family = 'mailmanspip';
|
/**
|
||||||
public $description = "Triggers of this module allows to synchronize Mailman an Spip.";
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
/**
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
* Version of the trigger
|
$this->family = "mailmanspip";
|
||||||
* @var string
|
$this->description = "Triggers of this module allows to synchronize Mailman an Spip.";
|
||||||
*/
|
// 'development', 'experimental', 'dolibarr' or version
|
||||||
public $version = self::VERSION_DOLIBARR;
|
$this->version = self::VERSION_DOLIBARR;
|
||||||
|
$this->picto = 'technic';
|
||||||
/**
|
}
|
||||||
* @var string Image of the trigger
|
|
||||||
*/
|
|
||||||
public $picto = 'technic';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
@ -61,13 +64,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
|||||||
require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php";
|
require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
|
require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
|
||||||
|
|
||||||
if ($action == 'CATEGORY_LINK')
|
if ($action == 'CATEGORY_LINK') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
// We add subscription if we change category (new category may means more mailing-list to subscribe)
|
// We add subscription if we change category (new category may means more mailing-list to subscribe)
|
||||||
if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0)
|
if (is_object($object->context['linkto']) && method_exists($object->context['linkto'], 'add_to_abo') && $object->context['linkto']->add_to_abo() < 0) {
|
||||||
{
|
|
||||||
$this->error = $object->context['linkto']->error;
|
$this->error = $object->context['linkto']->error;
|
||||||
$this->errors = $object->context['linkto']->errors;
|
$this->errors = $object->context['linkto']->errors;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
@ -76,13 +77,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
} elseif ($action == 'CATEGORY_UNLINK')
|
} elseif ($action == 'CATEGORY_UNLINK') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
|
// We remove subscription if we change category (lessw category may means less mailing-list to subscribe)
|
||||||
if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0)
|
if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) {
|
||||||
{
|
|
||||||
$this->error = $object->context['unlinkoff']->error;
|
$this->error = $object->context['unlinkoff']->error;
|
||||||
$this->errors = $object->context['unlinkoff']->errors;
|
$this->errors = $object->context['unlinkoff']->errors;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
@ -94,13 +93,11 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
elseif ($action == 'MEMBER_VALIDATE')
|
elseif ($action == 'MEMBER_VALIDATE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
$return = 0;
|
$return = 0;
|
||||||
if ($object->add_to_abo() < 0)
|
if ($object->add_to_abo() < 0) {
|
||||||
{
|
|
||||||
$this->errors = $object->errors;
|
$this->errors = $object->errors;
|
||||||
if (!empty($object->error)) $this->errors[] = $object->error;
|
if (!empty($object->error)) $this->errors[] = $object->error;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
@ -109,28 +106,23 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
} elseif ($action == 'MEMBER_MODIFY')
|
} elseif ($action == 'MEMBER_MODIFY') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
$return = 0;
|
$return = 0;
|
||||||
// Add user into some linked tools (mailman, spip, etc...)
|
// Add user into some linked tools (mailman, spip, etc...)
|
||||||
if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))
|
if (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid)) {
|
||||||
{
|
if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) { // If email has changed or if list has changed we delete mailman subscription for old email
|
||||||
if (is_object($object->oldcopy) && (($object->oldcopy->email != $object->email) || ($object->oldcopy->typeid != $object->typeid))) // If email has changed or if list has changed we delete mailman subscription for old email
|
if ($object->oldcopy->del_to_abo() < 0) {
|
||||||
{
|
|
||||||
if ($object->oldcopy->del_to_abo() < 0)
|
|
||||||
{
|
|
||||||
$this->errors = $object->oldcopy->errors;
|
$this->errors = $object->oldcopy->errors;
|
||||||
if (!empty($object->oldcopy->error)) $this->errors[] = $object->oldcopy->error;
|
if (!empty($object->oldcopy->error)) $this->errors[] = $object->oldcopy->error;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
} else {
|
} else {
|
||||||
$return = 1;
|
$return = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
|
// We add subscription if new email or new type (new type may means more mailing-list to subscribe)
|
||||||
if ($object->add_to_abo() < 0)
|
if ($object->add_to_abo() < 0) {
|
||||||
{
|
|
||||||
$this->errors = $object->errors;
|
$this->errors = $object->errors;
|
||||||
if (!empty($object->error)) $this->errors[] = $object->error;
|
if (!empty($object->error)) $this->errors[] = $object->error;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
@ -140,14 +132,12 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
} elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE')
|
} elseif ($action == 'MEMBER_RESILIATE' || $action == 'MEMBER_DELETE') {
|
||||||
{
|
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
$return = 0;
|
$return = 0;
|
||||||
// Remove from external tools (mailman, spip, etc...)
|
// Remove from external tools (mailman, spip, etc...)
|
||||||
if ($object->del_to_abo() < 0)
|
if ($object->del_to_abo() < 0) {
|
||||||
{
|
|
||||||
$this->errors = $object->errors;
|
$this->errors = $object->errors;
|
||||||
if (!empty($object->error)) $this->errors[] = $object->error;
|
if (!empty($object->error)) $this->errors[] = $object->error;
|
||||||
$return = -1;
|
$return = -1;
|
||||||
|
|||||||
@ -30,20 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceNotification extends DolibarrTriggers
|
class InterfaceNotification extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
public $family = 'notification';
|
|
||||||
public $description = "Triggers of this module send email notifications according to Notification module setup.";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Version of the trigger
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $version = self::VERSION_DOLIBARR;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Image of the trigger
|
|
||||||
*/
|
|
||||||
public $picto = 'email';
|
|
||||||
|
|
||||||
// @todo Defined also into notify.class.php)
|
// @todo Defined also into notify.class.php)
|
||||||
public $listofmanagedevents = array(
|
public $listofmanagedevents = array(
|
||||||
'BILL_VALIDATE',
|
'BILL_VALIDATE',
|
||||||
@ -63,6 +49,23 @@ class InterfaceNotification extends DolibarrTriggers
|
|||||||
'HOLIDAY_APPROVE'
|
'HOLIDAY_APPROVE'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
|
$this->family = "notification";
|
||||||
|
$this->description = "Triggers of this module send email notifications according to Notification module setup.";
|
||||||
|
// 'development', 'experimental', 'dolibarr' or version
|
||||||
|
$this->version = self::VERSION_DOLIBARR;
|
||||||
|
$this->picto = 'email';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
|
||||||
@ -107,20 +110,17 @@ class InterfaceNotification extends DolibarrTriggers
|
|||||||
$sql .= $this->db->order("rang, elementtype, code");
|
$sql .= $this->db->order("rang, elementtype, code");
|
||||||
dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
|
dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$qualified = 0;
|
$qualified = 0;
|
||||||
// Check is this event is supported by notification module
|
// Check is this event is supported by notification module
|
||||||
if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1;
|
if (in_array($obj->code, $this->listofmanagedevents)) $qualified = 1;
|
||||||
// Check if module for this event is active
|
// Check if module for this event is active
|
||||||
if ($qualified)
|
if ($qualified) {
|
||||||
{
|
|
||||||
//print 'xx'.$obj->code;
|
//print 'xx'.$obj->code;
|
||||||
$element = $obj->elementtype;
|
$element = $obj->elementtype;
|
||||||
|
|
||||||
@ -133,8 +133,7 @@ class InterfaceNotification extends DolibarrTriggers
|
|||||||
elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0;
|
elseif (!in_array($element, array('order_supplier', 'invoice_supplier', 'withdraw', 'shipping', 'member', 'expensereport')) && empty($conf->$element->enabled)) $qualified = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($qualified)
|
if ($qualified) {
|
||||||
{
|
|
||||||
$ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
|
$ret[] = array('rowid'=>$obj->rowid, 'code'=>$obj->code, 'label'=>$obj->label, 'description'=>$obj->description, 'elementtype'=>$obj->elementtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,11 +30,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceTicketEmail extends DolibarrTriggers
|
class InterfaceTicketEmail extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler.
|
|
||||||
*/
|
|
||||||
public $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -47,53 +42,10 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
$this->family = "ticket";
|
$this->family = "ticket";
|
||||||
$this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties";
|
$this->description = "Triggers of the module ticket to send notifications to internal users and to third-parties";
|
||||||
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
|
$this->version = self::VERSION_DOLIBARR; // 'development', 'experimental', 'dolibarr' or version
|
||||||
$this->picto = 'ticket';
|
$this->picto = 'ticket';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return name of trigger file
|
|
||||||
*
|
|
||||||
* @return string Name of trigger file
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return description of trigger file
|
|
||||||
*
|
|
||||||
* @return string Description of trigger file
|
|
||||||
*/
|
|
||||||
public function getDesc()
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return version of trigger file
|
|
||||||
*
|
|
||||||
* @return string Version of trigger file
|
|
||||||
*/
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
$langs->load("admin");
|
|
||||||
|
|
||||||
if ($this->version == 'development') {
|
|
||||||
return $langs->trans("Development");
|
|
||||||
} elseif ($this->version == 'experimental') {
|
|
||||||
return $langs->trans("Experimental");
|
|
||||||
} elseif ($this->version == 'dolibarr') {
|
|
||||||
return DOL_VERSION;
|
|
||||||
} elseif ($this->version) {
|
|
||||||
return $this->version;
|
|
||||||
} else {
|
|
||||||
return $langs->trans("Unknown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers
|
* All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers
|
||||||
@ -115,16 +67,13 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
case 'TICKET_ASSIGNED':
|
case 'TICKET_ASSIGNED':
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id)
|
if ($object->fk_user_assign > 0 && $object->fk_user_assign != $user->id) {
|
||||||
{
|
|
||||||
$userstat = new User($this->db);
|
$userstat = new User($this->db);
|
||||||
$res = $userstat->fetch($object->fk_user_assign);
|
$res = $userstat->fetch($object->fk_user_assign);
|
||||||
if ($res > 0)
|
if ($res > 0) {
|
||||||
{
|
|
||||||
// Send email to notification email
|
// Send email to notification email
|
||||||
|
|
||||||
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS))
|
if (empty($conf->global->TICKET_DISABLE_ALL_MAILS)) {
|
||||||
{
|
|
||||||
// Init to avoid errors
|
// Init to avoid errors
|
||||||
$filepath = array();
|
$filepath = array();
|
||||||
$filename = array();
|
$filename = array();
|
||||||
@ -184,10 +133,8 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
|
|
||||||
// Send email to notification email
|
// Send email to notification email
|
||||||
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
$sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
|
||||||
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail']))
|
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && empty($object->context['disableticketemail'])) {
|
||||||
{
|
if ($sendto) {
|
||||||
if ($sendto)
|
|
||||||
{
|
|
||||||
// Init to avoid errors
|
// Init to avoid errors
|
||||||
$filepath = array();
|
$filepath = array();
|
||||||
$filename = array();
|
$filename = array();
|
||||||
@ -248,8 +195,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
|
|
||||||
// Send email to customer
|
// Send email to customer
|
||||||
|
|
||||||
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create)
|
if (empty($conf->global->TICKET_DISABLE_CUSTOMER_MAILS) && empty($object->context['disableticketemail']) && $object->notify_tiers_at_create) {
|
||||||
{
|
|
||||||
$sendto = '';
|
$sendto = '';
|
||||||
if (empty($user->socid) && empty($user->email)) {
|
if (empty($user->socid) && empty($user->email)) {
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
@ -272,16 +218,13 @@ class InterfaceTicketEmail extends DolibarrTriggers
|
|||||||
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
$message_customer .= '<li>'.$langs->trans('Severity').' : '.$langs->getLabelFromKey($this->db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code).'</li>';
|
||||||
|
|
||||||
// Extrafields
|
// Extrafields
|
||||||
foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
|
foreach ($this->attributes[$object->table_element]['label'] as $key => $value) {
|
||||||
{
|
|
||||||
$enabled = 1;
|
$enabled = 1;
|
||||||
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
|
if ($enabled && isset($this->attributes[$object->table_element]['list'][$key])) {
|
||||||
{
|
|
||||||
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
|
$enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
|
||||||
}
|
}
|
||||||
$perms = 1;
|
$perms = 1;
|
||||||
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
|
if ($perms && isset($this->attributes[$object->table_element]['perms'][$key])) {
|
||||||
{
|
|
||||||
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
|
$perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,11 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceStripe extends DolibarrTriggers
|
class InterfaceStripe extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @var DoliDB Database handler.
|
|
||||||
*/
|
|
||||||
public $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -52,31 +47,10 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
$this->family = 'stripe';
|
$this->family = 'stripe';
|
||||||
$this->description = "Triggers of the module Stripe";
|
$this->description = "Triggers of the module Stripe";
|
||||||
$this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version
|
$this->version = self::VERSION_DOLIBARR; // 'development', 'experimental', 'dolibarr' or version
|
||||||
$this->picto = 'stripe';
|
$this->picto = 'stripe';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Trigger name
|
|
||||||
*
|
|
||||||
* @return string Name of trigger file
|
|
||||||
*/
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trigger description
|
|
||||||
*
|
|
||||||
* @return string Description of trigger file
|
|
||||||
*/
|
|
||||||
public function getDesc()
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
* All functions "runTrigger" are triggered if file
|
* All functions "runTrigger" are triggered if file
|
||||||
@ -104,8 +78,7 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
|
|
||||||
$service = 'StripeTest';
|
$service = 'StripeTest';
|
||||||
$servicestatus = 0;
|
$servicestatus = 0;
|
||||||
if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha'))
|
if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
|
||||||
{
|
|
||||||
$service = 'StripeLive';
|
$service = 'StripeLive';
|
||||||
$servicestatus = 1;
|
$servicestatus = 1;
|
||||||
}
|
}
|
||||||
@ -118,8 +91,7 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
|
|
||||||
if ($object->client != 0) {
|
if ($object->client != 0) {
|
||||||
$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request
|
$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus); // This make a network request
|
||||||
if ($customer)
|
if ($customer) {
|
||||||
{
|
|
||||||
$namecleaned = $object->name ? $object->name : null;
|
$namecleaned = $object->name ? $object->name : null;
|
||||||
$vatcleaned = $object->tva_intra ? $object->tva_intra : null; // Example of valid numbers are 'FR12345678901' or 'FR12345678902'
|
$vatcleaned = $object->tva_intra ? $object->tva_intra : null; // Example of valid numbers are 'FR12345678901' or 'FR12345678902'
|
||||||
$desccleaned = $object->name_alias ? $object->name_alias : null;
|
$desccleaned = $object->name_alias ? $object->name_alias : null;
|
||||||
@ -147,15 +119,13 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
if ($desccleaned != $customer->description) $changerequested++;
|
if ($desccleaned != $customer->description) $changerequested++;
|
||||||
if (($customer->tax_exempt == 'exempt' && !$object->tva_assuj) || (!$customer->tax_exempt == 'exempt' && empty($object->tva_assuj))) $changerequested++;
|
if (($customer->tax_exempt == 'exempt' && !$object->tva_assuj) || (!$customer->tax_exempt == 'exempt' && empty($object->tva_assuj))) $changerequested++;
|
||||||
if (!isset($customer->tax_ids['data']) && !is_null($vatcleaned)) $changerequested++;
|
if (!isset($customer->tax_ids['data']) && !is_null($vatcleaned)) $changerequested++;
|
||||||
elseif (isset($customer->tax_ids['data']))
|
elseif (isset($customer->tax_ids['data'])) {
|
||||||
{
|
|
||||||
$taxinfo = reset($customer->tax_ids['data']);
|
$taxinfo = reset($customer->tax_ids['data']);
|
||||||
if (empty($taxinfo) && !empty($vatcleaned)) $changerequested++;
|
if (empty($taxinfo) && !empty($vatcleaned)) $changerequested++;
|
||||||
if (isset($taxinfo->value) && $vatcleaned != $taxinfo->value) $changerequested++;
|
if (isset($taxinfo->value) && $vatcleaned != $taxinfo->value) $changerequested++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changerequested)
|
if ($changerequested) {
|
||||||
{
|
|
||||||
/*if (! empty($object->email)) $customer->email = $object->email;
|
/*if (! empty($object->email)) $customer->email = $object->email;
|
||||||
$customer->description = $namecleaned;
|
$customer->description = $namecleaned;
|
||||||
if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
if (empty($taxinfo)) $customer->tax_info = array('type'=>'vat', 'tax_id'=>null);
|
||||||
@ -167,22 +137,17 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Update Tax info on Stripe
|
// Update Tax info on Stripe
|
||||||
if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer
|
if (!empty($conf->global->STRIPE_SAVE_TAX_IDS)) { // We setup to save Tax info on Stripe side. Warning: This may result in error when saving customer
|
||||||
{
|
if (!empty($vatcleaned)) {
|
||||||
if (!empty($vatcleaned))
|
|
||||||
{
|
|
||||||
$isineec = isInEEC($object);
|
$isineec = isInEEC($object);
|
||||||
if ($object->country_code && $isineec)
|
if ($object->country_code && $isineec) {
|
||||||
{
|
|
||||||
//$taxids = $customer->allTaxIds($customer->id);
|
//$taxids = $customer->allTaxIds($customer->id);
|
||||||
$customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned));
|
$customer->createTaxId($customer->id, array('type'=>'eu_vat', 'value'=>$vatcleaned));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$taxids = $customer->allTaxIds($customer->id);
|
$taxids = $customer->allTaxIds($customer->id);
|
||||||
if (is_array($taxids->data))
|
if (is_array($taxids->data)) {
|
||||||
{
|
foreach ($taxids->data as $taxidobj) {
|
||||||
foreach ($taxids->data as $taxidobj)
|
|
||||||
{
|
|
||||||
$customer->deleteTaxId($customer->id, $taxidobj->id);
|
$customer->deleteTaxId($customer->id, $taxidobj->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,8 +156,7 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
|
|
||||||
// Update Customer on Stripe
|
// Update Customer on Stripe
|
||||||
$customer->save();
|
$customer->save();
|
||||||
} catch (Exception $e)
|
} catch (Exception $e) {
|
||||||
{
|
|
||||||
//var_dump(\Stripe\Stripe::getApiVersion());
|
//var_dump(\Stripe\Stripe::getApiVersion());
|
||||||
$this->errors[] = $e->getMessage();
|
$this->errors[] = $e->getMessage();
|
||||||
$ok = -1;
|
$ok = -1;
|
||||||
@ -209,12 +173,10 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
||||||
|
|
||||||
$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
|
$customer = $stripe->customerStripe($object, $stripeacc, $servicestatus);
|
||||||
if ($customer)
|
if ($customer) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
$customer->delete();
|
$customer->delete();
|
||||||
} catch (Exception $e)
|
} catch (Exception $e) {
|
||||||
{
|
|
||||||
dol_syslog("Failed to delete Stripe customer ".$e->getMessage(), LOG_WARNING);
|
dol_syslog("Failed to delete Stripe customer ".$e->getMessage(), LOG_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,13 +194,11 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') {
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
if (!empty($object->stripe_card_ref))
|
if (!empty($object->stripe_card_ref)) {
|
||||||
{
|
|
||||||
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
||||||
$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
|
$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
|
||||||
|
|
||||||
if ($stripecu)
|
if ($stripecu) {
|
||||||
{
|
|
||||||
// Get customer (required to get a card)
|
// Get customer (required to get a card)
|
||||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||||
$customer = \Stripe\Customer::retrieve($stripecu);
|
$customer = \Stripe\Customer::retrieve($stripecu);
|
||||||
@ -246,15 +206,13 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($customer)
|
if ($customer) {
|
||||||
{
|
|
||||||
$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
|
$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
|
||||||
if ($card) {
|
if ($card) {
|
||||||
$card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']));
|
$card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']));
|
||||||
try {
|
try {
|
||||||
$card->save();
|
$card->save();
|
||||||
} catch (Exception $e)
|
} catch (Exception $e) {
|
||||||
{
|
|
||||||
$ok = -1;
|
$ok = -1;
|
||||||
$this->error = $e->getMessages();
|
$this->error = $e->getMessages();
|
||||||
}
|
}
|
||||||
@ -266,13 +224,11 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
|
if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') {
|
||||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||||
|
|
||||||
if (!empty($object->stripe_card_ref))
|
if (!empty($object->stripe_card_ref)) {
|
||||||
{
|
|
||||||
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
$stripeacc = $stripe->getStripeAccount($service); // No need of network access for this. May return '' if no Oauth defined.
|
||||||
$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
|
$stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this
|
||||||
|
|
||||||
if ($stripecu)
|
if ($stripecu) {
|
||||||
{
|
|
||||||
// Get customer (required to get a card)
|
// Get customer (required to get a card)
|
||||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||||
$customer = \Stripe\Customer::retrieve($stripecu);
|
$customer = \Stripe\Customer::retrieve($stripecu);
|
||||||
@ -280,8 +236,7 @@ class InterfaceStripe extends DolibarrTriggers
|
|||||||
$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
$customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($customer)
|
if ($customer) {
|
||||||
{
|
|
||||||
$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
|
$card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus);
|
||||||
if ($card) {
|
if ($card) {
|
||||||
if (method_exists($card, 'detach')) $card->detach();
|
if (method_exists($card, 'detach')) $card->detach();
|
||||||
|
|||||||
@ -33,23 +33,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
|||||||
*/
|
*/
|
||||||
class InterfaceContactRoles extends DolibarrTriggers
|
class InterfaceContactRoles extends DolibarrTriggers
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
*/
|
||||||
|
public function __construct($db)
|
||||||
|
{
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
public $family = 'agenda';
|
$this->name = preg_replace('/^Interface/i', '', get_class($this));
|
||||||
|
$this->family = "agenda";
|
||||||
public $description = "Triggers of this module auto link contact to company.";
|
$this->description = "Triggers of this module auto link contact to company.";
|
||||||
|
// 'development', 'experimental', 'dolibarr' or version
|
||||||
/**
|
$this->version = self::VERSION_DOLIBARR;
|
||||||
* Version of the trigger
|
$this->picto = 'action';
|
||||||
*
|
}
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $version = self::VERSION_DOLIBARR;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var string Image of the trigger
|
|
||||||
*/
|
|
||||||
public $picto = 'action';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when a Dolibarrr business event is done.
|
* Function called when a Dolibarrr business event is done.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user