Merge pull request #22688 from altairis-noe/public_ticket_check
FIX: check if contact is active before creating associated ticket
This commit is contained in:
commit
ecdc92e219
@ -145,8 +145,18 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) {
|
|||||||
// Le premier contact trouvé est utilisé pour déterminer le contact suivi
|
// Le premier contact trouvé est utilisé pour déterminer le contact suivi
|
||||||
$contacts = $object->searchContactByEmail($origin_email);
|
$contacts = $object->searchContactByEmail($origin_email);
|
||||||
|
|
||||||
|
// Ensure that contact is active and select first active contact
|
||||||
|
$cid = -1;
|
||||||
|
foreach ($contacts as $key => $contact) {
|
||||||
|
if ((int) $contact->statut == 1) {
|
||||||
|
$cid = $key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Option to require email exists to create ticket
|
// Option to require email exists to create ticket
|
||||||
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && !$contacts[0]->socid) {
|
if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && ($cid < 0 || empty($contacts[$cid]->socid))) {
|
||||||
$error++;
|
$error++;
|
||||||
array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
|
array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -197,9 +207,9 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) {
|
|||||||
$object->fk_soc = $searched_companies[0]->id;
|
$object->fk_soc = $searched_companies[0]->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($contacts) and count($contacts) > 0) {
|
if (is_array($contacts) && count($contacts) > 0) {
|
||||||
$object->fk_soc = $contacts[0]->socid;
|
$object->fk_soc = $contacts[$cid]->socid;
|
||||||
$usertoassign = $contacts[0]->id;
|
$usertoassign = $contacts[$cid]->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user