2
0
forked from Wavyzz/dolibarr

Fix: ticket.class phan/phpstan notices (#31448)

* Qual: Fix ticket.class notices

* Do not analyze custom

* Fix: Correct reference to cache (+phpdoc)

* Update baseline, ignore everything in custom

* Qual: Fix notices in files related to ticket class
This commit is contained in:
MDW
2024-10-19 01:21:41 +02:00
committed by GitHub
parent 9643a27423
commit 11c43e8c63
8 changed files with 104 additions and 104 deletions

View File

@@ -9,25 +9,25 @@
*/
return [
// # Issue statistics:
// PhanUndeclaredProperty : 800+ occurrences
// PhanUndeclaredProperty : 770+ occurrences
// PhanPluginUnknownPropertyType : 710+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 600+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 410+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 400+ occurrences
// PhanUndeclaredGlobalVariable : 380+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 310+ occurrences
// PhanPluginUnknownArrayMethodParamType : 260+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 300+ occurrences
// PhanPluginUnknownArrayMethodParamType : 250+ occurrences
// PhanPossiblyUndeclaredVariable : 200+ occurrences
// PhanTypeMismatchProperty : 170+ occurrences
// PhanPluginUnknownArrayFunctionParamType : 95+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 70+ occurrences
// PhanPluginUndeclaredVariableIsset : 65+ occurrences
// PhanPluginUnknownArrayPropertyType : 60+ occurrences
// PhanPluginUnknownArrayPropertyType : 55+ occurrences
// PhanPluginUnknownArrayFunctionReturnType : 50+ occurrences
// PhanRedefineFunction : 50+ occurrences
// PhanPluginEmptyStatementIf : 45+ occurrences
// PhanTypeMismatchDimFetch : 40+ occurrences
// PhanTypeExpectedObjectPropAccess : 25+ occurrences
// PhanTypeInvalidDimOffset : 25+ occurrences
// PhanTypeExpectedObjectPropAccess : 40+ occurrences
// PhanTypeInvalidDimOffset : 35+ occurrences
// PhanTypeMismatchDimFetch : 30+ occurrences
// PhanPluginUnknownObjectMethodCall : 15+ occurrences
// PhanTypeComparisonFromArray : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
@@ -52,8 +52,6 @@ return [
'file_suppressions' => [
'htdocs/accountancy/class/accountancycategory.class.php' => ['PhanPluginUnknownArrayPropertyType'],
'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanUndeclaredProperty'],
'htdocs/accountancy/class/accountingjournal.class.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/accountancy/journal/purchasesjournal.php' => ['PhanTypeInvalidDimOffset'],
'htdocs/adherents/list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/admin/fckeditor.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/api/class/api_access.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanUndeclaredProperty'],
@@ -210,7 +208,7 @@ return [
'htdocs/compta/tva/index.php' => ['PhanRedefineFunction', 'PhanUndeclaredGlobalVariable'],
'htdocs/compta/tva/payments.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/compta/tva/quadri_detail.php' => ['PhanTypeArraySuspiciousNull', 'PhanTypeInvalidDimOffset', 'PhanTypeMismatchProperty'],
'htdocs/contact/canvas/actions_contactcard_common.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty', 'PhanTypeSuspiciousNonTraversableForeach'],
'htdocs/contact/canvas/actions_contactcard_common.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchProperty'],
'htdocs/contact/card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/contact/class/contact.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType'],
'htdocs/contact/consumption.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
@@ -360,19 +358,16 @@ return [
'htdocs/core/modules/commande/doc/pdf_einstein.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/commande/modules_commande.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/modules/contract/doc/pdf_strato.modules.php' => ['PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/delivery/doc/pdf_storm.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/delivery/doc/pdf_typhon.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/modules/contract/doc/pdf_strato.modules.php' => ['PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/modules/delivery/doc/pdf_storm.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/delivery/doc/pdf_typhon.modules.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/modules/delivery/mod_delivery_saphir.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/expedition/doc/pdf_espadon.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/expedition/doc/pdf_merou.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/expedition/doc/pdf_rouget.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/expedition/doc/pdf_merou.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_crabe.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_octopus.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/doc/pdf_sponge.modules.php' => ['PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/facture/modules_facture.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/fichinter/mod_pacific.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/core/modules/hrm/mod_evaluation_advanced.php' => ['PhanUndeclaredProperty'],
@@ -395,7 +390,6 @@ return [
'htdocs/core/modules/printsheet/modules_labels.php' => ['PhanParamTooMany'],
'htdocs/core/modules/product/doc/pdf_standard.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/doc/pdf_baleine.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/doc/pdf_timespent.modules.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/propale/doc/pdf_azur.modules.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
@@ -408,10 +402,10 @@ return [
'htdocs/core/modules/societe/mod_codecompta_digitaria.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanUndeclaredProperty'],
'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php' => ['PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php' => ['PhanPossiblyUndeclaredVariable'],
'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
@@ -743,7 +737,6 @@ return [
'htdocs/public/test/test_arrays.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/public/test/test_forms.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/ticket/create_ticket.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchDimFetchNullable', 'PhanTypeMismatchProperty'],
'htdocs/public/ticket/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/ticket/view.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/public/webportal/tpl/menu.tpl.php' => ['PhanUndeclaredProperty'],
'htdocs/public/webportal/webportal.main.inc.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanRedefineFunction'],
@@ -790,7 +783,6 @@ return [
'htdocs/societe/admin/societe.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredMethod'],
'htdocs/societe/ajax/ajaxcompanies.php' => ['PhanUndeclaredProperty'],
'htdocs/societe/ajax/company.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/societe/card.php' => ['PhanTypeMismatchProperty'],
'htdocs/societe/checkvat/checkVatPopup.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/societe/class/api_contacts.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty'],
'htdocs/societe/class/api_thirdparties.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
@@ -835,13 +827,12 @@ return [
'htdocs/theme/md/flags-sprite.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/theme/md/info-box.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/theme/md/progress.inc.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/ticket/card.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'],
'htdocs/ticket/card.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/actions_ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/ticket/class/api_tickets.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPossiblyUndeclaredVariable'],
'htdocs/ticket/class/cticketcategory.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/ticket.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'],
'htdocs/ticket/class/ticket.class.php' => ['PhanUndeclaredProperty'],
'htdocs/ticket/class/ticketstats.class.php' => ['PhanPluginUnknownPropertyType'],
'htdocs/ticket/contact.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/ticket/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/ticket/list.php' => ['PhanTypeComparisonFromArray'],
'htdocs/ticket/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'],

View File

@@ -320,7 +320,7 @@ return [
'exclude_file_regex' => '@^(' // @phpstan-ignore-line
.'dummy' // @phpstan-ignore-line
// mymodule seen in cti, but not in git.
.'|htdocs/custom/mymodule/.*' // @phpstan-ignore-line
.'|htdocs/custom/.*' // Ignore all custom modules @phpstan-ignore-line
.'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' // @phpstan-ignore-line
//.'|htdocs/modulebuilder/template/.*' // @phpstan-ignore-line
// Included as stub (better analysis)

View File

@@ -6348,7 +6348,7 @@ function print_fiche_titre($title, $mesg = '', $picto = 'generic', $pictoisfullp
* @param string $title Title to show (HTML sanitized content)
* @param string $morehtmlright Added message to show on right
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
* @param int<0,1> $pictoisfullpath 1=Icon name is a full absolute url of image
* @param string $id To force an id on html objects
* @param string $morecssontable More css on table
* @param string $morehtmlcenter Added message to show on center

View File

@@ -1,4 +1,6 @@
<?php
/* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*/
/* Copyright (C) 2013-2016 Jean-François FERRY <jfefe@aternatik.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -120,10 +122,11 @@ $arrayofcss = array(getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', '/public/t
llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
$display_ticket_list = false;
// Load the ticket from track_id
if ($action == "view_ticketlist") {
$error = 0;
$display_ticket_list = false;
if (!strlen($track_id)) {
$error++;
array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
@@ -143,7 +146,7 @@ if ($action == "view_ticketlist") {
}
if (!$error) {
$ret = $object->fetch('', '', $track_id);
$ret = $object->fetch(0, '', $track_id);
if ($ret && $object->id > 0) {
// vérifie si l'adresse email est bien dans les contacts du ticket

View File

@@ -351,7 +351,7 @@ if (empty($reshook)) {
// Mark as Read
if ($action == "set_read" && $permissiontoadd) {
$object->fetch('', '', GETPOST("track_id", 'alpha'));
$object->fetch(0, '', GETPOST("track_id", 'alpha'));
if ($object->markAsRead($user) > 0) {
setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
@@ -366,7 +366,7 @@ if (empty($reshook)) {
// Assign to someone
if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $permissiontoadd) {
$object->fetch('', '', GETPOST("track_id", 'alpha'));
$object->fetch(0, '', GETPOST("track_id", 'alpha'));
$useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOSTINT('fk_user_assign');
@@ -580,7 +580,7 @@ if (empty($reshook)) {
}
} elseif ($action == "set_message" && $user->hasRight('ticket', 'manage')) {
if (!GETPOST('cancel')) {
$object->fetch('', '', GETPOST('track_id', 'alpha'));
$object->fetch(0, '', GETPOST('track_id', 'alpha'));
//$oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial', 'restricthtml');
@@ -805,9 +805,9 @@ if ($action == 'create' || $action == 'presend') {
}
// Confirmation status change
if ($action == 'set_status') {
$new_status = GETPOST('new_status');
$new_status = GETPOSTINT('new_status');
//var_dump($url_page_current . "?track_id=" . $object->track_id);
$formconfirm = $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->labelStatusShort[$new_status])), "confirm_set_status", '', '', 1);
$formconfirm = $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".$new_status, $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->labelStatusShort[$new_status])), "confirm_set_status", '', '', 1);
}
// Call Hook formConfirm
@@ -1025,7 +1025,7 @@ if ($action == 'create' || $action == 'presend') {
$contratstatic = new Contrat($db);
$contratstatic->fetch($object->fk_contract);
//print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
$morehtmlref .= $contratstatic->getNomUrl(0, '', 1);
$morehtmlref .= $contratstatic->getNomUrl(0, 0, 1);
}
}
}
@@ -1047,7 +1047,7 @@ if ($action == 'create' || $action == 'presend') {
print '<tr><td class="titlefield">'.$langs->trans("TicketTrackId").'</td><td>';
if (!empty($object->track_id)) {
if (empty($object->ref)) {
$object->ref = $object->id;
$object->ref = (string) $object->id;
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id');
} else {
print dolPrintLabel($object->track_id);
@@ -1165,6 +1165,7 @@ if ($action == 'create' || $action == 'presend') {
if ($num) {
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype == "fichinter") {
'@phan-var-force Fichinter[] $objects';
foreach ($objects as $fichinter) {
$foundinter++;
/** @var Fichinter $fichinter */
@@ -1297,7 +1298,7 @@ if ($action == 'create' || $action == 'presend') {
$arrayselected[] = $cat->id;
}
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'maxwidth500 widthcentpercentminusx', 0, 0);
print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'maxwidth500 widthcentpercentminusx', 0, 0);
print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Save').'">';
print '</form>';
print "</td>";

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -361,7 +362,7 @@ class Tickets extends DolibarrApi
$this->ticket->$field = $this->_checkValForAPI($field, $value, $this->ticket);
}
$ticketMessageText = $this->ticket->message;
$result = $this->ticket->fetch('', '', $this->ticket->track_id);
$result = $this->ticket->fetch(0, '', $this->ticket->track_id);
if (!$result) {
throw new RestException(404, 'Ticket not found');
}

View File

@@ -105,7 +105,7 @@ class Ticket extends CommonObject
public $fk_user_assign;
/**
* var string Ticket subject
* @var string Ticket subject
*/
public $subject;
@@ -212,17 +212,17 @@ class Ticket extends CommonObject
public $date_close;
/**
* @var array cache_types_tickets
* @var array<int,array{code:string,label:string,use_default:int,pos:int}> cache_types_tickets
*/
public $cache_types_tickets;
/**
* @var array tickets categories
* @var array<int,array{code:string,use_default:int,pos:int,public:int,active:int,force_severity:int,fk_parent:int,label:string}> Cache of Ticket categories
*/
public $cache_category_tickets;
/**
* @var array cache msgs ticket
* @var array<int,array{private:0|1|'0'|'1',fk_user_author:int,fk_contact_author?:int,message:string}> cache msgs ticket
*/
public $cache_msgs_ticket;
@@ -252,7 +252,7 @@ class Ticket extends CommonObject
public $oldcopy;
/**
* @var Ticket[] array of Tickets
* @var Ticket[] Array of Tickets
*/
public $lines;
@@ -482,7 +482,7 @@ class Ticket extends CommonObject
{
$test = new self($this->db);
if ($test->fetch('', $getRef) > 0) {
if ($test->fetch(0, $getRef) > 0) {
if (($action == 'add') || ($action == 'update' && $this->ref != $getRef)) {
return true;
}
@@ -1385,14 +1385,14 @@ class Ticket extends CommonObject
/**
* Load into a cache array, the list of ticket categories (setup done into dictionary)
*
* @param int $publicgroup 0=No public group, 1=Public group only, -1=All
* @param int<-1,1> $publicgroup 0=No public group, 1=Public group only, -1=All
* @return int Number of lines loaded, 0 if already loaded, <0 if KO
*/
public function loadCacheCategoriesTickets($publicgroup = -1)
{
global $langs;
if ($publicgroup == -1 && !empty($this->cache_category_ticket) && count($this->cache_category_tickets)) {
if ($publicgroup == -1 && !empty($this->cache_category_tickets) && count($this->cache_category_tickets)) {
// Cache already loaded
return 0;
}
@@ -1759,7 +1759,7 @@ class Ticket extends CommonObject
*
* @param User $user Object user
* @param int $id_assign_user ID of user assigned
* @param int $notrigger Disable trigger
* @param int<0,1> $notrigger Disable trigger
* @return int Return integer <0 if KO, 0=Nothing done, >0 if OK
*/
public function assignUser($user, $id_assign_user, $notrigger = 0)
@@ -1813,12 +1813,12 @@ class Ticket extends CommonObject
* Add message into database
*
* @param User $user User that creates
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @param array $filename_list List of files to attach (full path of filename on file system)
* @param array $mimetype_list List of MIME type of attached files
* @param array $mimefilename_list List of attached file name in message
* @param boolean $send_email Whether the message is sent by email
* @param int $public_area 0=Default, 1 if we are creating the message from a public area (so we can search contact from email to add it as contact of ticket if TICKET_ASSIGN_CONTACT_TO_MESSAGE is set)
* @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
* @param string[] $filename_list List of files to attach (full path of filename on file system)
* @param string[] $mimetype_list List of MIME type of attached files
* @param string[] $mimefilename_list List of attached file name in message
* @param bool $send_email Whether the message is sent by email
* @param int<0,1> $public_area 0=Default, 1 if we are creating the message from a public area (so we can search contact from email to add it as contact of ticket if TICKET_ASSIGN_CONTACT_TO_MESSAGE is set)
* @return int Return integer <0 if KO, >0 if OK
*/
public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email = false, $public_area = 0)
@@ -2071,10 +2071,10 @@ class Ticket extends CommonObject
* Search and fetch thirparties by email
*
* @param string $email Email
* @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
* @param array $filters Array of couple field name/value to filter the companies with the same name
* @param int<0,3> $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
* @param array<string,mixed> $filters Array of couple field name/value to filter the companies with the same name
* @param string $clause Clause for filters
* @return array|int Array of thirdparties object
* @return Societe[]|int<-1,-1> Array of thirdparties object
*/
public function searchSocidByEmail($email, $type = 0, $filters = array(), $clause = 'AND')
{
@@ -2138,7 +2138,7 @@ class Ticket extends CommonObject
* @param string $email Email
* @param int $socid Limit to a thirdparty
* @param string $case Respect case
* @return array|int Array of contacts object
* @return Contact[]|int Array of contacts object
*/
public function searchContactByEmail($email, $socid = 0, $case = '')
{
@@ -2253,7 +2253,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts interne de suivi
*
* @return array Liste des id contacts suivi ticket
* @return null|int[] Liste des id contacts suivi ticket
*/
public function getIdTicketInternalContact()
{
@@ -2274,7 +2274,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients pour le suivi ticket
*
* @return array Liste des id contacts suivi ticket
* @return null|int[] Liste des id contacts suivi ticket
*/
public function getIdTicketCustomerContact()
{
@@ -2285,7 +2285,7 @@ class Ticket extends CommonObject
* Retrieve information about external contacts
*
* @param int $status Status of user or company
* @return array Array with datas : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
* @return array<int|array{source:string,id:int,rowid:int,email:string,civility:string,firstname:string,lastname:string,labeltype:string,libelle:string,socid:int,code:string,status:int,statuscontact:string,fk_c_typecontact:string,phone:string,phone_mobile:string,nom:string}>|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
*/
public function getInfosTicketExternalContact($status = -1)
{
@@ -2295,7 +2295,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients des intervenants
*
* @return array Liste des id contacts intervenants
* @return null|int[] Liste des id contacts intervenants
*/
public function getIdTicketInternalInvolvedContact()
{
@@ -2305,7 +2305,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients des intervenants
*
* @return array Liste des id contacts intervenants
* @return null|int[] Liste des id contacts intervenants
*/
public function getIdTicketCustomerInvolvedContact()
{
@@ -2315,7 +2315,7 @@ class Ticket extends CommonObject
/**
* Return id of all contacts for ticket
*
* @return array Array of contacts for tickets
* @return int[] Array of contacts for tickets
*/
public function getTicketAllContacts()
{
@@ -2333,7 +2333,7 @@ class Ticket extends CommonObject
/**
* Return id of all contacts for ticket
*
* @return array Array of contacts
* @return int[] Array of contacts
*/
public function getTicketAllCustomerContacts()
{
@@ -2480,6 +2480,7 @@ class Ticket extends CommonObject
// Search template files
$file = '';
$classname = '';
$reldir = '';
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
@@ -2543,7 +2544,7 @@ class Ticket extends CommonObject
* Files may be renamed during copy to avoid overwriting existing files.
*
* @param string $forcetrackid Force trackid used for $keytoavoidconflict into get_attached_files()
* @return array|int Array with final path/name/mime of files.
* @return array{listofpaths:string[],listofnames:string[],listofmimes:string[]}|int<-1,-1> Array with final path/name/mime of files.
*/
public function copyFilesForTicket($forcetrackid = null)
{
@@ -2682,7 +2683,7 @@ class Ticket extends CommonObject
$object = new Ticket($this->db);
$ret = $object->fetch('', '', GETPOST('track_id', 'alpha'));
$ret = $object->fetch(0, '', GETPOST('track_id', 'alpha'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
@@ -2751,6 +2752,8 @@ class Ticket extends CommonObject
} else {
$assigned_user_dont_have_email = $assigned_user->getFullName($langs);
}
} else {
$assigned_user = null;
}
// Build array to display recipient list
@@ -2761,7 +2764,7 @@ class Ticket extends CommonObject
}
// We check if the email address is not the assignee's address to prevent notification from being sent twice
if (!empty($info_sendto['email']) && $assigned_user->email != $info_sendto['email']) {
if (!empty($info_sendto['email']) && ($assigned_user === null || $assigned_user->email != $info_sendto['email'])) {
$sendto[] = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'])." <".$info_sendto['email'].">";
}
}
@@ -2816,7 +2819,7 @@ class Ticket extends CommonObject
$message .= '<br><br>';
$message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$object->track_id.'</a>';
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
$this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
}
}
} else {
@@ -2888,7 +2891,7 @@ class Ticket extends CommonObject
// don't try to send email if no recipient
if (!empty($sendto)) {
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
$this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
}
}
@@ -2990,7 +2993,7 @@ class Ticket extends CommonObject
// Don't try to send email when no recipient
if (!empty($sendto)) {
$result = $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
$result = $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
if ($result) {
// update last_msg_sent date (for last message sent to external users)
$this->date_last_msg_sent = dol_now();
@@ -3031,11 +3034,11 @@ class Ticket extends CommonObject
*
* @param string $subject Email subject
* @param string $message Email message
* @param int $send_internal_cc Receive a copy on internal email (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')
* @param array $array_receiver Array of receiver. Example array('name' => 'John Doe', 'email' => 'john@doe.com', etc...)
* @param array $filename_list List of files to attach (full path of filename on file system)
* @param array $mimetype_list List of MIME type of attached files
* @param array $mimefilename_list List of attached file name in message
* @param int<0,1> $send_internal_cc Receive a copy on internal email (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')
* @param array<string> $array_receiver Array of receiver. Example array('name' => 'John Doe', 'email' => 'john@doe.com', etc...)
* @param string[] $filename_list List of files to attach (full path of filename on file system)
* @param string[] $mimetype_list List of MIME type of attached files
* @param string[] $mimefilename_list List of attached file name in message
* @return boolean True if mail sent to at least one receiver, false otherwise
*/
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
@@ -3304,10 +3307,10 @@ class Ticket extends CommonObject
*
* @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs object lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @param null|array $moreparams Array to provide more information
* @param int<0,1> $hidedetails Hide details of lines
* @param int<0,1> $hidedesc Hide description
* @param int<0,1> $hideref Hide ref
* @param ?array<string,mixed> $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)

View File

@@ -2,6 +2,7 @@
/* Copyright (C) 2011-2016 Jean-François Ferry <hello@librethic.io>
* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -156,7 +157,7 @@ if ($action == 'deletecontact' && $user->hasRight('ticket', 'write')) {
$internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC');
foreach ($internal_contacts as $key => $contact) {
if ($contact['rowid'] == $lineid && $object->fk_user_assign == $contact['id']) {
$ret = $object->assignUser($user, null);
$ret = $object->assignUser($user, 0);
if ($ret < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');