Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW contact type on auto add contributor #26077

Merged
merged 10 commits into from
Feb 21, 2024
2 changes: 1 addition & 1 deletion htdocs/core/class/conf.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ public function setValues($db)

// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
$this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,reception,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
$this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,reception,agenda,resource,adherent,blockedlog,ticket'; // '' means 'all'. Note that contact is added here as it should be a module later.
}
if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/public/ticket/create_ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@

$object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later

$object->context['createdfrompublicinterface'] = 1; // To make a difference between a ticket created from the public interface and a ticket directly created from dolibarr

if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
$error++;
array_push($object->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
Expand Down
15 changes: 13 additions & 2 deletions htdocs/ticket/class/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,20 @@ public function create($user, $notrigger = 0)
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ticket");
}

if (!$error && getDolGlobalString('TICKET_ADD_AUTHOR_AS_CONTACT')) {
if (!$error && getDolGlobalString('TICKET_ADD_AUTHOR_AS_CONTACT') && empty($this->context["createdfrompublicinterface"])) {
// add creator as contributor
if ($this->add_contact($user->id, 'CONTRIBUTOR', 'internal') < 0) {

// We first check the type of contact (internal or external)
BenjaminFlr marked this conversation as resolved.
Show resolved Hide resolved
if (!empty($user->socid) && !empty($user->contact_id) && getDolGlobalInt('TICKET_ADD_AUTHOR_AS_CONTACT') == 2) {
$contact_type = 'external';
$contributor_id = $user->contact_id;
} else {
$contact_type = 'internal';
$contributor_id = $user->id;
}

// We add the creator as contributor
if ($this->add_contact($contributor_id, 'CONTRIBUTOR', $contact_type) < 0) {
$error++;
}
}
Expand Down
Loading