mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW contact type on auto add contributor (#26077)
* NEW contact type on auto add contributor * ADD second option * RESTORE ticket module for external and fix constant * GetDolGlobalInt * Update ticket.class.php --------- Co-authored-by: Benjamin Falière <benjamin.faliere@altairis.fr> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
5c01965e9e
commit
5460b97e8b
|
|
@ -875,7 +875,7 @@ class Conf extends stdClass
|
|||
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -337,6 +337,8 @@ if (empty($reshook)) {
|
|||
$object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
|
||||
$object->context['contactid'] = GETPOSTINT('contactid'); // 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"));
|
||||
|
|
|
|||
|
|
@ -580,9 +580,20 @@ class Ticket extends CommonObject
|
|||
$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)
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user