FIX missing the management of a constant in the Ticket config

This commit is contained in:
Regis Houssin 2022-09-27 17:08:08 +02:00
parent d4ad93a94d
commit aafecb6d2b
5 changed files with 30 additions and 11 deletions

View File

@ -181,14 +181,6 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') {
$error++;
$errors[] = $db->lasterror();
}
// enable captcha by default
// TODO Add a visible option in this setup page for this
$res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_TICKET', 1, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
$errors[] = $db->lasterror();
}
}
}
}
@ -273,6 +265,30 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
print '</td>';
print '</tr>';
// Enable Captcha code
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TicketUseCaptchaCode").'</td>';
print '<td class="left">';
if (function_exists("imagecreatefrompng")) {
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA_TICKET');
} else {
if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA_TICKET&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA_TICKET&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
}
}
} else {
$desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
print $desc;
}
print '</td>';
print '<td class="center width75">';
print $form->textwithpicto('', $langs->trans("TicketUseCaptchaCodeHelp"), 1, 'help');
print '</td>';
print '</tr>';
// Check if email exists
print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailMustExist").'</td>';
print '<td class="left">';

View File

@ -426,7 +426,7 @@ class FormTicket
$doleditor->Create();
print '</td></tr>';
if ($public && (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) || !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET))) {
if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td>';
print '<span class="span-icon-security inline-block">';

View File

@ -117,7 +117,8 @@ class modTicket extends DolibarrModules
9 => array('TICKET_NOTIFICATION_EMAIL_FROM', 'chaine', getDolGlobalString('MAIN_MAIL_EMAIL_FROM'), 'Email to use by default as sender for messages sent from Dolibarr', 0),
10 => array('TICKET_MESSAGE_MAIL_INTRO', 'chaine', $langs->trans('TicketMessageMailIntroText'), 'Introduction text of ticket replies sent from Dolibarr', 0),
11 => array('TICKET_MESSAGE_MAIL_SIGNATURE', 'chaine', $default_signature, 'Signature to use by default for messages sent from Dolibarr', 0),
12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0)
12 => array('MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER', 'chaine', "1", 'Disable the rendering of headers in tickets', 0),
13 => array('MAIN_SECURITY_ENABLECAPTCHA_TICKET', 'chaine', getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET'), 'Enable captcha code by default', 0)
);

View File

@ -149,6 +149,8 @@ TicketsAutoNotifyCloseHelp=When closing a ticket, you will be proposed to send a
TicketWrongContact=Provided contact is not part of current ticket contacts. Email not sent.
TicketChooseProductCategory=Product category for ticket support
TicketChooseProductCategoryHelp=Select the product category of ticket support. This will be used to automatically link a contract to a ticket.
TicketUseCaptchaCode=Use graphical code (CAPTCHA) when creating a ticket
TicketUseCaptchaCodeHelp=Adds CAPTCHA verification when creating a new ticket.
#
# Index & list page

View File

@ -218,7 +218,7 @@ if (empty($reshook)) {
}
// Check Captcha code if is enabled
if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA) || !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
$sessionkey = 'dol_antispam_value';
$ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
if (!$ok) {