Make code generic and usable for all modules
This commit is contained in:
parent
7acb066483
commit
cd4a4febf8
@ -76,23 +76,13 @@ class CSMSFile
|
|||||||
dol_syslog("CSMSFile::CSMSFile: deliveryreceipt=".$deliveryreceipt." deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG);
|
dol_syslog("CSMSFile::CSMSFile: deliveryreceipt=".$deliveryreceipt." deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG);
|
||||||
|
|
||||||
// Action according to choosed sending method
|
// Action according to choosed sending method
|
||||||
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh')
|
$this->addr_from=$from;
|
||||||
{
|
$this->addr_to=$to;
|
||||||
$this->addr_from=$from;
|
$this->message=$msg;
|
||||||
$this->addr_to=$to;
|
$this->deliveryreceipt=$deliveryreceipt;
|
||||||
$this->message=$msg;
|
$this->deferred=$deferred;
|
||||||
$this->deliveryreceipt=$deliveryreceipt;
|
$this->priority=$priority;
|
||||||
$this->deferred=$deferred;
|
$this->class=$class;
|
||||||
$this->priority=$priority;
|
|
||||||
$this->class=$class;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Send mail method not correctly defined
|
|
||||||
// --------------------------------------
|
|
||||||
|
|
||||||
return 'Bad value for MAIN_SMS_SENDMODE constant';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -119,25 +109,22 @@ class CSMSFile
|
|||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_ALL_SMS))
|
if (empty($conf->global->MAIN_DISABLE_ALL_SMS))
|
||||||
{
|
{
|
||||||
// Action according to choosed sending method
|
// Action according to choosed sending method
|
||||||
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh')
|
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated
|
||||||
{
|
{
|
||||||
dol_include_once('/ovh/class/ovhsms.class.php');
|
dol_include_once('/ovh/class/ovhsms.class.php');
|
||||||
$ovhsms=new OvhSms($this->db);
|
$sms=new OvhSms($this->db);
|
||||||
//$ovhsms->session='';
|
$sms->expe=$this->addr_from;
|
||||||
//$ovhsms->account='';
|
$sms->dest=$this->addr_to;
|
||||||
$ovhsms->expe=$this->addr_from;
|
$sms->message=$this->message;
|
||||||
$ovhsms->dest=$this->addr_to;
|
$sms->deferred=$this->deferred;
|
||||||
$ovhsms->message=$this->message;
|
$sms->priority=$this->priority;
|
||||||
//$ovhsms->validity='';
|
$sms->class=$this->class;
|
||||||
$ovhsms->deferred=$this->deferred;
|
|
||||||
$ovhsms->priority=$this->priority;
|
|
||||||
$ovhsms->class=$this->class;
|
|
||||||
|
|
||||||
$res=$ovhsms->SmsSend();
|
$res=$sms->SmsSend();
|
||||||
if ($res <= 0)
|
if ($res <= 0)
|
||||||
{
|
{
|
||||||
$this->error=$ovhsms->error;
|
$this->error=$sms->error;
|
||||||
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
|
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -147,6 +134,40 @@ class CSMSFile
|
|||||||
$this->dump_sms_result($res);
|
$this->dump_sms_result($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (! empty($conf->global->MAIN_SMS_SENDMODE)) // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
|
||||||
|
{
|
||||||
|
$tmp=explode('@',$conf->global->MAIN_SMS_SENDMODE);
|
||||||
|
$classfile=$tmp[0]; $module=(empty($tmp[1])?$tmp[0]:$tmp[1]);
|
||||||
|
dol_include_once('/'.$module.'/class/'.$classfile.'.class.php');
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$classname=ucfirst($classfile);
|
||||||
|
$sms = new $classname($this->db);
|
||||||
|
$sms->expe=$this->addr_from;
|
||||||
|
$sms->dest=$this->addr_to;
|
||||||
|
$sms->message=$this->message;
|
||||||
|
$sms->deferred=$this->deferred;
|
||||||
|
$sms->priority=$this->priority;
|
||||||
|
$sms->class=$this->class;
|
||||||
|
|
||||||
|
$res=$sms->SmsSend();
|
||||||
|
if ($res <= 0)
|
||||||
|
{
|
||||||
|
$this->error=$sms->error;
|
||||||
|
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
|
||||||
|
//var_dump($res); // 1973128
|
||||||
|
$this->dump_sms_result($res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
dol_print_error('','Error to get list of senders: '.$e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send mail method not correctly defined
|
// Send mail method not correctly defined
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user