Fix: error management
This commit is contained in:
parent
1948fc115e
commit
7acb066483
@ -85,6 +85,12 @@ if ($action == 'send' && ! $_POST['cancel'])
|
|||||||
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php');
|
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php');
|
||||||
$formsms = new FormSms($db);
|
$formsms = new FormSms($db);
|
||||||
|
|
||||||
|
if (! empty($formsms->error))
|
||||||
|
{
|
||||||
|
$message='<div class="error">'.$formsms->error.'</div>';
|
||||||
|
$action='test';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
if (empty($body))
|
if (empty($body))
|
||||||
{
|
{
|
||||||
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Message")).'</div>';
|
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Message")).'</div>';
|
||||||
@ -151,7 +157,7 @@ print_fiche_titre($langs->trans("SmsSetup"),'','setup');
|
|||||||
print $langs->trans("SmsDesc")."<br>\n";
|
print $langs->trans("SmsDesc")."<br>\n";
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
if ($message) print $message.'<br>';
|
dol_htmloutput_mesg($message);
|
||||||
|
|
||||||
// List of sending methods
|
// List of sending methods
|
||||||
$listofmethods=(is_array($conf->sms_engine)?$conf->sms_engine:array());
|
$listofmethods=(is_array($conf->sms_engine)?$conf->sms_engine:array());
|
||||||
|
|||||||
@ -84,6 +84,9 @@ class FormSms
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form to input an sms
|
* Show the form to input an sms
|
||||||
|
*
|
||||||
|
* @param string $width Width of form
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function show_form($width='180px')
|
function show_form($width='180px')
|
||||||
{
|
{
|
||||||
@ -100,7 +103,7 @@ class FormSms
|
|||||||
$soc->fetch($this->withtosocid);
|
$soc->fetch($this->withtosocid);
|
||||||
}
|
}
|
||||||
|
|
||||||
print "\n<!-- Debut form SMS -->\n";
|
print "\n<!-- Begin form SMS -->\n";
|
||||||
|
|
||||||
print '
|
print '
|
||||||
<script language="javascript">
|
<script language="javascript">
|
||||||
@ -170,7 +173,7 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
{
|
{
|
||||||
print "<tr><td width=\"".$width."\">".$langs->trans("SmsFrom")."</td><td>";
|
print "<tr><td width=\"".$width."\">".$langs->trans("SmsFrom")."</td><td>";
|
||||||
//print '<input type="text" name="fromname" size="30" value="'.$this->fromsms.'">';
|
//print '<input type="text" name="fromname" size="30" value="'.$this->fromsms.'">';
|
||||||
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh')
|
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // For backward compatibility @deprecated
|
||||||
{
|
{
|
||||||
dol_include_once('/ovh/class/ovhsms.class.php');
|
dol_include_once('/ovh/class/ovhsms.class.php');
|
||||||
try
|
try
|
||||||
@ -182,7 +185,7 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$resultsender = $sms->SmsSenderList($conf->global->OVHSMS_ACCOUNT);
|
$resultsender = $sms->SmsSenderList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
@ -190,12 +193,30 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
dol_print_error('','Error to get list of senders: '.$e->getMessage());
|
dol_print_error('','Error to get list of senders: '.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
$resultsender = $sms->SmsSenderList();
|
||||||
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
dol_print_error('','Error to get list of senders: '.$e->getMessage());
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog("Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
|
dol_syslog("Warning: The SMS sending method has not been defined into MAIN_SMS_SENDMODE", LOG_WARNING);
|
||||||
$resultsender[0]->number=$this->fromsms;
|
$resultsender[0]->number=$this->fromsms;
|
||||||
}
|
}
|
||||||
if (count($resultsender) > 0)
|
|
||||||
|
if (is_array($resultsender) && count($resultsender) > 0)
|
||||||
{
|
{
|
||||||
print '<select name="fromsms" id="valid" class="flat">';
|
print '<select name="fromsms" id="valid" class="flat">';
|
||||||
foreach($resultsender as $obj)
|
foreach($resultsender as $obj)
|
||||||
@ -204,7 +225,12 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
}
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
}
|
}
|
||||||
else print '<span class="error">'.$langs->trans("SmsNoPossibleRecipientFound").'</span>';
|
else
|
||||||
|
{
|
||||||
|
print '<span class="error">'.$langs->trans("SmsNoPossibleRecipientFound");
|
||||||
|
if (is_object($sms) && ! empty($sms->error)) print ' '.$sms->error;
|
||||||
|
print '</span>';
|
||||||
|
}
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
@ -224,7 +250,7 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<input size=\"16\" name=\"sendto\" value=\"".(! is_array($this->withto) && $this->withto != '1'? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto):"+")."\">";
|
print "<input size=\"16\" id=\"sendto\" name=\"sendto\" value=\"".(! is_array($this->withto) && $this->withto != '1'? (isset($_REQUEST["sendto"])?$_REQUEST["sendto"]:$this->withto):"+")."\">";
|
||||||
if (! empty($this->withtosocid) && $this->withtosocid > 0)
|
if (! empty($this->withtosocid) && $this->withtosocid > 0)
|
||||||
{
|
{
|
||||||
$liste=array();
|
$liste=array();
|
||||||
@ -245,7 +271,10 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
if ($this->withbody)
|
if ($this->withbody)
|
||||||
{
|
{
|
||||||
$defaultmessage='';
|
$defaultmessage='';
|
||||||
if ($this->param["models"]=='body') { $defaultmessage=$this->withbody; }
|
if ($this->param["models"]=='body')
|
||||||
|
{
|
||||||
|
$defaultmessage=$this->withbody;
|
||||||
|
}
|
||||||
$defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
|
$defaultmessage=make_substitutions($defaultmessage,$this->substit,$langs);
|
||||||
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
|
if (isset($_POST["message"])) $defaultmessage=$_POST["message"];
|
||||||
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
|
$defaultmessage=str_replace('\n',"\n",$defaultmessage);
|
||||||
@ -261,7 +290,7 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<textarea cols="40" name="message" id="message" rows="4" onkeyup="limitChars(this, 160, \'charlimitinfo\')">'.$defaultmessage.'</textarea>';
|
print '<textarea cols="40" name="message" id="message" rows="4" onkeyup="limitChars(this, 160, \'charlimitinfo\')">'.$defaultmessage.'</textarea>';
|
||||||
print '<div id="charlimitinfo">'.$langs->trans("SmsInfoCharRemain").': '.(160-dol_strlen($defaultmessage)).'</div></td>';
|
print '<div id="charlimitinfo">'.$langs->trans("SmsInfoCharRemain").': <span id="charlimitinfospan">'.(160-dol_strlen($defaultmessage)).'</span></div></td>';
|
||||||
}
|
}
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
@ -287,7 +316,9 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
<option value="3">ToolKit</option>
|
<option value="3">ToolKit</option>
|
||||||
</select></td></tr>';
|
</select></td></tr>';
|
||||||
|
|
||||||
print '<tr><td align="center" colspan="2"><center>';
|
print "</table>\n";
|
||||||
|
|
||||||
|
print '<center>';
|
||||||
print "<input class=\"button\" type=\"submit\" name=\"sendmail\" value=\"".$langs->trans("SendSms")."\"";
|
print "<input class=\"button\" type=\"submit\" name=\"sendmail\" value=\"".$langs->trans("SendSms")."\"";
|
||||||
print ">";
|
print ">";
|
||||||
if ($this->withcancel)
|
if ($this->withcancel)
|
||||||
@ -295,11 +326,10 @@ function limitChars(textarea, limit, infodiv)
|
|||||||
print " ";
|
print " ";
|
||||||
print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">";
|
print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">";
|
||||||
}
|
}
|
||||||
print "</center></td></tr>\n";
|
print "</center>\n";
|
||||||
print "</table>\n";
|
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
print "<!-- Fin form SMS -->\n";
|
print "<!-- End form SMS -->\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user