';
- print $langs->trans("ErrorContactEMail", $conf->global->MAIN_INFO_SOCIETE_MAIL, $prefixcode.dol_print_date($now,'%Y%m%d'));
+ print $langs->trans("ErrorContactEMail", $email, $prefixcode.dol_print_date($now,'%Y%m%d'));
if ($errormessage) print '
'.$errormessage;
if (is_array($errormessages) && count($errormessages))
{
@@ -6884,6 +6888,10 @@ function printCommonFooter($zone='private')
if ($zone == 'private') print "\n".''."\n";
else print "\n".''."\n";
+ // A div to store page_y POST parameter so we can read it using javascript
+ print "\n\n";
+ print '
'.$_POST['page_y'].'
'."\n";
+
$parameters=array();
$reshook=$hookmanager->executeHooks('printCommonFooter',$parameters); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index a367579e1cd..d7de2ea9a92 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -27,44 +27,75 @@
/**
- * Encode a string with base 64 algorithm + specific change
- * Code of this function is useless and we should use base64_encode only instead
+ * Encode a string with base 64 algorithm + specific delta change.
*
* @param string $chain string to encode
+ * @param string $key rule to use for delta ('0', '1' or 'myownkey')
* @return string encoded string
+ * @see dol_decode
*/
-function dol_encode($chain)
+function dol_encode($chain, $key='1')
{
- $strlength=dol_strlen($chain);
- for ($i=0; $i < $strlength; $i++)
+ if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
{
- $output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
+ $strlength=dol_strlen($chain);
+ for ($i=0; $i < $strlength; $i++)
+ {
+ $output_tab[$i] = chr(ord(substr($chain,$i,1))+17);
+ }
+ $chain = implode("",$output_tab);
+ }
+ elseif ($key)
+ {
+ $result='';
+ $strlength=dol_strlen($chain);
+ for ($i=0; $i < $strlength; $i++)
+ {
+ $keychar = substr($key, ($i % strlen($key))-1, 1);
+ $result.= chr(ord(substr($chain,$i,1))+(ord($keychar)-65));
+ }
+ $chain=$result;
}
- $string_coded = base64_encode(implode("",$output_tab));
- return $string_coded;
+ return base64_encode($chain);
}
/**
- * Decode a base 64 encoded + specific string.
+ * Decode a base 64 encoded + specific delta change.
* This function is called by filefunc.inc.php at each page call.
- * Code of this function is useless and we should use base64_decode only instead
*
* @param string $chain string to decode
+ * @param string $key rule to use for delta ('0', '1' or 'myownkey')
* @return string decoded string
+ * @see dol_encode
*/
-function dol_decode($chain)
+function dol_decode($chain, $key='1')
{
$chain = base64_decode($chain);
- $strlength=dol_strlen($chain);
- for($i=0; $i < $strlength;$i++)
+ if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char
{
- $output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
+ $strlength=dol_strlen($chain);
+ for ($i=0; $i < $strlength;$i++)
+ {
+ $output_tab[$i] = chr(ord(substr($chain,$i,1))-17);
+ }
+
+ $chain = implode("",$output_tab);
+ }
+ elseif ($key)
+ {
+ $result='';
+ $strlength=dol_strlen($chain);
+ for ($i=0; $i < $strlength; $i++)
+ {
+ $keychar = substr($key, ($i % strlen($key))-1, 1);
+ $result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65));
+ }
+ $chain=$result;
}
- $string_decoded = implode("",$output_tab);
- return $string_decoded;
+ return $chain;
}
diff --git a/htdocs/core/lib/ticketsup.lib.php b/htdocs/core/lib/ticketsup.lib.php
index 040dad6c656..e377fb5e064 100644
--- a/htdocs/core/lib/ticketsup.lib.php
+++ b/htdocs/core/lib/ticketsup.lib.php
@@ -195,7 +195,7 @@ function showlogo()
$urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
}
print '
';
- print '
';
+ print '
';
print '' . ($conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC ? $conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC : $langs->trans("TicketSystem")) . '';
print '';
}
diff --git a/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php
index 96be9ba9c74..d27f0d6aa67 100644
--- a/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php
+++ b/htdocs/core/triggers/interface_50_modTicketsup_TicketEmail.class.php
@@ -110,189 +110,209 @@ class InterfaceTicketEmail extends DolibarrTriggers
case 'TICKET_ASSIGNED':
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);
$res = $userstat->fetch($object->fk_user_assign);
- if ($res) {
- // Send email to assigned user
- $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
- $message = '
' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "
";
- $message .= '
- ' . $langs->trans('Title') . ' : ' . $object->subject . '
';
- $message .= '- ' . $langs->trans('Type') . ' : ' . $object->type_label . '
';
- $message .= '- ' . $langs->trans('Category') . ' : ' . $object->category_label . '
';
- $message .= '- ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
';
- // Extrafields
- if (is_array($object->array_options) && count($object->array_options) > 0) {
- foreach ($object->array_options as $key => $value) {
- $message .= '- ' . $langs->trans($key) . ' : ' . $value . '
';
+ if ($res > 0)
+ {
+ if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS))
+ {
+ // Init to avoid errors
+ $filepath = array();
+ $filename = array();
+ $mimetype = array();
+
+ // Send email to assigned user
+ $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketAssignedToYou');
+ $message = '' . $langs->transnoentities('TicketAssignedEmailBody', $object->track_id, dolGetFirstLastname($user->firstname, $user->lastname)) . "
";
+ $message .= '- ' . $langs->trans('Title') . ' : ' . $object->subject . '
';
+ $message .= '- ' . $langs->trans('Type') . ' : ' . $object->type_label . '
';
+ $message .= '- ' . $langs->trans('Category') . ' : ' . $object->category_label . '
';
+ $message .= '- ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
';
+ // Extrafields
+ if (is_array($object->array_options) && count($object->array_options) > 0) {
+ foreach ($object->array_options as $key => $value) {
+ $message .= '- ' . $langs->trans($key) . ' : ' . $value . '
';
+ }
+ }
+
+ $message .= '
';
+ $message .= '' . $langs->trans('Message') . ' :
' . $object->message . '
';
+ $message .= '' . $langs->trans('SeeThisTicketIntomanagementInterface') . '
';
+
+ $sendto = $userstat->email;
+ $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
+
+ $message = dol_nl2br($message);
+
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
- }
-
- $message .= '
';
- $message .= '
' . $langs->trans('Message') . ' :
' . $object->message . '
';
- $message .= '
' . $langs->trans('SeeThisTicketIntomanagementInterface') . '
';
-
- $sendto = $userstat->email;
- $from = dolGetFirstLastname($user->firstname, $user->lastname) . '<' . $user->email . '>';
-
- // Init to avoid errors
- $filepath = array();
- $filename = array();
- $mimetype = array();
-
- $message = dol_nl2br($message);
-
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
- }
- include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
- $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
- if ($mailfile->error) {
- setEventMessage($mailfile->error, 'errors');
- } else {
- $result = $mailfile->sendfile();
- }
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
- }
+ include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+ $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, '', '', 0, -1);
+ if ($mailfile->error) {
+ setEventMessage($mailfile->error, 'errors');
+ } else {
+ $result = $mailfile->sendfile();
+ }
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
+ }
+ }
$ok = 1;
}
+ else
+ {
+ $this->error = $userstat->error;
+ $this->errors = $userstat->errors;
+ }
}
break;
-
case 'TICKET_CREATE':
dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
- // Init to avoid errors
- $filepath = array();
- $filename = array();
- $mimetype = array();
-
$langs->load('ticketsup');
- $object->fetch('', $object->track_id);
+ $object->fetch('', $object->track_id); // Should be useless
- /* Send email to admin */
- $sendto = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO;
- $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
- $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
- $message_admin.='
- '.$langs->trans('Title').' : '.$object->subject.'
';
- $message_admin.='- '.$langs->trans('Type').' : '.$object->type_label.'
';
- $message_admin.='- '.$langs->trans('Category').' : '.$object->category_label.'
';
- $message_admin.='- '.$langs->trans('Severity').' : '.$object->severity_label.'
';
- $message_admin.='- '.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'
';
- // Extrafields
- if (is_array($object->array_options) && count($object->array_options) > 0) {
- foreach ($object->array_options as $key => $value) {
- $message_admin.='- '.$langs->trans($key).' : '.$value.'
';
+
+ // Send email to notification email
+
+ if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS) && empty($object->context['disableticketsupemail']))
+ {
+ $sendto = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO;
+
+ if ($sendto)
+ {
+ // Init to avoid errors
+ $filepath = array();
+ $filename = array();
+ $mimetype = array();
+
+ /* Send email to admin */
+ $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin');
+ $message_admin= $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n";
+ $message_admin.='- '.$langs->trans('Title').' : '.$object->subject.'
';
+ $message_admin.='- '.$langs->trans('Type').' : '.$object->type_label.'
';
+ $message_admin.='- '.$langs->trans('Category').' : '.$object->category_label.'
';
+ $message_admin.='- '.$langs->trans('Severity').' : '.$object->severity_label.'
';
+ $message_admin.='- '.$langs->trans('From').' : '.( $object->email_from ? $object->email_from : ( $object->fk_user_create > 0 ? $langs->trans('Internal') : '') ).'
';
+ // Extrafields
+ if (is_array($object->array_options) && count($object->array_options) > 0) {
+ foreach ($object->array_options as $key => $value) {
+ $message_admin.='- '.$langs->trans($key).' : '.$value.'
';
+ }
+ }
+ $message_admin.='
';
+
+ if ($object->fk_soc > 0) {
+ $object->fetch_thirdparty();
+ $message_admin.=''.$langs->trans('Company'). ' : '.$object->thirdparty->name.'
';
+ }
+
+ $message_admin.=''.$langs->trans('Message').' :
'.$object->message.'
';
+ $message_admin.=''.$langs->trans('SeeThisTicketIntomanagementInterface').'
';
+
+ $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
+ $replyto = $from;
+
+ $message_admin = dol_nl2br($message_admin);
+
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
+ }
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
+ if ($mailfile->error) {
+ dol_syslog($mailfile->error, LOG_DEBUG);
+ } else {
+ $result=$mailfile->sendfile();
+ }
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
+ }
+ }
+ }
+
+ // Send email to customer
+
+ if (empty($conf->global->TICKETS_DISABLE_ALL_MAILS) && empty($object->context['disableticketsupemail']) && $object->notify_tiers_at_create)
+ {
+ $sendto = '';
+ if (empty($user->socid) && empty($user->email)) {
+ $object->fetch_thirdparty();
+ $sendto = $object->thirdparty->email;
+ } else {
+ $sendto = $user->email;
+ }
+
+ if ($sendto) {
+ // Init to avoid errors
+ $filepath = array();
+ $filename = array();
+ $mimetype = array();
+
+ $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
+ $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
+ $message_customer.='- '.$langs->trans('Title').' : '.$object->subject.'
';
+ $message_customer.='- '.$langs->trans('Type').' : '.$object->type_label.'
';
+ $message_customer.='- '.$langs->trans('Category').' : '.$object->category_label.'
';
+ $message_customer.='- '.$langs->trans('Severity').' : '.$object->severity_label.'
';
+
+ // Extrafields
+ foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
+ {
+ $enabled = 1;
+ if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
+ {
+ $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
+ }
+ $perms = 1;
+ if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
+ {
+ $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
+ }
+
+ $qualified = true;
+ if (empty($enabled)) $qualified = false;
+ if (empty($perms)) $qualified = false;
+
+ if ($qualified) $message_customer.='- '.$langs->trans($key).' : '.$value.'
';
+ }
+
+ $message_customer.='
';
+ $message_customer.=''.$langs->trans('Message').' :
'.$object->message.'
';
+ $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE?$conf->global->TICKETS_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/public/ticketsup/view.php', 2)).'?track_id='.$object->track_id;
+ $message_customer.='' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : '.$url_public_ticket.'
';
+ $message_customer.=''.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'
';
+
+ $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
+ $replyto = $from;
+
+ $message_customer = dol_nl2br($message_customer);
+
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
+ }
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
+ if ($mailfile->error) {
+ dol_syslog($mailfile->error, LOG_DEBUG);
+ } else {
+ $result=$mailfile->sendfile();
+ }
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
+ }
}
}
- $message_admin.='
';
-
- if ($object->fk_soc > 0) {
- $object->fetch_thirdparty();
- $message_admin.='
'.$langs->trans('Company'). ' : '.$object->thirdparty->name.'
';
- }
-
- $message_admin.='
'.$langs->trans('Message').' :
'.$object->message.'
';
- $message_admin.='
'.$langs->trans('SeeThisTicketIntomanagementInterface').'
';
-
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
- $replyto = $from;
-
- $message_admin = dol_nl2br($message_admin);
-
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
- }
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
- if ($mailfile->error) {
- dol_syslog($mailfile->error, LOG_DEBUG);
- } else {
- $result=$mailfile->sendfile();
- }
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
- }
-
- /* Send email to customer */
- $sendto = '';
- if (empty($user->socid) && empty($user->email)) {
- $object->fetch_thirdparty();
- $sendto = $object->thirdparty->email;
- } else {
- $sendto = $user->email;
- }
-
- if ($sendto && $object->notify_tiers_at_create) {
- $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectCustomer');
- $message_customer= $langs->transnoentities('TicketNewEmailBodyCustomer', $object->track_id)."\n\n";
- $message_customer.='
- '.$langs->trans('Title').' : '.$object->subject.'
';
- $message_customer.='- '.$langs->trans('Type').' : '.$object->type_label.'
';
- $message_customer.='- '.$langs->trans('Category').' : '.$object->category_label.'
';
- $message_customer.='- '.$langs->trans('Severity').' : '.$object->severity_label.'
';
-
- // Extrafields
- foreach ($this->attributes[$object->table_element]['label'] as $key => $value)
- {
- $enabled = 1;
- if ($enabled && isset($this->attributes[$object->table_element]['list'][$key]))
- {
- $enabled = dol_eval($this->attributes[$object->table_element]['list'][$key], 1);
- }
- $perms = 1;
- if ($perms && isset($this->attributes[$object->table_element]['perms'][$key]))
- {
- $perms = dol_eval($this->attributes[$object->table_element]['perms'][$key], 1);
- }
-
- $qualified = true;
- if (empty($enabled)) $qualified = false;
- if (empty($perms)) $qualified = false;
-
- if ($qualified) $message_customer.='- '.$langs->trans($key).' : '.$value.'
';
- }
-
-
- $message_customer.='
';
- $message_customer.='
'.$langs->trans('Message').' :
'.$object->message.'
';
- $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE?$conf->global->TICKETS_URL_PUBLIC_INTERFACE.'/':dol_buildpath('/ticketsup/public/view.php', 2)).'?track_id='.$object->track_id;
- $message_customer.='
' . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : '.$url_public_ticket.'
';
- $message_customer.='
'.$langs->trans('TicketEmailPleaseDoNotReplyToThisEmail').'
';
-
-
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKETS_NOTIFICATION_EMAIL_FROM.'>';
- $replyto = $from;
-
- // Init to avoid errors
- $filepath = array();
- $filename = array();
- $mimetype = array();
-
- $message_customer = dol_nl2br($message_customer);
-
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
- }
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
- if ($mailfile->error) {
- dol_syslog($mailfile->error, LOG_DEBUG);
- } else {
- $result=$mailfile->sendfile();
- }
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
- }
- }
$ok = 1;
-
break;
case 'TICKET_DELETE':
diff --git a/htdocs/langs/en_US/dict.lang b/htdocs/langs/en_US/dict.lang
index f0fa27bcbf8..81f62469896 100644
--- a/htdocs/langs/en_US/dict.lang
+++ b/htdocs/langs/en_US/dict.lang
@@ -5,7 +5,8 @@ CountryIT=Italy
CountryES=Spain
CountryDE=Germany
CountryCH=Switzerland
-CountryGB=Great Britain
+# Warning, country code GB is for United Kingdom. UK Does not exists as country code in ISO standard.
+CountryGB=United Kingdom
CountryUK=United Kingdom
CountryIE=Ireland
CountryCN=China
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 5bc55bd0d53..862b0701e33 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -198,7 +198,7 @@ if (! empty($_POST["DOL_AUTOSET_COOKIE"]))
{
$tmpautoset=explode(':',$_POST["DOL_AUTOSET_COOKIE"],2);
$tmplist=explode(',',$tmpautoset[1]);
- $cookiearrayvalue='';
+ $cookiearrayvalue=array();
foreach ($tmplist as $tmpkey)
{
$postkey=$tmpautoset[0].'_'.$tmpkey;
diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php
index 559b5b13564..d37dfe0c83b 100644
--- a/htdocs/margin/admin/margin.php
+++ b/htdocs/margin/admin/margin.php
@@ -42,7 +42,7 @@ $action=GETPOST('action','alpha');
/*
* Action
*/
-if (preg_match('/set_(.*)/',$action,$reg))
+if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
@@ -56,7 +56,7 @@ if (preg_match('/set_(.*)/',$action,$reg))
}
}
-if (preg_match('/del_(.*)/',$action,$reg))
+if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
diff --git a/htdocs/public/ticketsup/create_ticket.php b/htdocs/public/ticketsup/create_ticket.php
index 56c81a8a530..91de0eb661e 100644
--- a/htdocs/public/ticketsup/create_ticket.php
+++ b/htdocs/public/ticketsup/create_ticket.php
@@ -17,9 +17,9 @@
*/
/**
- * Display public form to add new ticket
- *
- * \ingroup ticketsup
+ * \file htdocs/public/ticketsup/index.php
+ * \ingroup ticketsup
+ * \brief Display public form to add new ticket
*/
if (!defined('NOREQUIREUSER')) {
define('NOREQUIREUSER', '1');
@@ -127,11 +127,11 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
}
}
- if (!GETPOST("subject")) {
+ if (!GETPOST("subject","none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
$action = '';
- } elseif (!GETPOST("message")) {
+ } elseif (!GETPOST("message","none")) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("message")));
$action = '';
@@ -149,13 +149,13 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
$object->track_id = generate_random_id(16);
- $object->subject = GETPOST("subject");
- $object->message = GETPOST("message");
+ $object->subject = GETPOST("subject","none");
+ $object->message = GETPOST("message","none");
$object->origin_email = $origin_email;
- $object->type_code = GETPOST("type_code");
- $object->category_code = GETPOST("category_code");
- $object->severity_code = GETPOST("severity_code");
+ $object->type_code = GETPOST("type_code", 'az09');
+ $object->category_code = GETPOST("category_code", 'az09');
+ $object->severity_code = GETPOST("severity_code", 'az09');
if (is_array($searched_companies)) {
$object->fk_soc = $searched_companies[0]->id;
}
@@ -172,7 +172,10 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
if (!is_object($user)) {
$user = new User($db);
}
- $id = $object->create($user, 1); // Disable trigger for email (send by this page)
+
+ $object->context['disableticketsupemail']=1; // Disable emails sent by ticketsup trigger when creation is done from this page, emails are already sent later
+
+ $id = $object->create($user);
if ($id <= 0) {
$error++;
$errors = ($object->error ? array($object->error) : $object->errors);
@@ -184,9 +187,20 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
if ($usertoassign > 0) {
$object->add_contact($usertoassign, "SUPPORTCLI", 'external', $notrigger = 0);
}
+ }
- $object->db->commit();
+ if (! $error)
+ {
+ $object->db->commit();
+ $action = "infos_success";
+ } else {
+ $object->db->rollback();
+ setEventMessage($object->errors, 'errors');
+ $action = 'create_ticket';
+ }
+ if (! $error)
+ {
$res = $object->fetch($id);
if ($res) {
// Create form object
@@ -205,18 +219,19 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
$mimetype = $attachedfiles['mimes'];
// Send email to customer
+
$subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketNewEmailSubject');
$message .= ($conf->global->TICKETS_MESSAGE_MAIL_NEW ? $conf->global->TICKETS_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')) . "\n\n";
$message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket') . "\n";
- $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $object->track_id;
+ $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/' : dol_buildpath('/public/ticketsup/view.php', 2)) . '?track_id=' . $object->track_id;
$infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '
' . $object->track_id . '') . "\n";
$infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl') . "\n\n";
$message .= dol_nl2br($infos_new_ticket);
$message .= $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText');
- $sendto = GETPOST('email');
+ $sendto = GETPOST('email','alpha');
$from = $conf->global->MAIN_INFO_SOCIETE_NOM . '<' . $conf->global->TICKETS_NOTIFICATION_EMAIL_FROM . '>';
$replyto = $from;
@@ -238,79 +253,80 @@ if ($action == 'create_ticket' && GETPOST('add_ticket')) {
$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
}
- /* Send email to admin */
+
+ // Send email to TICKETS_NOTIFICATION_EMAIL_TO
+
$sendto = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO;
- $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketNewEmailSubjectAdmin');
- $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . "\n\n";
- $message_admin .= '
- ' . $langs->trans('Title') . ' : ' . $object->subject . '
';
- $message_admin .= '- ' . $langs->trans('Type') . ' : ' . $object->type_label . '
';
- $message_admin .= '- ' . $langs->trans('Category') . ' : ' . $object->category_label . '
';
- $message_admin .= '- ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
';
- $message_admin .= '- ' . $langs->trans('From') . ' : ' . $object->origin_email . '
';
- if (is_array($extrafields->attributes[$object->table_element]['label']))
+ if ($sendto)
{
- foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
- {
- $enabled = 1;
- if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
- {
- $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
- }
- $perms = 1;
- if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
- {
- $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
- }
+ $subject = '[' . $conf->global->MAIN_INFO_SOCIETE_NOM . '] ' . $langs->transnoentities('TicketNewEmailSubjectAdmin');
+ $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . "\n\n";
+ $message_admin .= '- ' . $langs->trans('Title') . ' : ' . $object->subject . '
';
+ $message_admin .= '- ' . $langs->trans('Type') . ' : ' . $object->type_label . '
';
+ $message_admin .= '- ' . $langs->trans('Category') . ' : ' . $object->category_label . '
';
+ $message_admin .= '- ' . $langs->trans('Severity') . ' : ' . $object->severity_label . '
';
+ $message_admin .= '- ' . $langs->trans('From') . ' : ' . $object->origin_email . '
';
- $qualified=true;
- if (empty($enabled) || $enabled == 2) $qualified = false;
- if (empty($perms)) $qualified = false;
- if ($qualified) $message_admin .= '- ' . $langs->trans($key) . ' : ' . $value . '
';
- }
- }
+ if (is_array($extrafields->attributes[$object->table_element]['label']))
+ {
+ foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val)
+ {
+ $enabled = 1;
+ if ($qualified && isset($extrafields->attributes[$object->table_element]['list'][$key]))
+ {
+ $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1);
+ }
+ $perms = 1;
+ if ($perms && isset($extrafields->attributes[$object->table_element]['perms'][$key]))
+ {
+ $perms = dol_eval($extrafields->attributes[$object->table_element]['perms'][$key], 1);
+ }
- $message_admin .= '
';
- $message_admin .= '' . $langs->trans('Message') . ' :
' . $object->message . '
';
- $message_admin .= '' . $langs->trans('SeeThisTicketIntomanagementInterface') . '
';
+ $qualified=true;
+ if (empty($enabled) || $enabled == 2) $qualified = false;
+ if (empty($perms)) $qualified = false;
+ if ($qualified) $message_admin .= '- ' . $langs->trans($key) . ' : ' . $value . '
';
+ }
+ }
- $from = $conf->global->MAIN_INFO_SOCIETE_NOM . '<' . $conf->global->TICKETS_NOTIFICATION_EMAIL_FROM . '>';
- $replyto = $from;
+ $message_admin .= '
';
+ $message_admin .= '
' . $langs->trans('Message') . ' :
' . $object->message . '
';
+ $message_admin .= '
' . $langs->trans('SeeThisTicketIntomanagementInterface') . '
';
- $message_admin = dol_nl2br($message_admin);
+ $from = $conf->global->MAIN_INFO_SOCIETE_NOM . '<' . $conf->global->TICKETS_NOTIFICATION_EMAIL_FROM . '>';
+ $replyto = $from;
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
- }
- include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
- $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
- if ($mailfile->error) {
- setEventMessage($mailfile->error, 'errors');
- } else {
- $result = $mailfile->sendfile();
- }
- if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
- $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
- }
+ $message_admin = dol_nl2br($message_admin);
- // Copy files into ticket directory
- $destdir = $conf->ticketsup->dir_output . '/' . $object->track_id;
- if (!dol_is_dir($destdir)) {
- dol_mkdir($destdir);
- }
- foreach ($filename as $i => $val) {
- dol_move($filepath[$i], $destdir . '/' . $filename[$i], 0, 1);
- $formmail->remove_attached_files($i);
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
+ }
+ include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+ $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
+ if ($mailfile->error) {
+ setEventMessage($mailfile->error, 'errors');
+ } else {
+ $result = $mailfile->sendfile();
+ }
+ if (!empty($conf->global->TICKETS_DISABLE_MAIL_AUTOCOPY_TO)) {
+ $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
+ }
}
}
+ // Copy files into ticket directory
+ $destdir = $conf->ticketsup->dir_output . '/' . $object->track_id;
+ if (! dol_is_dir($destdir)) {
+ dol_mkdir($destdir);
+ }
+ foreach ($filename as $i => $val) {
+ dol_move($filepath[$i], $destdir . '/' . $filename[$i], 0, 1);
+ $formmail->remove_attached_files($i);
+ }
+
setEventMessage($langs->trans('YourTicketSuccessfullySaved'));
- $action = "infos_success";
- } else {
- $object->db->rollback();
- setEventMessage($object->errors, 'errors');
- $action = 'create_ticket';
}
} else {
setEventMessage($object->errors, 'errors');
diff --git a/htdocs/public/ticketsup/index.php b/htdocs/public/ticketsup/index.php
index 576eee32bc4..bbb0be1d471 100644
--- a/htdocs/public/ticketsup/index.php
+++ b/htdocs/public/ticketsup/index.php
@@ -16,9 +16,9 @@
*/
/**
- * \file ticketsup/public/index.php
- * \ingroup ticketsup
- * \brief Public file to add and manage ticket
+ * \file htdocs/public/ticketsup/index.php
+ * \ingroup ticketsup
+ * \brief Public file to add and manage ticket
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
diff --git a/htdocs/public/ticketsup/list.php b/htdocs/public/ticketsup/list.php
index a071344fcb1..67d897cc493 100644
--- a/htdocs/public/ticketsup/list.php
+++ b/htdocs/public/ticketsup/list.php
@@ -16,9 +16,9 @@
*/
/**
- * \file ticketsup/public/index.php
- * \ingroup ticketsup
- * \brief Public file to add and manage ticket
+ * \file htdocs/public/ticketsup/list.php
+ * \ingroup ticketsup
+ * \brief Public file to add and manage ticket
*/
if (!defined('NOCSRFCHECK')) {
@@ -155,7 +155,7 @@ if ($action == "view_ticketlist") {
$search_fk_user_assign = GETPOST("search_fk_user_assign", 'int');
// Store current page url
- $url_page_current = dol_buildpath('/ticketsup/public/list.php', 1);
+ $url_page_current = dol_buildpath('/public/ticketsup/list.php', 1);
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x")) {
@@ -633,7 +633,7 @@ if ($action == "view_ticketlist") {
print '