diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 7d482dff305..aceda22aa52 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -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'], diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index aa13ceba1c6..712e14e87b7 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -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) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f51d74db425..ae4cd5bca15 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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 @@ -6599,7 +6599,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be print ''; } else { print '
  • '; - print ''; } $tmpchoice = explode(',', $pagesizechoices); $tmpkey = $limit.':'.$limit; @@ -6627,7 +6627,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be print ''; } else { print ''; - print ajax_combobox("limit".(is_numeric($selectlimitsuffix) ? '': $selectlimitsuffix), array(), 0, 0, 'resolve', '-1', 'limit'); + print ajax_combobox("limit".(is_numeric($selectlimitsuffix) ? '' : $selectlimitsuffix), array(), 0, 0, 'resolve', '-1', 'limit'); //print ajax_combobox("limit"); } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 352aae3e688..f956b2149ac 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -1,4 +1,6 @@ + */ /* Copyright (C) 2013-2016 Jean-François FERRY * * 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 @@ -423,7 +426,7 @@ if ($action == "view_ticketlist") { $baseurl = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.'/public/ticket/'); - $newcardbutton = ''; + $newcardbutton = ''; print_barre_liste($langs->trans('TicketList'), $page, 'list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket', 0, $newcardbutton); @@ -721,7 +724,7 @@ if ($action == "view_ticketlist") { $url_public_ticket = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', dol_buildpath('/public/ticket/', 1)); - print ''; print ""; diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 07df43e8015..5aa7bd65f7e 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024 MDW * * 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 @@ -16,7 +17,7 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; @@ -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'); } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index acbb86ccf94..00e0a4a126a 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -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 cache_types_tickets */ public $cache_types_tickets; /** - * @var array tickets categories + * @var array Cache of Ticket categories */ public $cache_category_tickets; /** - * @var array cache msgs ticket + * @var array 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 - * @return int Number of lines loaded, 0 if already loaded, <0 if KO + * @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; } @@ -1757,10 +1757,10 @@ class Ticket extends CommonObject /** * Set an assigned user to a ticket. * - * @param User $user Object user - * @param int $id_assign_user ID of user assigned - * @param int $notrigger Disable trigger - * @return int Return integer <0 if KO, 0=Nothing done, >0 if OK + * @param User $user Object user + * @param int $id_assign_user ID of user assigned + * @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) @@ -2070,11 +2070,11 @@ 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 string $clause Clause for filters - * @return array|int Array of thirdparties object + * @param string $email Email + * @param int<0,3> $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 string $clause Clause for filters + * @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<-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 .= '

    '; $message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.''; - $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(); @@ -3029,13 +3032,13 @@ class Ticket extends CommonObject /** * Send ticket by email to linked contacts * - * @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 string $subject Email subject + * @param string $message Email message + * @param int<0,1> $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 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()) @@ -3302,13 +3305,13 @@ class Ticket extends CommonObject /** * Create a document onto disk according to template module. * - * @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 - * @return int 0 if KO, 1 if OK + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs object lang a utiliser pour traduction + * @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 $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) { diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index 0a83c3ab454..565c6563d53 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011-2016 Jean-François Ferry * Copyright (C) 2011 Regis Houssin * Copyright (C) 2016 Christophe Battarel + * Copyright (C) 2024 MDW * * 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 @@ -104,21 +105,21 @@ if ($action == 'addcontact' && $user->hasRight('ticket', 'write')) { $error = 0; $codecontact = dol_getIdFromCode($db, $typeid, 'c_type_contact', 'rowid', 'code'); - if ($codecontact=='SUPPORTTEC') { + if ($codecontact == 'SUPPORTTEC') { $internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC'); foreach ($internal_contacts as $key => $contact) { if ($contact['id'] !== $contactid) { //print "user à effacer : ".$useroriginassign; $result = $object->delete_contact($contact['rowid']); - if ($result<0) { - $error ++; + if ($result < 0) { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } } $ret = $object->assignUser($user, $contactid); if ($ret < 0) { - $error ++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } @@ -155,10 +156,10 @@ if ($action == 'deletecontact' && $user->hasRight('ticket', 'write')) { if ($object->fetch($id, '', $track_id)) { $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); + if ($contact['rowid'] == $lineid && $object->fk_user_assign == $contact['id']) { + $ret = $object->assignUser($user, 0); if ($ret < 0) { - $error ++; + $error++; setEventMessages($object->error, $object->errors, 'errors'); } }