mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Remove hardcoded code for OVH sms. Generic method is ok now.
This commit is contained in:
parent
3199bd7137
commit
8cc3d2358b
|
|
@ -185,7 +185,7 @@ if ($action == 'edit') {
|
|||
// Method
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
|
||||
if (count($listofmethods)) {
|
||||
print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1);
|
||||
print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, getDolGlobalString('MAIN_SMS_SENDMODE'), 1);
|
||||
} else {
|
||||
print '<span class="error">'.$langs->trans("None").'</span>';
|
||||
}
|
||||
|
|
@ -224,7 +224,7 @@ if ($action == 'edit') {
|
|||
|
||||
// Method
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
|
||||
$text = empty(getDolGlobalString('MAIN_SMS_SENDMODE')) ? '' : $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')];
|
||||
$text = getDolGlobalString('MAIN_SMS_SENDMODE') ? $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')] : '';
|
||||
if (empty($text)) {
|
||||
$text = $langs->trans("Undefined").' '.img_warning();
|
||||
}
|
||||
|
|
@ -256,19 +256,7 @@ if ($action == 'edit') {
|
|||
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
|
||||
|
||||
/*if ($conf->global->MAIN_SMS_SENDMODE != 'mail' || ! $linuxlike)
|
||||
{
|
||||
if (function_exists('fsockopen') && $port && $server)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
|
||||
}*/
|
||||
|
||||
if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) {
|
||||
if (count($listofmethods) && getDolGlobalString('MAIN_SMS_SENDMODE')) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init">'.$langs->trans("DoTestSend").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("DoTestSend").'</a>';
|
||||
|
|
|
|||
|
|
@ -95,12 +95,12 @@ class CSMSFile
|
|||
}
|
||||
|
||||
// If ending method not defined
|
||||
if (empty($conf->global->MAIN_SMS_SENDMODE)) {
|
||||
if (!getDolGlobalString('MAIN_SMS_SENDMODE')) {
|
||||
$this->error = 'No SMS Engine defined';
|
||||
throw new Exception('No SMS Engine defined');
|
||||
}
|
||||
|
||||
dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".$conf->global->MAIN_SMS_SENDMODE." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".strlen($msg), LOG_DEBUG);
|
||||
dol_syslog("CSMSFile::CSMSFile: MAIN_SMS_SENDMODE=".getDolGlobalString('MAIN_SMS_SENDMODE')." charset=".$conf->file->character_set_client." from=".$from.", to=".$to.", msg length=".strlen($msg), LOG_DEBUG);
|
||||
dol_syslog("CSMSFile::CSMSFile: deferred=".$deferred." priority=".$priority." class=".$class, LOG_DEBUG);
|
||||
|
||||
// Action according to choosed sending method
|
||||
|
|
@ -138,69 +138,51 @@ class CSMSFile
|
|||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) {
|
||||
// Action according to choosed sending method
|
||||
if (getDolGlobalString('MAIN_SMS_SENDMODE') == 'ovh') { // Backward compatibility @deprecated
|
||||
dol_include_once('/ovh/class/ovhsms.class.php');
|
||||
/** @phpstan-ignore-next-line */
|
||||
$sms = new OvhSms($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;
|
||||
$sms->nostop = $this->nostop;
|
||||
|
||||
$sms->socid = $this->socid;
|
||||
$sms->contact_id = $this->contact_id;
|
||||
$sms->member_id = $this->member_id;
|
||||
$sms->project = $this->fk_project;
|
||||
|
||||
$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
|
||||
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
|
||||
$this->dump_sms_result($res);
|
||||
}
|
||||
// Action according to the choosed sending method
|
||||
if (getDolGlobalString('MAIN_SMS_SENDMODE')) {
|
||||
$sendmode = getDolGlobalString('MAIN_SMS_SENDMODE'); // $conf->global->MAIN_SMS_SENDMODE looks like a value 'module'
|
||||
$classmoduleofsender = getDolGlobalString('MAIN_MODULE_'.strtoupper($sendmode).'_SMS', $sendmode); // $conf->global->MAIN_MODULE_XXX_SMS looks like a value 'class@module'
|
||||
if ($classmoduleofsender == 'ovh') {
|
||||
$classmoduleofsender = 'ovhsms@ovh'; // For backward compatibility
|
||||
}
|
||||
} elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
|
||||
$tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE);
|
||||
|
||||
$tmp = explode('@', $classmoduleofsender);
|
||||
$classfile = $tmp[0];
|
||||
$module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
|
||||
dol_include_once('/'.$module.'/class/'.$classfile.'.class.php');
|
||||
dol_include_once('/'.$module.'/class/'.strtolower($classfile).'.class.php');
|
||||
try {
|
||||
$classname = ucfirst($classfile);
|
||||
$sms = new $classname($this->db);
|
||||
$sms->expe = $this->addr_from;
|
||||
$sms->dest = $this->addr_to;
|
||||
$sms->deferred = $this->deferred;
|
||||
$sms->priority = $this->priority;
|
||||
$sms->class = $this->class;
|
||||
$sms->message = $this->message;
|
||||
$sms->nostop = $this->nostop;
|
||||
if (class_exists($classname)) {
|
||||
$sms = new $classname($this->db);
|
||||
$sms->expe = $this->addr_from;
|
||||
$sms->dest = $this->addr_to;
|
||||
$sms->deferred = $this->deferred;
|
||||
$sms->priority = $this->priority;
|
||||
$sms->class = $this->class;
|
||||
$sms->message = $this->message;
|
||||
$sms->nostop = $this->nostop;
|
||||
|
||||
$sms->socid = $this->socid;
|
||||
$sms->contact_id = $this->contact_id;
|
||||
$sms->member_id = $this->member_id;
|
||||
$sms->fk_project = $this->fk_project;
|
||||
$sms->socid = $this->socid;
|
||||
$sms->contact_id = $this->contact_id;
|
||||
$sms->member_id = $this->member_id;
|
||||
$sms->fk_project = $this->fk_project;
|
||||
|
||||
$res = $sms->SmsSend();
|
||||
$res = $sms->SmsSend();
|
||||
|
||||
$this->error = $sms->error;
|
||||
$this->errors = $sms->errors;
|
||||
if ($res <= 0) {
|
||||
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
|
||||
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
|
||||
$this->dump_sms_result($res);
|
||||
$this->error = $sms->error;
|
||||
$this->errors = $sms->errors;
|
||||
if ($res <= 0) {
|
||||
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
|
||||
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
|
||||
$this->dump_sms_result($res);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sms = new stdClass();
|
||||
$sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).'_SMS is not found';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_print_error('', 'Error to get list of senders: '.$e->getMessage());
|
||||
|
|
|
|||
|
|
@ -374,11 +374,9 @@ class Conf
|
|||
$newvalue = '/'.$modulename.'/core/'.$partname.'/';
|
||||
} elseif (in_array($partname, array('models', 'theme'))) {
|
||||
$newvalue = '/'.$modulename.'/';
|
||||
} elseif (in_array($partname, array('sms'))) {
|
||||
$newvalue = '/'.$modulename.'/';
|
||||
} elseif ($value == 1) {
|
||||
$newvalue = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
|
||||
} else {
|
||||
} else { // $partname can be any other value like 'sms', ...
|
||||
$newvalue = $value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -553,7 +553,8 @@ class ExtraFields
|
|||
*/
|
||||
public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0, $moreparams = array())
|
||||
{
|
||||
global $hookmanager, $action;
|
||||
global $hookmanager;
|
||||
global $action;
|
||||
|
||||
if ($elementtype == 'thirdparty') {
|
||||
$elementtype = 'societe';
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@ class Form
|
|||
public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
global $langs;
|
||||
|
||||
// If product & services are enabled or both disabled.
|
||||
if ($forceall == 1 || (empty($forceall) && isModEnabled("product") && isModEnabled("service"))
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ class FormMargin
|
|||
public function displayMarginInfos($object, $force_price = false)
|
||||
{
|
||||
global $langs, $conf, $user, $hookmanager;
|
||||
global $action;
|
||||
|
||||
if (!empty($user->socid)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -471,6 +471,7 @@ class FormOther
|
|||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $hookmanager;
|
||||
global $action;
|
||||
|
||||
$langs->load('users');
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class FormSms
|
|||
public function show_form($morecss = 'titlefield', $showform = 1)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $user, $form;
|
||||
global $conf, $langs, $form;
|
||||
|
||||
if (!is_object($form)) {
|
||||
$form = new Form($this->db);
|
||||
|
|
@ -185,21 +185,14 @@ function limitChars(textarea, limit, infodiv)
|
|||
print "</td></tr>\n";
|
||||
} else {
|
||||
print '<tr><td class="'.$morecss.'">'.$langs->trans("SmsFrom")."</td><td>";
|
||||
//print '<input type="text" name="fromname" size="30" value="'.$this->fromsms.'">';
|
||||
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') { // For backward compatibility @deprecated
|
||||
dol_include_once('/ovh/class/ovhsms.class.php');
|
||||
try {
|
||||
$sms = new OvhSms($this->db);
|
||||
if (empty($conf->global->OVHSMS_ACCOUNT)) {
|
||||
$resultsender = 'ErrorOVHSMS_ACCOUNT not defined';
|
||||
} else {
|
||||
$resultsender = $sms->SmsSenderList();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_print_error('', 'Error to get list of senders: '.$e->getMessage());
|
||||
if (getDolGlobalString('MAIN_SMS_SENDMODE')) {
|
||||
$sendmode = getDolGlobalString('MAIN_SMS_SENDMODE'); // $conf->global->MAIN_SMS_SENDMODE looks like a value 'module'
|
||||
$classmoduleofsender = getDolGlobalString('MAIN_MODULE_'.strtoupper($sendmode).'_SMS', $sendmode); // $conf->global->MAIN_MODULE_XXX_SMS looks like a value 'class@module'
|
||||
if ($classmoduleofsender == 'ovh') {
|
||||
$classmoduleofsender = 'ovhsms@ovh'; // For backward compatibility
|
||||
}
|
||||
} elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
|
||||
$tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE);
|
||||
|
||||
$tmp = explode('@', $classmoduleofsender);
|
||||
$classfile = $tmp[0];
|
||||
$module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
|
||||
dol_include_once('/'.$module.'/class/'.$classfile.'.class.php');
|
||||
|
|
@ -210,7 +203,7 @@ function limitChars(textarea, limit, infodiv)
|
|||
$resultsender = $sms->SmsSenderList();
|
||||
} else {
|
||||
$sms = new stdClass();
|
||||
$sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_SMS_SENDMODE is not found';
|
||||
$sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).'_SMS is not found';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_print_error('', 'Error to get list of senders: '.$e->getMessage());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user