diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 622a8aaf927..4a6d405df03 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -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 ''; print ''; + // Enable Captcha code + print ''; + print ''.$langs->trans("TicketUseCaptchaCode").''; + print ''; + 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 ''.img_picto($langs->trans("Disabled"), 'off').''; + } else { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } + } + } else { + $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); + print $desc; + } + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUseCaptchaCodeHelp"), 1, 'help'); + print ''; + print ''; + // Check if email exists print ''.$langs->trans("TicketsEmailMustExist").''; print ''; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 281bf927944..b5ba0b0208e 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -426,7 +426,7 @@ class FormTicket $doleditor->Create(); print ''; - 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 ''; print ''; diff --git a/htdocs/core/modules/modTicket.class.php b/htdocs/core/modules/modTicket.class.php index 13967fc4096..18f0d368cfd 100644 --- a/htdocs/core/modules/modTicket.class.php +++ b/htdocs/core/modules/modTicket.class.php @@ -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) ); diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 3e252e407e4..1fe2e5b8a6e 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -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 diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 669c5e8d512..9ea689ec76c 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -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) {