From 278b708e1729345b1d47f022ec2c55f3cd8651ad Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Thu, 11 Apr 2019 11:57:50 +0200 Subject: [PATCH 0001/1091] use subproducts costprice and pmp if empty on father --- htdocs/fourn/ajax/getSupplierPrices.php | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 85b0ed37155..57874e3a122 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -86,12 +86,46 @@ if ($idprod > 0) // Add price for costprice $price=$producttmp->cost_price; + if (empty($price)) + { + // get costprice for subproducts if any + $producttmp->get_sousproduits_arbo(); + $prods_arbo=$producttmp->get_arbo_each_prod(); + if (!empty($prods_arbo)) + { + $price = 0; + foreach($prods_arbo as $child) + { + $sousprod = new Product($db); + $sousprod->fetch($child['id']); + $price += $sousprod->cost_price; + } + } + } + $prices[] = array("id" => 'costprice', "price" => price2num($price), "label" => $langs->trans("CostPrice").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() if(!empty($conf->stock->enabled)) { // Add price for pmp $price=$producttmp->pmp; + if (empty($price)) + { + // get pmp for subproducts if any + $producttmp->get_sousproduits_arbo(); + $prods_arbo=$producttmp->get_arbo_each_prod(); + if (!empty($prods_arbo)) + { + $price = 0; + foreach($prods_arbo as $child) + { + $sousprod = new Product($db); + $sousprod->fetch($child['id']); + $price += $sousprod->pmp; + } + } + } + $prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price() } } From 30ad0e7e11260d089d30743f1536ab4248031fc8 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 16 Apr 2019 09:00:39 +0200 Subject: [PATCH 0002/1091] introduce PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY --- htdocs/fourn/ajax/getSupplierPrices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 57874e3a122..211734f1129 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -86,7 +86,7 @@ if ($idprod > 0) // Add price for costprice $price=$producttmp->cost_price; - if (empty($price)) + if (empty($price) && ! empty($conf->global->PRODUCT_USE_SUB_COST_PRICES_IF_COST_PRICE_EMPTY)) { // get costprice for subproducts if any $producttmp->get_sousproduits_arbo(); From 4aab805b4edfbb536690b2c279e0078374d7b165 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 16 Apr 2021 12:39:39 +0200 Subject: [PATCH 0003/1091] FIX:Add ticket substition template --- htdocs/core/lib/functions.lib.php | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2b981530834..c3ce5128f57 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6838,6 +6838,28 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } +// add variables subtitutions ticket + if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { + $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; + $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; + $substitutionarray['__TICKET_SUBJECT__'] = '__TICKET_SUBJECT__'; + $substitutionarray['__TICKET_TYPE__'] = '__TICKET_TYPE__'; + $substitutionarray['__TICKET_SEVERITY__'] = '__TICKET_SEVERITY__'; + $substitutionarray['__TICKET_CATEGORY__'] = '__TICKET_CATEGORY__'; + $substitutionarray['__TICKET_ANALYTIC_CODE__'] = '__TICKET_ANALYTIC_CODE__'; + $substitutionarray['__TICKET_MESSAGE__'] = '__TICKET_MESSAGE__'; + $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; + $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; + $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; + + +} + + + + + + if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { $substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__'; $substitutionarray['__CANDIDATE_FIRSTNAME__'] = '__CANDIDATE_FIRSTNAME__'; @@ -7025,6 +7047,21 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } +// add substition variable for ticket + if (is_object($object) && $object->element == 'ticket') { + $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; + $substitutionarray['__TICKET_REF__'] = $object->ref; + $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; + $substitutionarray['__TICKET_TYPE__'] = $object->type_code; + $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; + $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility + $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; + $substitutionarray['__TICKET_MESSAGE__'] = $object->message; + $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; + $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($user->firstname, $user->lastname); + $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($user->firstname, $user->lastname); + } + // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) { From ff178667a3ee966b865c6693e961866bdd043893 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Tue, 11 May 2021 12:33:35 +0200 Subject: [PATCH 0004/1091] add thirdparty customer code to substitutionarray --- htdocs/comm/mailing/card.php | 7 +++++++ htdocs/core/class/html.formmail.class.php | 2 ++ htdocs/langs/fr_FR/mails.lang | 2 ++ 3 files changed, 11 insertions(+) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 5148956163e..4bf304bc519 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -201,6 +201,13 @@ if (empty($reshook)) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; + if ($obj->source_type == "thirdparty") { + $thirdpartystatic = new Societe($db); + $thirdpartystatic->fetch($obj->source_id); + + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + } $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; $substitutionarray['__FIRSTNAME__'] = $obj->firstname; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index c4723eacc57..5947ad8d810 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1502,6 +1502,8 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 3788acb53c4..9adfc684b8d 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -116,6 +116,8 @@ ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les liste NbOfEMailingsReceived=Emailings de masse reçus NbOfEMailingsSend=Emailings de masse envoyés IdRecord=ID enregistrement +CustomerCode = Code client +CustomerCodeWithoutPrefix = Code client sans préfix DeliveryReceipt=Accusé de réception YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère de séparation virgule pour spécifier plusieurs destinataires. TagCheckMail=Suivre l'ouverture de l'email From 4ce81ee53591f9b98088c2bada735c1c1c113204 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Tue, 11 May 2021 20:30:57 +0200 Subject: [PATCH 0005/1091] set new outside the loop, add fetch result check --- htdocs/comm/mailing/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 4bf304bc519..2aae9ef1d73 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -171,6 +171,7 @@ if (empty($reshook)) dol_print_error($db); } + $thirdpartystatic = new Societe($db); // Loop on each email and send it $i = 0; @@ -202,11 +203,12 @@ if (empty($reshook)) // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; if ($obj->source_type == "thirdparty") { - $thirdpartystatic = new Societe($db); - $thirdpartystatic->fetch($obj->source_id); + $result = $thirdpartystatic->fetch($obj->source_id); - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + if ($result > 0) { + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); + } } $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; From 09a694628106d1be9caae44a3f270571b0ed0588 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:34:58 +0200 Subject: [PATCH 0006/1091] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 5947ad8d810..a784521fcf9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1503,7 +1503,7 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; - $tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; + //$tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; // Not yet working $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; From 40106ff7670afb1de4d887ee2f8cea08433278bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:35:29 +0200 Subject: [PATCH 0007/1091] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a784521fcf9..99b25d27fc4 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1503,7 +1503,6 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; - //$tmparray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = 'CustomerCodeWithoutPrefix'; // Not yet working $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname'; From a4f4cca895b7fcb3a4f1fd6c56f3f355d676fd45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:36:49 +0200 Subject: [PATCH 0008/1091] Prefix length may have different length and be at a different place so i remove this tag. Must be replaced by a generic method to substring a substitution variable. --- htdocs/comm/mailing/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 2aae9ef1d73..f2b93ddbb80 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -207,7 +207,6 @@ if (empty($reshook)) if ($result > 0) { $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; - $substitutionarray['__THIRDPARTY_CUSTOMER_CODE_WITHOUT_PREFIX__'] = substr($thirdpartystatic->code_client, 1); } } $substitutionarray['__EMAIL__'] = $obj->email; From aa9642b86fd58299131565fe58a276f9280e0146 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 May 2021 08:38:38 +0200 Subject: [PATCH 0009/1091] Update mails.lang --- htdocs/langs/fr_FR/mails.lang | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index 9adfc684b8d..3788acb53c4 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -116,8 +116,6 @@ ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les liste NbOfEMailingsReceived=Emailings de masse reçus NbOfEMailingsSend=Emailings de masse envoyés IdRecord=ID enregistrement -CustomerCode = Code client -CustomerCodeWithoutPrefix = Code client sans préfix DeliveryReceipt=Accusé de réception YouCanUseCommaSeparatorForSeveralRecipients=Vous pouvez utiliser le caractère de séparation virgule pour spécifier plusieurs destinataires. TagCheckMail=Suivre l'ouverture de l'email From 30e04714513f99c9f31a23078fa2f11558794d30 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 10 Jun 2021 23:04:56 +0200 Subject: [PATCH 0010/1091] NEW: leave requests: add field into type dictionary to block request if balance is negative --- htdocs/admin/dict.php | 20 +++++++++++++++---- htdocs/holiday/class/holiday.class.php | 11 ++++++++++ .../install/mysql/migration/13.0.0-14.0.0.sql | 2 +- .../mysql/tables/llx_c_holiday_types.sql | 1 + htdocs/langs/en_US/holiday.lang | 2 ++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index b8bf1a5998a..2d4c651255f 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -223,7 +223,7 @@ $tabsql[24] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFI $tabsql[25] = "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; //$tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27] = "SELECT id as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm"; -$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; +$tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.block_if_negative, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; $tabsql[29] = "SELECT rowid as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status"; $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards"; //$tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s"; @@ -315,7 +315,7 @@ $tabfield[24] = "code,label"; $tabfield[25] = "code,label"; //$tabfield[26]= "code,label,short_label"; $tabfield[27] = "code,libelle,picto"; -$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country"; +$tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country,block_if_negative"; $tabfield[29] = "code,label,percent,position"; $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfield[31]= "pcg_version,label"; @@ -361,7 +361,7 @@ $tabfieldvalue[24] = "code,label"; $tabfieldvalue[25] = "code,label"; //$tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27] = "code,libelle,picto"; -$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country"; +$tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country,block_if_negative"; $tabfieldvalue[29] = "code,label,percent,position"; $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldvalue[31]= "pcg_version,label"; @@ -407,7 +407,7 @@ $tabfieldinsert[24] = "code,label"; $tabfieldinsert[25] = "code,label"; //$tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27] = "code,libelle,picto"; -$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country"; +$tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country,block_if_negative"; $tabfieldinsert[29] = "code,label,percent,position"; $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y"; //$tabfieldinsert[31]= "pcg_version,label"; @@ -1413,6 +1413,9 @@ if ($id) { if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { $valuetoshow = $langs->trans('TicketGroupIsPublic'); $class = 'center'; } + if ($value == 'block_if_negative') { + $valuetoshow = $langs->trans('BlockHolidayIfNegative'); + } if ($id == 2) { // Special case for state page if ($value == 'region_id') { @@ -1758,6 +1761,9 @@ if ($id) { if ($value == 'public' && $tablib[$id] == 'TicketDictCategory') { $valuetoshow = $langs->trans('TicketGroupIsPublic'); $cssprefix = 'center '; } + if ($value == 'block_if_negative') { + $valuetoshow = $langs->trans('BlockHolidayIfNegative'); + } if ($value == 'region_id' || $value == 'country_id') { $showfield = 0; @@ -1984,6 +1990,8 @@ if ($id) { } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_productbatch_qcstatus') { $langs->load("productbatch"); $valuetoshow = $langs->trans($obj->{$value}); + } elseif ($value == 'block_if_negative') { + $valuetoshow = yn($obj->{$value}); } $class .= ($class ? ' ' : '').'tddict'; if ($value == 'note' && $id == 10) { @@ -2366,6 +2374,10 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $form->selectExpenseRanges($obj->fk_range); print ''; + } elseif ($value == 'block_if_negative') { + print ''; + print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1); + print ''; } else { $fieldValue = isset($obj->{$value}) ? $obj->{$value}:''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 7e3585bd5bc..dc992e53285 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -259,6 +259,17 @@ class Holiday extends CommonObject $this->error = "ErrorBadParameterFkType"; return -1; } + $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + + if ($checkBalance > 0) { + $balance = $this->getCPforUser($this->fk_user, $this->fk_type); + + if ($balance < 0) { + $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; + return -1; + } + } + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; $sql .= "ref,"; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 741d92a88a1..6cc9bbeafd6 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -543,4 +543,4 @@ create table llx_c_partnership_type active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; - +ALTER TABLE llx_c_holiday_types ADD COLUMN block_if_negative integer NOT NULL DEFAULT 0 AFTER fk_country; diff --git a/htdocs/install/mysql/tables/llx_c_holiday_types.sql b/htdocs/install/mysql/tables/llx_c_holiday_types.sql index 9c09d486bec..612df739d04 100644 --- a/htdocs/install/mysql/tables/llx_c_holiday_types.sql +++ b/htdocs/install/mysql/tables/llx_c_holiday_types.sql @@ -24,5 +24,6 @@ CREATE TABLE llx_c_holiday_types ( delay integer NOT NULL, -- Minimum delay to be allowed to make request newByMonth double(8,5) DEFAULT 0 NOT NULL, -- Amount of new days for each user each month fk_country integer DEFAULT NULL, -- This type is dedicated to a country + block_if_negative integer NOT NULL DEFAULT 0, active integer DEFAULT 1 ) ENGINE=innodb; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2393a02ee50..95e77130564 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,5 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +BlockHolidayIfNegative=Block if balance negative +LeaveRequestCreationBlockedBecauseBalanceIsNegative=The creation of this leave request is blocked because your balance is negative From 084abe45474def01903f404227d2bbc71bfc4120 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Jun 2021 16:27:43 +0200 Subject: [PATCH 0011/1091] FIX: holiday: also block if balance is negative at request update, validation and approval --- htdocs/holiday/class/holiday.class.php | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index dc992e53285..2db0f36115f 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -703,6 +703,17 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; + $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + + if ($checkBalance > 0) { + $balance = $this->getCPforUser($this->fk_user, $this->fk_type); + + if ($balance < 0) { + $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; + return -1; + } + } + // Define new ref if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) { $num = $this->getNextNumRef(null); @@ -767,6 +778,17 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; + $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + + if ($checkBalance > 0) { + $balance = $this->getCPforUser($this->fk_user, $this->fk_type); + + if ($balance < 0) { + $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; + return -1; + } + } + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; @@ -876,6 +898,17 @@ class Holiday extends CommonObject global $conf, $langs; $error = 0; + $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); + + if ($checkBalance > 0) { + $balance = $this->getCPforUser($this->fk_user, $this->fk_type); + + if ($balance < 0) { + $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; + return -1; + } + } + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; From db0b00f93abcf4b804f5a9eaa25b76ada2902f0b Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 2 Jul 2021 12:30:07 +0200 Subject: [PATCH 0012/1091] Standard ticket substitutions --- htdocs/core/lib/functions.lib.php | 26 +++++++++++++------------- htdocs/ticket/card.php | 25 ------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f25e13ee88c..149cbd8530a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6848,7 +6848,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, /*$substitutionarray['__MEMBER_NOTE_PUBLIC__'] = '__MEMBER_NOTE_PUBLIC__'; $substitutionarray['__MEMBER_NOTE_PRIVATE__'] = '__MEMBER_NOTE_PRIVATE__';*/ } -// add variables subtitutions ticket + // add variables subtitutions ticket if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; @@ -6861,14 +6861,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; - - -} - - - - - + } if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { $substitutionarray['__CANDIDATE_FULLNAME__'] = '__CANDIDATE_FULLNAME__'; @@ -7058,7 +7051,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc'); $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } -// add substition variable for ticket + // add substition variable for ticket if (is_object($object) && $object->element == 'ticket') { $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; $substitutionarray['__TICKET_REF__'] = $object->ref; @@ -7069,10 +7062,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; $substitutionarray['__TICKET_MESSAGE__'] = $object->message; $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; - $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($user->firstname, $user->lastname); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($user->firstname, $user->lastname); - } + $userstat = new User($db); + if ($object->fk_user_assign > 0) { + $userstat->fetch($object->fk_user_assign); + $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + if ($object->fk_user_create > 0) { + $userstat->fetch($object->fk_user_create); + $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + } + } // Create dynamic tags for __EXTRAFIELD_FIELD__ if ($object->table_element && $object->id > 0) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5faa7b201b7..7de6ea2d966 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1347,31 +1347,6 @@ if ($action == 'create' || $action == 'presend') { $morehtmlright = ''; $help = ""; $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object); - if ($object->fk_soc > 0) { - $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name; - } - $substitutionarray['__USER_SIGNATURE__'] = $user->signature; - $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; - $substitutionarray['__TICKET_REF__'] = $object->ref; - $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; - $substitutionarray['__TICKET_TYPE__'] = $object->type_code; - $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; - $substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility - $substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code; - $substitutionarray['__TICKET_MESSAGE__'] = $object->message; - $substitutionarray['__TICKET_PROGRESSION__'] = $object->progress; - if ($object->fk_user_assign > 0) { - $userstat->fetch($object->fk_user_assign); - $substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); - } - - if ($object->fk_user_create > 0) { - $userstat->fetch($object->fk_user_create); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); - } - foreach ($substitutionarray as $key => $val) { - $help .= $key.' -> '.$langs->trans($val).'
'; - } $morehtmlright .= $form->textwithpicto(''.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution'); print '
'; From 68130ec274c6c3bc3690d8f696e0ab2ea0183a5d Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 16 Jul 2021 19:24:34 +0200 Subject: [PATCH 0013/1091] FIX: line extrafields are inoperative in dispatch cards even when they exist --- htdocs/reception/card.php | 68 ++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 8a4d5edc611..70dfd7f28b0 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -876,7 +876,14 @@ if ($action == 'create') // Reception lines $numAsked = 0; + + /** + * @var array $suffix2numAsked map HTTP query parameter suffixes (like '1_0') to line indices so that + * extrafields from HTTP query can be assigned to the correct dispatch line + */ + $suffix2numAsked = array(); $dispatchLines = array(); + foreach ($_POST as $key => $value) { // If create form is coming from the button "Create Reception" of previous page @@ -884,14 +891,16 @@ if ($action == 'create') $reg = array(); if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1] . '_' . $reg[2]; + $suffix2numAsked[$paramSuffix] = $numAsked; // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = "product_".$reg[1].'_'.$reg[2]; - $qty = "qty_".$reg[1].'_'.$reg[2]; - $ent = "entrepot_".$reg[1].'_'.$reg[2]; - $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount - $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; + $prod = "product_" . $paramSuffix; + $qty = "qty_" . $paramSuffix; + $ent = "entrepot_" . $paramSuffix; + $pu = "pu_" . $paramSuffix; // This is unit price including discount + $fk_commandefourndet = "fk_commandefourndet_" . $paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); } @@ -899,41 +908,51 @@ if ($action == 'create') if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1] . '_' . $reg[2]; + $suffix2numAsked[$paramSuffix] = $numAsked; // eat-by date dispatch // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = 'product_batch_'.$reg[1].'_'.$reg[2]; - $qty = 'qty_'.$reg[1].'_'.$reg[2]; - $ent = 'entrepot_'.$reg[1].'_'.$reg[2]; - $pu = 'pu_'.$reg[1].'_'.$reg[2]; - $lot = 'lot_number_'.$reg[1].'_'.$reg[2]; - $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); - $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); - $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; + $prod = 'product_batch_' . $paramSuffix; + $qty = 'qty_' . $paramSuffix; + $ent = 'entrepot_' . $paramSuffix; + $pu = 'pu_' . $paramSuffix; + $lot = 'lot_number_' . $paramSuffix; + $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$paramSuffix.'month'], $_POST['dluo_'.$paramSuffix.'day'], $_POST['dluo_'.$paramSuffix.'year']); + $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$paramSuffix.'month'], $_POST['dlc_'.$paramSuffix.'day'], $_POST['dlc_'.$paramSuffix.'year']); + $fk_commandefourndet = 'fk_commandefourndet_'.$paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } // If create form is coming from same page post was sent but an error occured if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) { $numAsked++; + $paramSuffix = $reg[1]; + $suffix2numAsked[$paramSuffix] = $numAsked; // eat-by date dispatch // $numline=$reg[2] + 1; // line of product $numline = $numAsked; - $prod = 'productid'.$reg[1]; - $comment = 'comment'.$reg[1]; - $qty = 'qtyl'.$reg[1]; - $ent = 'entl'.$reg[1]; - $pu = 'pul'.$reg[1]; - $lot = 'batch'.$reg[1]; - $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int')); - $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int')); - $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1]; + $prod = 'productid'.$paramSuffix; + $comment = 'comment'.$paramSuffix; + $qty = 'qtyl'.$paramSuffix; + $ent = 'entl'.$paramSuffix; + $pu = 'pul'.$paramSuffix; + $lot = 'batch'.$paramSuffix; + $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$paramSuffix.'month', 'int'), GETPOST('dluo'.$paramSuffix.'day', 'int'), GETPOST('dluo'.$paramSuffix.'year', 'int')); + $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$paramSuffix.'month', 'int'), GETPOST('dlc'.$paramSuffix.'day', 'int'), GETPOST('dlc'.$paramSuffix.'year', 'int')); + $fk_commandefourndet = 'fk_commandefournisseurdet'.$paramSuffix; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } } + // If extrafield values are passed in the HTTP query, assign them to the correct dispatch line + // Note that if an extrafield with the same name exists in the origin supplier order line, the value + // from the HTTP query will be ignored + foreach ($suffix2numAsked as $suffix => $n) { + $dispatchLines[$n]['array_options'] = $extrafields->getOptionalsFromPost('commande_fournisseur_dispatch', '_' . $suffix, ''); + } print ''; } include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); - print $formother->getHTMLScannerForm(); + print $formother->getHTMLScannerForm("barcodescannerjs"); } //Call method to undo changes in real qty From 4d2b96d0294cf9fbf36fb08df277368f22762e13 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Thu, 21 Oct 2021 18:08:20 +0200 Subject: [PATCH 0023/1091] fix inventory scan --- htdocs/core/class/html.formother.class.php | 4 ++-- htdocs/product/inventory/ajax/searchfrombarcode.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 1d8dd1db08e..d1f50889182 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -77,9 +77,9 @@ class FormOther $out .= ' Scan a product barcode
'; $out .= ' Scan a product lot or serial number
'; - $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan","tmphtml"); + $stringaddbarcode = $langs->trans("QtyToAddAfterBarcodeScan", "tmphtml"); $htmltoreplaceby = ''; - $stringaddbarcode = str_replace("tmphtml",$htmltoreplaceby,$stringaddbarcode); + $stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode); $out .= $stringaddbarcode.'
'; $out .= ''; diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 259aa5999f6..7ee9d2b6be9 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,4 +51,3 @@ if (!defined('NOBROWSERNOTIF')) { } require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; - From 56ff2412c1712c39d3ecee14b2fd22ed107eb46c Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Fri, 22 Oct 2021 16:39:42 +0200 Subject: [PATCH 0024/1091] start code to searchfrmbarcode --- .../inventory/ajax/searchfrombarcode.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 7ee9d2b6be9..73b1943f4c7 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,3 +51,29 @@ if (!defined('NOBROWSERNOTIF')) { } require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; + +$action = GETPOST("action", "alpha"); +$barcode = GETPOST("barcode", "aZ09"); +$response = ""; +$fk_entrepot = -1; +if ($action == "existbarcode" && !empty($barcode)) { + $sql = "SELECT *"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; + " WHERE p.barcode = '".$db->escape($barcode)."'"; + $result = $db->query($sql); + if ($result) { + $objecttab = $db->fetch_row($resql); + $nbline = $db->num_rows($resql); + for ($i=0; $i < $nbline; $i++) { + if ($fk_entrepot != $objecttab[$i]) { + // code... + } + } + } else { + $response = "No results found for barcode"; + } +} else { + $response = "Error on action"; +} + +echo $response; From ae78bed41d6ca6de523859676a6eaba37fb6fce6 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 14:36:31 +0200 Subject: [PATCH 0025/1091] call to ajax file --- htdocs/product/inventory/inventory.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 9445e7896c6..f2702fbc0db 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -600,6 +600,16 @@ if ($object->id > 0) { function barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ textarray.forEach(function(element,index){ + $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', + data: { "action":"existbarcode","barcode":element}, + type: \'POST\', + success: function(response) { + console.log("test+1"); + }, + error : function(output) { + console.error("Error on Fetch of KM articles"); + }, + }); console.log("Product "+(index+=1)+": "+element); BarCodeDoesNotExist=0; tabproduct.forEach(product => { From 58b28d3d7db0bfcaf3652f4182d5c9555114739e Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 22:32:03 +0200 Subject: [PATCH 0026/1091] Fix: fix php 8.0 warnings project --- htdocs/core/tpl/list_print_total.tpl.php | 2 +- htdocs/eventorganization/conferenceorbooth_list.php | 11 ++++++----- htdocs/projet/activity/perday.php | 9 +++++++-- htdocs/projet/activity/perweek.php | 7 ++++++- htdocs/projet/tasks/list.php | 8 +++++--- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 543bb939850..ec60dc36679 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,7 +13,7 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''.price($totalarray['val'][$totalarray['pos'][$i]]).''; + print ''.price(!empty($totalarray['val'][$totalarray['pos'][$i]])?:0).''; } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 0deb1707cfc..a82b39c1a76 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -494,7 +494,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.id = ef.fk_object)"; } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; @@ -710,11 +710,11 @@ foreach ($object->fields as $key => $val) { if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], !empty($search[$key])?:'', $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); + print $object->showInputField($val, $key, !empty($search[$key])?:'', '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + print ''; } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -772,7 +772,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -796,6 +796,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Show here line of result print ''; + $totalarray['nbfield'] = 0; foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 29a3c40209c..06ae3a018a6 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -77,6 +77,9 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_declared_progress = GETPOST('search_declared_progress', 'alpha'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); + $monthofday = GETPOST('addtimemonth'); $dayofday = GETPOST('addtimeday'); $yearofday = GETPOST('addtimeyear'); @@ -127,7 +130,7 @@ $arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'ena ); */ // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs((int) $extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); @@ -612,6 +615,8 @@ print ''.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to $restrictviewformytask = ((!isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); +$numendworkingday = 0; +$numstartworkingday = 0; // Get if user is available or not for each day $isavailable = array(); if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { @@ -776,7 +781,7 @@ print '
'; print ''."\n"; print '
'; -print ''; +print ''; print '
'; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 08304cecaab..d529cadeb02 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -77,6 +77,9 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha'); $search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_declared_progress = GETPOST('search_declared_progress', 'alpha'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); + $startdayarray = dol_get_first_day_week($day, $month, $year); $prev = $startdayarray; @@ -135,7 +138,7 @@ $arrayfields['timeconsumed'] = array('label'=>'TimeConsumed', 'checked'=>1, 'ena }*/ // Definition of fields for list // Extra fields -if (is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { +if (!empty($extrafields->attributes['projet_task']['label']) && is_array($extrafields->attributes['projet_task']['label']) && count($extrafields->attributes['projet_task']['label']) > 0) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if (!empty($extrafields->attributes['projet_task']['list'][$key])) { $arrayfields["efpt.".$key] = array('label'=>$extrafields->attributes['projet_task']['label'][$key], 'checked'=>(($extrafields->attributes['projet_task']['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes['projet_task']['pos'][$key], 'enabled'=>(abs((int) $extrafields->attributes['projet_task']['list'][$key]) != 3 && $extrafields->attributes['projet_task']['perms'][$key])); @@ -501,6 +504,8 @@ print '
'; $startday = dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); +$numendworkingday = 0; +$numstartworkingday = 0; // Get if user is available or not for each day $isavailable = array(); if (!empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e1ed162f9c2..6e44b8352ad 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -67,11 +67,13 @@ $search_task_user = GETPOST('search_task_user', 'int'); $search_task_progress = GETPOST('search_task_progress'); $search_task_budget_amount = GETPOST('search_task_budget_amount'); $search_societe = GETPOST('search_societe'); +$search_opp_status = GETPOST('$search_projectstatus'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = (!empty($_REQUEST['mode']) && $_REQUEST['mode'] == 'mine') ? 1 : 0; if ($mine) { $search_task_user = $user->id; $mine = 0; } +$type = GETPOST('type'); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); @@ -346,7 +348,7 @@ $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($search_project_user > 0) { @@ -634,7 +636,7 @@ if ($search_all) { print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; } -$morehtmlfilter = ''; +$moreforfilter = ''; // Filter on categories if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { From 051f6ca7170ce0886570740b8486934a5445777d Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 23 Oct 2021 23:12:42 +0200 Subject: [PATCH 0027/1091] Fix: php 8.0 warning commercial part --- htdocs/comm/propal/card.php | 9 +++++---- htdocs/comm/propal/index.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/contrat/list.php | 3 ++- htdocs/contrat/services_list.php | 3 ++- htdocs/fourn/commande/list.php | 2 +- 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 222f6ab8a87..7aa4ac02e00 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1442,7 +1442,7 @@ if (empty($reshook)) { } // Actions to build doc - $upload_dir = $conf->propal->multidir_output[$object->entity]; + $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?:$conf->propal->dir_output; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -1584,6 +1584,7 @@ if ($action == 'create') { // Third party print ''; print ''.$langs->trans('Customer').''; + $shipping_method_id = 0; if ($socid > 0) { print ''; print $soc->getNomUrl(1); @@ -1700,7 +1701,7 @@ if ($action == 'create') { // Delivery date (or manufacturing) print ''.$langs->trans("DeliveryDate").''; print ''; - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { + if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); $smonth = date("m", $tmpdte); @@ -1737,7 +1738,7 @@ if ($action == 'create') { print ''; print img_picto('', 'pdf').' '; $liste = ModelePDFPropales::liste_modeles($db); - $preselected = ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF); + $preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : getDolGlobalString("PROPALE_ADDON_PDF")); print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth200 widthcentpercentminusx', 1); print ""; @@ -1754,7 +1755,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans('NotePublic').''; print ''; - $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index e170f873961..9f020bc1613 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -100,8 +100,8 @@ if (!empty($conf->propal->enabled)) { $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD)); startSimpleTable("DraftPropals", "comm/propal/list.php", "search_status=".Propal::STATUS_DRAFT, 2, $num); + $total = 0; if ($num) { - $total = 0; $i = 0; while ($i < $nbofloop) { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 3535ae0cde1..347954cc711 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -534,7 +534,7 @@ if (!empty($search_categ_cus) && $search_categ_cus != '-1') { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ } $sql .= ', '.MAIN_DB_PREFIX.'propal as p'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index cb62cf0094f..23a32e5796e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1355,7 +1355,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to build doc - $upload_dir = $conf->commande->multidir_output[$object->entity]; + $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?:$conf->propal->dir_output; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 503c125b59c..6c14b57ef35 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -452,7 +452,7 @@ if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ } $sql .= ', '.MAIN_DB_PREFIX.'commande as c'; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index cee0faf95aa..08c85bc620a 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -229,6 +229,7 @@ $formother = new FormOther($db); $socstatic = new Societe($db); $formcompany = new FormCompany($db); $contracttmp = new Contrat($db); +$title = ""; $sql = 'SELECT'; $sql .= " c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,"; @@ -259,7 +260,7 @@ if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 5bd98ded8c4..07cad07d2dd 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('products', 'contracts', 'companies')); $optioncss = GETPOST('optioncss', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); @@ -248,7 +249,7 @@ if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; } $sql .= " ".MAIN_DB_PREFIX."contratdet as cd"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cd.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 419e75b55aa..c96de8c2aec 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -765,7 +765,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { From 9f23528ccdad01acd200f55fbff3edbb59eb10da Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 29 Oct 2021 12:39:22 +0200 Subject: [PATCH 0028/1091] Fix: Import don't work if extrafield is separator --- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modCommande.class.php | 4 ++-- htdocs/core/modules/modFournisseur.class.php | 8 ++++---- htdocs/core/modules/modProduct.class.php | 4 ++-- htdocs/core/modules/modProjet.class.php | 2 +- htdocs/core/modules/modPropale.class.php | 4 ++-- htdocs/core/modules/modResource.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- htdocs/core/modules/modSociete.class.php | 4 ++-- htdocs/core/modules/modUser.class.php | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 1db3e2b7d50..a047d14371c 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -339,7 +339,7 @@ class modAdherent extends DolibarrModules 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index f257c6e3132..2c0496430e6 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -310,7 +310,7 @@ class modCommande extends DolibarrModules // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'commande' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { @@ -392,7 +392,7 @@ class modCommande extends DolibarrModules } // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'commandedet' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 39b2f3d3237..dd4f904a209 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -698,7 +698,7 @@ class modFournisseur extends DolibarrModules } // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'facture_fourn' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { @@ -785,7 +785,7 @@ class modFournisseur extends DolibarrModules } // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'facture_fourn_det' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { @@ -874,7 +874,7 @@ class modFournisseur extends DolibarrModules // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { @@ -951,7 +951,7 @@ class modFournisseur extends DolibarrModules } // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 78f638b1821..46b9fb692ce 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -530,7 +530,7 @@ class modProduct extends DolibarrModules // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -666,7 +666,7 @@ class modProduct extends DolibarrModules // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHEREtype != 'separate' AND elementtype = 'product_fournisseur_price' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index ff2edd3c787..4bd52a68ecf 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -293,7 +293,7 @@ class modProjet extends DolibarrModules $this->import_tables_array[$r] = array('t'=>MAIN_DB_PREFIX.'projet_task', 'extra'=>MAIN_DB_PREFIX.'projet_task_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('t.fk_projet'=>'ProjectRef*', 't.ref'=>'RefTask*', 't.label'=>'LabelTask*', 't.dateo'=>"DateStart", 't.datee'=>"DateEnd", 't.planned_workload'=>"PlannedWorkload", 't.progress'=>"Progress", 't.note_private'=>"NotePrivate", 't.note_public'=>"NotePublic", 't.datec'=>"DateCreation"); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'projet_task' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 9b40a236511..156cd845128 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -292,7 +292,7 @@ class modPropale extends DolibarrModules } // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propal' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'propal' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { @@ -376,7 +376,7 @@ class modPropale extends DolibarrModules } // Add extra fields $import_extrafield_sample = []; - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'propaldet' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0d1353076ec..62c86e2e2a8 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -265,7 +265,7 @@ class modResource extends DolibarrModules $this->import_tables_array[$r] = array('r'=>MAIN_DB_PREFIX.'resource', 'extra'=>MAIN_DB_PREFIX.'resource_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r] = array('r.ref'=>"ResourceFormLabel_ref*", 'r.fk_code_type_resource'=>'ResourceTypeCode', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>'DateCreation'); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'resource' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index b4dd93ff3e0..02c1a989914 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -462,7 +462,7 @@ class modService extends DolibarrModules if (!empty($conf->global->PRODUCT_USE_UNITS)) $this->import_fields_array[$r]['p.fk_unit'] = 'Unit'; // Add extra fields $import_extrafield_sample = array(); - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'product' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'product' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 1bb0c61b83e..2382e59f1aa 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -465,7 +465,7 @@ class modSociete extends DolibarrModules ); if (!empty($conf->global->PRODUIT_MULTIPRICES)) $this->import_fields_array[$r]['s.price_level'] = 'PriceLevel'; // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'societe' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { @@ -642,7 +642,7 @@ class modSociete extends DolibarrModules 's.note_public' => "NotePublic" ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'socpeople' AND entity IN (0, ".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on an old database (during a migration for example) { diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 4b397df65e4..9c99c43b804 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -291,7 +291,7 @@ class modUser extends DolibarrModules 'u.statut'=>'Status' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'user' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From 694ce9be17f09697d6eb9aa604ac55933682cd07 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 15 Nov 2021 14:23:52 +0100 Subject: [PATCH 0029/1091] update inventory --- .../inventory/ajax/searchfrombarcode.php | 20 ++++-- htdocs/product/inventory/inventory.php | 67 ++++++++++--------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 73b1943f4c7..559bf8b72da 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,23 +50,29 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +//require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; $action = GETPOST("action", "alpha"); $barcode = GETPOST("barcode", "aZ09"); +$product = GETPOST("product"); $response = ""; -$fk_entrepot = -1; +$fk_entrepot = GETPOST("fk_entrepot", "int"); if ($action == "existbarcode" && !empty($barcode)) { - $sql = "SELECT *"; + $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; - " WHERE p.barcode = '".$db->escape($barcode)."'"; + $sql .= " WHERE p.barcode = '".$db->escape($barcode)."'"; + if (!empty($fk_entrepot)) { + $sql .= "AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'"; + } $result = $db->query($sql); if ($result) { - $objecttab = $db->fetch_row($resql); $nbline = $db->num_rows($resql); for ($i=0; $i < $nbline; $i++) { - if ($fk_entrepot != $objecttab[$i]) { - // code... + $object = $db->fetch_object($resql); + if ($barcode == $object->barcode) { + if (!empty($object->fk_entrepot) && $product["Warehouse"] == $object->fk_entrepot) { + //si warehouse !=$object->fk_entrepot erreur + } } } } else { diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index f2702fbc0db..8adf1ebc67c 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -572,21 +572,23 @@ if ($object->id > 0) { } tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput}); }) - switch(barcodemode){ - case "barcodeforautodetect": - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"barcode",true); - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"lotserial",true); - break; - case "barcodeforproduct": //TODO: create product !exist + ajout - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"barcode"); - break; - case "barcodeforlotserial": - barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,"lotserial"); - break; - default: - alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); - throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; - } + tabproduct.forEach(product => { + switch(barcodemode){ + case "barcodeforautodetect": + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode",true); + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial",true); + break; + case "barcodeforproduct": //TODO: create product !exist + ajout + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode"); + break; + case "barcodeforlotserial": + barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial"); + break; + default: + alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); + throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; + } + )} tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); @@ -598,13 +600,14 @@ if ($object->id > 0) { } - function barcodeserialforproduct(textarray,tabproduct,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ + function barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ textarray.forEach(function(element,index){ $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', - data: { "action":"existbarcode","barcode":element}, + data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', success: function(response) { console.log("test+1"); + //gerer erreur si entrepot different }, error : function(output) { console.error("Error on Fetch of KM articles"); @@ -612,23 +615,21 @@ if ($object->id > 0) { }); console.log("Product "+(index+=1)+": "+element); BarCodeDoesNotExist=0; - tabproduct.forEach(product => { - if(mode == "barcode"){ - testonproduct = product.Barcode - }else if (mode == "lotserial"){ - testonproduct = product.Batch + if(mode == "barcode"){ + testonproduct = product.Barcode + }else if (mode == "lotserial"){ + testonproduct = product.Batch + } + if(testonproduct == element){ + if(selectaddorreplace == "add"){ + productqty = parseInt(product.Qty,10) + product.Qty = productqty + (1*barcodeproductqty) + }else if(selectaddorreplace == "replace"){ + product.Qty = (1*barcodeproductqty) } - if(testonproduct == element){ - if(selectaddorreplace == "add"){ - productqty = parseInt(product.Qty,10) - product.Qty = productqty + (1*barcodeproductqty) - }else if(selectaddorreplace == "replace"){ - product.Qty = (1*barcodeproductqty) - } - }else{ - BarCodeDoesNotExist+=1; - } - }) + }else{ + BarCodeDoesNotExist+=1; + } if(autodetect == false){ if(BarCodeDoesNotExist >= tabproduct.length && mode == "barcode"){ alert("'.$langs->trans('ProductBarcodeDoesNotExist').': "+element); From 7380f5901b398618b2b5f92c9d6f69f60daae9d6 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Nov 2021 17:41:38 +0100 Subject: [PATCH 0030/1091] ZENDSI: fix margin calc with credit note --- htdocs/accountancy/customer/index.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 7dc88a6939a..8f23ee5c532 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -511,7 +511,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange print "
\n"; print '
'; print ''; - print ''; + print ''; for ($i = 1; $i <= 12; $i++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; if ($j > 12) { @@ -529,7 +529,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange } $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; } - $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + //$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= ' SUM(CASE WHEN + MONTH(f.datef)='.$j.' + THEN (CASE WHEN fd.total_ht < 0 + THEN (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))) + ELSE (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))) + END) + ELSE 0 END) AS month'.str_pad($j, 2, '0', STR_PAD_LEFT); $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; From 8bb7f9c8fb34c399e8cf678c13c5adb68164d60b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Nov 2021 17:44:18 +0100 Subject: [PATCH 0031/1091] ZENDSI: fix margin calc with credit note --- htdocs/accountancy/customer/index.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 8f23ee5c532..87fe74e2c77 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -520,23 +520,22 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange print ''; } print ''; - $sql = "SELECT '".$db->escape($langs->trans("Vide"))."' AS marge,"; for ($i = 1; $i <= 12; $i++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; if ($j > 12) { $j -= 12; } - $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$j, '(fd.total_ht-(fd.qty * fd.buy_price_ht))', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).","; - } - //$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; - $sql .= ' SUM(CASE WHEN + $sql .= ' SUM(CASE WHEN MONTH(f.datef)='.$j.' THEN (CASE WHEN fd.total_ht < 0 THEN (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))) ELSE (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))) END) - ELSE 0 END) AS month'.str_pad($j, 2, '0', STR_PAD_LEFT); + ELSE 0 END) AS month'.str_pad($j, 2, '0', STR_PAD_LEFT).','; + } + $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " WHERE f.datef >= '".$db->idate($search_date_start)."'"; From e4803dda882c3165d2386ff4dcadad4595b7dc64 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Nov 2021 17:46:12 +0100 Subject: [PATCH 0032/1091] ZENDSI: fix margin calc with credit note --- htdocs/accountancy/customer/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 87fe74e2c77..54262c32dbd 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -511,7 +511,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange print "
\n"; print '
'; print '
'.$langs->trans("TotalMarge").'
'.$langs->trans("TotalMarge").'SSSSS'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).''.$langs->trans("Total").'
'; - print ''; + print ''; for ($i = 1; $i <= 12; $i++) { $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; if ($j > 12) { From 23249751d57ab712642544027d72908cd6d61080 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Wed, 17 Nov 2021 12:10:12 +0100 Subject: [PATCH 0033/1091] FIX : reorder all lines when delete document line everywhere --- htdocs/commande/card.php | 2 ++ htdocs/compta/facture/card.php | 2 ++ htdocs/fourn/commande/card.php | 2 ++ htdocs/fourn/facture/card.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b9900459006..21b8897a3e3 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -216,6 +216,8 @@ if (empty($reshook)) $result = $object->deleteline($user, $lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86d3abedd2b..5a500eafe12 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -243,6 +243,8 @@ if (empty($reshook)) $result = $object->deleteline(GETPOST('lineid')); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f79f37d16e5..c85d1f56c29 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -805,6 +805,8 @@ if (empty($reshook)) $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 985c9a4cc62..d912f6917f7 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -253,6 +253,8 @@ if (empty($reshook)) $result = $object->deleteline($lineid); if ($result > 0) { + // reorder lines + $object->line_order(true); // Define output language /*$outputlangs = $langs; $newlang = ''; From 0e8e8a79dc5911e41524660d9d752febf55a035d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 18 Nov 2021 21:12:43 +0100 Subject: [PATCH 0034/1091] review code --- htdocs/accountancy/customer/index.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 54262c32dbd..a88524ec5d4 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -526,13 +526,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange if ($j > 12) { $j -= 12; } - $sql .= ' SUM(CASE WHEN - MONTH(f.datef)='.$j.' - THEN (CASE WHEN fd.total_ht < 0 - THEN (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))) - ELSE (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))) - END) - ELSE 0 END) AS month'.str_pad($j, 2, '0', STR_PAD_LEFT).','; + $sql .= ' + SUM('.$db->ifsql('MONTH(f.datef)='.$j, + ' ('. + $db->ifsql('fd.total_ht < 0', + ' (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))', + ' (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))' + ).')', + 0).') AS month'.str_pad($j, 2, '0', STR_PAD_LEFT).','; } $sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; @@ -552,7 +553,6 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange } else { $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.", ".Facture::TYPE_REPLACEMENT.", ".Facture::TYPE_CREDIT_NOTE.", ".Facture::TYPE_DEPOSIT.", ".Facture::TYPE_SITUATION.")"; } - dol_syslog('htdocs/accountancy/customer/index.php'); $resql = $db->query($sql); if ($resql) { From 5b1028611aacd583fa9d7bde4f225e50770a65df Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 19 Nov 2021 13:55:59 +0100 Subject: [PATCH 0035/1091] update inventory 19 11 --- .../inventory/ajax/searchfrombarcode.php | 17 +++++++++++-- htdocs/product/inventory/inventory.php | 24 +++++++++---------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 559bf8b72da..884aff9ec12 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,13 +50,17 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -//require_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +//include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +$object = new Inventory($db); + $action = GETPOST("action", "alpha"); $barcode = GETPOST("barcode", "aZ09"); $product = GETPOST("product"); $response = ""; $fk_entrepot = GETPOST("fk_entrepot", "int"); +$warehousefound = 0; +$warehouseid = 0; if ($action == "existbarcode" && !empty($barcode)) { $sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode"; $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; @@ -71,10 +75,19 @@ if ($action == "existbarcode" && !empty($barcode)) { $object = $db->fetch_object($resql); if ($barcode == $object->barcode) { if (!empty($object->fk_entrepot) && $product["Warehouse"] == $object->fk_entrepot) { - //si warehouse !=$object->fk_entrepot erreur + $warehousefound++; + $warehouseid = $object->fk_entrepot; } } } + if ($warehousefound < 1) { + $response = array('status'=>'error','errorcode'=>'NotFound','message'=>'No warehouse found for barcode'.$barcode); + } elseif ($warehousefound > 1) { + $response = array('status'=>'error','errorcode'=>'TooManyWarehouse','message'=>'Too many warehouse found'); + } else { + $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); + } + $response = json_encode($response); } else { $response = "No results found for barcode"; } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 8adf1ebc67c..76e3d53de2f 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -588,7 +588,7 @@ if ($object->id > 0) { alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\""; } - )} + }); tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); @@ -605,12 +605,17 @@ if ($object->id > 0) { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', + async: false, success: function(response) { - console.log("test+1"); - //gerer erreur si entrepot different + response = JSON.parse(response); + if(response.status == "success"){ + console.log(response.message); + }else{ + console.error(response.message); + } }, error : function(output) { - console.error("Error on Fetch of KM articles"); + console.error("Error on barcodeserialforproduct function"); }, }); console.log("Product "+(index+=1)+": "+element); @@ -623,20 +628,13 @@ if ($object->id > 0) { if(testonproduct == element){ if(selectaddorreplace == "add"){ productqty = parseInt(product.Qty,10) - product.Qty = productqty + (1*barcodeproductqty) + product.Qty = productqty + barcodeproductqty }else if(selectaddorreplace == "replace"){ - product.Qty = (1*barcodeproductqty) + product.Qty = barcodeproductqty } }else{ BarCodeDoesNotExist+=1; } - if(autodetect == false){ - if(BarCodeDoesNotExist >= tabproduct.length && mode == "barcode"){ - alert("'.$langs->trans('ProductBarcodeDoesNotExist').': "+element); - }else if(BarCodeDoesNotExist >= tabproduct.length && mode == "lotserial"){ - alert("'.$langs->trans('ProductBatchDoesNotExist').': "+element); - } - } }) } '; From 3bcafb548a4379ce56a2872eeea22d2b682fe008 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 19 Nov 2021 14:01:37 +0100 Subject: [PATCH 0036/1091] fix errors --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 7aa4ac02e00..36ebc1e1246 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1442,7 +1442,7 @@ if (empty($reshook)) { } // Actions to build doc - $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?:$conf->propal->dir_output; + $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 23a32e5796e..89e671c7784 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1355,7 +1355,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to build doc - $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?:$conf->propal->dir_output; + $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; From be44e5b0ca7c455b7887872bb201357f4e5e91fe Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 19 Nov 2021 14:27:29 +0100 Subject: [PATCH 0037/1091] NEW: for developper select_dictionnry can now deal with label translated --- htdocs/core/class/html.formother.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 99ee1b6af9b..8a77367bc25 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1382,12 +1382,12 @@ class FormOther while ($i < $num) { $obj = $this->db->fetch_object($result); - if ($selected == $obj->rowid || $selected == $obj->$keyfield) { - print ''; $i++; } From c90082925cae2b5ab07d5649c6eb262a4b7bfe72 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 19 Nov 2021 14:30:33 +0100 Subject: [PATCH 0038/1091] fix --- htdocs/core/class/html.formother.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index cef9795ef9b..a93d744cbaf 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1387,6 +1387,7 @@ class FormOther print ''; $i++; } From 00369a5269956303f6fa656bec47039952deed76 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 19 Nov 2021 14:32:40 +0100 Subject: [PATCH 0039/1091] fix errors --- htdocs/core/tpl/list_print_total.tpl.php | 2 +- htdocs/projet/tasks/list.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index ec60dc36679..929ea2df50f 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,7 +13,7 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''; + print ''; } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 4e94eb37990..1553c58683f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -349,7 +349,6 @@ $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; if (!empty($arrayfields['t.tobill']['checked']) || !empty($arrayfields['t.billed']['checked'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tt ON tt.fk_task = t.rowid"; } - if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } From 4fcac5b53c61c966830553140cd6fcd2faf9e2fc Mon Sep 17 00:00:00 2001 From: Martin Neubauer Date: Fri, 19 Nov 2021 16:38:41 +0100 Subject: [PATCH 0040/1091] Fix check for non-custom modules The check turned out to be true even for custom modules, causing the copying of the language file to fail. This attempts to bring the code behaviour in line with the code explaining it. --- htdocs/modulebuilder/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1ab03743747..f490788f291 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -742,9 +742,9 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) { // Dir for module $diroflang = dol_buildpath($modulelowercase, 0); - if ($diroflang == $dirread.'/'.$modulelowercase) { + if ($diroflang == $dolibarr_main_document_root.'/'.$modulelowercase) { // This is not a custom module, we force diroflang to htdocs root - $diroflang = $dirread; + $diroflang = $dolibarr_main_document_root; $srcfile = $diroflang.'/langs/en_US/'.$modulelowercase.'.lang'; $destfile = $diroflang.'/langs/'.$newlangcode.'/'.$modulelowercase.'.lang'; From 5f40c2e9dde572e872796fc1d40538cc603867a0 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 19 Nov 2021 17:08:07 +0100 Subject: [PATCH 0041/1091] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 648a2e6b0dc..f3a7a6116e9 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6992,7 +6992,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, // add variables subtitutions ticket if (!empty($conf->ticket->enabled) && (!is_object($object) || $object->element == 'ticket')) { $substitutionarray['__TICKET_TRACKID__'] = '__TICKET_TRACKID__'; - $substitutionarray['__TICKET_REF__'] = '__TICKET_REF__'; $substitutionarray['__TICKET_SUBJECT__'] = '__TICKET_SUBJECT__'; $substitutionarray['__TICKET_TYPE__'] = '__TICKET_TYPE__'; $substitutionarray['__TICKET_SEVERITY__'] = '__TICKET_SEVERITY__'; @@ -7001,7 +7000,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__TICKET_MESSAGE__'] = '__TICKET_MESSAGE__'; $substitutionarray['__TICKET_PROGRESSION__'] = '__TICKET_PROGRESSION__'; $substitutionarray['__TICKET_USER_ASSIGN__'] = '__TICKET_USER_ASSIGN__'; - $substitutionarray['__TICKET_USER_CREATE__'] = '__TICKET_USER_CREATE__'; } if (!empty($conf->recruitment->enabled) && (!is_object($object) || $object->element == 'candidature')) { From c8c6d5c1d24f5e9f091ff789f8fdb523a5522085 Mon Sep 17 00:00:00 2001 From: Laurent Magnin Date: Fri, 19 Nov 2021 17:09:51 +0100 Subject: [PATCH 0042/1091] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f3a7a6116e9..f2c968412b2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7194,7 +7194,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, // add substition variable for ticket if (is_object($object) && $object->element == 'ticket') { $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; - $substitutionarray['__TICKET_REF__'] = $object->ref; + $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; $substitutionarray['__TICKET_TYPE__'] = $object->type_code; $substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code; @@ -7210,7 +7210,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->fk_user_create > 0) { $userstat->fetch($object->fk_user_create); - $substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); + $substitutionarray['__USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); } } From bf8008a320c44a379c3ed781f3963f60299fc42e Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 20 Nov 2021 09:55:04 +0100 Subject: [PATCH 0043/1091] TakePOS Direct Payment (Cash) Button doesn't work --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 8bd1c4dbca9..e5dda0110f2 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -789,7 +789,7 @@ function ModalBox(ModalID) function DirectPayment(){ console.log("DirectPayment"); - $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=trans("cash"); ?>", function() { + $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=LIQ", function() { }); } From bc6f38c556b43c167239e60da90ef4a4adcf22f8 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 20 Nov 2021 15:25:51 +0100 Subject: [PATCH 0044/1091] TakePOS Direct Payment (Cash) Button doesn't work --- htdocs/takepos/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index dc6a0cd82e9..1956166cf60 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -768,7 +768,7 @@ function ModalBox(ModalID) function DirectPayment(){ console.log("DirectPayment"); - $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=trans("cash"); ?>", function() { + $("#poslines").load("invoice.php?place="+place+"&action=valid&pay=LIQ", function() { }); } From eb76ff75052d9184ba1aaa7b4c7e0cb1acae2287 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 22 Nov 2021 11:52:25 +0100 Subject: [PATCH 0045/1091] NEW hidden configuration to modify the link to return on dolibarr. Used for externalaccess --- htdocs/user/class/user.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 18cfb950619..318c50d70a7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2264,6 +2264,8 @@ class User extends CommonObject if (!$changelater) { $url = $urlwithroot.'/'; + if(!empty($conf->global->URL_REDIRECTION_AFTER_CHANGEPASSWORD)) + $url = $conf->global->URL_REDIRECTION_AFTER_CHANGEPASSWORD; $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived").".\n"; $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs")." :\n\n"; $mesg .= $outputlangs->transnoentitiesnoconv("Login")." = ".$this->login."\n"; From 690466506ec9ad98d06ec5f927cff1f6d2b127e6 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 22 Nov 2021 12:01:20 +0100 Subject: [PATCH 0046/1091] NEW new hidden option to change the link of authentication in the mail after changing password --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 318c50d70a7..1fad896633b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * Copyright (C) 2018 charlene Benke - * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018-2021 Nicolas ZABOURI * Copyright (C) 2019-2020 Frédéric France * Copyright (C) 2019 Abbes Bahfir * From 0388a12a4bbf7b0a95447e95f02d9b33ce3af84d Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 22 Nov 2021 13:07:05 +0100 Subject: [PATCH 0047/1091] Stickler --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1fad896633b..1780c73fc69 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2264,7 +2264,7 @@ class User extends CommonObject if (!$changelater) { $url = $urlwithroot.'/'; - if(!empty($conf->global->URL_REDIRECTION_AFTER_CHANGEPASSWORD)) + if (!empty($conf->global->URL_REDIRECTION_AFTER_CHANGEPASSWORD)) $url = $conf->global->URL_REDIRECTION_AFTER_CHANGEPASSWORD; $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived").".\n"; $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs")." :\n\n"; From a3315e8e160b4a94b9187d0518ebc8fb0b2fbfc4 Mon Sep 17 00:00:00 2001 From: bomuux Date: Mon, 22 Nov 2021 16:17:49 +0100 Subject: [PATCH 0048/1091] contact/note.php always restricted for external users Case of external user : 1- restrictedArea always block the access, 2- if this weren't the case, the following code is obviously wrong : fetching a Contact from a Societe id... --- htdocs/contact/note.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index 1cb76b5336e..6ced85a5735 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -36,9 +36,9 @@ $langs->load("companies"); // Security check $id = GETPOST('id', 'int'); -if ($user->socid) { - $id = $user->socid; -} +//if ($user->socid) { +// $id = $user->socid; +//} $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $object = new Contact($db); From b28b12f93af7dfe16ef2787fcc191b2029631b7a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 22 Nov 2021 16:19:01 +0100 Subject: [PATCH 0049/1091] FIX Accountancy - SQL error on subledger account search in journal --- htdocs/accountancy/bookkeeping/list.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index ec01d9c697c..52ac288856b 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -333,10 +333,6 @@ if (empty($reshook)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } - if (!empty($search_accountancy_aux_code)) { - $filter['t.subledger_account'] = $search_accountancy_aux_code; - $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); - } if (!empty($search_accountancy_aux_code_start)) { $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); @@ -533,14 +529,12 @@ if (count($filter) > 0) { $sqlwhere[] = $key.'=\''.$db->idate($value).'\''; } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; - } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=') { + } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') { $sqlwhere[] = $key.'\''.$db->escape($value).'\''; } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key.'='.$value; - } elseif ($key == 't.numero_compte') { + } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { $sqlwhere[] = $key.' LIKE \''.$db->escape($value).'%\''; - } elseif ($key == 't.subledger_account') { - $sqlwhere[] = natural_search($key, $value, 0, 1); } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$db->idate($value).'\''; } elseif ($key == 't.tms>=' || $key == 't.tms<=') { From 955eb9bc4a4b6b54d12700f5cfb1ce7b91cd2479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 00:22:43 +0100 Subject: [PATCH 0050/1091] fix #19374 --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7f141d684b7..c14298d0142 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -944,7 +944,7 @@ class FormFile $out .= '">'.img_picto($langs->trans("Delete"), 'delete').''; } if ($printer) { - $out .= ''.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').''; } From bc4ce6725a6d67f21187e32182106a70b7ba46ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:14:25 +0100 Subject: [PATCH 0051/1091] fix undefined variable $result --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 9c84e2c2e89..f609befc076 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -13,7 +13,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2019-2020 Frédéric France + * Copyright (C) 2019-2021 Frédéric France * Copyright (C) 2020 Tobias Sekan * * This program is free software; you can redistribute it and/or modify @@ -3200,7 +3200,8 @@ class SupplierProposalLine extends CommonObjectLine // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); + if ($result < 0) { return $result; } else { $this->pa_ht = $result; From 5e2dcf322cf0b2a0a59c4c810b0e4303449bd013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 22:17:05 +0100 Subject: [PATCH 0052/1091] Update supplier_proposal.class.php --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index f609befc076..ea10b4d7137 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2998,7 +2998,8 @@ class SupplierProposalLine extends CommonObjectLine // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); + if ($result < 0) { return $result; } else { $this->pa_ht = $result; From e6af0facdd6c50d766ebd8ea3b91edaaba1d4389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 23 Nov 2021 23:27:07 +0100 Subject: [PATCH 0053/1091] keep info on latest activation version of module --- htdocs/admin/modulehelp.php | 5 +++++ htdocs/core/modules/DolibarrModules.class.php | 15 +++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index a3c7c3d5c08..4ef01ab29af 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -262,6 +262,11 @@ if ($ip) { $text .= '
'.$langs->trans("LastActivationIP").': '; $text .= $ip; } +$lastactivationversion = $tmp['lastactivationversion']; +if ($lastactivationversion) { + $text .= '
'.$langs->trans("LastActivationVersion").': '; + $text .= $lastactivationversion; +} $moreinfo = $text; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 50171253938..9ecb73234de 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -957,7 +957,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $tmp = json_decode($obj->note, true); } if ($obj) { - return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + return array( + 'authorid' => $tmp['authorid'], + 'ip' => $tmp['ip'], + 'lastactivationdate' => $this->db->jdate($obj->tms), + 'lastactivationversion' => (!empty($tmp['lastactivationversion']) ? $tmp['lastactivationversion'] : 'unknown'), + ); } } @@ -991,7 +996,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $err++; } - $note = json_encode(array('authorid'=>(is_object($user) ? $user->id : 0), 'ip'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']))); + $note = json_encode( + array( + 'authorid' => (is_object($user) ? $user->id : 0), + 'ip' => (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']), + 'lastactivationversion' => $this->version, + ) + ); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name, value, visible, entity, note) VALUES"; $sql .= " (".$this->db->encrypt($this->const_name); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4601f2c15b9..5b936c49291 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -353,6 +353,7 @@ LastStableVersion=Latest stable version LastActivationDate=Latest activation date LastActivationAuthor=Latest activation author LastActivationIP=Latest activation IP +LastActivationVersion=Latest activation version UpdateServerOffline=Update server offline WithCounter=Manage a counter GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags can be used:
{000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask.
{000000+000} same as the previous one but an offset corresponding to the number to the right of the + sign is applied starting on the first %s.
{000000@x} same as the previous one but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then the sequence {yy}{mm} or {yyyy}{mm} is also required.
{dd} day (01 to 31).
{mm} month (01 to 12).
{yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
From 0b871ea0fb463890f5142c2d958a128736c8c178 Mon Sep 17 00:00:00 2001 From: Klaas Oldenburger Date: Wed, 24 Nov 2021 08:06:56 +0100 Subject: [PATCH 0054/1091] Update main.lang Changing date format the Dutch way --- htdocs/langs/nl_NL/main.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/nl_NL/main.lang b/htdocs/langs/nl_NL/main.lang index 3043bba6410..ab495070879 100644 --- a/htdocs/langs/nl_NL/main.lang +++ b/htdocs/langs/nl_NL/main.lang @@ -8,12 +8,12 @@ FONTFORPDF=helvetica FONTSIZEFORPDF=10 SeparatorDecimal=, SeparatorThousand=Space -FormatDateShort=%m/%d/%Y -FormatDateShortInput=%m/%d/%Y -FormatDateShortJava=MM/dd/yyyy -FormatDateShortJavaInput=MM/dd/yyyy -FormatDateShortJQuery=mm/dd/yy -FormatDateShortJQueryInput=mm/dd/yy +FormatDateShort=%d-%m-%Y +FormatDateShortInput=%d-%m-%Y +FormatDateShortJava=dd-MM-yyyy +FormatDateShortJavaInput=dd-MM-yyyy +FormatDateShortJQuery=dd-mm-yy +FormatDateShortJQueryInput=dd-mm-yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p FormatHourShortDuration=%H:%M From c97083f596a9e4baf2f01664e2b2834bce19c55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Hahn?= Date: Wed, 24 Nov 2021 09:43:46 +0100 Subject: [PATCH 0055/1091] Better wording Use "Modify" instead of "Update" "Modify" is more like "I want to change something" "Update" is more like "I want to confirm my changes" --- htdocs/product/traduction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 2bd92f40e78..cff6ee0dd09 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -233,7 +233,7 @@ if (empty($reshook)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print '' . $langs->trans("Add") . ''; if ($cnt_trans > 0) { - print '' . $langs->trans("Update") . ''; + print '' . $langs->trans("Modify") . ''; } } } From 632147ad889c2ea7c73eec0c90e2cf8e781b2310 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Wed, 24 Nov 2021 12:04:18 +0100 Subject: [PATCH 0056/1091] object->id is always empty --- htdocs/compta/facture/contact.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 60fdeaf3e64..c340d68242e 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -118,14 +118,6 @@ elseif ($action == 'deletecontact' && $user->rights->facture->creer) * View */ -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
'.$langs->trans("ErrorRecordNotFound").'
'; - llxFooter(); - exit; -} - $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('ContactsAddresses'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); From c33205d564061f72d93fce964517d86b07fdcb9a Mon Sep 17 00:00:00 2001 From: Maximilian Stein Date: Tue, 16 Nov 2021 19:09:14 +0100 Subject: [PATCH 0057/1091] NEW: Show sum of holidays in holiday list Show a footer in the holidays list with the sum of all holidays currently visible. --- htdocs/holiday/list.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 953f5eabb2f..c49d1f4b600 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -736,6 +736,7 @@ if ($resql) { $i = 0; $totalarray = array(); $totalarray['nbfield'] = 0; + $totalduration = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -805,6 +806,7 @@ if ($resql) { if (!empty($arrayfields['duration']['checked'])) { print '
'; if (!$i) { @@ -887,6 +889,20 @@ if ($resql) { $i++; } + + if (!empty($arrayfields['duration']['checked'])) { + print ''; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + if($key == 'duration') { + print ''; + } else { + print ''; + } } // Si il n'y a pas d'enregistrement suite à une recherche From b212778da0f72f370f0170a9f4d1d47eacdca67f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 24 Nov 2021 17:09:11 +0000 Subject: [PATCH 0058/1091] Fixing style errors. --- htdocs/holiday/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index c49d1f4b600..0ecdcb2dd69 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -894,7 +894,7 @@ if ($resql) { print ''; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { - if($key == 'duration') { + if ($key == 'duration') { print ''; } else { print ''; +print ''; + +print ''; + // Desc print '"; + $counter = ""; } $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index eeca990ef28..a1f63b997e8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -378,7 +378,7 @@ if ($cats < 0) { ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" : $categstatic->getObjectsInCateg($type, 1); - $counter = ""; + $counter = ""; } $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e8a8eb2843e..85987c8a3cf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -860,7 +860,7 @@ abstract class CommonObject if (!empty($conf->socialnetworks->enabled)) { $outsocialnetwork = ''; - if (!empty($this->socialnetworks) && is_countable($this->socialnetworks) && count($this->socialnetworks) > 0) { + if (!empty($this->socialnetworks) && is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { $socialnetworksdict = getArrayOfSocialNetworks(); foreach ($this->socialnetworks as $key => $value) { if ($value) { From 2ba5f1369fe1e37a434835f055b6e0df4bfec229 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:53:55 +0100 Subject: [PATCH 0079/1091] Fix alternate --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f40c21778f5..0e192ff0212 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2366,7 +2366,7 @@ if ($action == 'generatesitemaps' && $usercanedit) { } if ($tmpshortlangcode != $shortlangcode) { $xhtmllink = $domtree->createElement('xhtml:link', ''); - $xhtmllink->setAttribute("rel", "alternante"); + $xhtmllink->setAttribute("rel", "alternate"); $xhtmllink->setAttribute("hreflang", $tmpshortlangcode); $xhtmllink->setAttribute("href", $domainname.($objp->fk_default_home == $tmppage->id ? '/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ? '/'.$tmpshortlangcode : '').'/'.$tmppage->pageurl.'.php')); $url->appendChild($xhtmllink); From 36eb79c14d49469deb17fbc03b7bffc6557a599d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 16:49:13 +0100 Subject: [PATCH 0080/1091] Fix filter on "Refuse emailing" --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index dc8c77d0e1e..695d4ead3cc 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -76,7 +76,7 @@ $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); $search_fax = GETPOST("search_fax", 'alpha'); $search_email = GETPOST("search_email", 'alpha'); if (!empty($conf->mailing->enabled)) { - $search_no_email = GETPOST("search_no_email", 'int'); + $search_no_email = GETPOSTISSET("search_no_email") ? GETPOST("search_no_email", 'int') : -1; } else { $search_no_email = -1; } From 5473dbd3f055ea10e218d60b3dd3928912172b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 28 Nov 2021 20:55:17 +0100 Subject: [PATCH 0081/1091] add direct print for contracts --- htdocs/contrat/card.php | 2 ++ htdocs/core/class/html.formfile.class.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 31405545dbb..c52b57e305f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -916,6 +916,8 @@ if (empty($reshook)) { } } + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to build doc $upload_dir = $conf->contrat->multidir_output[$object->entity]; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7f141d684b7..e30f35758d1 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -442,7 +442,8 @@ class FormFile } $printer = 0; - if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) { // The direct print feature is implemented only for such elements + // The direct print feature is implemented only for such elements + if (in_array($modulepart, array('contract', 'facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?true:false; } @@ -944,7 +945,7 @@ class FormFile $out .= '">'.img_picto($langs->trans("Delete"), 'delete').''; } if ($printer) { - $out .= ''.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').''; } From 81e74839113e5932e4040242d10936409c98ceb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 23:51:20 +0100 Subject: [PATCH 0082/1091] css --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index c543b9edd9b..c2cbc6de76b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -429,7 +429,7 @@ if ($action == 'create') { print ''; print ''; // Tags-Categories From bb38ea79f492a4aa88290f8587f7928ab25d094b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 00:05:42 +0100 Subject: [PATCH 0083/1091] css --- htdocs/theme/eldy/global.inc.php | 1 + htdocs/theme/md/style.css.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1c8891202a7..37692f46c1e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1681,6 +1681,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select div.statusref { padding-right: 10px; + max-width: 55%; } div.statusref img { padding-right: 3px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index cbd8b4bb7fb..3118b576e1e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1744,6 +1744,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select div.statusref { padding-right: 10px; + max-width: 55%; } div.statusref img { padding-right: 3px !important; From 186185267e7a0ee4c4f2dae7446a1606892bd26e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 00:49:18 +0100 Subject: [PATCH 0084/1091] Clean code for v15 --- htdocs/accountancy/admin/fiscalyear.php | 1 - htdocs/adherents/cartes/carte.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/extrafields.class.php | 139 +----------------- .../core/tpl/admin_extrafields_view.tpl.php | 2 +- ...terface_50_modTicket_TicketEmail.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/hrm/admin/admin_establishment.php | 1 - htdocs/product/fournisseurs.php | 2 +- htdocs/public/ticket/create_ticket.php | 2 +- htdocs/public/ticket/list.php | 2 +- 11 files changed, 14 insertions(+), 143 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 44c5309f531..2eb77815b60 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -127,7 +127,6 @@ if ($result) { $title = $langs->trans('AccountingPeriods'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1); - // Load attribute_label print '
'; print '
'.$langs->trans("TotalMarge").'SSSSS
'.$langs->trans("TotalMarge").''.price(!empty($totalarray['val'][$totalarray['pos'][$i]])?:0).''.price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0).''; $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; print $nbopenedday.' '.$langs->trans('DurationDays'); print '
'.$totalduration.' '.$langs->trans('DurationDays').''; + } + } + } + print '
'.$totalduration.' '.$langs->trans('DurationDays').''; From 124e7f9b8823e4c509b7d11bd69b9e9294a119f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 23:07:06 +0100 Subject: [PATCH 0059/1091] enable societe.class.php in coding test --- htdocs/societe/class/societe.class.php | 12 ++++++------ test/phpunit/CodingPhpTest.php | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 22276cc7bee..84f551bbd93 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4752,12 +4752,12 @@ class Societe extends CommonObject * Function used to replace a thirdparty id with another one. * It must be used within a transaction to avoid trouble * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test * @param int $origin_id Old thirdparty id (will be removed) * @param int $dest_id New thirdparty id * @return bool True if success, False if error */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { if ($origin_id == $dest_id) { dol_syslog('Error: Try to merge a thirdparty into itself'); @@ -4774,9 +4774,9 @@ class Societe extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; - $resql = $db->query($sql); - while ($obj = $db->fetch_object($resql)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); + $resql = $dbs->query($sql); + while ($obj = $dbs->fetch_object($resql)) { + $dbs->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); } /** @@ -4792,7 +4792,7 @@ class Societe extends CommonObject 'societe_rib' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 383c37e95e5..b069140f420 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -213,12 +213,11 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'multicurrency.class.php', 'productbatch.class.php', 'reception.class.php', - 'societe.class.php' ))) { - // Must not found $db-> + // Must not find $db-> $ok=true; $matches=array(); - // Check string $db-> inside a class.php file (it should be $this->db-> insto such classes) + // Check string $db-> inside a class.php file (it should be $this->db-> into such classes) preg_match_all('/'.preg_quote('$db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { $ok=false; From f66f3e73554f8678adc1a80981e42ee7aa3c019d Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Thu, 25 Nov 2021 15:25:17 +0100 Subject: [PATCH 0060/1091] FIX #19476 --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 16fdaf315f1..ab2c2794e38 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -568,7 +568,7 @@ if (empty($reshook)) { if ($ret > 0) { $log_action = $langs->trans('TicketInitialMessageModified')." \n"; // include the Diff class - dol_include_once('/ticket/class/utils_diff.class.php'); + dol_include_once('/core/class/utils_diff.class.php'); // output the result of comparing two files as plain text $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); From 9d2fb782fafb8207f56204f0dda5efbf3ead0ceb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 25 Nov 2021 15:41:28 +0100 Subject: [PATCH 0061/1091] FIX Option MAIN_DIRECT_STATUS_UPDATE broken. Ajax on/off not saving value in DB after updating to version >=12 --- htdocs/core/ajax/objectonoff.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index f7bf1d6299c..20256da94d7 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -80,5 +80,9 @@ if (($action == 'set') && !empty($id)) { $format = 'int'; + $object->table_element = $tablename; + $object->id = $id; + $object->fields[$field] = array('type' => $format, 'enabled' => 1); + $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); } From 6e68eaaef4e7e6bb1062dede5e46f60ca789c882 Mon Sep 17 00:00:00 2001 From: "moreauf@theobald-groupe.com" Date: Thu, 25 Nov 2021 16:36:18 +0100 Subject: [PATCH 0062/1091] card Modif --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ebf655c77e5..b46eb9e0112 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -459,7 +459,7 @@ if ($action == "transfert_stock" && !$cancel) { } } } -}m.lalanne +} /* From 419eaa217fad255c53b2e7352841a612d02cc020 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 26 Nov 2021 12:38:09 +0100 Subject: [PATCH 0063/1091] dejar igual que 13 --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index a047d14371c..a3d9f7a5323 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -339,7 +339,7 @@ class modAdherent extends DolibarrModules 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From 5265cd808415ccab398347fbe8b00b4777214c9c Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 26 Nov 2021 12:49:07 +0100 Subject: [PATCH 0064/1091] Fix: correctly display the products of a warehouse in the pdf --- .../stock/doc/pdf_standard.modules.php | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 55923d68a79..519da28a3b5 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -289,8 +289,8 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 80 + $top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_top = 65 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 + $top_shift : 10); $tab_height = 130; @@ -323,7 +323,7 @@ class pdf_standard extends ModelePDFStock $i = 0; $nblines = $num; - $this->tabTitleHeight = 0; + $this->tabTitleHeight = 10; $nexY = $tab_top + $this->tabTitleHeight; for ($i = 0; $i < $nblines; $i++) @@ -362,7 +362,8 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 3, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -370,7 +371,8 @@ class pdf_standard extends ModelePDFStock $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 4, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text @@ -418,8 +420,8 @@ class pdf_standard extends ModelePDFStock $productstatic->status_batch = $objp->tobatch; // Ref. - $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + //$pdf->SetXY($this->posxdesc, $curY); + //$pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); // Label $pdf->SetXY($this->posxlabel + 0.8, $curY); @@ -506,7 +508,7 @@ class pdf_standard extends ModelePDFStock /** * Footer table */ - $nexY = $pdf->GetY(); + //$nexY = $pdf->GetY(); $nexY += 2; $curY = $nexY; @@ -572,11 +574,11 @@ class pdf_standard extends ModelePDFStock $height_note = 0; } - $iniY = $tab_top + 7; + /*$iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage + 25 + $top_shift; + $tab_top = $tab_top_newpage + 25 + $top_shift;*/ // Show square if ($pagenb == 1) @@ -732,10 +734,12 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R'); } - $pdf->SetDrawColor(200, 200, 200); - $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); - $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); - $pdf->SetLineStyle(array('dash'=>0)); + if (empty($hidetop)) { + $pdf->SetDrawColor(200, 200, 200); + $pdf->SetLineStyle(array('dash' => '0', 'color' => array(200, 200, 200))); + $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); + $pdf->SetLineStyle(array('dash' => 0)); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From 1361abffe515722631dafbfba68ff0c20f553a10 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:22:31 +0100 Subject: [PATCH 0065/1091] FIX: holiday list: only mass delete if leave request is not in draft, canceled or refused, like in card --- htdocs/core/actions_massactions.inc.php | 6 ++++++ htdocs/langs/en_US/holiday.lang | 1 + 2 files changed, 7 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index abcdd690d5c..0c84b2d3781 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1280,6 +1280,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } + if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) { + $nbignored++; + setEventMessage($langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref)); + continue; + } + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index eb2cd89adf1..ef96e72cc9d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted From f5343c55c39791f4351afedc6669bf7483db6957 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:23:31 +0100 Subject: [PATCH 0066/1091] FIX: holiday mass deletion: correct return of record deleted --- htdocs/core/actions_massactions.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 0c84b2d3781..2ce94cad8ed 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1320,7 +1320,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + elseif ($nbok > 0) setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); $db->commit(); } else From 72493a5663cc6011395d694fbc59abbbd8b29342 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 15:13:36 +0100 Subject: [PATCH 0067/1091] Fix typo --- test/phpunit/SecurityTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 81eff830b49..6bece069cc9 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -594,7 +594,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." login=".$login."\n"; $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); - $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method + $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method print __METHOD__." login=".$login."\n"; $this->assertEquals($login, 'admin'); @@ -749,42 +749,42 @@ class SecurityTest extends PHPUnit\Framework\TestCase $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow print __METHOD__." url=".$url."\n"; - $this->assertEquals(301, $tmp['http_code'], 'GET url 301 without following -> 301'); + $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 without following -> 301'); $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page - $tmp = getURLContent($url); // We DO follow + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 print __METHOD__." url=".$url."\n"; - $this->assertEquals(200, $tmp['http_code'], 'GET url 301 with following -> 200'); // Test error if return does not contains 'not supported' + $this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with following -> 200 but we get '.$tmp['http_code']); $url = 'http://localhost'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL $url = 'http://127.0.0.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL $url = 'http://127.0.2.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL $url = 'https://169.254.0.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL $url = 'http://[::1]'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL /*$url = 'localtest.me'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL */ return 0; From 2030d55c67b68144e9844c27aded4a899ba4726e Mon Sep 17 00:00:00 2001 From: Klaas Oldenburger Date: Sat, 27 Nov 2021 16:42:53 +0100 Subject: [PATCH 0068/1091] Update main.lang Did not complete earlier work. --- htdocs/langs/nl_NL/main.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/nl_NL/main.lang b/htdocs/langs/nl_NL/main.lang index 3043bba6410..1afc7f49fb7 100644 --- a/htdocs/langs/nl_NL/main.lang +++ b/htdocs/langs/nl_NL/main.lang @@ -17,12 +17,12 @@ FormatDateShortJQueryInput=mm/dd/yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p FormatHourShortDuration=%H:%M -FormatDateTextShort=%b %d, %Y -FormatDateText=%B %d, %Y -FormatDateHourShort=%m/%d/%Y %I:%M %p -FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p -FormatDateHourTextShort=%b %d, %Y, %I:%M %p -FormatDateHourText=%B %d, %Y, %I:%M %p +FormatDateTextShort=%d %b %Y +FormatDateText=%d %B %Y +FormatDateHourShort=%d-%m-%Y %I:%M %p +FormatDateHourSecShort=%d-%m-%Y %I:%M:%S %p +FormatDateHourTextShort=%d %b %Y, %I:%M %p +FormatDateHourText=%d %B %Y, %I:%M %p DatabaseConnection=Databaseverbinding NoTemplateDefined=Geen sjabloon beschikbaar voor dit e-mailtype AvailableVariables=Beschikbare substitutievariabelen From 5bb21a93a1fba9ac222b9062c471ac51751ca750 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 27 Nov 2021 18:25:38 +0100 Subject: [PATCH 0069/1091] FIX fatal error on cron list. --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/cron/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 03366e9bae1..9a5ab68f898 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8082,7 +8082,7 @@ function verifCond($strRights) //print $strRights."
\n"; $rights = true; - if ($strRights !== '') { + if (isset($strRights) && $strRights !== '') { $str = 'if(!('.$strRights.')) { $rights = false; }'; dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 4d829258b2b..686bb8a52a9 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -478,7 +478,7 @@ if ($num > 0) { if (empty($obj)) { break; } - if (!verifCond($obj->test)) { + if (isset($obj->test) && !verifCond($obj->test)) { continue; // Discard line with test = false } From a75ae6a8cfd3a2526fc1fee9fa45b08262497680 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:11:03 +0100 Subject: [PATCH 0070/1091] Fix missing formsetup elements --- htdocs/core/class/html.formsetup.class.php | 144 +++++++++++++++++- htdocs/modulebuilder/template/admin/setup.php | 85 ++++++----- 2 files changed, 189 insertions(+), 40 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 6f2ec2acfb6..a8ed08587ed 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -44,6 +44,47 @@ class FormSetup /** @var int */ protected $maxItemRank; + /** + * this is an html string display before output form + * @var string + */ + public $htmlBeforeOutputForm = ''; + + /** + * this is an html string display after output form + * @var string + */ + public $htmlAfterOutputForm = ''; + + /** + * this is an html string display on buttons zone + * @var string + */ + public $htmlOutputMoreButton = ''; + + + /** + * + * @var array + */ + public $formAttributes = array( + 'action' => '', // set in __construct + 'method' => 'POST' + ); + + /** + * an list of hidden inputs used only in edit mode + * @var array + */ + public $formHiddenInputs = array(); + + + /** + * the value of action attribute of form + * @var string + */ + public $formAction; + /** * Constructor * @@ -55,6 +96,11 @@ class FormSetup global $langs; $this->db = $db; $this->form = new Form($this->db); + $this->formAttributes['action'] = $_SERVER["PHP_SELF"]; + + $this->formHiddenInputs['token'] = newToken(); + $this->formHiddenInputs['action'] = 'update'; + if ($outputLangs) { $this->langs = $outputLangs; @@ -63,6 +109,38 @@ class FormSetup } } + /** + * a quick method to sanitize html attributes + * @param string $var the string to sanitize + * @return string + */ + static public function sanitizeHtmlAttribute($var) + { + $var = preg_replace("/\r|\n/", "", $var); + return htmlspecialchars($var, ENT_QUOTES); + } + + /** + * Generae an attributes string form an input array + * @param array $attributes an array of attributes keys and values, + * @return string + */ + static public function generateAttributesStringFromArray($attributes) + { + $Aattr = array(); + if (is_array($attributes)) { + foreach ($attributes as $attribute => $value) { + if (is_array($value) || is_object($value)) { + continue; + } + $Aattr[] = $attribute.'="'.self::sanitizeHtmlAttribute($value).'"'; + } + } + + return !empty($Aattr)?implode(' ', $Aattr):''; + } + + /** * @param bool $editMode true will display output on edit mod * @return string @@ -83,12 +161,70 @@ class FormSetup if ($reshook > 0) { return $hookmanager->resPrint; } else { - $out = ''; + $out = ''; + $out.= $this->htmlBeforeOutputForm; + if ($editMode) { - $out .= ''; + $out.= '
formAttributes) . ' >'; + + // generate hidden values from $this->formHiddenInputs + if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) { + foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) { + $out.= ''; + } + } } - $out .= ''; + // generate output table + $out .= $this->generateTableOutput($editMode); + + + $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutputButton', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if ($reshook > 0) { + return $hookmanager->resPrint; + } elseif ($editMode) { + $out .= '
'; // Todo : remove this
by adding style to form-setup-button-container css class in all themes + $out .= '
'; // Todo : remove .center by adding style to form-setup-button-container css class in all themes + $out.= $this->htmlOutputMoreButton; + $out .= ''; // Todo fix dolibarr style for
'; $out .= ''; $out .= ''; $out .= ' '; @@ -247,7 +383,7 @@ class FormSetup public function exportItemsAsParamsArray() { $arrayofparameters = array(); - foreach ($this->items as $key => $item) { + foreach ($this->items as $item) { $arrayofparameters[$item->confKey] = array( 'type' => $item->getType(), 'enabled' => $item->enabled diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 5690d18678b..6836585285c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -88,6 +88,9 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); +$error = 0; +$setupnotempty = 0; + // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 0; // Convert arrayofparameter into a formSetup object @@ -95,35 +98,44 @@ if (!empty($arrayofparameters) && $useFormSetup && (float) DOL_VERSION >= 15) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; $formSetup = new FormSetup($db); - foreach ($arrayofparameters as $key => $val) { - if ($val['enabled']) { - $item = $formSetup->newItem($key); + // you can use the param convertor + $formSetup->addItemsFromParamsArray($arrayofparameters); - if ($val['type'] == 'string') { - $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; - $item->cssClass = $val['css']; - } - if ($val['type'] == 'thirdparty_type') { - $item->setAsThirdpartyType(); - } - if ($val['type'] == 'yesno') { - $formSetup->newItem($key)->setAsYesNo(); - } - if ($val['type'] == 'emailtemplate:thirdparty') { - $formSetup->newItem($key)->setAsEmailTemplate('thirdparty'); - } - if ($val['type'] == 'securekey') { - $formSetup->newItem($key)->setAsSecureKey()->enabled = 0; // disabled - } - if ($val['type'] == 'product') { - $formSetup->newItem($key)->setAsProduct(); - } - } - } + // or use the new system see exemple as follow (or use both because you can ;-) ) + + /* + // Hôte + $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); + $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; + $item->cssClass = 'minwidth500'; + + // Setup conf MYMODULE_MYPARAM1 as a simple string input + $item = $formSetup->newItem('MYMODULE_MYPARAM1'); + + // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title + $item = $formSetup->newItem('MYMODULE_MYPARAM2'); + $item->nameText = $item->getNameText().' more html text '; + + // Setup conf MYMODULE_MYPARAM3 + $item = $formSetup->newItem('MYMODULE_MYPARAM3'); + $item->setAsThirdpartyType(); + + // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style + $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); + + // Setup conf MYMODULE_MYPARAM5 + $formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + + // Setup conf MYMODULE_MYPARAM6 + $formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + + // Setup conf MYMODULE_MYPARAM7 + $formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + */ + + $setupnotempty = count($formSetup->items); } -$error = 0; -$setupnotempty = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -258,13 +270,13 @@ echo ''.$langs->trans("MyModuleSetupPage").'< if ($action == 'edit') { - print ''; - print ''; - print ''; - if ($useFormSetup && (float) DOL_VERSION >= 15) { print $formSetup->generateOutput(true); } else { + print ''; + print ''; + print ''; + print '
' . $this->langs->trans("Parameter") . '
'; print ''; @@ -350,18 +362,19 @@ if ($action == 'edit') { } } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - } - print '
'; - print ''; - print '
'; - print '
'; + print '
'; + print ''; + print '
'; + + print ''; + } + print '
'; } else { if ($useFormSetup && (float) DOL_VERSION >= 15) { if (!empty($formSetup->items)) { print $formSetup->generateOutput(); - $setupnotempty = count($formSetup->items); } } else { if (!empty($arrayofparameters)) { From f08adef1e8d6eef6910eb8cd7803e3537216c138 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 28 Nov 2021 12:12:16 +0100 Subject: [PATCH 0071/1091] Fix ExpenseReport define template Can use template for expense report notification but not define it :/ --- htdocs/admin/mails_templates.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 7d8bc2f22b1..0adc526d69e 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -225,6 +225,9 @@ if (!empty($conf->contrat->enabled) && !empty($user->rights->contrat->lire)) { if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) { $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket')); } +if (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire)) { + $elementList['expensereport_send'] = img_picto('', 'trip', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTExpenseReport')); +} if (!empty($conf->agenda->enabled)) { $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush')); } From 29437a22b9364314cafd4021547f885a2ab51c54 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:15:31 +0100 Subject: [PATCH 0072/1091] Fix comment and remove not use global --- htdocs/core/class/html.formsetup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a8ed08587ed..149e416fd81 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -121,7 +121,7 @@ class FormSetup } /** - * Generae an attributes string form an input array + * Generate an attributes string form an input array * @param array $attributes an array of attributes keys and values, * @return string */ @@ -690,7 +690,7 @@ class FormSetupItem */ public function generateInputField() { - global $conf, $user; + global $conf; if (!empty($this->fieldOverride)) { return $this->fieldOverride; From e97e0e4f17d315c989d07ab1fd640febab4fb921 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:18:09 +0100 Subject: [PATCH 0073/1091] Fix remove not used propertie --- htdocs/core/class/html.formsetup.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 149e416fd81..13dd3a8694c 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -79,12 +79,6 @@ class FormSetup public $formHiddenInputs = array(); - /** - * the value of action attribute of form - * @var string - */ - public $formAction; - /** * Constructor * From 5a165ae2bfd5d66e6b895120de4bb7acb1b1a3e8 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Sun, 28 Nov 2021 14:40:15 +0100 Subject: [PATCH 0074/1091] FIX PDF_NOLD_PRODUCT_LABEL --- htdocs/admin/pdf.php | 23 +++++++++++++++++++++++ htdocs/core/lib/pdf.lib.php | 19 ++++++++++++++----- htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/fr_FR/admin.lang | 2 ++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index c22d365d932..c4ae5d59225 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -170,6 +170,13 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) { + dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){ + dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity); + } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -499,6 +506,22 @@ if ($conf->use_javascript_ajax) { } print '
'.$langs->trans("BoldLabelOnPDF").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_BOLD_PRODUCT_LABEL'); +} else { + print $form->selectyesno('PDF_BOLD_PRODUCT_LABEL', (!empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) ? $conf->global->PDF_BOLD_PRODUCT_LABEL : 0, 1); +} +print '
'.$langs->trans("BoldRefAndPeriodOnPDF").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_BOLD_PRODUCT_REF_AND_PERIOD'); +} else { + print $form->selectyesno('PDF_BOLD_PRODUCT_REF_AND_PERIOD', (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) ? $conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD : 0, 1); +} +print '
'.$langs->trans("HideDescOnPDF").''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 5121506087c..7a78db5a14e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1363,7 +1363,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { - // This part of code is bugged. It introduces a HTML tag making the label a html string but without converting \n into br if it was a full text non html string before. + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $libelleproduitservice = ''.$libelleproduitservice.''; } } @@ -1375,7 +1377,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) { $tmparrayofsubproducts = reset($prodser->sousprods); foreach ($tmparrayofsubproducts as $subprodval) { - $libelleproduitservice .= "\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; + $libelleproduitservice .= "__N__ * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; } } } @@ -1419,7 +1421,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (empty($hidedesc)) { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice = $desc."\n".$libelleproduitservice; + $libelleproduitservice = $desc."__N__".$libelleproduitservice; } else { if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; @@ -1493,10 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $ref_prodserv = ''.$ref_prodserv.''; - } + // $prefix_prodserv and $ref_prodser are not HTML var + } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; - + // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -1527,6 +1533,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } //print '>'.$outputlangs->charset_output.','.$period; if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $libelleproduitservice .= ''."__N__ ".$period.''; } else { $libelleproduitservice .= "__N__".$period; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c258df38441..c36f29fa0d7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - admin +BoldRefAndPeriodOnPDF=Bold reference and period in PDF +BoldLabelOnPDF=Bold label in PDF Foundation=Foundation Version=Version Publisher=Publisher diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0b4d7aa4f10..9d2de4d5ca8 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - admin +BoldRefAndPeriodOnPDF=Mettre en gras la référence et la période dans les PDF +BoldLabelOnPDF=Mettre en gras le label des produits dans les PDF Foundation=Association Version=Version Publisher=Editeur From a933793b8a43903fb6c514ae89da9df96690f9af Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 28 Nov 2021 13:42:25 +0000 Subject: [PATCH 0075/1091] Fixing style errors. --- htdocs/admin/pdf.php | 2 +- htdocs/core/lib/pdf.lib.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index c4ae5d59225..18a4ca0825f 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -173,7 +173,7 @@ if ($action == 'update') { if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) { dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity); } - if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){ + if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')) { dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 7a78db5a14e..2d8ce3b2996 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1363,7 +1363,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $libelleproduitservice = ''.$libelleproduitservice.''; @@ -1495,14 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $ref_prodserv = ''.$ref_prodserv.''; // $prefix_prodserv and $ref_prodser are not HTML var - } + } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; - + // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -1533,7 +1533,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } //print '>'.$outputlangs->charset_output.','.$period; if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $libelleproduitservice .= ''."__N__ ".$period.''; From ce651fae587669831f88ca3ac64ba31d10800299 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:34:08 +0100 Subject: [PATCH 0076/1091] Fix php compatibility --- htdocs/core/lib/memory.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 1300c1b771f..b3fd7109343 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -$rescode; } @@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0) //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -1; } From ca11dcae22ff60af1bed4464ba5ac22e6d1c1596 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:41:19 +0100 Subject: [PATCH 0077/1091] Fix php compatibility --- htdocs/core/lib/memory.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index b3fd7109343..94884ea302d 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { - return is_array($data) ? count($data) : 0; + return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0); } else { return -$rescode; } @@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0) //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { - return is_array($data) ? count($data) : 0; + return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0); } else { return -1; } From c41578a3c360560b18f6af20d442306c03135ef8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:43:22 +0100 Subject: [PATCH 0078/1091] Fix php compatibility --- htdocs/categories/index.php | 2 +- htdocs/categories/viewcat.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 708fb3a3e83..c585217dfda 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -186,7 +186,7 @@ foreach ($fulltree as $key => $val) { ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" : $categstatic->getObjectsInCateg($type, 1); - $counter = "".(is_countable($elements) ? count($elements) : '0')."".(is_array($elements) ? count($elements) : '0')."".(is_countable($elements) ? count($elements) : '0')."".(is_array($elements) ? count($elements) : '0')."
'.$langs->trans("Web").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 271cb09fa81..93054dad234 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -119,7 +119,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { } //if (!empty($objp->$key)) // $objp->array_options[$tmpkey] = $objp->$key; - //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', $object->table_element); //$objp->$tmpkey; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5dd392ad065..040d3c519d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7862,7 +7862,7 @@ abstract class CommonObject switch ($mode) { case "view": - $out .= $extrafields->showOutputField($key, $value); + $out .= $extrafields->showOutputField($key, $value, '', $this->table_element); break; case "create": $out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 057b1d9ace9..e73f83d1340 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -42,12 +42,6 @@ class ExtraFields */ public $db; - /** - * @var array Array with type of element (for what object is the extrafield) - * @deprecated - */ - public $attribute_elementtype; - /** * @var array Array with type of the extra field * @deprecated @@ -60,90 +54,12 @@ class ExtraFields */ public $attribute_label; - /** - * @var array Array with size of extra field - * @deprecated - */ - public $attribute_size; - /** * @var array Array with list of possible values for some types of extra fields * @deprecated */ public $attribute_choice; - /** - * @var array Array to store compute formula for computed fields - * @deprecated - */ - public $attribute_computed; - - /** - * @var array Array to store default value - * @deprecated - */ - public $attribute_default; - - /** - * @var array Array to store if attribute is unique or not - * @deprecated - */ - public $attribute_unique; - - /** - * @var array Array to store if attribute is required or not - * @deprecated - */ - public $attribute_required; - - /** - * @var array Array to store parameters of attribute (used in select type) - * @deprecated - */ - public $attribute_param; - - /** - * @var array Array to store position of attribute - * @deprecated - */ - public $attribute_pos; - - /** - * @var array Array to store if attribute is editable regardless of the document status - * @deprecated - */ - public $attribute_alwayseditable; - - /** - * @var array Array to store permission to check - * @deprecated - */ - public $attribute_perms; - - /** - * @var array Array to store language file to translate label of values - * @deprecated - */ - public $attribute_langfile; - - /** - * @var array Array to store if field is visible by default on list - * @deprecated - */ - public $attribute_list; - - /** - * @var array Array to store if field is summable - * @deprecated - */ - public $attribute_totalizable; - - /** - * @var array Array to store entity id of extrafield - * @deprecated - */ - public $attribute_entityid; - /** * @var array New array to store extrafields definition @@ -203,17 +119,8 @@ class ExtraFields $this->attributes = array(); // For old usage - $this->attribute_elementtype = array(); $this->attribute_type = array(); $this->attribute_label = array(); - $this->attribute_size = array(); - $this->attribute_computed = array(); - $this->attribute_default = array(); - $this->attribute_unique = array(); - $this->attribute_required = array(); - $this->attribute_perms = array(); - $this->attribute_langfile = array(); - $this->attribute_list = array(); } /** @@ -238,7 +145,7 @@ class ExtraFields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @param int $totalizable Is a measure. Must show a total on lists - * @param int $printable Is extrafield displayed on PDF + * @param int $printable Is extrafield displayed on PDF * @return int <=0 if KO, >0 if OK */ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) @@ -873,7 +780,7 @@ class ExtraFields // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ... + * Load array this->attributes (and some old this->attribute_xxx like attribute_label, attribute_type, ... * * @param string $elementtype Type of element ('' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...). * @param boolean $forceload Force load of extra fields whatever is status of cache. @@ -932,20 +839,6 @@ class ExtraFields // Old usage $this->attribute_type[$tab->name] = $tab->type; $this->attribute_label[$tab->name] = $tab->label; - $this->attribute_size[$tab->name] = $tab->size; - $this->attribute_elementtype[$tab->name] = $tab->elementtype; - $this->attribute_default[$tab->name] = $tab->fielddefault; - $this->attribute_computed[$tab->name] = $tab->fieldcomputed; - $this->attribute_unique[$tab->name] = $tab->fieldunique; - $this->attribute_required[$tab->name] = $tab->fieldrequired; - $this->attribute_param[$tab->name] = ($tab->param ? jsonOrUnserialize($tab->param) : ''); - $this->attribute_pos[$tab->name] = $tab->pos; - $this->attribute_alwayseditable[$tab->name] = $tab->alwayseditable; - $this->attribute_perms[$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); - $this->attribute_langfile[$tab->name] = $tab->langs; - $this->attribute_list[$tab->name] = $tab->list; - $this->attribute_totalizable[$tab->name] = $tab->totalizable; - $this->attribute_entityid[$tab->name] = $tab->entity; // New usage $this->attributes[$tab->elementtype]['type'][$tab->name] = $tab->type; @@ -1028,20 +921,10 @@ class ExtraFields $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } else // Old usage - { + } else { + // Old usage $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $elementtype = $this->attribute_elementtype[$key]; // Seems not used - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $langfile = $this->attribute_langfile[$key]; - $list = $this->attribute_list[$key]; - $totalizable = $this->attribute_totalizable[$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } @@ -1626,20 +1509,10 @@ class ExtraFields $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } else // Old usage - { - //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); + } else { + // Old usage $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $perms = dol_eval($this->attribute_perms[$key], 1); - $langfile = $this->attribute_langfile[$key]; - $list = dol_eval($this->attribute_list[$key], 1); $help = ''; // Not supported with old syntax $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 0c1d34efa08..d1145229db7 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -41,7 +41,7 @@ $langs->load("modulebuilder"); print ''.$langs->trans("DefineHereComplementaryAttributes", $textobject).'
'."\n"; print '
'; -// Load attribute_label +// Load $extrafields->attributes $extrafields->fetch_name_optionals_label($elementtype); print '
'; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 12b688d9b61..cab6779bf8c 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -157,7 +157,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (is_array($object->array_options) && count($object->array_options) > 0) { foreach ($object->array_options as $key => $value) { $key = substr($key, 8); // remove "options_" - $message_admin .= '
  • '.$langs->trans($extraFields->attributes[$object->element]['label'][$key]).' : '.$extraFields->showOutputField($key, $value).'
  • '; + $message_admin .= '
  • '.$langs->trans($extraFields->attributes[$object->element]['label'][$key]).' : '.$extraFields->showOutputField($key, $value, '', $object->table_element).'
  • '; } } $message_admin .= ''; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5b523d8d7e8..fc3054fdd51 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -635,7 +635,7 @@ class ProductFournisseur extends Product * @param int $limit Limit * @param int $offset Offset * @param int $socid Filter on a third party id - * @return array Array of Products with new properties to define supplier price + * @return array Array of ProductFournisseur with new properties to define supplier price */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index dd17a2be4b0..11a34b939a2 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -99,7 +99,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - // Load attribute_label print '
    '; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 02e0211c01d..b79fe5fb843 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1211,7 +1211,7 @@ END; $obj = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - print '"; + print '"; } } } diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 00eff71da78..1a11b16d1ea 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -297,7 +297,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { if (is_array($object->array_options) && count($object->array_options) > 0) { foreach ($object->array_options as $key => $value) { $key = substr($key, 8); // remove "options_" - $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value).'
  • '; + $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'
  • '; } } $message_admin .= ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index db5f5d8d754..4fbfd29106a 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -651,7 +651,7 @@ if ($action == "view_ticketlist") { } print '>'; $tmpkey = 'options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print $extrafields->showOutputField($key, $obj->$tmpkey, '', $object->table_element); print ''; } } From e3e4b154e7cddca44ad234642bdef9c2e2459657 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 01:04:32 +0100 Subject: [PATCH 0085/1091] Fix partnership --- htdocs/core/lib/company.lib.php | 1 + htdocs/langs/en_US/partnership.lang | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 313dd5d8fbe..2b8aad7453c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -274,6 +274,7 @@ function societe_prepare_head(Societe $object) if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'thirdparty') { if (!empty($user->rights->partnership->read)) { + $langs->load("partnership"); $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; $head[$h][0] = DOL_URL_ROOT.'/societe/partnership.php?socid='.$object->id; $head[$h][1] = $langs->trans("Partnership"); diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 0eb73c17920..f542bfab670 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -19,7 +19,7 @@ ModulePartnershipName=Partnership management PartnershipDescription=Module Partnership management PartnershipDescriptionLong= Module Partnership management - +Partnership=Partnership AddPartnership=Add partnership CancelPartnershipForExpiredMembers=Partnership: Cancel partnership of members with expired subscriptions PartnershipCheckBacklink=Partnership: Check referring backlink From 1fa3e9f37d1d971b4b00ed89533f8fa2ccaa4f18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 01:13:43 +0100 Subject: [PATCH 0086/1091] Look and feel v15 --- htdocs/compta/bank/various_payment/card.php | 7 +++---- htdocs/compta/bank/various_payment/list.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index d4245594447..bd81a0433eb 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -415,7 +415,7 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } @@ -490,9 +490,8 @@ if ($action == 'create') { $langs->load("projects"); print ''; } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index dda68a096a1..fec2d025c7a 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -160,7 +160,7 @@ $arrayfields = array( 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), - 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), + 'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130), 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3118b576e1e..10768184b1b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3421,7 +3421,7 @@ tr.liste_titre.box_titre td table td, .bordernooddeven tr td { } table.border td, table.bordernooddeven td, div.border div div.tagtd { - padding: 2px 4px 2px 4px; + padding: 4px 4px 4px 4px; border: 1px solid #f0f0f0; border-collapse: collapse; } From 5bdaab8dcb6f35ee79f7f8e50f53d90f1536900e Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 29 Nov 2021 14:30:04 +0100 Subject: [PATCH 0087/1091] Fix duplicated code --- htdocs/core/class/commonobject.class.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 040d3c519d9..cc74c30c191 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4872,13 +4872,9 @@ abstract class CommonObject $reshook = 0; //if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (is_object($hookmanager)) { // Old code is commented on preceding line. - if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); - $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } else { - $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines, 'fk_parent_line'=>$line->fk_parent_line); - $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); + if (!empty($line->fk_parent_line)) { $parameters['fk_parent_line'] = $line->fk_parent_line; } + $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); From c529d1a928aef79b1a8c6518761b1f048d35b408 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 29 Nov 2021 15:00:23 +0100 Subject: [PATCH 0088/1091] update inventory add replace work --- .../inventory/ajax/searchfrombarcode.php | 9 ++--- .../inventory/class/inventory.class.php | 1 + htdocs/product/inventory/inventory.php | 40 ++++++++++++------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 884aff9ec12..1a613c7a837 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,8 +50,6 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -//include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; -$object = new Inventory($db); $action = GETPOST("action", "alpha"); @@ -87,12 +85,11 @@ if ($action == "existbarcode" && !empty($barcode)) { } else { $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); } - $response = json_encode($response); } else { - $response = "No results found for barcode"; + $response = array('status'=>'error','errorcode'=>'NotFound','message'=>"No results found for barcode"); } } else { - $response = "Error on action"; + $response = array('status'=>'error','errorcode'=>'ActionError','message'=>"Error on action"); } - +$response = json_encode($response); echo $response; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b972e44245b..092d98ea854 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -26,6 +26,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 4dcda1bba41..910084c12fe 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -571,19 +571,19 @@ if ($object->id > 0) { if(productinput == ""){ productinput = 0 } - tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput}); + tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false}); }) - tabproduct.forEach(product => { + textarray.forEach(function(element,index){ switch(barcodemode){ case "barcodeforautodetect": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode",true); - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true); break; case "barcodeforproduct": //TODO: create product !exist + ajout - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode"); break; case "barcodeforlotserial": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial"); break; default: alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); @@ -601,8 +601,10 @@ if ($object->id > 0) { } - function barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ - textarray.forEach(function(element,index){ + function barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ + BarcodeIsInProduct=0; + BarcodeSuccess=false; + tabproduct.forEach(product => { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', @@ -611,6 +613,7 @@ if ($object->id > 0) { response = JSON.parse(response); if(response.status == "success"){ console.log(response.message); + BarcodeSucess=true; }else{ console.error(response.message); } @@ -618,9 +621,8 @@ if ($object->id > 0) { error : function(output) { console.error("Error on barcodeserialforproduct function"); }, - }); + }); console.log("Product "+(index+=1)+": "+element); - BarCodeDoesNotExist=0; if(mode == "barcode"){ testonproduct = product.Barcode }else if (mode == "lotserial"){ @@ -628,15 +630,23 @@ if ($object->id > 0) { } if(testonproduct == element){ if(selectaddorreplace == "add"){ - productqty = parseInt(product.Qty,10) - product.Qty = productqty + barcodeproductqty + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); }else if(selectaddorreplace == "replace"){ - product.Qty = barcodeproductqty + if(product.fetched == false){ + product.Qty = barcodeproductqty + product.fetched=true + }else{ + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); + } } - }else{ - BarCodeDoesNotExist+=1; + BarcodeIsInProduct+=1; } }) + if(BarcodeIsInProduct==0 && BarcodeSuccess){ + //addproduct to db and tabproduct + } } '; print ''; From 819a76e16a8dd33479a906cf674c4cadb1c111b5 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Fri, 27 Aug 2021 15:31:31 +0200 Subject: [PATCH 0089/1091] remove some deprecated html attributes https://developer.mozilla.org/en-US/docs/web/html/element/td#attr-align --- htdocs/bom/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/reception/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index c42da9bdb19..2737b425c9c 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -54,7 +54,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; - echo ''; - echo ''; + echo ''; echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; echo ' - - + + '; } @@ -622,6 +622,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index d7bd8bee9b4..781f2037dba 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -486,28 +486,36 @@ if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown if (preg_match('/k$/i', $maxphp)) { + $maxphp = preg_replace('/k$/i', '', $maxphp); $maxphp = $maxphp * 1; } if (preg_match('/m$/i', $maxphp)) { + $maxphp = preg_replace('/m$/i', '', $maxphp); $maxphp = $maxphp * 1024; } if (preg_match('/g$/i', $maxphp)) { + $maxphp = preg_replace('/g$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024; } if (preg_match('/t$/i', $maxphp)) { + $maxphp = preg_replace('/t$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024 * 1024; } $maxphp2 = @ini_get('post_max_size'); // In unknown if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = preg_replace('/k$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1; } if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = preg_replace('/m$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024; } if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = preg_replace('/g$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024; } if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = preg_replace('/t$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; } // Now $max and $maxphp and $maxphp2 are in Kb diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 7d261a73f7a..06d470b9b57 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -68,6 +68,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startyear = GETPOST('search_date_startyear', 'int'); @@ -87,6 +88,8 @@ $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $search_fk_projet=GETPOST("search_fk_projet", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$type = GETPOST("type", "int"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -498,7 +501,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; @@ -1298,6 +1301,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 3c987cd1cfa..5e85daf06ba 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('stocks', 'productbatch', 'other', 'users')); // Get parameters $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productlotlist'; // To manage different context of search @@ -64,7 +65,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $object = new Productlot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->productbatch->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('product_lotlist')); // Fetch optionals attributes and labels @@ -215,7 +216,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if ( !empty($extrafields->attributes[$object->table_element]['label']) && ($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($object->ismultientitymanaged == 1) { @@ -340,7 +341,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -424,9 +425,9 @@ foreach ($object->fields as $key => $val) { if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + print $object->showInputField($val, $key, !empty($search[$key])?$search[$key]:0, '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print ''; } @@ -477,7 +478,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -535,6 +536,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { From 63c7ab0302d8aeeb10a7544b04bef6b8c6b0a676 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 1 Dec 2021 14:29:24 +0700 Subject: [PATCH 0112/1091] Fix typo 'usercanreceived' -> 'usercanreceive' in 'card.php' --- htdocs/fourn/commande/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 92501d57d1d..616cda0376f 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1082,7 +1082,7 @@ if (empty($reshook)) { } // Set status of reception (complete, partial, ...) - if ($action == 'livraison' && $usercanreceived) { + if ($action == 'livraison' && $usercanreceive) { if ($cancel) { $action = ''; } else { @@ -2510,7 +2510,7 @@ if ($action == 'create') { } if (in_array($object->statut, array(3, 4, 5))) { - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceived) { + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceive) { print ''; } else { print ''; @@ -2528,7 +2528,7 @@ if ($action == 'create') { // Classify received (this does not record reception) if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { - if ($usercanreceived) { + if ($usercanreceive) { print ''; } } @@ -2647,7 +2647,7 @@ if ($action == 'create') { print '
    '; if ($action == 'classifyreception') { - if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { + if ($usercanreceive && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print ''."\n"; print '
    '; From 16ab6ce800a10887e31890d772a6356b34759f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 1 Dec 2021 10:26:24 +0100 Subject: [PATCH 0113/1091] No Category --- htdocs/takepos/index.php | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 8bd1c4dbca9..59205c638a6 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1186,13 +1186,22 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
    + } ?>" + global->TAKEPOS_NO_CATEGORY == 1) { + print ''; + } + ?>> -
    - global->TAKEPOS_NO_CATEGORY == 1) { + print '
    '; print ''; print ''; From 9190581d0a67c48579860c6264be11afd1dc35fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 1 Dec 2021 10:45:56 +0100 Subject: [PATCH 0115/1091] No category --- htdocs/takepos/index.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 59205c638a6..1b9799efec4 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1186,12 +1186,7 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) {
    global->TAKEPOS_NO_CATEGORY == 1) { - print ''; - } - ?>> + } ?>"> Date: Wed, 1 Dec 2021 09:53:28 +0000 Subject: [PATCH 0116/1091] Fixing style errors. --- htdocs/takepos/index.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 1b9799efec4..9ac9ca39c36 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1190,14 +1190,14 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) { global->TAKEPOS_NO_CATEGORY == 1) { - print '
    '; // # @@ -1776,7 +1776,7 @@ if ($action == 'create') { $text .= ' - '.$label; $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : 0, !empty($lines[$i]->date_end) ? $lines[$i]->date_end : 0); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
    '.dol_htmlentitiesbr($lines[$i]->description) : ''; } @@ -1925,7 +1925,7 @@ if ($action == 'create') { // Weight print '"; // Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines) > 0) { + if (!empty($extralabelslines) && is_array($extralabelslines) && count($extralabelslines) > 0) { $colspan = empty($conf->productbatch->enabled) ? 8 : 9; $line = new CommandeFournisseurDispatch($db); $line->id = $lines[$i]->id; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 8f20ed58065..865d0e95082 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -59,7 +59,7 @@ llxHeader(); print load_fiche_titre($langs->trans("StatisticsOfReceptions"), '', 'dollyrevert'); - +$dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); dol_mkdir($dir); $stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0)); @@ -78,6 +78,7 @@ if (empty($user->rights->societe->client->voir) || $user->socid) { $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); +$fileurlnb = ''; if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); From c0d00a859f1f9883c85abdeb1d22055ab798dee6 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 1 Dec 2021 16:59:30 +0100 Subject: [PATCH 0126/1091] use dol_escape_htmltag --- htdocs/core/class/html.formsetup.class.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 13dd3a8694c..1778b46995e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -103,17 +103,6 @@ class FormSetup } } - /** - * a quick method to sanitize html attributes - * @param string $var the string to sanitize - * @return string - */ - static public function sanitizeHtmlAttribute($var) - { - $var = preg_replace("/\r|\n/", "", $var); - return htmlspecialchars($var, ENT_QUOTES); - } - /** * Generate an attributes string form an input array * @param array $attributes an array of attributes keys and values, @@ -127,7 +116,7 @@ class FormSetup if (is_array($value) || is_object($value)) { continue; } - $Aattr[] = $attribute.'="'.self::sanitizeHtmlAttribute($value).'"'; + $Aattr[] = $attribute.'="'.dol_escape_htmltag($value).'"'; } } @@ -164,7 +153,7 @@ class FormSetup // generate hidden values from $this->formHiddenInputs if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) { foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) { - $out.= ''; + $out.= ''; } } } From bacf569e0b2974f32b401e7f4e91562d0f54bef8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 17:33:26 +0100 Subject: [PATCH 0127/1091] Fix phpcs --- htdocs/compta/facture/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c05e109d585..da77b75d9a6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1645,10 +1645,10 @@ if (empty($reshook)) { $discount->tva_tx = $lines[$i]->tva_tx; $discount->fk_user = $user->id; $discount->description = $desc; - $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); - $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); - $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); - $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); + $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); + $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); + $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); + $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); $discountid = $discount->create($user); if ($discountid > 0) { From 10e126eb694b1fdcfda10be1e5c39707381f71e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 10:43:44 +0100 Subject: [PATCH 0128/1091] Clean code on pdf templates --- htdocs/compta/facture/card.php | 21 ++++++++------- .../core/modules/bank/doc/pdf_ban.modules.php | 4 +-- .../bank/doc/pdf_sepamandate.modules.php | 4 +-- .../commande/doc/pdf_eratosthene.modules.php | 6 +++-- .../delivery/doc/pdf_storm.modules.php | 6 ++--- .../delivery/doc/pdf_typhon.modules.php | 6 ++--- .../expedition/doc/pdf_espadon.modules.php | 6 ++--- .../expedition/doc/pdf_merou.modules.php | 4 +-- .../expedition/doc/pdf_rouget.modules.php | 6 ++--- .../doc/pdf_standard.modules.php | 4 +-- .../facture/doc/pdf_sponge.modules.php | 27 ++++++++++--------- .../fichinter/doc/pdf_soleil.modules.php | 4 +-- .../movement/doc/pdf_standard.modules.php | 10 +++---- .../modules/mrp/doc/pdf_vinci.modules.php | 6 +++-- .../product/doc/pdf_standard.modules.php | 4 +-- .../project/doc/pdf_baleine.modules.php | 4 +-- .../project/doc/pdf_beluga.modules.php | 4 +-- .../project/doc/pdf_timespent.modules.php | 4 +-- .../modules/propale/doc/pdf_cyan.modules.php | 5 ++-- .../reception/doc/pdf_squille.modules.php | 6 ++--- .../stock/doc/pdf_standard.modules.php | 8 ++---- .../supplier_order/doc/pdf_cornas.modules.php | 6 +++-- .../doc/pdf_standard.modules.php | 4 +-- 23 files changed, 81 insertions(+), 78 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 66dadaa3beb..20f289ae141 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4283,7 +4283,7 @@ if ($action == 'create') { print '
    '; print '
    '; - print '
    '.$extrafields->showOutputField($key, $obj->{$key})."'.$extrafields->showOutputField($key, $obj->{$key}, '', 'product_fournisseur_price')."
    '; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).''; - $form->select_comptes($accountid, "accountid", 0, '', 2); // Affiche liste des comptes courant + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($accountid, "accountid", 0, '', 2, '', 0, '', 1); // Affiche liste des comptes courant print '
    '.$langs->trans("Project").''; - - $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); - + print img_picto('', 'bank_account', 'class="pictofixedwidth"'); + print $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); print '
    '.$objectlink->getNomUrl(1).''; + echo ''; $result = $product_static->fetch($objectlink->fk_product); if ($result < 0) { setEventMessage($product_static->error, 'errors'); @@ -62,7 +62,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $product_static->getNomUrl(1); } print ''.dol_print_date($objectlink->date_creation, 'day').''.dol_print_date($objectlink->date_creation, 'day').''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index aba881a63c6..2a6140aaeed 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -52,8 +52,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } echo ''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index bb6777c0639..c8ff1196c0f 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -56,8 +56,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> getNomUrl(1); ?>date_delivery, 'day'); ?>date_delivery, 'day'); ?> rights->reception->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 10768184b1b..f8ff67ae8ce 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1444,6 +1444,10 @@ table[summary="list_of_modules"] .fa-cog { min-width: 100px; } +.linkedcol-date { + text-align: center; +} + .img-skinthumb { width: 160px; height: 100px; From 6608f5f0d8f62ce290bf47a53b151c31699089f9 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 29 Nov 2021 15:09:18 +0100 Subject: [PATCH 0090/1091] update all script tags to be uniform. `language="javascript"` removed https://developer.mozilla.org/en-US/docs/web/html/element/script#attr-language --- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/index.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/adherents/admin/website.php | 2 +- .../canvas/actions_adherentcard_common.class.php | 2 +- htdocs/adherents/card.php | 4 ++-- htdocs/adherents/subscription.php | 2 +- htdocs/admin/accountant.php | 2 +- htdocs/admin/company.php | 2 +- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/mails.php | 2 +- htdocs/admin/mails_emailing.php | 2 +- htdocs/admin/mails_ticket.php | 2 +- htdocs/admin/menus/edit.php | 2 +- htdocs/admin/proxy.php | 2 +- htdocs/admin/system/perf.php | 2 +- htdocs/barcode/codeinit.php | 2 +- htdocs/barcode/printsheet.php | 2 +- htdocs/comm/action/card.php | 4 ++-- htdocs/comm/action/pertype.php | 2 +- htdocs/comm/action/peruser.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/compta/bank/card.php | 4 ++-- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/compta/facture/card.php | 10 +++++----- htdocs/compta/paiement.php | 2 +- htdocs/compta/paiement/cheque/card.php | 2 +- htdocs/compta/paiement_charge.php | 2 +- htdocs/compta/paiement_vat.php | 2 +- htdocs/compta/tva/card.php | 2 +- .../canvas/actions_contactcard_common.class.php | 2 +- htdocs/contact/card.php | 8 ++++---- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/core/boxes/box_graph_invoices_permonth.php | 2 +- .../boxes/box_graph_invoices_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php | 2 +- htdocs/core/boxes/box_graph_orders_permonth.php | 2 +- .../core/boxes/box_graph_orders_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_product_distribution.php | 2 +- htdocs/core/boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_task.php | 2 +- htdocs/core/class/doleditor.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formbarcode.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 ++-- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formsms.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 6 +++--- htdocs/core/class/openid.class.php | 2 +- htdocs/core/customreports.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/treeview.lib.php | 2 +- htdocs/core/photos_resize.php | 2 +- htdocs/cron/card.php | 2 +- htdocs/don/payment/payment.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expensereport/card.php | 4 ++-- htdocs/expensereport/payment/payment.php | 2 +- htdocs/fourn/facture/card.php | 6 +++--- htdocs/fourn/facture/paiement.php | 4 ++-- htdocs/imports/import.php | 2 +- htdocs/includes/nusoap/lib/class.wsdl.php | 2 +- htdocs/includes/nusoap/lib/nusoap.php | 2 +- htdocs/install/upgrade2.php | 2 +- htdocs/loan/schedule.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/paybox/lib/paybox.lib.php | 2 +- htdocs/product/inventory/inventory.php | 4 ++-- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/projet/card.php | 4 ++-- htdocs/public/payment/newpayment.php | 2 +- htdocs/public/test/test_arrays.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/salaries/card.php | 2 +- htdocs/salaries/paiement_salary.php | 2 +- htdocs/societe/canvas/actions_card_common.class.php | 4 ++-- .../canvas/company/actions_card_company.class.php | 2 +- htdocs/societe/card.php | 6 +++--- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 4 ++-- htdocs/takepos/phone.php | 2 +- htdocs/ticket/index.php | 2 +- htdocs/user/hierarchy.php | 2 +- htdocs/user/param_ihm.php | 2 +- htdocs/website/index.php | 8 ++++---- htdocs/workstation/workstation_card.php | 2 +- 93 files changed, 121 insertions(+), 121 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 9e393beeacd..8cef3a05cf4 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -142,7 +142,7 @@ $linkback = ''; print load_fiche_titre($langs->trans('ExportOptions'), $linkback, 'accountancy'); -print "\n".''; // This ajax service is called only when a directory $selecteddir is opened but not when closed. - //print ''; } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 65498ab6362..8179e134bcf 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -227,7 +227,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (!$mesg) { $stringtoshow = ''; - $stringtoshow .= ''; } else { // Default Header Redirect diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index b7f01de0aeb..1cede60f892 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -351,7 +351,7 @@ print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '' if (empty($conf->use_javascript_ajax)) { print ''; } else { - print ' -'; + $sectionwithinvoicelink .= ''; } } @@ -905,7 +905,7 @@ if ($action == "valid" || $action == "history" || $action == 'creditnote') { $form = new Form($db); ?> -'; From f39dd30a7f49b6cd9a542eb291e3c742090caf40 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 15:38:48 +0100 Subject: [PATCH 0106/1091] fix precommit --- htdocs/product/inventory/ajax/searchfrombarcode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 32cba249896..947a9904bf0 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -52,7 +52,7 @@ $fk_inventory = GETPOST("fk_inventory", "int"); $fk_product = GETPOST("fk_product", "int"); $reelqty = GETPOST("reelqty", "int"); $qtyview = GETPOST("Qty", "int"); -$batch = GETPOST("batch","int"); +$batch = GETPOST("batch", "int"); $warehousefound = 0; $warehouseid = 0; @@ -71,7 +71,7 @@ if ($action == "existbarcode" && !empty($barcode)) { for ($i=0; $i < $nbline; $i++) { $object = $db->fetch_object($result); if ($barcode == $object->barcode) { - $warehouse->fetch(0,$product["Warehouse"]); + $warehouse->fetch(0, $product["Warehouse"]); if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) { $warehousefound++; $warehouseid = $object->fk_entrepot; @@ -112,10 +112,10 @@ if ($action == "addnewlineproduct") { $result = $inventoryline->create($user); if ($result > 0) { $response = array('status'=>'success','message'=>'Success on creating line'); - }else { + } else { $response = array('status'=>'error','errorcode'=>'ErrorCreation','message'=>"Error on line creation"); } - }else { + } else { $response = array('status'=>'error','errorcode'=>'NoIdForInventory','message'=>"No id for inventory"); } } From e43b95f05a191a1a541bf6918c862b66541fa534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 30 Nov 2021 15:41:46 +0100 Subject: [PATCH 0107/1091] Show reference product --- htdocs/takepos/index.php | 20 +++++++++++++++++--- htdocs/takepos/invoice.php | 6 +++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 8bd1c4dbca9..ad123ccd5e7 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -335,7 +335,11 @@ function LoadProducts(position, issubcat) { var titlestring = ; global->TAKEPOS_HIDE_PRODUCT_IMAGES) { echo '$("#prodivdesc"+ishow).show();'; - echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + if ($conf->global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { + echo '$("#prodesc"+ishow).html(data[parseInt(idata)][\'ref\'].bold() + \' - \' + data[parseInt(idata)][\'label\']);'; + } else { + echo '$("#prodesc"+ishow).text(data[parseInt(idata)][\'label\']);'; + } echo '$("#proimg"+ishow).attr("title", titlestring);'; echo '$("#proimg"+ishow).attr("src", "genimg/index.php?query=pro&id="+data[idata][\'id\']);'; } else { @@ -401,7 +405,12 @@ function MoreProducts(moreorless) { else if ((data[idata]['status']) == "1") { //Only show products with status=1 (for sell) $("#prodivdesc"+ishow).show(); - $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> + $("#prodesc"+ishow).html(data[parseInt(idata)]['ref'].bold() + ' - ' + data[parseInt(idata)]['label']); + + $("#prodesc"+ishow).text(data[parseInt(idata)]['label']); + $("#probutton"+ishow).text(data[parseInt(idata)]['label']); $("#probutton"+ishow).show(); if (data[parseInt(idata)]['price_formated']) { @@ -579,7 +588,12 @@ function Search2(keyCodeForEnter) { $titlestring .= " + ' - ".dol_escape_js($langs->trans("Barcode").': ')."' + data[i]['barcode']"; ?> var titlestring = ; - $("#prodesc" + i).text(data[i]['label']); + global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> + $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); + + $("#prodesc" + i).text(data[i]['label']); + $("#prodivdesc" + i).show(); $("#probutton" + i).text(data[i]['label']); $("#probutton" + i).show(); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2a951a505ae..01599cae4b6 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1447,7 +1447,11 @@ if ($placeid > 0) { $tooltiptext .= $line->desc; } } - $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); + if ($conf->global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { + $htmlforlines .= $form->textwithpicto($line->product_label ? '' . $line->product_ref . ' - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); + } else { + $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); + } } else { if ($line->product_label) { $htmlforlines .= $line->product_label; From 5d7f8d3831cdfc17bb9cbb80fa3b3ff2e9f1a79a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Nov 2021 15:54:28 +0100 Subject: [PATCH 0108/1091] Fix fatal error --- htdocs/core/boxes/box_funnel_of_prospection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 28c3b22788d..dd5bce78301 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -237,7 +237,7 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph->setBorderColor(array_values($bordercolorseries)); $dolgraph->setShowLegend(2); if (!empty($conf->dol_optimize_smallscreen)) { - $px1->SetWidth(320); + $dolgraph->SetWidth(320); } $dolgraph->setShowPercent(1); $dolgraph->setMirrorGraphValues(true); From 7c3b2f1e9bed3f2b45438810a89d2bba6c266dda Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 30 Nov 2021 15:07:59 +0000 Subject: [PATCH 0109/1091] Fixing style errors. --- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index ad123ccd5e7..bf5428f81d0 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -589,7 +589,7 @@ function Search2(keyCodeForEnter) { ?> var titlestring = ; global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> + if ($conf->global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { ?> $("#prodesc" + i).html(data[i]['ref'].bold() + ' - ' + data[i]['label']); $("#prodesc" + i).text(data[i]['label']); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 01599cae4b6..2f857e7a3ce 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -1447,9 +1447,9 @@ if ($placeid > 0) { $tooltiptext .= $line->desc; } } - if ($conf->global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { + if ($conf->global->TAKEPOS_SHOW_PRODUCT_REFERENCE == 1) { $htmlforlines .= $form->textwithpicto($line->product_label ? '' . $line->product_ref . ' - ' . $line->product_label : dolGetFirstLineOfText($line->desc, 1), $tooltiptext); - } else { + } else { $htmlforlines .= $form->textwithpicto($line->product_label ? $line->product_label : ($line->product_ref ? $line->product_ref : dolGetFirstLineOfText($line->desc, 1)), $tooltiptext); } } else { From db06de0ac2e1e6c499184789ff86433c3647c351 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 30 Nov 2021 16:27:50 +0100 Subject: [PATCH 0110/1091] add printFieldListHaving hook --- htdocs/comm/propal/list.php | 5 +++++ htdocs/commande/list.php | 5 +++++ htdocs/expedition/list.php | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 4f59682abb8..3e467539c88 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -696,6 +696,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $sql .= ', p.ref DESC'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9c278359acc..b534d915914 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -628,6 +628,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 6a1b26fa19f..79ed3b52215 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -373,6 +373,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; From 1c4a7a00cbcdc1bd8db5022f4321efc3124ef96d Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 16:35:46 +0100 Subject: [PATCH 0111/1091] fix php8.0 warning --- htdocs/expedition/card.php | 1 + htdocs/expedition/index.php | 1 + htdocs/expedition/list.php | 2 +- htdocs/product/stats/card.php | 2 +- htdocs/product/stock/list.php | 9 ++++++--- htdocs/product/stock/massstockmove.php | 8 ++++++++ htdocs/product/stock/movement_list.php | 8 +++++++- htdocs/product/stock/productlot_list.php | 16 ++++++++++------ 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 64a080e8f6e..f077d9360de 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -81,6 +81,7 @@ if (empty($origin_id)) { } $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; +$facid = GETPOST('facid', 'int'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 49777518509..8a992e0c7ec 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $hookmanager = new HookManager($db); +$socid = GETPOST('socid', 'int'); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('sendingindex')); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ac5704511ef..f569501d440 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -253,7 +253,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && sis_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d2d9f289fd1..463297f043a 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -276,7 +276,7 @@ if ($result || !($id > 0)) { print '
    '; // Generation of graphs - $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); + $dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); if ($object->id > 0) { // We are on statistics for a dedicated product if (!file_exists($dir.'/'.$object->id)) { if (dol_mkdir($dir.'/'.$object->id) < 0) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index bfd96716bb7..52c18c9cc97 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -78,7 +78,7 @@ if (!$sortorder) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('stocklist')); // Fetch optionals attributes and labels @@ -228,7 +228,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid"); } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot"; @@ -473,7 +473,7 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print '
    '.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; -print ''; +print ''; print ' 
    '; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->weight * $lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); } else { print ' '; @@ -1934,7 +1934,7 @@ if ($action == 'create') { // Volume print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->volume * $lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); } else { print ' '; @@ -1965,7 +1965,7 @@ if ($action == 'create') { print "
    '; + print '
    '; // Type print ''; @@ -478,7 +478,7 @@ if ($object->id > 0) { print $langs->trans("CustomerAbsoluteDiscountShort"); print '
    '.$langs->trans('Type').''; @@ -4364,7 +4364,7 @@ if ($action == 'create') { // Date invoice print '
    '; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - */ + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + */ } else { $default = (empty($colorbacklinepairchecked) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($colorbacklinepairchecked))); @@ -905,6 +906,52 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; } + // Btn action + if ($foruserprofile) { + /* + print ''; + print ''; + print ''; + print ''; + print '';*/ + } else { + $default = (empty($butactionbg) ? $langs->trans("Unknown") : colorArrayToHex(colorStringToArray($butactionbg))); + + print ''; + print ''; + print ''; + print ''; + } + // Use MAIN_OPTIMIZEFORTEXTBROWSER if ($foruserprofile && !empty($fuser->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) { //$default=yn($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0d626c3b323..70f454aded4 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1920,6 +1920,7 @@ ConfFileMustContainCustom=Installing or building an external module from applica HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (use 'ffffff' for no highlight) HighlightLinesChecked=Highlight color of the line when it is checked (use 'ffffff' for no highlight) +BtnActionColor=Color of the action button TextTitleColor=Text color of Page title LinkColor=Color of links PressF5AfterChangingThis=Press CTRL+F5 on keyboard or clear your browser cache after changing this value to have it effective diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index af8f26b9a24..9c570a79a5f 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -9,13 +9,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { --btncolorbg: #fbfbfb; --btncolorborderhover: none; --btncolorborder: #FFF; - /* --butactionbg:rgba(150, 110, 162, 0.95); */ - --butactionbg:rgb(118, 145, 225); - --butactionbg:rgba(150, 110, 162, 0.95); --butactiondeletebg: rgb(234,228,225); - /* tertiary color */ - /* --butactionbg:rgb(218, 235, 225); */ - /* --butactionbg:rgb(228, 218, 235); */ } global->THEME_DARKMODEENABLED)) { --btncolorbg: rgb(26,27,27); --btncolorborderhover: #ffffff; --btncolorborder: #2b2c2e; - --butactionbg: rgb(173,140,79); --butactiondeletebg: rgb(252,84,91); }\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index da23e60498c..ec40936601a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -211,7 +211,7 @@ input, select { margin-top: 1px; } #mainbody input.button:not(.buttongen):not(.bordertransp), #mainbody a.button:not(.buttongen):not(.bordertransp) { - background: var(--butactionbg); + background: rgb(); color: #FFF !important; border-radius: 3px; border-collapse: collapse; @@ -358,7 +358,7 @@ a.butStatus { padding-right: 5px; background-color: transparent; color: var(--colortext) !important; - border: 2px solid var( --butactionbg) !important; + border: 2px solid rgb() !important; margin: 0 0.45em !important; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index de089ecba54..edeab565f9d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -150,7 +151,9 @@ if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) { if (!isset($conf->global->THEME_ELDY_TEXTLINK)) { $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; } - +if (!isset($conf->global->THEME_ELDY_BTNACTION)) { + $conf->global->THEME_ELDY_BTNACTION = $butactionbg; +} // Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) { $conf->global->THEME_ELDY_BACKTABCARD1 = '255,255,255'; // card @@ -178,6 +181,7 @@ $colortexttitle = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (emp $colortexttitlelink = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXTTITLELINK) ? $colortexttitlelink : $conf->global->THEME_ELDY_TEXTTITLELINK) : (empty($user->conf->THEME_ELDY_TEXTTITLELINK) ? $colortexttitlelink : $user->conf->THEME_ELDY_TEXTTITLELINK); $colortext = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXT) ? $colortext : $conf->global->THEME_ELDY_TEXT) : (empty($user->conf->THEME_ELDY_TEXT) ? $colortext : $user->conf->THEME_ELDY_TEXT); $colortextlink = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXTLINK) ? $colortextlink : $conf->global->THEME_ELDY_TEXTLINK) : (empty($user->conf->THEME_ELDY_TEXTLINK) ? $colortextlink : $user->conf->THEME_ELDY_TEXTLINK); +$butactionbg = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_BTNACTION) ? $butactionbg : $conf->global->THEME_ELDY_BTNACTION) : (empty($user->conf->THEME_ELDY_BTNACTION) ? $butactionbg : $user->conf->THEME_ELDY_BTNACTION); $fontsize = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_FONT_SIZE1) ? $fontsize : $conf->global->THEME_ELDY_FONT_SIZE1) : (empty($user->conf->THEME_ELDY_FONT_SIZE1) ? $fontsize : $user->conf->THEME_ELDY_FONT_SIZE1); $fontsizesmaller = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_FONT_SIZE2) ? $fontsize : $conf->global->THEME_ELDY_FONT_SIZE2) : (empty($user->conf->THEME_ELDY_FONT_SIZE2) ? $fontsize : $user->conf->THEME_ELDY_FONT_SIZE2); diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 00d5456cab5..41d162e6cbc 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -5,6 +5,7 @@ * Copyright (C) 2011 Philippe Grand * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -73,6 +74,7 @@ $fontsizesmaller = '0.75em'; $topMenuFontSize = '1.1em'; $toolTipBgColor = 'rgba(255, 255, 255, 0.96)'; $toolTipFontColor = '#333'; +$butactionbg = '150, 110, 162, 0.95'; // text color $textSuccess = '#28a745'; diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php index 0269bba74f2..5ef2dbe9e8d 100644 --- a/htdocs/theme/md/btn.inc.php +++ b/htdocs/theme/md/btn.inc.php @@ -10,10 +10,6 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { --btncolorborderhover: none; --btncolorborder: #FFF; --butactiondeletebg: rgb(234,228,225); - /* tertiary color */ - /* --butactionbg:rgb(218, 235, 225); */ - /* --butactionbg:rgb(228, 218, 235); */ - --butactionbg:rgb(118, 145, 225); } global->THEME_DARKMODEENABLED)) { --btncolorbg: rgb(26,27,27); --btncolorborderhover: #ffffff; --btncolorborder: #2b2c2e; - --butactionbg:rgb(173,140,79); --butactiondeletebg: rgb(252,84,91); }\n"; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8873149a9be..9c3b2bb0202 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6,6 +6,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -148,6 +149,9 @@ if (!isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) { if (!isset($conf->global->THEME_ELDY_TEXTLINK)) { $conf->global->THEME_ELDY_TEXTLINK = $colortextlink; } +if (!isset($conf->global->THEME_ELDY_BTNACTION)) { + $conf->global->THEME_ELDY_BTNACTION = $butactionbg; +} // Case of option editable only if option THEME_ELDY_ENABLE_PERSONALIZED is on if (empty($conf->global->THEME_ELDY_ENABLE_PERSONALIZED)) { @@ -177,6 +181,7 @@ $colortexttitle = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (emp $colortexttitlelink = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXTTITLELINK) ? $colortexttitlelink : $conf->global->THEME_ELDY_TEXTTITLELINK) : (empty($user->conf->THEME_ELDY_TEXTTITLELINK) ? $colortexttitlelink : $user->conf->THEME_ELDY_TEXTTITLELINK); $colortext = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXT) ? $colortext : $conf->global->THEME_ELDY_TEXT) : (empty($user->conf->THEME_ELDY_TEXT) ? $colortext : $user->conf->THEME_ELDY_TEXT); $colortextlink = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TEXTLINK) ? $colortext : $conf->global->THEME_ELDY_TEXTLINK) : (empty($user->conf->THEME_ELDY_TEXTLINK) ? $colortextlink : $user->conf->THEME_ELDY_TEXTLINK); +$butactionbg = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_BTNACTION) ? $butactionbg : $conf->global->THEME_ELDY_BTNACTION) : (empty($user->conf->THEME_ELDY_BTNACTION) ? $butactionbg : $user->conf->THEME_ELDY_BTNACTION); $fontsize = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_FONT_SIZE1) ? $fontsize : $conf->global->THEME_ELDY_FONT_SIZE1) : (empty($user->conf->THEME_ELDY_FONT_SIZE1) ? $fontsize : $user->conf->THEME_ELDY_FONT_SIZE1); $fontsizesmaller = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_FONT_SIZE2) ? $fontsize : $conf->global->THEME_ELDY_FONT_SIZE2) : (empty($user->conf->THEME_ELDY_FONT_SIZE2) ? $fontsize : $user->conf->THEME_ELDY_FONT_SIZE2); @@ -439,7 +444,7 @@ input, select { margin-top:1px; } #mainbody input.button:not(.buttongen):not(.bordertransp), #mainbody a.button:not(.buttongen):not(.bordertransp) { - background: var(--butactionbg); + background: rgb(); color: #FFF !important; border-radius: 3px; border-collapse: collapse; @@ -564,7 +569,7 @@ a.butStatus { padding-right: 5px; background-color: transparent; color: var(--colortext) !important; - border: 2px solid var( --butactionbg); + border: 2px solid rgb(); margin: 0 0.45em !important; } diff --git a/htdocs/theme/md/theme_vars.inc.php b/htdocs/theme/md/theme_vars.inc.php index 216a5043111..d8441964f65 100644 --- a/htdocs/theme/md/theme_vars.inc.php +++ b/htdocs/theme/md/theme_vars.inc.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2021 Anthony Berton * * 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 @@ -68,6 +69,7 @@ $fontsizesmaller = '11'; $topMenuFontSize = '1.1em'; $toolTipBgColor = 'rgba(255, 255, 255, 0.96)'; $toolTipFontColor = '#333'; +$butactionbg = '150, 110, 162, 0.95'; // text color $textSuccess = '#28a745'; From 3b65d46b53a408ffe05ac8887099512b88d4169a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Dec 2021 11:19:41 +0100 Subject: [PATCH 0278/1091] FIX avoid blank page with error --- htdocs/core/lib/pdf.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 735e6892fcd..187687a0fe2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -707,9 +707,12 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) // Add a background image on document only if good setup of const if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF != '-1')) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; + if (file_exists($filepath)) { + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + } } } From 9a6f78fc15791235c36763e0426b67e7f02c0045 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 14 Dec 2021 11:45:31 +0100 Subject: [PATCH 0279/1091] erreur btn action --- htdocs/theme/eldy/btn.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index 9c570a79a5f..cf2f1ead60e 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -64,7 +64,7 @@ span.butAction, span.butActionDelete { font-size: 0.9em; } .butAction { - background: var(--butactionbg); + background: rgb(); color: #FFF !important; /* background: rgb(230, 232, 239); */ } From 1d8cf297de0d115a07c1b50f77c4e7594f912e96 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 14 Dec 2021 12:10:09 +0100 Subject: [PATCH 0280/1091] Update html.formsetup.class.php --- htdocs/core/class/html.formsetup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1778b46995e..a3f8a58d88e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -45,7 +45,7 @@ class FormSetup protected $maxItemRank; /** - * this is an html string display before output form + * this is an html string display before output form * @var string */ public $htmlBeforeOutputForm = ''; From 66c486c8788b6c65e496542461db39343d0056ad Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 14 Dec 2021 11:12:54 +0000 Subject: [PATCH 0281/1091] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a3f8a58d88e..1778b46995e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -45,7 +45,7 @@ class FormSetup protected $maxItemRank; /** - * this is an html string display before output form + * this is an html string display before output form * @var string */ public $htmlBeforeOutputForm = ''; From b971efb0626915b7ba10804c59e1fe3debee2ebd Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 14 Dec 2021 12:25:43 +0100 Subject: [PATCH 0282/1091] FIX : marginInfos array should be used by reference to allow to update it with a hook without draw again margin table --- htdocs/core/class/html.formmargin.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index d578f19ff2f..f39680d1fe3 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -213,7 +213,7 @@ class FormMargin $marginInfo = $this->getMarginInfosArray($object, $force_price); - $parameters=array('marginInfo'=>$marginInfo); + $parameters=array('marginInfo'=>&$marginInfo); $reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); From c3ac93b9175fee880cc92afececb929b2529b4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Tue, 14 Dec 2021 16:03:12 +0100 Subject: [PATCH 0283/1091] Add Hooks for takepos ajax search --- htdocs/takepos/ajax/ajax.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 6cfbf4b3c1a..58c1906cd42 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -53,6 +53,8 @@ if (empty($user->rights->takepos->run)) { accessforbidden(); } +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks +$hookmanager->initHooks(array('takeposproductsearch')); /* * View @@ -109,13 +111,30 @@ if ($action == 'getProducts') { } } - $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price FROM '.MAIN_DB_PREFIX.'product as p'; + $sql = 'SELECT rowid, ref, label, tosell, tobuy, barcode, price' ; + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + + $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; + + // Add tables from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListTables', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $sql .= ' WHERE entity IN ('.getEntity('product').')'; if ($filteroncategids) { $sql .= ' AND EXISTS (SELECT cp.fk_product FROM '.MAIN_DB_PREFIX.'categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$db->sanitize($filteroncategids).'))'; } $sql .= ' AND tosell = 1'; $sql .= natural_search(array('ref', 'label', 'barcode'), $term); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook + $sql .= $hookmanager->resPrint; + $resql = $db->query($sql); if ($resql) { $rows = array(); From aeb16d69d14604c30f4bdb67536f17825754a0ba Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Tue, 14 Dec 2021 17:15:18 +0100 Subject: [PATCH 0284/1091] FIX: When creating an invoice, extrafields with visibility = 4 are displayed When creating an invoice, extrafields with visibility = 4 are displayed --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 99bf843f50b..f6d217b2d83 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3652,7 +3652,7 @@ if ($action == 'create') { } }; - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'create', $parameters); } // Template to use by default From f9e426600798da29516336f7904dcb2a28c96865 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Dec 2021 19:37:44 +0100 Subject: [PATCH 0285/1091] FIX debug inventory feature (missing link to mvt, bad label of mvt) --- htdocs/core/class/commonobject.class.php | 9 ++- .../inventory/class/inventory.class.php | 2 +- htdocs/product/inventory/inventory.php | 76 ++++++++++++++++--- .../stock/class/mouvementstock.class.php | 17 +++-- 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2471d122af..a83cfae3000 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4174,9 +4174,16 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql .= " SET ".$fieldstatus." = ".((int) $status); // If status = 1 = validated, update also fk_user_valid - if ($status == 1 && $elementTable == 'expensereport') { + // TODO Replace the test on $elementTable by doing a test on existence of the field in $this->fields + if ($status == 1 && in_array($elementTable, array('expensereport', 'inventory'))) { $sql .= ", fk_user_valid = ".((int) $user->id); } + if ($status == 1 && in_array($elementTable, array('expensereport'))) { + $sql .= ", date_valid = '".$this->db->idate(dol_now())."'"; + } + if ($status == 1 && in_array($elementTable, array('inventory'))) { + $sql .= ", date_validation = '".$this->db->idate(dol_now())."'"; + } $sql .= " WHERE rowid=".((int) $elementId); dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 092d98ea854..7a87f344e68 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -626,7 +626,7 @@ class Inventory extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_RECORDED) { - $statusType = 'status5'; + $statusType = 'status6'; } return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index b6fa70ad551..c467b4367df 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -121,6 +121,8 @@ if (empty($reshook)) { $stockmovment = new MouvementStock($db); $stockmovment->setOrigin($object->element, $object->id); + $cacheOfProducts = array(); + $db->begin(); $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; @@ -139,8 +141,30 @@ if (empty($reshook)) { $qty_stock = $line->qty_stock; $qty_view = $line->qty_view; // The quantity viewed by inventorier, the qty we target + + // Load real stock we have now. + if (isset($cacheOfProducts[$line->fk_product])) { + $product_static = $cacheOfProducts[$line->fk_product]; + } else { + $product_static = new Product($db); + $result = $product_static->fetch($line->fk_product, '', '', '', 1, 1, 1); + + //$option = 'nobatch'; + $option .= ',novirtual'; + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. + + $cacheOfProducts[$product_static->id] = $product_static; + } + + // Get the real quantity in stock now, but before the stock move for inventory. + $realqtynow = $product_static->stock_warehouse[$line->fk_warehouse]->real; + if ($conf->productbatch->enabled && $product_static->hasbatch()) { + $realqtynow = $product_static->stock_warehouse[$line->fk_warehouse]->detail_batch[$line->batch]->qty; + } + + if (!is_null($qty_view)) { - $stock_movement_qty = price2num($qty_view - $qty_stock, 'MS'); + $stock_movement_qty = price2num($qty_view - $realqtynow, 'MS'); if ($stock_movement_qty != 0) { if ($stock_movement_qty < 0) { $movement_type = 1; @@ -152,15 +176,20 @@ if (empty($reshook)) { //$inventorycode = 'INV'.$object->id; $inventorycode = 'INV-'.$object->ref; - $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->id), $inventorycode, $datemovement, '', '', $line->batch); + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); if ($idstockmove < 0) { $error++; setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); break; } - // Update line with id of stock movement - $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet SET fk_movement = ".((int) $idstockmove)." WHERE rowid = ".((int) $line->rowid); + // Update line with id of stock movement (and the start quantity if it has changed this last recording) + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; + $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); + if ($qty_stock != $realqtynow) { + $sqlupdate .= ", qty_stock = ".((float) $realqtynow); + } + $sqlupdate .= " WHERE rowid = ".((int) $line->rowid); $resqlupdate = $db->query($sqlupdate); if (! $resqlupdate) { $error++; @@ -215,7 +244,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv("RealQty")), null, 'errors'); } if ($result > 0) { - $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value we want + $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field $inventoryline->qty_view = $qtytoupdate; // The new value we want $resultupdate = $inventoryline->update($user); } @@ -236,6 +265,18 @@ if (empty($reshook)) { } } + // Update line with id of stock movement (and the start quantity if it has changed this last recording) + if (! $error) { + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventory"; + $sqlupdate .= " SET fk_user_modif = ".((int) $user->id); + $sqlupdate .= " WHERE rowid = ".((int) $object->id); + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } + } + if (!$error) { $db->commit(); } else { @@ -766,9 +807,14 @@ if ($object->id > 0) { print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print ''; if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - // Actions + // Actions or link to stock movement print ''; + } else { + // Actions or link to stock movement + print ''; } print ''; @@ -799,7 +845,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -826,6 +872,7 @@ if ($object->id > 0) { $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static; } + // Load real stock we have now if (isset($cacheOfProducts[$obj->fk_product])) { $product_static = $cacheOfProducts[$obj->fk_product]; } else { @@ -834,7 +881,7 @@ if ($object->id > 0) { //$option = 'nobatch'; $option .= ',novirtual'; - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. $cacheOfProducts[$product_static->id] = $product_static; } @@ -855,14 +902,14 @@ if ($object->id > 0) { // Expected quantity = Quantity in stock when we start inventory print ''; } else { - print ''; + print ''; } print ''; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index da06076fe97..a6bc6c2ec26 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -1071,7 +1071,7 @@ class MouvementStock extends CommonObject * Use this->id,this->lastname, this->firstname * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to + * @param string $option On what the link point to ('' = Tab of stock movement of warehouse, 'movements' = list of movements) * @param integer $notooltip 1=Disable tooltip * @param int $maxlen Max length of visible user name * @param string $morecss Add more css on link @@ -1082,16 +1082,21 @@ class MouvementStock extends CommonObject global $langs, $conf, $db; $result = ''; - $companylink = ''; - $label = ''.$langs->trans("Movement").' '.$this->id.''; + $label = img_picto('', 'stock', 'class="pictofixedwidth"').''.$langs->trans("Movement").' '.$this->id.''; $label .= '
    '; $label .= ''.$langs->trans('Label').': '.$this->label; - $label .= '
    '.$langs->trans('Qty').': '.$this->qty; + $label .= '
    '.$langs->trans('Qty').': '.($this->qty > 0 ? '+' : '').$this->qty; $label .= '
    '; - $link = 'id; + } else { + $url = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$this->warehouse_id.'&msid='.$this->id; + } + + $link = ' Date: Tue, 14 Dec 2021 22:45:33 +0100 Subject: [PATCH 0286/1091] check for mbstring extension at install --- htdocs/install/check.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 14448841217..d3c5cba1290 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -149,11 +149,19 @@ if (!function_exists("easter_date")) { if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
    \n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
    \n"; } +// Check for mbstring extension +if (!extension_loaded("mbstring")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupportMbstring")."
    \n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "mbstring")."
    \n"; +} // Check if intl methods are supported if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { From a02cb4c9b11ce24058eecfac5d3fac6675fa7fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Dec 2021 22:52:39 +0100 Subject: [PATCH 0287/1091] Update install.lang --- htdocs/langs/en_US/install.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index c1ffee936d7..989f6aa9793 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -21,6 +21,7 @@ ErrorPHPDoesNotSupportCurl=Your PHP installation does not support Curl. ErrorPHPDoesNotSupportCalendar=Your PHP installation does not support php calendar extensions. ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr cannot work correctly. Resolve this before installing Dolibarr. ErrorPHPDoesNotSupportIntl=Your PHP installation does not support Intl functions. +ErrorPHPDoesNotSupportMbstring=Your PHP installation does not support mbstring functions. ErrorPHPDoesNotSupportxDebug=Your PHP installation does not support extend debug functions. ErrorPHPDoesNotSupport=Your PHP installation does not support %s functions. ErrorDirDoesNotExists=Directory %s does not exist. From 8e3b617671bdcde070936e6c0103eebbaa6ec0f6 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 15 Dec 2021 16:21:08 +0700 Subject: [PATCH 0288/1091] Fix search_user in stock/movement_list.php --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index a1d143335cd..e1418bed4c4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -548,7 +548,7 @@ if ($search_warehouse != '' && $search_warehouse != '-1') { $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); From fca26827ecd7fa1a9c576a8a9275658f90621f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 15 Dec 2021 10:47:30 +0100 Subject: [PATCH 0289/1091] Add constant TAKEPOS_CHANGE_PRICE_HT --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2a951a505ae..61f955636f5 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -680,6 +680,8 @@ if ($action == "updateprice") { } else { if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif ($conf->global->TAKEPOS_CHANGE_PRICE_HT == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } From 7c1879a11a46f3239a2cbb91f69abcf5123f7c79 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 15 Dec 2021 16:52:57 +0700 Subject: [PATCH 0290/1091] Fix author searching include first and last name --- htdocs/fourn/facture/list.php | 2 +- htdocs/mrp/mo_movements.php | 2 +- htdocs/product/stock/movement_card.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 8b83048d8d3..e77ae1fea28 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -564,7 +564,7 @@ if ($search_multicurrency_montant_ttc != '') { $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); } if ($search_login) { - $sql .= natural_search('u.login', $search_login); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); } if ($search_status != '' && $search_status >= 0) { $sql .= " AND f.fk_statut = ".((int) $search_status); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 3b1ac109e5d..f7c25a1ec83 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -468,7 +468,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 25dac24b592..f9c0778eea4 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -489,7 +489,7 @@ if ($search_warehouse != '' && $search_warehouse != '-1') { $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a64ac94b169..c881203b2d8 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -364,7 +364,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_login) { - $sql .= natural_search('u.login', $search_login); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); } if ($search_montant_ht) { $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); From 9f7e8fa3ed17006d8aeaea6ff696b8bfbe043024 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 15 Dec 2021 15:19:12 +0100 Subject: [PATCH 0291/1091] NEW : Creation of the llx_facture_fourn_rec.sql table for recurring supplier invoices --- .../mysql/tables/llx_facture_fourn_rec.sql | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_facture_fourn_rec.sql diff --git a/htdocs/install/mysql/tables/llx_facture_fourn_rec.sql b/htdocs/install/mysql/tables/llx_facture_fourn_rec.sql new file mode 100644 index 00000000000..edaa49e0ea1 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_facture_fourn_rec.sql @@ -0,0 +1,77 @@ +-- =========================================================================== +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =========================================================================== + +create table llx_facture_fourn_rec +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + titre varchar(200) NOT NULL, + ref_supplier varchar(180) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, + + datec datetime, -- date de creation + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- last modification date + + suspended integer DEFAULT 0, -- 1=suspended + + libelle varchar(255), + amount double(24, 8) DEFAULT 0 NOT NULL, + remise real DEFAULT 0, + + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + localtax1 double(24,8) DEFAULT 0, + localtax2 double(24,8) DEFAULT 0, + total_ht double(24,8) DEFAULT 0, + total_tva double(24,8) DEFAULT 0, + total_ttc double(24,8) DEFAULT 0, + + fk_user_author integer, -- user creating + fk_user_modif integer, -- user making last change + + fk_projet integer, -- projet auquel est associe la facture + + fk_account integer, -- bank account + fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...) + fk_mode_reglement integer, -- mode de reglement (CHQ, VIR, ...) + date_lim_reglement date, -- date limite de reglement + + note_private text, + note_public text, + modelpdf varchar(255), + + fk_multicurrency integer, + multicurrency_code varchar(3), + multicurrency_tx double(24,8) DEFAULT 1, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0, + + + -- Fields linked to the recurring behavior + + usenewprice integer DEFAULT 0, -- update invoice with current price of product instead of recorded price + frequency integer, -- frequency (for example: 3 for every 3 month) + unit_frequency varchar(2) DEFAULT 'm', -- 'm' for month (date_when must be a day <= 28), 'y' for year, ... + + date_when datetime DEFAULT NULL, -- date for next gen (when an invoice is generated, this field must be updated with next date) + date_last_gen datetime DEFAULT NULL, -- date for last gen (date with last successfull generation of invoice) + nb_gen_done integer DEFAULT NULL, -- nb of generation done (when an invoice is generated, this field must incremented) + nb_gen_max integer DEFAULT NULL, -- maximum number of generation + auto_validate integer DEFAULT 0, -- 0 to create in draft, 1 to create and validate the new invoice + generate_pdf integer DEFAULT 1 -- 0 disable pdf, 1 to generate pdf + +)ENGINE=innodb; From 53be92fac3b146c62114d53b2b53449692e0591a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Dec 2021 17:32:15 +0100 Subject: [PATCH 0292/1091] FIX #19626 --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 735e6892fcd..b7ef5925748 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -35,6 +35,8 @@ * \ingroup core */ +include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; + /** * Return array head with list of tabs to view object informations. From f589121199a6cb60726d3e4b7fa7bfd10e4f683a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 01:17:22 +0100 Subject: [PATCH 0293/1091] Trans --- htdocs/langs/en_US/main.lang | 2 +- htdocs/theme/eldy/global.inc.php | 21 ++++++++++++++++----- htdocs/theme/md/style.css.php | 23 +++++++++++++++++------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 027b7c428ec..06acd399d25 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1159,6 +1159,6 @@ Properties=Properties hasBeenValidated=%s has been validated ClientTZ=Client Time Zone (user) NotClosedYet=Not yet closed -ClearSignature=Signature reset +ClearSignature=Reset signature CanceledHidden=Canceled hidden CanceledShown=Canceled shown diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index da23e60498c..e413623fb0c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2883,11 +2883,18 @@ input.vmenusearchselectcombo[type=text] { .searchform input { font-size: 16px; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { white-space: nowrap; font-family: ; text-align: ; } +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-family: ; text-align: ; +} a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vmenu:link, span.vmenu:visited, span.vmenu:hover, span.vmenu:active { font-weight: bold; } /* bold = 600, 500 is ko with Edge on 1200x960 */ -span.vmenudisabled, font.vmenudisabled { font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } /* bold = 600, 500 is ko with Edge on 1200x960 */ -a.vmenu:link, a.vmenu:visited { color: var(--colortextbackvmenu); } +span.vmenudisabled, font.vmenudisabled { + /* bold = 600, 500 is ko with Edge on 1200x960 */ + font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; +} +a.vmenu:link, a.vmenu:visited { + color: var(--colortextbackvmenu); +} a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-family: ; @@ -2895,7 +2902,9 @@ a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { color: #202020; margin: 1px 1px 1px 6px; } -span.vsmenudisabled, font.vsmenudisabled { font-family: ; text-align: ; color: #aaa; } +span.vsmenudisabled, font.vsmenudisabled { + font-family: ; text-align: ; color: #aaa; +} a.vsmenu:link, a.vsmenu:visited { color: var(--colortextbackvmenu); white-space: nowrap; @@ -2903,7 +2912,9 @@ a.vsmenu:link, a.vsmenu:visited { span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 6px; } li a.vsmenudisabled, li.vsmenudisabled { color: #aaa !important; } -a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: ; color: #aaa; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { + text-align: ; color: #aaa; text-decoration: none; +} .helppresent, .helppresent:hover { /* color: #f3e4ac !important; */ } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8873149a9be..a2a68168e8e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2462,7 +2462,7 @@ div.tmenucenter width: 100%; } div.menu_titre { - padding-bottom: 2px; + padding-bottom: 5px; overflow: hidden; text-overflow: ellipsis; } @@ -2959,16 +2959,27 @@ div.vmenu, td.vmenu { .searchform { padding-top: 10px; } .searchform .bordertransp { border: 0; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; } +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; +} span.vmenudisabled, font.vmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } -a.vmenu:link, a.vmenu:visited { color: #; } +a.vmenu:link, a.vmenu:visited { + color: var(--colortextbackvmenu); +} a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #202020; margin: 1px 1px 1px 8px; } -span.vsmenudisabled, font.vsmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; } -a.vsmenu:link, a.vsmenu:visited { color: #; white-space: nowrap; } +span.vsmenudisabled, font.vsmenudisabled { + font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; +} +a.vsmenu:link, a.vsmenu:visited { + color: var(--colortextbackvmenu); + white-space: nowrap; +} span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } -a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: ; font-weight: normal; color: #999; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { + text-align: ; font-weight: normal; color: #999; text-decoration: none; +} .helppresentcircle { color: var(--colorbackhmenu1); From cc12baed57bda34c2833fdfcba78926ea23c86a0 Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Thu, 16 Dec 2021 10:19:42 +0100 Subject: [PATCH 0294/1091] fix info tab on customer invoice record not found --- htdocs/compta/facture/info.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index ccf6dca135c..340dfda2957 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -43,6 +43,12 @@ $ref = GETPOST("ref", 'alpha'); * View */ +$object = new Facture($db); +$object->fetch($id, $ref); +$object->fetch_thirdparty(); + +$object->info($object->id); + if (empty($object->id)) { llxHeader(); $langs->load('errors'); @@ -57,12 +63,6 @@ $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); -$object = new Facture($db); -$object->fetch($id, $ref); -$object->fetch_thirdparty(); - -$object->info($object->id); - $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); From 32ef42d163277ac67bc712900290335e9807f3fd Mon Sep 17 00:00:00 2001 From: Alain Rihs Date: Thu, 16 Dec 2021 10:22:43 +0100 Subject: [PATCH 0295/1091] Update notes.tpl.php See https://github.com/Dolibarr/dolibarr/issues/19580 The options of the advanced editor were not taken into account when editing public and private notes. I propose this code to fix this bug. --- htdocs/core/tpl/notes.tpl.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 6c01c44bc36..e0f0c5d9142 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -99,16 +99,26 @@ if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_ } else { $typeofdata = 'textarea:12:95%'; } +if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC)) { + $typeofdatapub = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. +} else { + $typeofdatapub = 'textarea:12:95%'; +} +if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE)) { + $typeofdatapriv = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. +} else { + $typeofdatapriv = 'textarea:12:95%'; +} print ''."\n"; print '
    '."\n"; print '
    '."\n"; $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_public); print '
    '."\n"; -print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); +print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, $moreparam, '', 0); print '
    '."\n"; print '
    '."\n"; -print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; +print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, '', null, null, $moreparam, 1)."\n"; print '
    '."\n"; print '
    '."\n"; if (empty($user->socid)) { @@ -116,10 +126,10 @@ if (empty($user->socid)) { print '
    '."\n"; $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_private); print '
    '."\n"; - print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); + print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, $moreparam, '', 0); print '
    '."\n"; print '
    '."\n"; - print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); + print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, '', null, null, $moreparam, 1); print '
    '."\n"; print '
    '."\n"; } From 41e4e70c6ec10eb3cf185d0c62525524ecaa922d Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Thu, 16 Dec 2021 16:28:45 +0700 Subject: [PATCH 0296/1091] Fix author searching include first and last name --- htdocs/compta/facture/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/mrp/mo_movements.php | 2 +- htdocs/product/stock/movement_card.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/replenishorders.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fb27f03d72a..40b672cbd9e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -537,7 +537,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 83e87e9b0f6..ab5fbe05e03 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -461,7 +461,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode); if ($search_paymentcond > 0) $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 600563f6cfd..c1d51bea6b0 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -428,7 +428,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); - if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); + if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cf3cc67bdc2..5921679b238 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -464,7 +464,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login')', $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 47e28939e05..fa9cd293e1a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -490,7 +490,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c73c7b1ca39..9ee5ad40fd5 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -132,7 +132,7 @@ if (!$user->rights->societe->client->voir && !$socid) { } if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); -if ($suser) $sql .= natural_search('u.login', $suser); +if ($suser) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); $sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 421ac40b447..ae1336c49d2 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -297,7 +297,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1); From d1495960439dd04dd377317b1f0394676bb9427f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 16 Dec 2021 10:33:53 +0100 Subject: [PATCH 0297/1091] fix test of method exist on wrong object --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 281e45baf51..7749a1176b2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1937,7 +1937,7 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { $prev_progress = 0; - if (method_exists($object, 'get_prev_progress')) + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } From e8eaf986feece47f1cc9c4eff0ecc0f398c8fd51 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Thu, 16 Dec 2021 16:55:47 +0700 Subject: [PATCH 0298/1091] Fix author searching include first and last name --- htdocs/product/stock/movement_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 5921679b238..dd9e86f9737 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -464,7 +464,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login')', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); From 43e682b56f41e5cc080abb1dc3abab3170b5addd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 12:33:45 +0100 Subject: [PATCH 0299/1091] Fix several pb with down payments --- htdocs/compta/facture/card.php | 44 ++++++++++++++----- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/core/class/commoninvoice.class.php | 1 + htdocs/fourn/facture/card.php | 5 ++- htdocs/install/mysql/migration/repair.sql | 3 ++ 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index da77b75d9a6..80c7bafc3d7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -970,10 +970,13 @@ if (empty($reshook)) { $object->fetch($id); if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { $paiement = new Paiement($db); - $result = $paiement->fetch(GETPOST('paiement_id')); + $result = $paiement->fetch(GETPOST('paiement_id', 'int')); if ($result > 0) { $result = $paiement->delete(); // If fetch ok and found - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -3857,7 +3860,6 @@ if ($action == 'create') { // For example print 239.2 - 229.3 - 9.9; does not return 0. // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency @@ -3866,7 +3868,10 @@ if ($action == 'create') { $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + // Code to fix case of corrupted data + if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + } } if ($object->paye) { @@ -5297,7 +5302,7 @@ if ($action == 'create') { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); - // Reopen a standard paid invoice + // Reopen an invoice if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)) @@ -5362,14 +5367,18 @@ if ($action == 'create') { if ($objectidnext) { print ''.$langs->trans('DoPayment').''; } else { - //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) - // print '
    ' . $langs->trans('DoPayment') . '
    '; - //} else { + if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { + // For down payment, we refuse to receive more than amount to pay. + print ''.$langs->trans('DoPayment').''; + } else { + // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) print '
    '.$langs->trans('DoPayment').''; - //} + } } } + $sumofpayment = $object->getSommePaiement(); + // Reverse back money or convert to reduction if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) { // For credit note only @@ -5387,21 +5396,32 @@ if ($action == 'create') { } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercancreate - && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $sumofpayment == 0) ) { print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { - print ''.$langs->trans('ConvertToReduc').''; + if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + // We can close a down payment only if paid amount is same than amount of down payment (by definition) + print ''.$langs->trans('ConvertToReduc').''; + } else { + print ''.$langs->trans('ConvertToReduc').''; + } } } // Classify paid if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) + || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && !empty($discount->id)) // If down payment is paid and then converted in credit, we can close it. ) { - print ''.$langs->trans('ClassifyPaid').''; + if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + // We can close a down payment only if paid amount is same than amount of down payment (by definition) + print ''.$langs->trans('ClassifyPaid').''; + } else { + print ''.$langs->trans('ClassifyPaid').''; + } } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 971400afa5e..6b5ab4ef333 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -483,7 +483,7 @@ class Paiement extends CommonObject // Verifier si paiement porte pas sur une facture classee // Si c'est le cas, on refuse la suppression - $billsarray = $this->getBillsArray('fk_statut > 1'); + $billsarray = $this->getBillsArray('f.fk_statut > 1'); if (is_array($billsarray)) { if (count($billsarray)) { $this->error = "ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible"; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 605ffec63bd..f6edbd3f8d4 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -168,6 +168,7 @@ abstract class CommonInvoice extends CommonObject $discountstatic = new DiscountAbsolute($this->db); $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) { return $result; } else { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 79a93cf3b0c..9efb21c4594 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2412,7 +2412,10 @@ if ($action == 'create') { $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + // Code to fix case of corrupted data + if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + } } if ($object->paye) { diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 5208a733769..4935577cbf8 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -534,6 +534,9 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL --update llx_facture set paye = 1, fk_statut = 2 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available); +-- TODO We should fix multicurrency_amount that are empty into llx_societe_remise_except, but we can't because we don't know what is the rate +-- We may retreive info fro minvoice line by using fk_facture_line or fk_facture_supplier_line +-- select * from llx_societe_remise_except where multicurrency_amount_ht = 0 and amount_ht <> 0; -- Note to migrate from old counter aquarium to new one From f1af5a41bf6a1c298e5e78c589c4657bda8546ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 12:53:46 +0100 Subject: [PATCH 0300/1091] Fix several pb with down payments --- htdocs/compta/facture/card.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 80c7bafc3d7..1ca81169cfb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5412,15 +5412,14 @@ if ($action == 'create') { } // Classify paid - if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && !empty($discount->id)) // If down payment is paid and then converted in credit, we can close it. + if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment + && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0) || ($object->type == Facture::TYPE_DEPOSIT && $object->total_ttc > 0))) ) { - if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpayment, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - print ''.$langs->trans('ClassifyPaid').''; - } else { print ''.$langs->trans('ClassifyPaid').''; + } else { + print ''.$langs->trans('ClassifyPaid').''; } } From 84400cf1d30df850a47a4ebe14e2d6c72d91eabb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 13:35:17 +0100 Subject: [PATCH 0301/1091] Fix backto page --- htdocs/comm/card.php | 6 +++--- htdocs/comm/remise.php | 27 +++++++++++++++--------- htdocs/core/tpl/object_discounts.tpl.php | 4 ++-- htdocs/fourn/card.php | 6 +++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index aaab987fd9c..2fe683f4f8e 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -465,7 +465,7 @@ if ($object->id > 0) { print $langs->trans("CustomerRelativeDiscountShort"); print '
    '; + print ''; if ($action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { @@ -4385,7 +4385,7 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { // Date invoice print '
    '; print $langs->trans('DateInvoice'); print '
    '; - print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $oldyear = $year; } From 01893caa610240b48076a315697319a2fd5778aa Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Wed, 8 Dec 2021 14:40:46 +0100 Subject: [PATCH 0201/1091] bad default value --- htdocs/contact/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 113fc5e74f7..1672bdd3f7f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -96,6 +96,7 @@ $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); if ($search_status == '') $search_status = 1; // always display active customer first +if ($search_no_email == '') $search_no_email = -1; $optioncss = GETPOST('optioncss', 'alpha'); @@ -418,7 +419,7 @@ if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type From 8de8dacaa3c14396a594aa0b934fb2ec059bbf9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:07:55 +0100 Subject: [PATCH 0202/1091] Fix php warning --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a1bc165ee49..05ec2b969b3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -274,7 +274,7 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { // Set the handler of session // if (ini_get('session.save_handler') == 'user') -if ($php_session_save_handler == 'db') { +if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { require_once 'core/lib/phpsessionin'.$php_session_save_handler.'.lib.php'; } From 5007282d7a0dc114bd327e16e448694788cb4993 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:16:06 +0100 Subject: [PATCH 0203/1091] Fix missing info popup on product --- htdocs/fourn/commande/dispatch.php | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 311cbd5f022..abeee1a9e26 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -788,6 +788,8 @@ if ($id > 0 || !empty($ref)) { $nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default) // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on. + $conf->cache['product'] = array(); + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -815,11 +817,20 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; - $linktoprod = ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; + if (empty($conf->cache['product'][$objp->fk_product])) { + $tmpproduct = new Product($db); + $tmpproduct->fetch($objp->fk_product); + $conf->cache['product'][$objp->fk_product] = $tmpproduct; + } else { + $tmpproduct = $conf->cache['product'][$objp->fk_product]; + } + + $linktoprod = $tmpproduct->getNomUrl(1); $linktoprod .= ' - '.$objp->label."\n"; if (!empty($conf->productbatch->enabled)) { if ($objp->tobatch) { + // Product print '"; @@ -831,6 +842,7 @@ if ($id > 0 || !empty($ref)) { print ''; } } else { + // Product print '"; @@ -1150,10 +1162,11 @@ if ($id > 0 || !empty($ref)) { print '
    '; + print ''; print ''; @@ -4401,7 +4401,7 @@ if ($action == 'create') { // Payment term print ''; print ''; print '
    '; print $langs->trans('DatePointOfTax'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; - print ''; print ''; print '
    '; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) { @@ -4422,7 +4422,7 @@ if ($action == 'create') { // Date payment term print ''; print ''; print '
    '; print $langs->trans('PaymentConditionsShort'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) { @@ -4446,7 +4446,7 @@ if ($action == 'create') { // Payment mode print ''; print ''; print '
    '; print $langs->trans('DateMaxPayment'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($action != 'editmode' && $usercancreate) { @@ -4466,7 +4466,7 @@ if ($action == 'create') { // Multicurrency code print ''; print ''; print ''; print '
    '; print $langs->trans('PaymentMode'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { @@ -4510,7 +4510,7 @@ if ($action == 'create') { // Bank Account if (!empty($conf->banque->enabled)) { print ''; print ''; print '
    '; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '
    '; - print ''; print ''; print '
    '; + print ''; print ''; print '
    '; print $langs->trans('BankAccount'); print ''; if (($action != 'editbankaccount') && $usercancreate) { @@ -4530,7 +4530,7 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { print '
    '; - print ''; print ''; print '
    '; + print ''; - // Bank Account + // Bank account if (!empty($conf->banque->enabled)) { print ''; + print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; + print ''; print '\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; @@ -768,7 +769,7 @@ if ($id) { if ($action == 'edit') { print $form->buttonsSaveCancel(); - print ""; + print "\n"; } From bfc8bb85a3d82b6ac989c740e0c515178b3f19e1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 6 Dec 2021 18:23:47 +0100 Subject: [PATCH 0188/1091] FIX: thirparty ajax selector: no name or highlighting if at least ref and/or address displayed --- htdocs/societe/ajax/ajaxcompanies.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/ajax/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php index 89aa4f524b6..cbbcb14f361 100644 --- a/htdocs/societe/ajax/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -125,15 +125,17 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn', 'int if ($resql) { while ($row = $db->fetch_array($resql)) { $label = ''; - if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { + if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) { if (($row['client']) && (!empty($row['code_client']))) { $label = $row['code_client'].' - '; } if (($row['fournisseur']) && (!empty($row['code_fournisseur']))) { $label .= $row['code_fournisseur'].' - '; } - $label .= ' '.$row['name']; } + + $label .= $row['nom']; + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $label .= ($row['address'] ? ' - '.$row['address'] : '').($row['zip'] ? ' - '.$row['zip'] : '').($row['town'] ? ' '.$row['town'] : ''); if (!empty($row['country_code'])) { From fe40668f43998bf28bba206fc4d3ff89516095ed Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 20:32:44 +0100 Subject: [PATCH 0189/1091] Parameter 4 extrafieldsobjectkey seems to be required now. --- ChangeLog | 1 + htdocs/core/class/extrafields.class.php | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..a70ff0d00e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 61c40499150..4eefdd4c6bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1488,7 +1488,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data + * @param string $extrafieldsobjectkey Required (for example $object->table_element). * @return string Formated value */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') @@ -1510,11 +1510,9 @@ class ExtraFields $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else { - // Old usage - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $help = ''; // Not supported with old syntax - $hidden = 0; // hidden option only available for new syntax + // Old usage not allowed anymore + dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_WARNING); + return ''; } if ($hidden) { From ba507e7735ee91b9275487792af6244563f7cbe4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 20:53:01 +0100 Subject: [PATCH 0190/1091] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 3c1a5abbe43..f61f5ab5c94 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3607,7 +3607,7 @@ div.refidno { font-weight: normal; color: var(--refidnocolor); font-size: ; - line-height: 21px; + line-height: 1.4em; } div.refidno form { display: inline-block; From 5efa31204b4a6833e4d6b49e4f620fc3fde9f93c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 02:00:34 +0100 Subject: [PATCH 0191/1091] FIX ECM module was mixing contributions and vat and not showing salaries --- htdocs/core/ajax/ajaxdirpreview.php | 12 +++-- htdocs/core/ajax/ajaxdirtree.php | 4 +- htdocs/core/class/html.formfile.class.php | 9 +++- htdocs/ecm/index_auto.php | 57 ++++++++++++++--------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 63b4b3f7fc6..c4b79d89920 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -204,6 +204,8 @@ if ($type == 'directory') { 'contract', 'product', 'tax', + 'tax-vat', + 'salaries', 'project', 'project_task', 'fichinter', @@ -225,6 +227,7 @@ if ($type == 'directory') { // TODO change for multicompany sharing if ($module == 'company') { $upload_dir = $conf->societe->dir_output; + $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts. } elseif ($module == 'invoice') { $upload_dir = $conf->facture->dir_output; } elseif ($module == 'invoice_supplier') { @@ -243,6 +246,11 @@ if ($type == 'directory') { $upload_dir = $conf->product->dir_output; } elseif ($module == 'tax') { $upload_dir = $conf->tax->dir_output; + $excludefiles[] = '^vat$'; // The subdir 'vat' contains files of vats. + } elseif ($module == 'tax-vat') { + $upload_dir = $conf->tax->dir_output.'/vat'; + } elseif ($module == 'salaries') { + $upload_dir = $conf->salaries->dir_output; } elseif ($module == 'project') { $upload_dir = $conf->projet->dir_output; } elseif ($module == 'project_task') { @@ -280,10 +288,6 @@ if ($type == 'directory') { $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') { - $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - } - $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index d9a2c250b89..19c389ec7f8 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -125,7 +125,7 @@ $userstatic = new User($db); $form = new Form($db); $ecmdirstatic = new EcmDirectory($db); -// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir +// Load full manual tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); } @@ -169,7 +169,7 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '
      '; - // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir + // Load full manual tree from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e30f35758d1..cf3ff8dae4e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1676,6 +1676,12 @@ class FormFile } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($this->db); + } elseif ($modulepart == 'tax-vat') { + include_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; + $object_instance = new Tva($this->db); + } elseif ($modulepart == 'salaries') { + include_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; + $object_instance = new Salary($this->db); } elseif ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object_instance = new Project($this->db); @@ -1723,6 +1729,7 @@ class FormFile } //var_dump($filearray); + //var_dump($object_instance); // Get list of files stored into database for same relative directory $relativepathfromroot = preg_replace('/'.preg_quote(DOL_DATA_ROOT.'/', '/').'/', '', $upload_dir); @@ -1752,7 +1759,7 @@ class FormFile // To show ref or specific information according to view to show (defined by $modulepart) // $modulepart can be $object->table_name (that is 'mymodule_myobject') or $object->element.'-'.$module (for compatibility purpose) $reg = array(); - if ($modulepart == 'company' || $modulepart == 'tax') { + if ($modulepart == 'company' || $modulepart == 'tax' || $modulepart == 'tax-vat' || $modulepart == 'salaries') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } elseif ($modulepart == 'invoice_supplier') { diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7f098951fe7..c4ec6afc90b 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -310,59 +310,73 @@ $rowspan = 0; $sectionauto = array(); if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); + $langs->load("products"); + $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } if (!empty($conf->societe->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); + $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (!empty($conf->propal->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (!empty($conf->contrat->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (!empty($conf->commande->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (!empty($conf->facture->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (!empty($conf->supplier_proposal->enabled)) { - $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $langs->load("supplier_proposal"); + $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); + $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); + $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (!empty($conf->tax->enabled)) { - $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); + } + if (!empty($conf->salaries->enabled)) { + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>$conf->salaries->enabled, 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); } if (!empty($conf->projet->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); + $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); + $rowspan++; $sectionauto[] = array('position'=>140, 'level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); } if (!empty($conf->ficheinter->enabled)) { - $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $langs->load("interventions"); + $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (!empty($conf->expensereport->enabled)) { - $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $langs->load("trips"); + $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (!empty($conf->holiday->enabled)) { - $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $langs->load("holiday"); + $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (!empty($conf->banque->enabled)) { - $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); + $langs->load("banks"); + $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); } if (!empty($conf->mrp->enabled)) { - $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $langs->load("mrp"); + $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (!empty($conf->recruitment->enabled)) { - $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $langs->load("recruitment"); + $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); + $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); $parameters = array(); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); @@ -439,7 +453,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act $oldvallevel = 0; foreach ($sectionauto as $key => $val) { if (empty($val['test'])) { - continue; // If condition to show is ok + continue; // If condition to show the ECM auto directory is ok } print '
    '; print ''; print '
    '; print $langs->trans('IncotermLabel'); print ''; if ($usercancreate) { @@ -4658,7 +4658,8 @@ if ($action == 'create') { print '
    '; print ''."\n"; - print ''; + print '
    '."\n"; + print '
    '; $sign = 1; if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index a87817cdc73..2a76b04fa41 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -186,9 +186,9 @@ class pdf_ban extends ModeleBankAccountDoc $pdf->SetTextColor(0, 0, 0); $tab_top = 50; - $tab_height = 200; $tab_top_newpage = 40; - $tab_height_newpage = 210; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Affiche notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 2259897f044..5d18a2ec8fc 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -198,9 +198,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->SetTextColor(0, 0, 0); $tab_top = 50; - $tab_height = 200; $tab_top_newpage = 40; - $tab_height_newpage = 210; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 01fde021cb0..e6ed244fc8f 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -388,6 +388,8 @@ class pdf_eratosthene extends ModelePDFCommandes $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { @@ -521,8 +523,8 @@ class pdf_eratosthene extends ModelePDFCommandes } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 9c549576818..903c8a233cd 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -342,8 +342,8 @@ class pdf_storm extends ModelePDFDeliveryOrder $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $this->posxdesc = $this->marge_gauche + 1; @@ -352,7 +352,7 @@ class pdf_storm extends ModelePDFDeliveryOrder if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 19e319d0522..865bef37fbb 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -321,15 +321,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 2752f9a9c9b..fc1094ea949 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -324,8 +324,8 @@ class pdf_espadon extends ModelePdfExpedition $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $this->posxdesc = $this->marge_gauche + 1; @@ -334,7 +334,7 @@ class pdf_espadon extends ModelePdfExpedition if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 56c8fb143fb..9a905422ff1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -282,8 +282,8 @@ class pdf_merou extends ModelePdfExpedition $tab_top = 52; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter; - $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Display notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 4b542e4e636..211231b9812 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -349,15 +349,15 @@ class pdf_rouget extends ModelePdfExpedition $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index f5862bfc5f2..6fdc14ec1ad 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -313,8 +313,8 @@ class pdf_standard extends ModeleExpenseReport $tab_top = 95; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b919b90abfd..8d01927e1dc 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -411,18 +411,21 @@ class pdf_sponge extends ModelePDFFactures } $pagenb++; + // Output header (logo, ref and address blocks). This is first call for first page. $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90 + $top_shift; + // You can add more thing undr header here, if you increase top_shift too. + // TODO + + // $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks) + $tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases) $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); - $tab_height = 130 - $top_shift; - $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $tab_height_newpage -= $top_shift; - } + + // Define heigth of table for lines (for first page) + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $nexY = $tab_top - 1; @@ -447,7 +450,7 @@ class pdf_sponge extends ModelePDFFactures } } - // Displays notes + // Displays notes. Here we are still on code eecuted only for the first page. $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep @@ -560,8 +563,8 @@ class pdf_sponge extends ModelePDFFactures } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; @@ -594,7 +597,7 @@ class pdf_sponge extends ModelePDFFactures // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // Table simulation to know the height of the title line + // Table simulation to know the height of the title line (this set this->tableTitleHeight) $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -1853,11 +1856,11 @@ class pdf_sponge extends ModelePDFFactures // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Show top header of page. + * Show top header of page. This include the logo, ref and address blocs * * @param TCPDF $pdf Object PDF * @param Facture $object Object to show - * @param int $showaddress 0=no, 1=yes + * @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages) * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @return void diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index e23a0aa1701..719fb670672 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -271,8 +271,8 @@ class pdf_soleil extends ModelePDFFicheinter $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Display notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index 7f487fdcf94..bf06a1b73d2 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -499,14 +499,10 @@ class pdf_standard extends ModelePDFMovement $tab_top = 42; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; - /* ************************************************************************** */ - /* */ - /* Affichage de la liste des produits du MouvementStock */ - /* */ - /* ************************************************************************** */ + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + + // Show list of product of the MouvementStock $nexY += 5; $nexY = $pdf->GetY(); diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index d116976eb88..0927c795749 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -309,6 +309,8 @@ class pdf_vinci extends ModelePDFMo $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; @@ -412,8 +414,8 @@ class pdf_vinci extends ModelePDFMo } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 815fc4d1c66..37aca08d146 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -270,8 +270,8 @@ class pdf_standard extends ModelePDFProduct $tab_top = 42; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Label of product $pdf->SetFont('', 'B', $default_font_size); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 373d41abc31..716c88e1f92 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -286,8 +286,8 @@ class pdf_baleine extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 30b9271a110..f71b0cdb6a7 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -327,8 +327,8 @@ class pdf_beluga extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index ef2ec4fcaf8..991ff794d72 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -286,8 +286,8 @@ class pdf_timespent extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index d0e51fb8bc7..fd8b5c3389b 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -408,6 +408,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); $tab_top = $nexY + 6; + $height_incoterms += 4; } } @@ -537,8 +538,8 @@ class pdf_cyan extends ModelePDFPropales } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 38344a5f486..9f03abef52c 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -263,15 +263,15 @@ class pdf_squille extends ModelePdfReception $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 0c627322d69..5d5e24f5fd1 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -293,14 +293,10 @@ class pdf_standard extends ModelePDFStock $tab_top = 80 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); - $tab_height = 130; + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; - /* ************************************************************************** */ - /* */ - /* Show list of product in warehouse */ - /* */ - /* ************************************************************************** */ + // Show list of product in warehouse */ $totalunit = 0; $totalvalue = $totalvaluesell = 0; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 436017cda0a..7738f1ec404 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -363,6 +363,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Incoterm if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); @@ -484,8 +486,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 5b9ffa062a3..beaddc3a33d 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -317,8 +317,8 @@ class pdf_standard extends ModelePDFSuppliersPayments $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; From ca6f22266285866c9479d9394f9e4da101f453ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:19:44 +0100 Subject: [PATCH 0129/1091] Fix notification (pb static var unknown) --- htdocs/core/class/notify.class.php | 6 +++--- htdocs/theme/eldy/global.inc.php | 22 +++++++++++++++++++++- htdocs/theme/md/style.css.php | 19 +++++++++++++++++++ test/phpunit/NumberingModulesTest.php | 6 ++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 2df88f51c0d..32ff4444a72 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -83,7 +83,6 @@ class Notify 'ACTION_CREATE' ); - /** * Constructor * @@ -92,6 +91,7 @@ class Notify public function __construct($db) { $this->db = $db; + $this->arrayofnotifsupported = self::$arrayofnotifsupported; } @@ -437,10 +437,10 @@ class Notify $notifcodedefid = $obj->adid; $trackid = ''; if ($obj->type_target == 'tocontactid') { - $trackid = 'con'.$obj->id; + $trackid = 'con'.$obj->cid; } if ($obj->type_target == 'touserid') { - $trackid = 'use'.$obj->id; + $trackid = 'use'.$obj->cid; } if (dol_strlen($obj->email)) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 37692f46c1e..bd342be3f65 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4688,8 +4688,28 @@ div.ui-tooltip.mytooltip { background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor); line-height: 1.6em; - min-width: 200px; + min-width: 550px; } +@media only screen and (max-width: 768px) +{ + div.ui-tooltip.mytooltip { + max-width: 400px; + } +} +@media only screen and (max-width: 480px) +{ + div.ui-tooltip.mytooltip { + max-width: 300px; + } +} +@media only screen and (max-width: 320px) +{ + div.ui-tooltip.mytooltip { + max-width: 230px; + } +} + + diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index dccd193454b..5d6cf2d8ead 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4642,6 +4642,25 @@ div.ui-tooltip.mytooltip { /*background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor);*/ line-height: 1.6em; + min-width: 550px; +} +@media only screen and (max-width: 768px) +{ + div.ui-tooltip.mytooltip { + max-width: 400px; + } +} +@media only screen and (max-width: 480px) +{ + div.ui-tooltip.mytooltip { + max-width: 300px; + } +} +@media only screen and (max-width: 320px) +{ + div.ui-tooltip.mytooltip { + max-width: 230px; + } } diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index a34d3b28d1c..ceab1948732 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -144,13 +144,15 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase // First we try with a simple mask, with no reset // and we test counter is still increase second year. $conf->global->FACTURE_ADDON='mercure'; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_DEPOSIT='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT='{yyyy}-{0000}'; $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (usefull only if numbering is {0000@1} $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; From bd0208b59574c08ab061fb4075e2b19c21d6e0b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:30:56 +0100 Subject: [PATCH 0130/1091] css --- htdocs/theme/md/style.css.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5d6cf2d8ead..6fd1a0f95f0 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3182,12 +3182,12 @@ div.tabBar { margin: 0px 0px 18px 0px; -webkit-border-radius: 3px; border-radius: 3px; - border-right: 1px solid #BBB; - border-left: 1px solid #BBB; + border-right: 1px solid #CCC; + border-left: 1px solid #CCC; border-top: 1px solid #CCC; + border-bottom: 1px solid #CCC; width: auto; background: var(--colorbacktabcard1); - border-bottom: 1px solid #aaa; } div.tabBar tr.titre td { From a3493d0132c1c15015550894bfe2f580b7af3a93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:33:51 +0100 Subject: [PATCH 0131/1091] Clean code --- htdocs/core/class/notify.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 32ff4444a72..a741af3d867 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -91,7 +91,6 @@ class Notify public function __construct($db) { $this->db = $db; - $this->arrayofnotifsupported = self::$arrayofnotifsupported; } @@ -346,7 +345,7 @@ class Notify global $dolibarr_main_url_root; global $action; - if (!in_array($notifcode, $this->arrayofnotifsupported)) { + if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { return 0; } From 202b123aaaf0d5b5615e607d364a9009b38850b7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 2 Dec 2021 15:10:29 +0100 Subject: [PATCH 0132/1091] FIX compatibility with multicompany --- htdocs/societe/card.php | 4 ++-- htdocs/societe/website.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e5a624ec07f..fdff7c1940a 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -900,7 +900,7 @@ if (empty($reshook)) { // Actions to build doc $id = $socid; - $upload_dir = $conf->societe->dir_output; + $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -3006,7 +3006,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Presend form $modelmail = 'thirdparty'; $defaulttopic = 'Information'; - $diroutput = $conf->societe->dir_output; + $diroutput = $conf->societe->multidir_output[$object->entity]; $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 0740200867d..7d79a429eea 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -159,7 +159,7 @@ if (empty($reshook)) { $objectlabel = 'WebsiteAccount'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; - $uploaddir = $conf->societe->dir_output; + $uploaddir = $conf->societe->multidir_output[$object->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } From b732d80ca5fc504799eeef70cd6f8a2965a5bd97 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 2 Dec 2021 15:56:34 +0100 Subject: [PATCH 0133/1091] Fix php 8.0 warnings --- htdocs/compta/facture/card.php | 10 ++++++---- htdocs/compta/facture/invoicetemplate_list.php | 6 +++++- htdocs/compta/facture/list.php | 8 ++++---- htdocs/compta/facture/stats/index.php | 6 +++--- htdocs/core/class/html.form.class.php | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 20f289ae141..c50f7a4e8e8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -92,6 +92,8 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); +$facid = GETPOST('facid', 'int'); +$ref_client = GETPOST('ref_client', 'int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2771,7 +2773,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc - $upload_dir = $conf->facture->multidir_output[$object->entity]; + $upload_dir = $conf->facture->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -3555,7 +3557,7 @@ if ($action == 'create') { print ''; - if ($conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $rwStyle = 'display:none;'; if (in_array(GETPOST('type', 'int'), $retainedWarrantyInvoiceAvailableType)) { $rwStyle = ''; @@ -3631,7 +3633,7 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index babadfe7366..c100263ac7f 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -380,11 +380,11 @@ foreach ($data as $val) { print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $oldyear = $year; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a6718531ff3..5423175859b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8435,7 +8435,7 @@ class Form 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), - 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'fichinter'=>array('enabled'=>!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), From c171ba3a45dc9a12ece0e7f8a5bf238a9f86ac54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 16:07:33 +0100 Subject: [PATCH 0134/1091] Fix regression in cron jobs --- htdocs/core/class/conf.class.php | 5 +++-- htdocs/cron/class/cronjob.class.php | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 8776060b60f..581de47178c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -167,15 +167,16 @@ class Conf * Load setup values into conf object (read llx_const) for a specified entity * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * + * @param DoliDB $db Database handler * @param int $entity Entity to get * @return int < 0 if KO, >= 0 if OK */ - public function setEntityValues($entity) + public function setEntityValues($db, $entity) { if ($this->entity != $entity) { // If we ask to reload setup for a new entity $this->entity = $entity; - return $this->setValues($this->db); + return $this->setValues($db); } return 0; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 34fe7b6cd58..44564e1b0ab 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); } $savcurrententity = $conf->entity; - $conf->setEntityValues($this->entity); + $conf->setEntityValues($this->db, $this->entity); dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject if ($result < 0) { $this->error = "User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } else { if (empty($user->id)) { $this->error = " User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } } @@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject if ($ret === false) { $this->error = $langs->trans('CronCannotLoadLib').': '.$libpath; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject $result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing if ($result < 0) { // If technical error dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return $error ?-1 : 1; } From 39ad96c230a9b5b5db6ede0951680d8897d10ca7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 17:47:03 +0100 Subject: [PATCH 0135/1091] css --- htdocs/holiday/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 0ecdcb2dd69..207c7c31707 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -890,14 +890,15 @@ if ($resql) { $i++; } + // Add a line for total if there is a total to show if (!empty($arrayfields['duration']['checked'])) { - print ''; + print ''; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { if ($key == 'duration') { print ''; } else { - print ''; } } } From 075faded4760fde81266a01c4cc17822d0382155 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Oct 2021 11:58:21 +0200 Subject: [PATCH 0136/1091] FIX list of categories in stats of supplier invoices Conflicts: htdocs/compta/facture/stats/index.php --- htdocs/compta/facture/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index a42003e3c2a..8a32077cb54 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -309,7 +309,7 @@ if (!empty($conf->category->enabled)) { $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } print ''; - print ''; + print ''; print ''; $i++; From 1db52532ff34924a60757c9ec873c4c253bf3d66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Dec 2021 01:50:17 +0100 Subject: [PATCH 0144/1091] FIX: do not update holiday for closed users --- htdocs/holiday/class/holiday.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 89760c4d1ac..9a45a735716 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1470,11 +1470,11 @@ class Holiday extends CommonObject $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; //print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit; - // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp + // If month date is not same than the one of last update (the one we saved in database), then we update the timestamp and balance of each open user. if ($month != $monthLastUpdate) { $this->db->begin(); - $users = $this->fetchUsers(false, false); + $users = $this->fetchUsers(false, false, ' AND u.statut > 0'); $nbUser = count($users); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1675,7 +1675,7 @@ class Holiday extends CommonObject * * @param boolean $stringlist If true return a string list of id. If false, return an array with detail. * @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list. - * @param string $filters Filters + * @param string $filters Filters. Warning: This must not contains data from user input. * @return array|string|int Return an array */ public function fetchUsers($stringlist = true, $type = true, $filters = '') @@ -1776,7 +1776,7 @@ class Holiday extends CommonObject // Si faux donc return array // List for Dolibarr users if ($type) { - // If user of Dolibarr + // If we need users of Dolibarr $sql = "SELECT"; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " DISTINCT"; From 1e845434e05569dc88d8b228a4b7d51547f42cf4 Mon Sep 17 00:00:00 2001 From: mbinformatique68 Date: Fri, 3 Dec 2021 09:42:50 +0100 Subject: [PATCH 0145/1091] Get societe terms of payment if getpost terms of payment is 0 --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2d8887c7929..66191110de2 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1646,7 +1646,7 @@ if ($action == 'create') { // Terms of payment print ''; // Mode of payment From 093191aeebc6685290c317884cc9d2c526265aba Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 3 Dec 2021 10:37:48 +0100 Subject: [PATCH 0146/1091] FIx php8.0 warnings --- htdocs/fourn/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index c4e18d50f90..5c76c1dddd0 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -348,7 +348,7 @@ if ($moreforfilter) { $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if (!empty($massactionbutton)) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } From 2f4fe2b898c445f44dfbb7efcc37033c7b5a323e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Dec 2021 10:59:47 +0100 Subject: [PATCH 0147/1091] error message --- htdocs/hrm/class/skill.class.php | 8 ++++++- htdocs/hrm/lib/hrm_skillrank.lib.php | 36 +++++++++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 0b247e7f5f4..ebf568e68fe 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -410,7 +410,13 @@ class Skill extends CommonObject $skilldet = new Skilldet($this->db); $this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), ''); - return (count($this->lines) > 0 ) ? $this->lines : array(); + if (is_array($this->lines)) { + return (count($this->lines) > 0) ? $this->lines : array(); + } elseif ($this->lines < 0) { + $this->errors = array_merge($this->errors, $skilldet->errors); + $this->error = $skilldet->error; + return $this->lines; + } } diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php index 2aca41504ad..78a53823c2d 100644 --- a/htdocs/hrm/lib/hrm_skillrank.lib.php +++ b/htdocs/hrm/lib/hrm_skillrank.lib.php @@ -115,44 +115,48 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode $skilldet = new Skilldet($db); $Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); + if (!is_array($Lines) && $Lines<0) { + setEventMessages($skilldet->error, $skilldet->errors, 'errors'); + } if (empty($Lines)) return $langs->trans('SkillHasNoLines'); $ret = '0'; + if (is_array($Lines) && !empty($Lines)) { + foreach ($Lines as $line) { + $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; + if ($line->rank > $MaxNumberSkill) { + continue; + } - foreach ($Lines as $line) { - $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; - if ($line->rank > $MaxNumberSkill) { - continue; + $ret .= '' . $line->rank . ''; } - $ret.= ''.$line->rank.''; - } - - if ($mode == 'edit') { - $ret.= ' - + if ($mode == 'edit') { + $ret .= ' + '; + } } return $ret; From b024bf20ed699b1cf7cb17d0adb35931569a823c Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Fri, 3 Dec 2021 13:57:34 +0100 Subject: [PATCH 0148/1091] Update html.form.class.php When you pay an invoice, you can send the payment multiple times. --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5813c45047a..7f7f3313139 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5018,7 +5018,7 @@ class Form } $formconfirm .= '
    '; - if (empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $formconfirm .= ''; $formconfirm .= ''; From 7018fe9530e75a1eb13e5d4eb2f28f076cb3c60c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 16:48:39 +0100 Subject: [PATCH 0184/1091] Update changelog ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 00962b10419..023b70ec79e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed From 6af2626f081e18f736f92dbf30d980039ea56659 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:55:51 +0100 Subject: [PATCH 0185/1091] FIX: contact card: bad colspan value for separator extrafield in creation/modification form --- htdocs/contact/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5110e08e2fc..a43c7c34e7f 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -850,7 +850,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Other attributes - $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); + $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3, 'colspanvalue' => 3); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print "
    '; $incoterm_id = GETPOST('incoterm_id'); $incoterm_location = GETPOST('location_incoterms'); @@ -3644,7 +3646,7 @@ if ($action == 'create') { } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); + $parameters = array('objectsrc' => !empty($objectsrc) ? $objectsrc : 0, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 9619e1a9ddd..d785ccbce93 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -692,6 +692,10 @@ if ($resql) { if ($num > 0) { $i = 0; $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['f.total_ht'] = 0; + $totalarray['val']['f.total_tva'] = 0; + $totalarray['val']['f.total_ttc'] = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); if (empty($objp)) { @@ -701,7 +705,7 @@ if ($resql) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; - $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; + $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; $invoicerectmp->frequency = $objp->frequency; $invoicerectmp->suspended = $objp->suspended; $invoicerectmp->unit_frequency = $objp->unit_frequency; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 52b2fcceee0..02ce893b96d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -805,7 +805,7 @@ if (!$sall) { } } // Add GroupBy from hooks - $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } else { @@ -1650,7 +1650,7 @@ if ($resql) { $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; - if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $facturestatic->retained_warranty = $obj->retained_warranty; $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; $facturestatic->situation_final = $obj->retained_warranty_date_limit; @@ -1846,8 +1846,8 @@ if ($resql) { } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print dol_escape_htmltag($obj->name_alias); + print ''; + print dol_escape_htmltag((!empty($obj->name_alias) ? $obj->name_alias : '')); print '
    0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.($val['nb_diff'] < 0 ? '' : '+').round($val['nb_diff']).'%'.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.price(price2num($val['total'], 'MT'), 1).''.($val['total_diff'] < 0 ? '' : '+').round($val['total_diff']).'%'.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.price(price2num($val['avg'], 'MT'), 1).''.($val['avg_diff'] < 0 ? '' : '+').round($val['avg_diff']).'%'.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%
    '.$totalduration.' '.$langs->trans('DurationDays').''; + print '
    '.$cat_label.''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + $cate_arbo = $form->select_all_categories($cat_type, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"'); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), 0, 0, 'widthcentpercentminusx maxwidth300'); //print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); From 7e835ec91534435873758e7ba110537e092c7559 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 19:06:44 +0100 Subject: [PATCH 0137/1091] Fix css --- htdocs/theme/eldy/info-box.inc.php | 12 ++++++------ htdocs/theme/md/info-box.inc.php | 31 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 3fe2552c86a..40a62dbf18a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -330,15 +330,15 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { color: #b06080 !important; } /* Color for customer object */ -.infobox-propal:not(.pictotitle), -.infobox-facture:not(.pictotitle), -.infobox-commande:not(.pictotitle) { +.infobox-propal:not(.pictotitle):not(.error), +.infobox-facture:not(.pictotitle):not(.error), +.infobox-commande:not(.pictotitle):not(.error) { color: #65953d !important; } /* Color for vendor object */ -.infobox-supplier_proposal:not(.pictotitle), -.infobox-invoice_supplier:not(.pictotitle), -.infobox-order_supplier:not(.pictotitle){ +.infobox-supplier_proposal:not(.pictotitle):not(.error), +.infobox-invoice_supplier:not(.pictotitle):not(.error), +.infobox-order_supplier:not(.pictotitle):not(.error) { color: #599caf !important; } .infobox-contrat, .infobox-ticket{ diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index a363475c409..02f263900c6 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -28,7 +28,7 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { ?> .customer-back { - background-color: #99a17d !important; + background-color: #65953d !important; color: #FFF !important; padding: 2px; margin: 2px; @@ -56,15 +56,11 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { .bg-infobox-action{ color: #a47080 !important; } -.bg-infobox-propal, -.bg-infobox-facture, -.bg-infobox-commande{ - color: #99a17d !important; +.bg-infobox-propal, .bg-infobox-facture, .bg-infobox-commande { + color: #65953d !important; } -.bg-infobox-supplier_proposal, -.bg-infobox-invoice_supplier, -.bg-infobox-order_supplier{ - color: #599caf !important; +.bg-infobox-supplier_proposal, .bg-infobox-invoice_supplier, .bg-infobox-order_supplier { + color: #599caf !important; } .bg-infobox-contrat, .bg-infobox-ticket{ color: #46a676 !important; @@ -92,16 +88,19 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { .infobox-action{ color: #a47080 !important; } -.infobox-propal, -.infobox-facture, -.infobox-commande{ - color: #99a17d !important; +/* Color for customer object */ +.infobox-propal:not(.pictotitle):not(.error), +.infobox-facture:not(.pictotitle):not(.error), +.infobox-commande:not(.pictotitle):not(.error) { + color: #65953d !important; } -.infobox-supplier_proposal, -.infobox-invoice_supplier, -.infobox-order_supplier{ +/* Color for vendor object */ +.infobox-supplier_proposal:not(.pictotitle):not(.error), +.infobox-invoice_supplier:not(.pictotitle):not(.error), +.infobox-order_supplier:not(.pictotitle):not(.error) { color: #599caf !important; } + .infobox-contrat, .infobox-ticket{ color: #46a676 !important; } From 9c083071b8e3eda104c14b0b32f716d072d18406 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:39:53 +0100 Subject: [PATCH 0138/1091] Better test --- htdocs/public/test/test_exec.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index a25e860021c..f805cc19b5c 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -66,7 +66,7 @@ echo "Test
    \n"; $out=''; $ret=0; -$file = '/tmp/aaa'; +$file = '/tmp/test.txt'; $f=fopen($file, 'r'); if ($f) { $s=fread($f, 4096); @@ -76,10 +76,14 @@ if ($f) { print "Failed to open file ".$file."
    \n"; } -exec('cat /aaa; ls /dev/std*; sleep 1;', $out, $ret); +print '

    '."\n"; + +exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); +print '

    '."\n"; + $ret = 0; $out = null; exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret); From 2300f1710188dc467e1e4f73c58b389f5fc414cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:40:41 +0100 Subject: [PATCH 0139/1091] test --- htdocs/public/test/test_exec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index f805cc19b5c..3fd66b40635 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -78,7 +78,7 @@ if ($f) { print '

    '."\n"; -exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); +exec('cat /test.txt; ls /dev/std*; id; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); From ac17378972b2168501a0e901f2a8604c3a481937 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:41:13 +0100 Subject: [PATCH 0140/1091] revert --- htdocs/public/test/test_exec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index 3fd66b40635..f805cc19b5c 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -78,7 +78,7 @@ if ($f) { print '

    '."\n"; -exec('cat /test.txt; ls /dev/std*; id; sleep 1;', $out, $ret); +exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); From c23914f367eaf1555bff2569d77e800c6e5205ca Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 2 Dec 2021 23:05:18 +0100 Subject: [PATCH 0141/1091] FIX load css file --- htdocs/takepos/split.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index 75599d0160f..dbe474968a9 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -137,7 +137,7 @@ if ($invoiceid > 0) { } } -$arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/split.css.php'); +$arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); $head = ''; @@ -225,4 +225,4 @@ $( document ).ready(function() { - \ No newline at end of file + From 2b5bcda8d8a7a9ce0fadcbf0b0c6d287c5ce348e Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 2 Dec 2021 23:08:22 +0100 Subject: [PATCH 0142/1091] FIX Avoid move line to the same place in TakePOS --- htdocs/takepos/split.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index dbe474968a9..02c37cb75e5 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -84,6 +84,7 @@ if ($action=="split") { $db->query($sql); } elseif ($split==0) { // Unsplit line $invoice = new Facture($db); + if ($place=="SPLIT") $place="0"; // Avoid move line to the same place (from SPLIT to SPLIT place) $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); if ($ret > 0) { $placeid = $invoice->id; From d9aa4713709d3082d40795cddc4a18353efc581a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Dec 2021 01:39:16 +0100 Subject: [PATCH 0143/1091] Fix color status --- htdocs/hrm/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 6bd777401f7..ef231b48eff 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -223,6 +223,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = $obj->ref; $holidaystatic->statut = $obj->status; + $holidaystatic->date_debut = $db->jdate($obj->date_start); $userstatic->id = $obj->uid; $userstatic->lastname = $obj->lastname; @@ -243,7 +244,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print '
    '.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3).''.$holidaystatic->LibStatut($obj->status, 3, $holidaystatic->date_debut).'
    '.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'paiment'); - $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '

    "; @@ -1161,7 +1161,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); + $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3', 'colspanvalue'=> '3'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; $object->load_ref_elements(); From 16c4dec6dac82cc1f672b11e6c3f2de82626f056 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 17:36:00 +0100 Subject: [PATCH 0186/1091] Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 023b70ec79e..9fa65871f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed From 1caaa335d16b5b5bfb1dbff16ae23cfb4ab9d36a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 18:18:31 +0100 Subject: [PATCH 0187/1091] Fix missing section with files on social contribution page --- htdocs/compta/sociales/card.php | 132 ++++++++++++++++++++++++++------ htdocs/compta/tva/card.php | 13 ++-- 2 files changed, 114 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 8207802feaa..98ebe32f970 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -26,11 +26,11 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -46,8 +46,14 @@ if (!empty($conf->accounting->enabled)) { $langs->loadLangs(array('compta', 'bills', 'banks', 'hrm')); $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $fk_project = (GETPOST('fk_project') ? GETPOST('fk_project', 'int') : 0); $dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear')); @@ -56,11 +62,28 @@ $label = GETPOST('label', 'alpha'); $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); +// Initialize technical objects $object = new ChargeSociales($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('taxsocialcontributioncard', 'globalcard')); + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + +// Load object if ($id > 0) { $object->fetch($id); } +$permissiontoread = $user->rights->tax->charges->lire; +$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { @@ -74,6 +97,12 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges') * Actions */ +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + // Classify paid if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { $object->fetch($id); @@ -122,7 +151,7 @@ if ($action == 'setmode' && $user->rights->tax->charges->creer) { } } -// bank account +// Bank account if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); @@ -151,7 +180,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // Add social contribution if ($action == 'add' && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -189,7 +218,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) { if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -297,6 +326,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char */ $form = new Form($db); +$formfile = new FormFile($db); $formsocialcontrib = new FormSocialContrib($db); $bankaccountstatic = new Account($db); if (!empty($conf->projet->enabled)) { @@ -308,7 +338,7 @@ $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividen llxHeader("", $title, $help_url); -// Mode creation +// Form to create a social contribution if ($action == 'create') { print load_fiche_titre($langs->trans("NewSocialContribution")); @@ -411,11 +441,7 @@ if ($action == 'create') { print ''; } -/* *************************************************************************** */ -/* */ -/* Card Mode */ -/* */ -/* *************************************************************************** */ +// View mode if ($id > 0) { $object = new ChargeSociales($db); $result = $object->fetch($id); @@ -594,7 +620,7 @@ if ($id > 0) { } print '
    '; print ''; } + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
    '; @@ -614,6 +640,11 @@ if ($id > 0) { print '
    '; print ''; @@ -627,7 +658,7 @@ if ($id > 0) { /* * Payments */ - $sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,"; + $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,"; $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -637,7 +668,7 @@ if ($id > 0) { $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " WHERE p.fk_charge = ".((int) $id); $sql .= " AND p.fk_charge = cs.rowid"; - $sql .= " AND cs.entity IN (".getEntity('tax').")"; + $sql .= " AND cs.entity IN (".getEntity('sc').")"; $sql .= " ORDER BY dp DESC"; //print $sql; @@ -735,22 +766,15 @@ if ($id > 0) { print dol_get_fiche_end(); if ($action == 'edit') { - print '
    '; - print ''; - print '   '; - print ''; - print '
    '; - } + print $form->buttonsSaveCancel(); - if ($action == 'edit') { print "\n"; } - /* - * Actions buttons - */ + // Buttons for actions + if ($action != 'edit') { print '
    '."\n"; @@ -788,6 +812,64 @@ if ($id > 0) { print "
    "; } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
    '; + print ''; // ancre + + $includedocgeneration = 1; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->tax->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content + $genallowed = 0; + $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); + //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
    '; + + /* + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + */ + + print '
    '; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'sc'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->tax->dir_output; + $trackid = 'sc'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } else { /* Social contribution not found */ dol_print_error('', $object->error); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ef09cd5aabc..530d18d17f9 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -306,7 +306,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { } if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount')); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); @@ -317,7 +317,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->cr } else { $result = $object->fetch($id); - $object->amount = price2num($amount); + $object->amount = $amount; $result = $object->update($user); if ($result <= 0) { @@ -339,8 +339,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->fetch($id); if ($object->id > 0) { - $object->paye = 0; $object->id = $object->ref = null; + $object->paye = 0; if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); @@ -535,7 +535,7 @@ if ($action == 'create') { } // View mode -if ($id) { +if ($id > 0) { $head = vat_prepare_head($object); $totalpaye = $object->getSommePaiement(); @@ -705,7 +705,8 @@ if ($id) { $objp = $db->fetch_object($resql); print '
    '; - print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."
    '; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 8a3a6a142aa..3d2dee9a286 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -347,7 +347,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 8e4860bd2f2..7da90915b18 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -260,7 +260,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index babadfe7366..cc94deb4ba6 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -102,7 +102,7 @@ if ($mode == 'customer') { $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')'; } if (is_array($custcats) && !empty($custcats)) { - $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')'; } } @@ -341,7 +341,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index bb7d6b314aa..f56bdcd15ac 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -233,7 +233,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index fc8d69e4ce7..b97af33cb6e 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -238,7 +238,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index 500fe874747..ded5a7a3805 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -249,7 +249,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index f1247adb457..9e49d9bc4b5 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -245,7 +245,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index 878b80165d5..f41651e15d8 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -298,7 +298,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 5fd6b47407c..70c093f46e3 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -168,7 +168,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 8f20ed58065..35569dd7035 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -233,7 +233,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index 7eefe7982fc..cb8eb14a05b 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -212,7 +212,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index d76800f6da5..37273ee4d1d 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -243,7 +243,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; From 5f5c284af750111839586ed763b1b6b77a5bb078 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Thu, 2 Dec 2021 18:20:06 +0100 Subject: [PATCH 0193/1091] Fixes https://github.com/Dolibarr/dolibarr/issues/19541 --- htdocs/expensereport/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 8880a60f351..38f7703f744 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1098,6 +1098,7 @@ if (empty($reshook)) { $arrayoffiles = GETPOST('attachfile', 'array'); if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $entityprefix = ($conf->entity != '1') ? $conf->entity.'/' : ''; $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); From b2384190204b1f8eaacb7cfad91b0c8eff7bf485 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 13:39:06 +0100 Subject: [PATCH 0194/1091] Clean code --- htdocs/admin/system/xdebug.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index fd10aad05e8..8c3a70ff6ec 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -73,10 +73,10 @@ if (function_exists('socket_create')) { print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."
    \n"; print "
    \n"; - echo "To run a debug session, add parameter
    "; - echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; - echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; - echo "* XDEBUG_PROFILE=aname on each URL.
    "; + print "To run a debug session, add parameter
    "; + print "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; + print "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; + print "* XDEBUG_PROFILE=aname on each URL.
    "; print "
    "; print "Test debugger server (Eclipse for example):
    \n"; @@ -89,12 +89,12 @@ if (function_exists('socket_create')) { //$client = socket_accept($sock); $client = socket_connect($socket, $address, $port); if ($client) { - echo "Connection established: ".$client." - address=".$address." port=".$port."
    \n"; - echo "There is a Remote debug server at this address.
    \n"; - echo "
    \n"; - echo "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n"; - echo "your php.ini file with this :
    \n"; - echo '\n"; print "

    \n"; - echo 'Then check in your debug server (Eclipse), you have setup:
    + print 'Then check in your debug server (Eclipse), you have setup:
    XDebug with same port than in php.ini
    Allow Remote debug=yes or prompt
    '."\n"; print "
    \n"; } else { print socket_strerror(socket_last_error()); - echo "Failed to connect to address=".$address." port=".$port."
    \n"; - echo "There is no Remote debug server at this address.\n"; + print " - Failed to connect to address=".$address." port=".$port."
    \n"; + print "There is no Remote debug server at this address.\n"; } socket_close($socket); } else { From 0e7d23e169169816c67bb6e9946db9780e89ea0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 14:14:13 +0100 Subject: [PATCH 0195/1091] Fix constraint and loading on module activation. --- htdocs/core/modules/DolibarrModules.class.php | 50 ++++++++++++++++--- htdocs/core/modules/modHRM.class.php | 6 +-- .../tables/llx_hrm_evaluationdet-hrm.key.sql | 2 +- .../mysql/tables/llx_hrm_skilldet-hrm.key.sql | 2 +- .../tables/llx_hrm_skillrank-hrm.key.sql | 2 +- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 9ecb73234de..1ed58b2905a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1049,15 +1049,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Create tables and keys required by module. - * Files module.sql and module.key.sql with create table and create keys - * commands must be stored in directory reldir='/module/sql/' - * This function is called by this->init + * Create tables and keys required by module: + * - Files module.sql files with create table instructions + * - Then files modules.key.sql with create keys instructions + * - Then data_xxx.sql (usualy provided by external modules only) + * - Then update_xxx.sql (usualy provided by external modules only) + * Files must be stored in directory defined by reldir (Example: '/install/mysql/tables' or '/module/sql/') + * This function is usually called by the this->init of module descriptors. * - * @param string $reldir Relative directory where to scan files - * @return int <=0 if KO, >0 if OK + * @param string $reldir Relative directory where to scan files. Example: '/install/mysql/tables' or '/module/sql/' + * @param string $onlywithsuffix Only with the defined suffix + * @return int <=0 if KO, >0 if OK */ - protected function _load_tables($reldir) + protected function _load_tables($reldir, $onlywithsuffix = '') { // phpcs:enable global $conf; @@ -1088,6 +1092,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1105,6 +1117,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1122,6 +1142,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1139,6 +1167,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 8feb6bd7ac0..a72479115c5 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -56,7 +56,7 @@ class modHRM extends DolibarrModules // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "HRM"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. @@ -268,10 +268,10 @@ class modHRM extends DolibarrModules // Permissions $this->remove($options); - /*$result = $this->_load_tables('/hrm/sql/'); + $result = $this->_load_tables('/install/mysql/tables/', 'hrm'); if ($result < 0) { return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') - }*/ + } $sql = array(); diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql index 05309ce57e2..5a3bbc844c2 100644 --- a/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql @@ -25,5 +25,5 @@ ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_evaluation --ALTER TABLE llx_hrm_evaluationdet ADD UNIQUE INDEX uk_hrm_evaluationdet_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_evaluation FOREIGN KEY (fk_evaluation) REFERENCES llx_hrm_evaluation(rowid); diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql index 289276e07b5..00dd26e6817 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql @@ -23,5 +23,5 @@ ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREI --ALTER TABLE llx_hrm_skilldet ADD UNIQUE INDEX uk_hrm_skilldet_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_skill FOREIGN KEY (fk_skill) REFERENCES llx_hrm_skill(rowid); diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql index 11d89b0187c..c8cc19641b2 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql @@ -23,5 +23,5 @@ ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOR --ALTER TABLE llx_hrm_skillrank ADD UNIQUE INDEX uk_hrm_skillrank_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_skill FOREIGN KEY (fk_skill) REFERENCES llx_hrm_skill(rowid); From 1ca199d7962505f92be5af52a11d409385bda992 Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 7 Dec 2021 17:11:34 +0100 Subject: [PATCH 0196/1091] FIX: Update swiftmailer librairies --- .../EmailValidator/EmailLexer.php | 74 ++- .../EmailValidator/EmailParser.php | 39 +- .../EmailValidator/EmailValidator.php | 10 +- .../Exception/DomainAcceptsNoMail.php | 9 + .../Exception/ExpectingQPair.php | 2 +- .../Exception/LocalOrReservedDomain.php | 9 + .../EmailValidator/Exception/NoDNSRecord.php | 2 - .../Exception/UnclosedComment.php | 2 +- .../EmailValidator/Parser/DomainPart.php | 125 ++++- .../EmailValidator/Parser/LocalPart.php | 25 +- .../EmailValidator/Parser/Parser.php | 40 +- .../Validation/DNSCheckValidation.php | 129 ++++- .../Exception/EmptyValidationList.php | 3 + .../Validation/MultipleErrors.php | 8 +- .../Validation/MultipleValidationWithAnd.php | 22 +- .../Validation/NoRFCWarningsValidation.php | 5 +- .../Validation/RFCValidation.php | 4 +- .../Validation/SpoofCheckValidation.php | 8 +- .../EmailValidator/Warning/QuotedPart.php | 4 + .../EmailValidator/Warning/QuotedString.php | 4 + .../EmailValidator/Warning/Warning.php | 23 +- .../Doctrine/Common/Lexer/AbstractLexer.php | 5 + .../swiftmailer/lib/classes/Swift.php | 9 +- .../lib/classes/Swift/AddressEncoder.php | 25 + .../AddressEncoder/IdnAddressEncoder.php | 50 ++ .../AddressEncoder/Utf8AddressEncoder.php | 36 ++ .../classes/Swift/AddressEncoderException.php | 32 ++ .../lib/classes/Swift/Attachment.php | 11 +- .../AbstractFilterableInputStream.php | 15 +- .../Swift/ByteStream/ArrayByteStream.php | 20 +- .../Swift/ByteStream/FileByteStream.php | 14 +- .../ByteStream/TemporaryFileByteStream.php | 14 +- .../GenericFixedWidthReader.php | 2 +- .../Swift/CharacterReader/UsAsciiReader.php | 4 +- .../Swift/CharacterReader/Utf8Reader.php | 22 +- .../SimpleCharacterReaderFactory.php | 34 +- .../lib/classes/Swift/CharacterStream.php | 2 - .../CharacterStream/ArrayCharacterStream.php | 40 +- .../CharacterStream/NgCharacterStream.php | 17 +- .../lib/classes/Swift/DependencyContainer.php | 62 ++- .../lib/classes/Swift/EmbeddedFile.php | 4 +- .../classes/Swift/Encoder/Base64Encoder.php | 2 +- .../lib/classes/Swift/Encoder/QpEncoder.php | 34 +- .../classes/Swift/Encoder/Rfc2231Encoder.php | 8 +- .../lib/classes/Swift/Events/CommandEvent.php | 9 +- .../classes/Swift/Events/CommandListener.php | 2 - .../classes/Swift/Events/EventDispatcher.php | 25 +- .../lib/classes/Swift/Events/EventObject.php | 2 - .../classes/Swift/Events/ResponseEvent.php | 5 +- .../classes/Swift/Events/ResponseListener.php | 2 - .../lib/classes/Swift/Events/SendEvent.php | 5 +- .../lib/classes/Swift/Events/SendListener.php | 4 - .../Swift/Events/SimpleEventDispatcher.php | 56 +- .../Swift/Events/TransportChangeListener.php | 8 - .../Swift/Events/TransportExceptionEvent.php | 3 - .../Events/TransportExceptionListener.php | 2 - .../lib/classes/Swift/FailoverTransport.php | 6 +- .../lib/classes/Swift/FileSpool.php | 8 +- .../lib/classes/Swift/Filterable.php | 3 +- .../lib/classes/Swift/InputByteStream.php | 4 +- .../lib/classes/Swift/IoException.php | 5 +- .../lib/classes/Swift/KeyCache.php | 7 +- .../classes/Swift/KeyCache/ArrayKeyCache.php | 33 +- .../classes/Swift/KeyCache/DiskKeyCache.php | 36 +- .../Swift/KeyCache/KeyCacheInputStream.php | 4 - .../classes/Swift/KeyCache/NullKeyCache.php | 12 +- .../KeyCache/SimpleKeyCacheInputStream.php | 4 - .../classes/Swift/LoadBalancedTransport.php | 6 +- .../swiftmailer/lib/classes/Swift/Mailer.php | 8 +- .../Swift/Mailer/ArrayRecipientIterator.php | 4 +- .../lib/classes/Swift/MemorySpool.php | 2 +- .../swiftmailer/lib/classes/Swift/Message.php | 45 +- .../lib/classes/Swift/Mime/Attachment.php | 15 +- .../ContentEncoder/Base64ContentEncoder.php | 21 +- .../ContentEncoder/NativeQpContentEncoder.php | 20 +- .../ContentEncoder/NullContentEncoder.php | 79 +++ .../ContentEncoder/PlainContentEncoder.php | 24 +- .../Mime/ContentEncoder/QpContentEncoder.php | 10 +- .../ContentEncoder/QpContentEncoderProxy.php | 6 +- .../Mime/ContentEncoder/RawContentEncoder.php | 9 +- .../lib/classes/Swift/Mime/EmbeddedFile.php | 8 +- .../classes/Swift/Mime/EncodingObserver.php | 2 - .../lib/classes/Swift/Mime/Header.php | 2 +- .../HeaderEncoder/Base64HeaderEncoder.php | 2 +- .../Mime/HeaderEncoder/QpHeaderEncoder.php | 6 +- .../Swift/Mime/Headers/AbstractHeader.php | 61 ++- .../classes/Swift/Mime/Headers/DateHeader.php | 2 - .../Mime/Headers/IdentificationHeader.php | 25 +- .../Swift/Mime/Headers/MailboxHeader.php | 25 +- .../Swift/Mime/Headers/OpenDKIMHeader.php | 4 +- .../Mime/Headers/ParameterizedHeader.php | 28 +- .../classes/Swift/Mime/Headers/PathHeader.php | 15 +- .../Swift/Mime/Headers/UnstructuredHeader.php | 3 +- .../lib/classes/Swift/Mime/IdGenerator.php | 7 +- .../lib/classes/Swift/Mime/MimePart.php | 23 +- .../Swift/Mime/SimpleHeaderFactory.php | 24 +- .../classes/Swift/Mime/SimpleHeaderSet.php | 88 ++-- .../lib/classes/Swift/Mime/SimpleMessage.php | 65 +-- .../classes/Swift/Mime/SimpleMimeEntity.php | 99 ++-- .../lib/classes/Swift/MimePart.php | 4 +- .../lib/classes/Swift/NullTransport.php | 4 +- .../classes/Swift/Plugins/AntiFloodPlugin.php | 4 - .../Swift/Plugins/BandwidthMonitorPlugin.php | 18 +- .../classes/Swift/Plugins/DecoratorPlugin.php | 28 +- .../Swift/Plugins/ImpersonatePlugin.php | 4 - .../classes/Swift/Plugins/LoggerPlugin.php | 24 +- .../Swift/Plugins/Loggers/ArrayLogger.php | 6 +- .../classes/Swift/Plugins/MessageLogger.php | 14 +- .../Swift/Plugins/PopBeforeSmtpPlugin.php | 37 +- .../Swift/Plugins/RedirectingPlugin.php | 26 +- .../lib/classes/Swift/Plugins/Reporter.php | 5 +- .../classes/Swift/Plugins/ReporterPlugin.php | 10 +- .../Swift/Plugins/Reporters/HitReporter.php | 11 +- .../Swift/Plugins/Reporters/HtmlReporter.php | 5 +- .../classes/Swift/Plugins/ThrottlerPlugin.php | 6 +- .../lib/classes/Swift/Preferences.php | 2 +- .../lib/classes/Swift/SendmailTransport.php | 4 +- .../swiftmailer/lib/classes/Swift/Signer.php | 1 - .../lib/classes/Swift/Signers/BodySigner.php | 2 - .../lib/classes/Swift/Signers/DKIMSigner.php | 78 ++- .../classes/Swift/Signers/DomainKeySigner.php | 46 +- .../classes/Swift/Signers/HeaderSigner.php | 4 - .../classes/Swift/Signers/OpenDKIMSigner.php | 28 +- .../lib/classes/Swift/Signers/SMimeSigner.php | 485 +++++++++++------- .../lib/classes/Swift/SmtpTransport.php | 17 +- .../lib/classes/Swift/SpoolTransport.php | 6 +- .../ByteArrayReplacementFilter.php | 44 +- .../StringReplacementFilterFactory.php | 6 +- .../lib/classes/Swift/SwiftException.php | 5 +- .../lib/classes/Swift/Transport.php | 7 +- .../Swift/Transport/AbstractSmtpTransport.php | 164 +++--- .../Esmtp/Auth/CramMd5Authenticator.php | 28 +- .../Esmtp/Auth/LoginAuthenticator.php | 18 +- .../Esmtp/Auth/NTLMAuthenticator.php | 123 ++--- .../Esmtp/Auth/PlainAuthenticator.php | 16 +- .../Esmtp/Auth/XOAuth2Authenticator.php | 14 +- .../Swift/Transport/Esmtp/AuthHandler.php | 47 +- .../Swift/Transport/Esmtp/Authenticator.php | 9 +- .../Transport/Esmtp/EightBitMimeHandler.php | 113 ++++ .../Swift/Transport/Esmtp/SmtpUtf8Handler.php | 107 ++++ .../classes/Swift/Transport/EsmtpHandler.php | 4 +- .../Swift/Transport/EsmtpTransport.php | 101 ++-- .../Swift/Transport/FailoverTransport.php | 15 +- .../lib/classes/Swift/Transport/IoBuffer.php | 2 - .../Swift/Transport/LoadBalancedTransport.php | 23 +- .../classes/Swift/Transport/NullTransport.php | 11 +- .../Swift/Transport/SendmailTransport.php | 31 +- .../lib/classes/Swift/Transport/SmtpAgent.php | 2 +- .../Swift/Transport/SpoolTransport.php | 7 +- .../classes/Swift/Transport/StreamBuffer.php | 65 ++- .../lib/classes/Swift/TransportException.php | 5 +- .../lib/dependency_maps/cache_deps.php | 4 +- .../lib/dependency_maps/mime_deps.php | 62 +-- .../lib/dependency_maps/transport_deps.php | 56 +- .../includes/swiftmailer/lib/mime_types.php | 4 +- .../lib/swiftmailer_generate_mimes_config.php | 43 +- 156 files changed, 2370 insertions(+), 1637 deletions(-) create mode 100644 htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php create mode 100644 htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/LocalOrReservedDomain.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/IdnAddressEncoder.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder/Utf8AddressEncoder.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoderException.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NullContentEncoder.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php create mode 100644 htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php index 882c968154d..59dcd5876fd 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailLexer.php @@ -13,6 +13,8 @@ class EmailLexer extends AbstractLexer const S_BACKSLASH = 92; const S_DOT = 46; const S_DQUOTE = 34; + const S_SQUOTE = 39; + const S_BACKTICK = 96; const S_OPENPARENTHESIS = 49; const S_CLOSEPARENTHESIS = 261; const S_OPENBRACKET = 262; @@ -58,6 +60,8 @@ class EmailLexer extends AbstractLexer '/' => self::S_SLASH, ',' => self::S_COMMA, '.' => self::S_DOT, + "'" => self::S_SQUOTE, + "`" => self::S_BACKTICK, '"' => self::S_DQUOTE, '-' => self::S_HYPHEN, '::' => self::S_DOUBLECOLON, @@ -73,25 +77,73 @@ class EmailLexer extends AbstractLexer '\0' => self::C_NUL, ); + /** + * @var bool + */ protected $hasInvalidTokens = false; - protected $previous; + /** + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int}|array + */ + protected $previous = []; + /** + * The last matched/seen token. + * + * @var array + * + * @psalm-var array{value:string, type:null|int, position:int} + */ + public $token; + + /** + * The next token in the input. + * + * @var array|null + */ + public $lookahead; + + /** + * @psalm-var array{value:'', type:null, position:0} + */ + private static $nullToken = [ + 'value' => '', + 'type' => null, + 'position' => 0, + ]; + + public function __construct() + { + $this->previous = $this->token = self::$nullToken; + $this->lookahead = null; + } + + /** + * @return void + */ public function reset() { $this->hasInvalidTokens = false; parent::reset(); + $this->previous = $this->token = self::$nullToken; } + /** + * @return bool + */ public function hasInvalidTokens() { return $this->hasInvalidTokens; } /** - * @param $type + * @param int $type * @throws \UnexpectedValueException * @return boolean + * + * @psalm-suppress InvalidScalarArgument */ public function find($type) { @@ -107,7 +159,7 @@ class EmailLexer extends AbstractLexer /** * getPrevious * - * @return array token + * @return array */ public function getPrevious() { @@ -122,8 +174,10 @@ class EmailLexer extends AbstractLexer public function moveNext() { $this->previous = $this->token; + $hasNext = parent::moveNext(); + $this->token = $this->token ?: self::$nullToken; - return parent::moveNext(); + return $hasNext; } /** @@ -179,6 +233,11 @@ class EmailLexer extends AbstractLexer return self::GENERIC; } + /** + * @param string $value + * + * @return bool + */ protected function isValid($value) { if (isset($this->charValue[$value])) { @@ -189,7 +248,7 @@ class EmailLexer extends AbstractLexer } /** - * @param $value + * @param string $value * @return bool */ protected function isNullType($value) @@ -202,7 +261,7 @@ class EmailLexer extends AbstractLexer } /** - * @param $value + * @param string $value * @return bool */ protected function isUTF8Invalid($value) @@ -214,6 +273,9 @@ class EmailLexer extends AbstractLexer return false; } + /** + * @return string + */ protected function getModifiers() { return 'iu'; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php index d0627d82410..6b7bad66927 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailParser.php @@ -17,11 +17,33 @@ class EmailParser { const EMAIL_MAX_LENGTH = 254; - protected $warnings; + /** + * @var array + */ + protected $warnings = []; + + /** + * @var string + */ protected $domainPart = ''; + + /** + * @var string + */ protected $localPart = ''; + /** + * @var EmailLexer + */ protected $lexer; + + /** + * @var LocalPart + */ protected $localPartParser; + + /** + * @var DomainPart + */ protected $domainPartParser; public function __construct(EmailLexer $lexer) @@ -29,11 +51,10 @@ class EmailParser $this->lexer = $lexer; $this->localPartParser = new LocalPart($this->lexer); $this->domainPartParser = new DomainPart($this->lexer); - $this->warnings = new \SplObjectStorage(); } /** - * @param $str + * @param string $str * @return array */ public function parse($str) @@ -57,6 +78,9 @@ class EmailParser return array('local' => $this->localPart, 'domain' => $this->domainPart); } + /** + * @return Warning\Warning[] + */ public function getWarnings() { $localPartWarnings = $this->localPartParser->getWarnings(); @@ -68,11 +92,17 @@ class EmailParser return $this->warnings; } + /** + * @return string + */ public function getParsedDomainPart() { return $this->domainPart; } + /** + * @param string $email + */ protected function setParts($email) { $parts = explode('@', $email); @@ -80,6 +110,9 @@ class EmailParser $this->localPart = $parts[0]; } + /** + * @return bool + */ protected function hasAtToken() { $this->lexer->moveNext(); diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php index 44b4b93c6bb..a30f21dcd30 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/EmailValidator.php @@ -13,12 +13,12 @@ class EmailValidator private $lexer; /** - * @var array + * @var Warning\Warning[] */ - protected $warnings; + protected $warnings = []; /** - * @var InvalidEmail + * @var InvalidEmail|null */ protected $error; @@ -28,7 +28,7 @@ class EmailValidator } /** - * @param $email + * @param string $email * @param EmailValidation $emailValidation * @return bool */ @@ -58,7 +58,7 @@ class EmailValidator } /** - * @return InvalidEmail + * @return InvalidEmail|null */ public function getError() { diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php new file mode 100644 index 00000000000..40a99705ce9 --- /dev/null +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Exception/DomainAcceptsNoMail.php @@ -0,0 +1,9 @@ +lexer->moveNext(); - if ($this->lexer->token['type'] === EmailLexer::S_DOT) { - throw new DotAtStart(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_EMPTY) { - throw new NoDomainPart(); - } - if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { - throw new DomainHyphened(); - } - - if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { - $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); - $this->parseDomainComments(); - } + $this->performDomainStartChecks(); $domain = $this->doParseDomainPart(); @@ -77,11 +68,50 @@ class DomainPart extends Parser $this->domainPart = $domain; } + private function performDomainStartChecks() + { + $this->checkInvalidTokensAfterAT(); + $this->checkEmptyDomain(); + + if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) { + $this->warnings[DeprecatedComment::CODE] = new DeprecatedComment(); + $this->parseDomainComments(); + } + } + + private function checkEmptyDomain() + { + $thereIsNoDomain = $this->lexer->token['type'] === EmailLexer::S_EMPTY || + ($this->lexer->token['type'] === EmailLexer::S_SP && + !$this->lexer->isNextToken(EmailLexer::GENERIC)); + + if ($thereIsNoDomain) { + throw new NoDomainPart(); + } + } + + private function checkInvalidTokensAfterAT() + { + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + throw new DotAtStart(); + } + if ($this->lexer->token['type'] === EmailLexer::S_HYPHEN) { + throw new DomainHyphened(); + } + } + + /** + * @return string + */ public function getDomainPart() { return $this->domainPart; } + /** + * @param string $addressLiteral + * @param int $maxGroups + */ public function checkIPV6Tag($addressLiteral, $maxGroups = 8) { $prev = $this->lexer->getPrevious(); @@ -125,9 +155,13 @@ class DomainPart extends Parser } } + /** + * @return string + */ protected function doParseDomainPart() { $domain = ''; + $label = ''; $openedParenthesis = 0; do { $prev = $this->lexer->getPrevious(); @@ -158,7 +192,12 @@ class DomainPart extends Parser $this->parseDomainLiteral(); } - $this->checkLabelLength($prev); + if ($this->lexer->token['type'] === EmailLexer::S_DOT) { + $this->checkLabelLength($label); + $label = ''; + } else { + $label .= $this->lexer->token['value']; + } if ($this->isFWS()) { $this->parseFWS(); @@ -166,12 +205,17 @@ class DomainPart extends Parser $domain .= $this->lexer->token['value']; $this->lexer->moveNext(); - } while ($this->lexer->token); + if ($this->lexer->token['type'] === EmailLexer::S_SP) { + throw new CharNotAllowed(); + } + } while (null !== $this->lexer->token['type']); + + $this->checkLabelLength($label); return $domain; } - private function checkNotAllowedChars($token) + private function checkNotAllowedChars(array $token) { $notAllowed = [EmailLexer::S_BACKSLASH => true, EmailLexer::S_SLASH=> true]; if (isset($notAllowed[$token['type']])) { @@ -179,6 +223,9 @@ class DomainPart extends Parser } } + /** + * @return string|false + */ protected function parseDomainLiteral() { if ($this->lexer->isNextToken(EmailLexer::S_COLON)) { @@ -195,6 +242,9 @@ class DomainPart extends Parser return $this->doParseDomainLiteral(); } + /** + * @return string|false + */ protected function doParseDomainLiteral() { $IPv6TAG = false; @@ -262,6 +312,11 @@ class DomainPart extends Parser return $addressLiteral; } + /** + * @param string $addressLiteral + * + * @return string|false + */ protected function checkIPV4Tag($addressLiteral) { $matchesIP = array(); @@ -279,16 +334,18 @@ class DomainPart extends Parser return false; } // Convert IPv4 part to IPv6 format for further testing - $addressLiteral = substr($addressLiteral, 0, $index) . '0:0'; + $addressLiteral = substr($addressLiteral, 0, (int) $index) . '0:0'; } return $addressLiteral; } - protected function checkDomainPartExceptions($prev) + protected function checkDomainPartExceptions(array $prev) { $invalidDomainTokens = array( EmailLexer::S_DQUOTE => true, + EmailLexer::S_SQUOTE => true, + EmailLexer::S_BACKTICK => true, EmailLexer::S_SEMICOLON => true, EmailLexer::S_GREATERTHAN => true, EmailLexer::S_LOWERTHAN => true, @@ -320,6 +377,9 @@ class DomainPart extends Parser } } + /** + * @return bool + */ protected function hasBrackets() { if ($this->lexer->token['type'] !== EmailLexer::S_OPENBRACKET) { @@ -335,16 +395,31 @@ class DomainPart extends Parser return true; } - protected function checkLabelLength($prev) + /** + * @param string $label + */ + protected function checkLabelLength($label) { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && - $prev['type'] === EmailLexer::GENERIC && - strlen($prev['value']) > 63 - ) { + if ($this->isLabelTooLong($label)) { $this->warnings[LabelTooLong::CODE] = new LabelTooLong(); } } + /** + * @param string $label + * @return bool + */ + private function isLabelTooLong($label) + { + if (preg_match('/[^\x00-\x7F]/', $label)) { + idn_to_ascii($label, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46, $idnaInfo); + + return (bool) ($idnaInfo['errors'] & IDNA_ERROR_LABEL_TOO_LONG); + } + + return strlen($label) > self::LABEL_MAX_LENGTH; + } + protected function parseDomainComments() { $this->isUnclosedComment(); diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php index 8ab16ab4a1f..3c21f34ac07 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/LocalPart.php @@ -5,7 +5,6 @@ namespace Egulias\EmailValidator\Parser; use Egulias\EmailValidator\Exception\DotAtEnd; use Egulias\EmailValidator\Exception\DotAtStart; use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\EmailValidator; use Egulias\EmailValidator\Exception\ExpectingAT; use Egulias\EmailValidator\Exception\ExpectingATEXT; use Egulias\EmailValidator\Exception\UnclosedQuotedString; @@ -20,9 +19,10 @@ class LocalPart extends Parser $parseDQuote = true; $closingQuote = false; $openedParenthesis = 0; + $totalLength = 0; - while ($this->lexer->token['type'] !== EmailLexer::S_AT && $this->lexer->token) { - if ($this->lexer->token['type'] === EmailLexer::S_DOT && !$this->lexer->getPrevious()) { + while ($this->lexer->token['type'] !== EmailLexer::S_AT && null !== $this->lexer->token['type']) { + if ($this->lexer->token['type'] === EmailLexer::S_DOT && null === $this->lexer->getPrevious()['type']) { throw new DotAtStart(); } @@ -35,12 +35,13 @@ class LocalPart extends Parser $this->parseComments(); $openedParenthesis += $this->getOpenedParenthesis(); } + if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { if ($openedParenthesis === 0) { throw new UnopenedComment(); - } else { - $openedParenthesis--; } + + $openedParenthesis--; } $this->checkConsecutiveDots(); @@ -58,15 +59,18 @@ class LocalPart extends Parser $this->parseFWS(); } + $totalLength += strlen($this->lexer->token['value']); $this->lexer->moveNext(); } - $prev = $this->lexer->getPrevious(); - if (strlen($prev['value']) > LocalTooLong::LOCAL_PART_LENGTH) { + if ($totalLength > LocalTooLong::LOCAL_PART_LENGTH) { $this->warnings[LocalTooLong::CODE] = new LocalTooLong(); } } + /** + * @return bool + */ protected function parseDoubleQuote() { $parseAgain = true; @@ -86,7 +90,7 @@ class LocalPart extends Parser $this->lexer->moveNext(); - while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && $this->lexer->token) { + while ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE && null !== $this->lexer->token['type']) { $parseAgain = false; if (isset($special[$this->lexer->token['type']]) && $setSpecialsWarning) { $this->warnings[CFWSWithFWS::CODE] = new CFWSWithFWS(); @@ -118,7 +122,10 @@ class LocalPart extends Parser return $parseAgain; } - protected function isInvalidToken($token, $closingQuote) + /** + * @param bool $closingQuote + */ + protected function isInvalidToken(array $token, $closingQuote) { $forbidden = array( EmailLexer::S_COMMA, diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php index e5042e1a859..ccdc93889a2 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Parser/Parser.php @@ -8,7 +8,7 @@ use Egulias\EmailValidator\Exception\ConsecutiveDot; use Egulias\EmailValidator\Exception\CRLFAtTheEnd; use Egulias\EmailValidator\Exception\CRLFX2; use Egulias\EmailValidator\Exception\CRNoLF; -use Egulias\EmailValidator\Exception\ExpectedQPair; +use Egulias\EmailValidator\Exception\ExpectingQPair; use Egulias\EmailValidator\Exception\ExpectingATEXT; use Egulias\EmailValidator\Exception\ExpectingCTEXT; use Egulias\EmailValidator\Exception\UnclosedComment; @@ -21,8 +21,19 @@ use Egulias\EmailValidator\Warning\QuotedString; abstract class Parser { + /** + * @var array + */ protected $warnings = []; + + /** + * @var EmailLexer + */ protected $lexer; + + /** + * @var int + */ protected $openedParenthesis = 0; public function __construct(EmailLexer $lexer) @@ -30,11 +41,17 @@ abstract class Parser $this->lexer = $lexer; } + /** + * @return \Egulias\EmailValidator\Warning\Warning[] + */ public function getWarnings() { return $this->warnings; } + /** + * @param string $str + */ abstract public function parse($str); /** @return int */ @@ -50,7 +67,7 @@ abstract class Parser { if (!($this->lexer->token['type'] === EmailLexer::INVALID || $this->lexer->token['type'] === EmailLexer::C_DEL)) { - throw new ExpectedQPair(); + throw new ExpectingQPair(); } $this->warnings[QuotedPart::CODE] = @@ -80,6 +97,9 @@ abstract class Parser } } + /** + * @return bool + */ protected function isUnclosedComment() { try { @@ -122,6 +142,9 @@ abstract class Parser } } + /** + * @return bool + */ protected function isFWS() { if ($this->escaped()) { @@ -140,11 +163,14 @@ abstract class Parser return false; } + /** + * @return bool + */ protected function escaped() { $previous = $this->lexer->getPrevious(); - if ($previous['type'] === EmailLexer::S_BACKSLASH + if ($previous && $previous['type'] === EmailLexer::S_BACKSLASH && $this->lexer->token['type'] !== EmailLexer::GENERIC ) { @@ -154,6 +180,9 @@ abstract class Parser return false; } + /** + * @return bool + */ protected function warnEscaping() { if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) { @@ -174,6 +203,11 @@ abstract class Parser } + /** + * @param bool $hasClosingQuote + * + * @return bool + */ protected function checkDQUOTE($hasClosingQuote) { if ($this->lexer->token['type'] !== EmailLexer::S_DQUOTE) { diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php index ecca1dd976a..491082a590f 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/DNSCheckValidation.php @@ -4,6 +4,8 @@ namespace Egulias\EmailValidator\Validation; use Egulias\EmailValidator\EmailLexer; use Egulias\EmailValidator\Exception\InvalidEmail; +use Egulias\EmailValidator\Exception\LocalOrReservedDomain; +use Egulias\EmailValidator\Exception\DomainAcceptsNoMail; use Egulias\EmailValidator\Warning\NoDNSMXRecord; use Egulias\EmailValidator\Exception\NoDNSRecord; @@ -15,10 +17,23 @@ class DNSCheckValidation implements EmailValidation private $warnings = []; /** - * @var InvalidEmail + * @var InvalidEmail|null */ private $error; + /** + * @var array + */ + private $mxRecords = []; + + + public function __construct() + { + if (!function_exists('idn_to_ascii')) { + throw new \LogicException(sprintf('The %s class requires the Intl extension.', __CLASS__)); + } + } + public function isValid($email, EmailLexer $emailLexer) { // use the input to check DNS if we cannot extract something similar to a domain @@ -29,7 +44,40 @@ class DNSCheckValidation implements EmailValidation $host = substr($email, $lastAtPos + 1); } - return $this->checkDNS($host); + // Get the domain parts + $hostParts = explode('.', $host); + + // Reserved Top Level DNS Names (https://tools.ietf.org/html/rfc2606#section-2), + // mDNS and private DNS Namespaces (https://tools.ietf.org/html/rfc6762#appendix-G) + $reservedTopLevelDnsNames = [ + // Reserved Top Level DNS Names + 'test', + 'example', + 'invalid', + 'localhost', + + // mDNS + 'local', + + // Private DNS Namespaces + 'intranet', + 'internal', + 'private', + 'corp', + 'home', + 'lan', + ]; + + $isLocalDomain = count($hostParts) <= 1; + $isReservedTopLevel = in_array($hostParts[(count($hostParts) - 1)], $reservedTopLevelDnsNames, true); + + // Exclude reserved top level DNS names + if ($isLocalDomain || $isReservedTopLevel) { + $this->error = new LocalOrReservedDomain(); + return false; + } + + return $this->checkDns($host); } public function getError() @@ -42,20 +90,77 @@ class DNSCheckValidation implements EmailValidation return $this->warnings; } - protected function checkDNS($host) + /** + * @param string $host + * + * @return bool + */ + protected function checkDns($host) { - $host = rtrim($host, '.') . '.'; + $variant = INTL_IDNA_VARIANT_UTS46; - $Aresult = true; - $MXresult = checkdnsrr($host, 'MX'); + $host = rtrim(idn_to_ascii($host, IDNA_DEFAULT, $variant), '.') . '.'; - if (!$MXresult) { - $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); - $Aresult = checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA'); - if (!$Aresult) { - $this->error = new NoDNSRecord(); + return $this->validateDnsRecords($host); + } + + + /** + * Validate the DNS records for given host. + * + * @param string $host A set of DNS records in the format returned by dns_get_record. + * + * @return bool True on success. + */ + private function validateDnsRecords($host) + { + // Get all MX, A and AAAA DNS records for host + // Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149 + $dnsRecords = @dns_get_record($host, DNS_MX + DNS_A + DNS_AAAA); + + + // No MX, A or AAAA DNS records + if (empty($dnsRecords)) { + $this->error = new NoDNSRecord(); + return false; + } + + // For each DNS record + foreach ($dnsRecords as $dnsRecord) { + if (!$this->validateMXRecord($dnsRecord)) { + return false; } } - return $MXresult || $Aresult; + + // No MX records (fallback to A or AAAA records) + if (empty($this->mxRecords)) { + $this->warnings[NoDNSMXRecord::CODE] = new NoDNSMXRecord(); + } + + return true; + } + + /** + * Validate an MX record + * + * @param array $dnsRecord Given DNS record. + * + * @return bool True if valid. + */ + private function validateMxRecord($dnsRecord) + { + if ($dnsRecord['type'] !== 'MX') { + return true; + } + + // "Null MX" record indicates the domain accepts no mail (https://tools.ietf.org/html/rfc7505) + if (empty($dnsRecord['target']) || $dnsRecord['target'] === '.') { + $this->error = new DomainAcceptsNoMail(); + return false; + } + + $this->mxRecords[] = $dnsRecord; + + return true; } } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php index 775ad16fb51..ee7c41aa033 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/Exception/EmptyValidationList.php @@ -6,6 +6,9 @@ use Exception; class EmptyValidationList extends \InvalidArgumentException { + /** + * @param int $code + */ public function __construct($code = 0, Exception $previous = null) { parent::__construct("Empty validation list is not allowed", $code, $previous); diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php index d5e87d8ce06..3be59732664 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleErrors.php @@ -9,16 +9,22 @@ class MultipleErrors extends InvalidEmail const CODE = 999; const REASON = "Accumulated errors for multiple validations"; /** - * @var array + * @var InvalidEmail[] */ private $errors = []; + /** + * @param InvalidEmail[] $errors + */ public function __construct(array $errors) { $this->errors = $errors; parent::__construct(); } + /** + * @return InvalidEmail[] + */ public function getErrors() { return $this->errors; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php index 43fa42a64b7..feb224023da 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/MultipleValidationWithAnd.php @@ -30,12 +30,12 @@ class MultipleValidationWithAnd implements EmailValidation private $warnings = []; /** - * @var MultipleErrors + * @var MultipleErrors|null */ private $error; /** - * @var bool + * @var int */ private $mode; @@ -62,7 +62,8 @@ class MultipleValidationWithAnd implements EmailValidation $errors = []; foreach ($this->validations as $validation) { $emailLexer->reset(); - $result = $result && $validation->isValid($email, $emailLexer); + $validationResult = $validation->isValid($email, $emailLexer); + $result = $result && $validationResult; $this->warnings = array_merge($this->warnings, $validation->getWarnings()); $errors = $this->addNewError($validation->getError(), $errors); @@ -78,6 +79,12 @@ class MultipleValidationWithAnd implements EmailValidation return $result; } + /** + * @param \Egulias\EmailValidator\Exception\InvalidEmail|null $possibleError + * @param \Egulias\EmailValidator\Exception\InvalidEmail[] $errors + * + * @return \Egulias\EmailValidator\Exception\InvalidEmail[] + */ private function addNewError($possibleError, array $errors) { if (null !== $possibleError) { @@ -87,13 +94,20 @@ class MultipleValidationWithAnd implements EmailValidation return $errors; } + /** + * @param bool $result + * + * @return bool + */ private function shouldStop($result) { return !$result && $this->mode === self::STOP_ON_ERROR; } /** - * {@inheritdoc} + * Returns the validation errors. + * + * @return MultipleErrors|null */ public function getError() { diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php index f3656b35a52..6b31e5440ec 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/NoRFCWarningsValidation.php @@ -9,7 +9,7 @@ use Egulias\EmailValidator\Validation\Error\RFCWarnings; class NoRFCWarningsValidation extends RFCValidation { /** - * @var InvalidEmail + * @var InvalidEmail|null */ private $error; @@ -22,8 +22,7 @@ class NoRFCWarningsValidation extends RFCValidation return false; } - $ret = $this->getWarnings(); - if (empty($ret)) { + if (empty($this->getWarnings())) { return true; } diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php index c4ffe35034b..8781e0b62d1 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/RFCValidation.php @@ -9,7 +9,7 @@ use Egulias\EmailValidator\Exception\InvalidEmail; class RFCValidation implements EmailValidation { /** - * @var EmailParser + * @var EmailParser|null */ private $parser; @@ -19,7 +19,7 @@ class RFCValidation implements EmailValidation private $warnings = []; /** - * @var InvalidEmail + * @var InvalidEmail|null */ private $error; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php index 4721f0d8c98..e10bfabd92f 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Validation/SpoofCheckValidation.php @@ -10,7 +10,7 @@ use \Spoofchecker; class SpoofCheckValidation implements EmailValidation { /** - * @var InvalidEmail + * @var InvalidEmail|null */ private $error; @@ -21,6 +21,9 @@ class SpoofCheckValidation implements EmailValidation } } + /** + * @psalm-suppress InvalidArgument + */ public function isValid($email, EmailLexer $emailLexer) { $checker = new Spoofchecker(); @@ -33,6 +36,9 @@ class SpoofCheckValidation implements EmailValidation return $this->error === null; } + /** + * @return InvalidEmail|null + */ public function getError() { return $this->error; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php index 7be9e6a3f25..36a4265a515 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedPart.php @@ -6,6 +6,10 @@ class QuotedPart extends Warning { const CODE = 36; + /** + * @param scalar $prevToken + * @param scalar $postToken + */ public function __construct($prevToken, $postToken) { $this->message = "Deprecated Quoted String found between $prevToken and $postToken"; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php index e9d56e1e032..817e4e84b07 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/QuotedString.php @@ -6,6 +6,10 @@ class QuotedString extends Warning { const CODE = 11; + /** + * @param scalar $prevToken + * @param scalar $postToken + */ public function __construct($prevToken, $postToken) { $this->message = "Quoted String found between $prevToken and $postToken"; diff --git a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php index ec6a365ffb7..a2ee7b0de1e 100644 --- a/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php +++ b/htdocs/includes/swiftmailer/egulias/email-validator/EmailValidator/Warning/Warning.php @@ -5,19 +5,36 @@ namespace Egulias\EmailValidator\Warning; abstract class Warning { const CODE = 0; - protected $message; - protected $rfcNumber; + /** + * @var string + */ + protected $message = ''; + + /** + * @var int + */ + protected $rfcNumber = 0; + + /** + * @return string + */ public function message() { return $this->message; } + /** + * @return int + */ public function code() { - return self::CODE; + return static::CODE; } + /** + * @return int + */ public function RFCNumber() { return $this->rfcNumber; diff --git a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php index 399a55230b0..dd3ea768e3b 100644 --- a/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php +++ b/htdocs/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php @@ -258,6 +258,11 @@ abstract class AbstractLexer $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE; $matches = preg_split($regex, $input, -1, $flags); + if (false === $matches) { + // Work around https://bugs.php.net/78122 + $matches = array(array($input, 0)); + } + foreach ($matches as $match) { // Must remain before 'value' assignment since it can change content $type = $this->getType($match[0]); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift.php b/htdocs/includes/swiftmailer/lib/classes/Swift.php index e89703eaebb..51b19c9cb4e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift.php @@ -11,15 +11,14 @@ /** * General utility class in Swift Mailer, not to be instantiated. * - * * @author Chris Corbyn */ abstract class Swift { - const VERSION = '6.0.2'; + const VERSION = '6.3.0'; public static $initialized = false; - public static $inits = array(); + public static $inits = []; /** * Registers an initializer callable that will be called the first time @@ -57,7 +56,7 @@ abstract class Swift if (self::$inits && !self::$initialized) { self::$initialized = true; foreach (self::$inits as $init) { - call_user_func($init); + \call_user_func($init); } } } @@ -74,6 +73,6 @@ abstract class Swift if (null !== $callable) { self::$inits[] = $callable; } - spl_autoload_register(array('Swift', 'autoload')); + spl_autoload_register(['Swift', 'autoload']); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php new file mode 100644 index 00000000000..a1704ffb40a --- /dev/null +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/AddressEncoder.php @@ -0,0 +1,25 @@ +address = $address; + } + + public function getAddress(): string + { + return $this->address; + } +} diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php index 1fb232c9fe6..7a1420f7986 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Attachment.php @@ -26,17 +26,14 @@ class Swift_Attachment extends Swift_Mime_Attachment */ public function __construct($data = null, $filename = null, $contentType = null) { - call_user_func_array( - array($this, 'Swift_Mime_Attachment::__construct'), + \call_user_func_array( + [$this, 'Swift_Mime_Attachment::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.attachment') ); - $this->setBody($data); + $this->setBody($data, $contentType); $this->setFilename($filename); - if ($contentType) { - $this->setContentType($contentType); - } } /** @@ -45,7 +42,7 @@ class Swift_Attachment extends Swift_Mime_Attachment * @param string $path * @param string $contentType optional * - * @return Swift_Mime_Attachment + * @return self */ public static function fromPath($path, $contentType = null) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php index bfd2c79bcbd..3a69c15f1c4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -25,7 +25,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I * * @var Swift_StreamFilter[] */ - private $filters = array(); + private $filters = []; /** * A buffer for writing. @@ -37,7 +37,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I * * @var Swift_InputByteStream[] */ - private $mirrors = array(); + private $mirrors = []; /** * Commit the given bytes to the storage medium immediately. @@ -54,8 +54,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I /** * Add a StreamFilter to this InputByteStream. * - * @param Swift_StreamFilter $filter - * @param string $key + * @param string $key */ public function addFilter(Swift_StreamFilter $filter, $key) { @@ -110,8 +109,6 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is */ public function bind(Swift_InputByteStream $is) { @@ -124,14 +121,12 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. - * - * @param Swift_InputByteStream $is */ public function unbind(Swift_InputByteStream $is) { foreach ($this->mirrors as $k => $stream) { if ($is === $stream) { - if ($this->writeBuffer !== '') { + if ('' !== $this->writeBuffer) { $stream->write($this->writeBuffer); } unset($this->mirrors[$k]); @@ -147,7 +142,7 @@ abstract class Swift_ByteStream_AbstractFilterableInputStream implements Swift_I */ public function flushBuffers() { - if ($this->writeBuffer !== '') { + if ('' !== $this->writeBuffer) { $this->doWrite($this->writeBuffer); } $this->flush(); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php index 31b85e0e02a..4f3dcc37745 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -20,7 +20,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * * @var string[] */ - private $array = array(); + private $array = []; /** * The size of the stack. @@ -41,7 +41,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * * @var Swift_InputByteStream[] */ - private $mirrors = array(); + private $mirrors = []; /** * Create a new ArrayByteStream. @@ -52,13 +52,13 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O */ public function __construct($stack = null) { - if (is_array($stack)) { + if (\is_array($stack)) { $this->array = $stack; - $this->arraySize = count($stack); - } elseif (is_string($stack)) { + $this->arraySize = \count($stack); + } elseif (\is_string($stack)) { $this->write($stack); } else { - $this->array = array(); + $this->array = []; } } @@ -102,7 +102,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O foreach ($to_add as $value) { $this->array[] = $value; } - $this->arraySize = count($this->array); + $this->arraySize = \count($this->array); foreach ($this->mirrors as $stream) { $stream->write($bytes); @@ -121,8 +121,6 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is */ public function bind(Swift_InputByteStream $is) { @@ -135,8 +133,6 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. - * - * @param Swift_InputByteStream $is */ public function unbind(Swift_InputByteStream $is) { @@ -172,7 +168,7 @@ class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_O public function flushBuffers() { $this->offset = 0; - $this->array = array(); + $this->array = []; $this->arraySize = 0; foreach ($this->mirrors as $stream) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php index 61f820e5a14..f6391219e71 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -81,7 +81,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl // If we read one byte after reaching the end of the file // feof() will return false and an empty string is returned - if ($bytes === '' && feof($fp)) { + if ((false === $bytes || '' === $bytes) && feof($fp)) { $this->resetReadHandle(); return false; @@ -131,7 +131,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl throw new Swift_IoException('Unable to open file for reading ['.$this->path.']'); } $this->reader = $pointer; - if ($this->offset != 0) { + if (0 != $this->offset) { $this->getReadStreamSeekableStatus(); $this->seekReadStreamToPosition($this->offset); } @@ -145,9 +145,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl { if (!isset($this->writer)) { if (!$this->writer = fopen($this->path, $this->mode)) { - throw new Swift_IoException( - 'Unable to open file for writing ['.$this->path.']' - ); + throw new Swift_IoException('Unable to open file for writing ['.$this->path.']'); } } @@ -173,10 +171,10 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl /** Streams in a readOnly stream ensuring copy if needed */ private function seekReadStreamToPosition($offset) { - if ($this->seekable === null) { + if (null === $this->seekable) { $this->getReadStreamSeekableStatus(); } - if ($this->seekable === false) { + if (false === $this->seekable) { $currentPos = ftell($this->reader); if ($currentPos < $offset) { $toDiscard = $offset - $currentPos; @@ -194,7 +192,7 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl { if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { /* We have opened a php:// Stream Should work without problem */ - } elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { + } elseif (\function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { /* We have opened a tmpfile */ } else { throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php index 1c9a80c0376..0dc61909d31 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -17,7 +17,7 @@ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByte { $filePath = tempnam(sys_get_temp_dir(), 'FileByteStream'); - if ($filePath === false) { + if (false === $filePath) { throw new Swift_IoException('Failed to retrieve temporary file name.'); } @@ -26,7 +26,7 @@ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByte public function getContent() { - if (($content = file_get_contents($this->getPath())) === false) { + if (false === ($content = file_get_contents($this->getPath()))) { throw new Swift_IoException('Failed to get temporary file content.'); } @@ -39,4 +39,14 @@ class Swift_ByteStream_TemporaryFileByteStream extends Swift_ByteStream_FileByte @unlink($this->getPath()); } } + + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php index b09bb5b6c38..3e055afd9dc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -45,7 +45,7 @@ class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterRe */ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) { - $strlen = strlen($string); + $strlen = \strlen($string); // % and / are CPU intensive, so, maybe find a better way $ignored = $strlen % $this->width; $ignoredChars = $ignored ? substr($string, -$ignored) : ''; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php index 67da48f6cb0..ffc05f7166a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -27,7 +27,7 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader */ public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) { - $strlen = strlen($string); + $strlen = \strlen($string); $ignoredChars = ''; for ($i = 0; $i < $strlen; ++$i) { if ($string[$i] > "\x07F") { @@ -65,7 +65,7 @@ class Swift_CharacterReader_UsAsciiReader implements Swift_CharacterReader public function validateByteSequence($bytes, $size) { $byte = reset($bytes); - if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { + if (1 == \count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { return 0; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php index 22746bd8575..da37e0da9ab 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -17,8 +17,8 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader { /** Pre-computed for optimization */ - private static $length_map = array( - // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F, + private static $length_map = [ + // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x0N 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x1N 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x2N @@ -34,10 +34,10 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xCN 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xDN 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xEN - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN - ); + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // 0xFN + ]; - private static $s_length_map = array( + private static $s_length_map = [ "\x00" => 1, "\x01" => 1, "\x02" => 1, "\x03" => 1, "\x04" => 1, "\x05" => 1, "\x06" => 1, "\x07" => 1, "\x08" => 1, "\x09" => 1, "\x0a" => 1, "\x0b" => 1, "\x0c" => 1, "\x0d" => 1, "\x0e" => 1, "\x0f" => 1, "\x10" => 1, "\x11" => 1, "\x12" => 1, "\x13" => 1, "\x14" => 1, "\x15" => 1, "\x16" => 1, "\x17" => 1, @@ -70,7 +70,7 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader "\xe8" => 3, "\xe9" => 3, "\xea" => 3, "\xeb" => 3, "\xec" => 3, "\xed" => 3, "\xee" => 3, "\xef" => 3, "\xf0" => 4, "\xf1" => 4, "\xf2" => 4, "\xf3" => 4, "\xf4" => 4, "\xf5" => 4, "\xf6" => 4, "\xf7" => 4, "\xf8" => 5, "\xf9" => 5, "\xfa" => 5, "\xfb" => 5, "\xfc" => 6, "\xfd" => 6, "\xfe" => 0, "\xff" => 0, - ); + ]; /** * Returns the complete character map. @@ -85,22 +85,22 @@ class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) { if (!isset($currentMap['i']) || !isset($currentMap['p'])) { - $currentMap['p'] = $currentMap['i'] = array(); + $currentMap['p'] = $currentMap['i'] = []; } - $strlen = strlen($string); - $charPos = count($currentMap['p']); + $strlen = \strlen($string); + $charPos = \count($currentMap['p']); $foundChars = 0; $invalid = false; for ($i = 0; $i < $strlen; ++$i) { $char = $string[$i]; $size = self::$s_length_map[$char]; - if ($size == 0) { + if (0 == $size) { /* char is invalid, we must wait for a resync */ $invalid = true; continue; } else { - if ($invalid == true) { + if (true === $invalid) { /* We mark the chars as invalid and start a new char */ $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; $currentMap['i'][$charPos + $foundChars] = true; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php index f3641f46b46..86900894ab1 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterReaderFactory/SimpleCharacterReaderFactory.php @@ -20,14 +20,14 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift * * @var array */ - private static $map = array(); + private static $map = []; /** * Factories which have already been loaded. * * @var Swift_CharacterReaderFactory[] */ - private static $loaded = array(); + private static $loaded = []; /** * Creates a new CharacterReaderFactory. @@ -44,32 +44,32 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift public function init() { - if (count(self::$map) > 0) { + if (\count(self::$map) > 0) { return; } $prefix = 'Swift_CharacterReader_'; - $singleByte = array( + $singleByte = [ 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => array(1), - ); + 'constructor' => [1], + ]; - $doubleByte = array( + $doubleByte = [ 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => array(2), - ); + 'constructor' => [2], + ]; - $fourBytes = array( + $fourBytes = [ 'class' => $prefix.'GenericFixedWidthReader', - 'constructor' => array(4), - ); + 'constructor' => [4], + ]; // Utf-8 - self::$map['utf-?8'] = array( + self::$map['utf-?8'] = [ 'class' => $prefix.'Utf8Reader', - 'constructor' => array(), - ); + 'constructor' => [], + ]; //7-8 bit charsets self::$map['(us-)?ascii'] = $singleByte; @@ -103,11 +103,11 @@ class Swift_CharacterReaderFactory_SimpleCharacterReaderFactory implements Swift */ public function getReaderFor($charset) { - $charset = strtolower(trim($charset)); + $charset = strtolower(trim($charset ?? '')); foreach (self::$map as $pattern => $spec) { $re = '/^'.$pattern.'$/D'; if (preg_match($re, $charset)) { - if (!array_key_exists($pattern, self::$loaded)) { + if (!\array_key_exists($pattern, self::$loaded)) { $reflector = new ReflectionClass($spec['class']); if ($reflector->getConstructor()) { $reader = $reflector->newInstanceArgs($spec['constructor']); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php index 717924f5d63..c9d8a078ee0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -28,8 +28,6 @@ interface Swift_CharacterStream /** * Set the CharacterReaderFactory for multi charset support. - * - * @param Swift_CharacterReaderFactory $factory */ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php index e43bd2ed510..5c2869455b8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/ArrayCharacterStream.php @@ -31,10 +31,10 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea private $charset; /** Array of characters */ - private $array = array(); + private $array = []; /** Size of the array of character */ - private $array_size = array(); + private $array_size = []; /** The current character offset in the stream */ private $offset = 0; @@ -65,8 +65,6 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea /** * Set the CharacterReaderFactory for multi charset support. - * - * @param Swift_CharacterReaderFactory $factory */ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) { @@ -87,16 +85,16 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea $startLength = $this->charReader->getInitialByteSize(); while (false !== $bytes = $os->read($startLength)) { - $c = array(); - for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $c = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { $c[] = self::$byteMap[$bytes[$i]]; } - $size = count($c); + $size = \count($c); $need = $this->charReader ->validateByteSequence($c, $size); if ($need > 0 && false !== $bytes = $os->read($need)) { - for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { $c[] = self::$byteMap[$bytes[$i]]; } } @@ -132,7 +130,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea } // Don't use array slice - $arrays = array(); + $arrays = []; $end = $length + $this->offset; for ($i = $this->offset; $i < $end; ++$i) { if (!isset($this->array[$i])) { @@ -162,7 +160,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea if ($this->offset == $this->array_size) { return false; } - $arrays = array(); + $arrays = []; $end = $length + $this->offset; for ($i = $this->offset; $i < $end; ++$i) { if (!isset($this->array[$i])) { @@ -172,7 +170,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea } $this->offset += ($i - $this->offset); // Limit function calls - return call_user_func_array('array_merge', $arrays); + return array_merge(...$arrays); } /** @@ -194,19 +192,19 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea unset($chars); fseek($fp, 0, SEEK_SET); - $buffer = array(0); + $buffer = [0]; $buf_pos = 1; $buf_len = 1; $has_datas = true; do { - $bytes = array(); + $bytes = []; // Buffer Filing if ($buf_len - $buf_pos < $startLength) { $buf = array_splice($buffer, $buf_pos); $new = $this->reloadBuffer($fp, 100); if ($new) { $buffer = array_merge($buf, $new); - $buf_len = count($buffer); + $buf_len = \count($buffer); $buf_pos = 0; } else { $has_datas = false; @@ -226,7 +224,7 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea if ($new) { $buffer = array_merge($buffer, $new); - $buf_len = count($buffer); + $buf_len = \count($buffer); } } for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { @@ -262,15 +260,15 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea public function flushContents() { $this->offset = 0; - $this->array = array(); + $this->array = []; $this->array_size = 0; } private function reloadBuffer($fp, $len) { - if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) { - $buf = array(); - for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + if (!feof($fp) && false !== ($bytes = fread($fp, $len))) { + $buf = []; + for ($i = 0, $len = \strlen($bytes); $i < $len; ++$i) { $buf[] = self::$byteMap[$bytes[$i]]; } @@ -283,9 +281,9 @@ class Swift_CharacterStream_ArrayCharacterStream implements Swift_CharacterStrea private static function initializeMaps() { if (!isset(self::$charMap)) { - self::$charMap = array(); + self::$charMap = []; for ($byte = 0; $byte < 256; ++$byte) { - self::$charMap[$byte] = chr($byte); + self::$charMap[$byte] = \chr($byte); } self::$byteMap = array_flip(self::$charMap); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php index 0d62fa68ff3..7578dda9cac 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -81,8 +81,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * Constructor. * - * @param Swift_CharacterReaderFactory $factory - * @param string $charset + * @param string $charset */ public function __construct(Swift_CharacterReaderFactory $factory, $charset) { @@ -106,8 +105,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * Set the CharacterReaderFactory for multi charset support. - * - * @param Swift_CharacterReaderFactory $factory */ public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) { @@ -128,8 +125,6 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream /** * @see Swift_CharacterStream::importByteStream() - * - * @param Swift_OutputByteStream $os */ public function importByteStream(Swift_OutputByteStream $os) { @@ -220,7 +215,7 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream public function readBytes($length) { $read = $this->read($length); - if ($read !== false) { + if (false !== $read) { $ret = array_map('ord', str_split($read, 1)); return $ret; @@ -252,16 +247,16 @@ class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream if (!isset($this->charReader)) { $this->charReader = $this->charReaderFactory->getReaderFor( $this->charset); - $this->map = array(); + $this->map = []; $this->mapType = $this->charReader->getMapType(); } $ignored = ''; $this->datas .= $chars; $this->charCount += $this->charReader->getCharPositions(substr($this->datas, $this->datasSize), $this->datasSize, $this->map, $ignored); - if ($ignored !== false) { - $this->datasSize = strlen($this->datas) - strlen($ignored); + if (false !== $ignored) { + $this->datasSize = \strlen($this->datas) - \strlen($ignored); } else { - $this->datasSize = strlen($this->datas); + $this->datasSize = \strlen($this->datas); } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php index b1bc3306f22..3cc885ec03b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -16,22 +16,25 @@ class Swift_DependencyContainer { /** Constant for literal value types */ - const TYPE_VALUE = 0x0001; + const TYPE_VALUE = 0x00001; /** Constant for new instance types */ - const TYPE_INSTANCE = 0x0010; + const TYPE_INSTANCE = 0x00010; /** Constant for shared instance types */ - const TYPE_SHARED = 0x0100; + const TYPE_SHARED = 0x00100; /** Constant for aliases */ - const TYPE_ALIAS = 0x1000; + const TYPE_ALIAS = 0x01000; + + /** Constant for arrays */ + const TYPE_ARRAY = 0x10000; /** Singleton instance */ private static $instance = null; /** The data container */ - private $store = array(); + private $store = []; /** The current endpoint in the data container */ private $endPoint; @@ -80,7 +83,7 @@ class Swift_DependencyContainer */ public function has($itemName) { - return array_key_exists($itemName, $this->store) + return \array_key_exists($itemName, $this->store) && isset($this->store[$itemName]['lookupType']); } @@ -98,9 +101,7 @@ class Swift_DependencyContainer public function lookup($itemName) { if (!$this->has($itemName)) { - throw new Swift_DependencyException( - 'Cannot lookup dependency "'.$itemName.'" since it is not registered.' - ); + throw new Swift_DependencyException('Cannot lookup dependency "'.$itemName.'" since it is not registered.'); } switch ($this->store[$itemName]['lookupType']) { @@ -112,6 +113,8 @@ class Swift_DependencyContainer return $this->createNewInstance($itemName); case self::TYPE_SHARED: return $this->createSharedInstance($itemName); + case self::TYPE_ARRAY: + return $this->createDependenciesFor($itemName); } } @@ -124,7 +127,7 @@ class Swift_DependencyContainer */ public function createDependenciesFor($itemName) { - $args = array(); + $args = []; if (isset($this->store[$itemName]['args'])) { $args = $this->resolveArgs($this->store[$itemName]['args']); } @@ -147,7 +150,7 @@ class Swift_DependencyContainer */ public function register($itemName) { - $this->store[$itemName] = array(); + $this->store[$itemName] = []; $this->endPoint = &$this->store[$itemName]; return $this; @@ -227,6 +230,21 @@ class Swift_DependencyContainer return $this; } + /** + * Specify the previously registered item as array of dependencies. + * + * {@link register()} must be called before this will work. + * + * @return $this + */ + public function asArray() + { + $endPoint = &$this->getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ARRAY; + + return $this; + } + /** * Specify a list of injected dependencies for the previously registered item. * @@ -234,14 +252,12 @@ class Swift_DependencyContainer * * @see addConstructorValue(), addConstructorLookup() * - * @param array $lookups - * * @return $this */ public function withDependencies(array $lookups) { $endPoint = &$this->getEndPoint(); - $endPoint['args'] = array(); + $endPoint['args'] = []; foreach ($lookups as $lookup) { $this->addConstructorLookup($lookup); } @@ -263,9 +279,9 @@ class Swift_DependencyContainer { $endPoint = &$this->getEndPoint(); if (!isset($endPoint['args'])) { - $endPoint['args'] = array(); + $endPoint['args'] = []; } - $endPoint['args'][] = array('type' => 'value', 'item' => $value); + $endPoint['args'][] = ['type' => 'value', 'item' => $value]; return $this; } @@ -284,9 +300,9 @@ class Swift_DependencyContainer { $endPoint = &$this->getEndPoint(); if (!isset($this->endPoint['args'])) { - $endPoint['args'] = array(); + $endPoint['args'] = []; } - $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup); + $endPoint['args'][] = ['type' => 'lookup', 'item' => $lookup]; return $this; } @@ -330,9 +346,7 @@ class Swift_DependencyContainer private function &getEndPoint() { if (!isset($this->endPoint)) { - throw new BadMethodCallException( - 'Component must first be registered by calling register()' - ); + throw new BadMethodCallException('Component must first be registered by calling register()'); } return $this->endPoint; @@ -341,7 +355,7 @@ class Swift_DependencyContainer /** Get an argument list with dependencies resolved */ private function resolveArgs(array $args) { - $resolved = array(); + $resolved = []; foreach ($args as $argDefinition) { switch ($argDefinition['type']) { case 'lookup': @@ -359,8 +373,8 @@ class Swift_DependencyContainer /** Resolve a single dependency with an collections */ private function lookupRecursive($item) { - if (is_array($item)) { - $collection = array(); + if (\is_array($item)) { + $collection = []; foreach ($item as $k => $v) { $collection[$k] = $this->lookupRecursive($v); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php index 9755a88e176..30fc68ab03e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/EmbeddedFile.php @@ -26,8 +26,8 @@ class Swift_EmbeddedFile extends Swift_Mime_EmbeddedFile */ public function __construct($data = null, $filename = null, $contentType = null) { - call_user_func_array( - array($this, 'Swift_Mime_EmbeddedFile::__construct'), + \call_user_func_array( + [$this, 'Swift_Mime_EmbeddedFile::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.embeddedfile') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php index 0e7b2a1b0c8..b1eedaa051b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Base64Encoder.php @@ -34,7 +34,7 @@ class Swift_Encoder_Base64Encoder implements Swift_Encoder $maxLineLength = 76; } - $encodedString = base64_encode($string); + $encodedString = base64_encode($string ?? ''); $firstLine = ''; if (0 != $firstLineOffset) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php index b23b07702ef..f078d6d7c38 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -36,7 +36,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * * @var string[] */ - protected static $qpMap = array( + protected static $qpMap = [ 0 => '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', @@ -89,16 +89,16 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', 255 => '=FF', - ); + ]; - protected static $safeMapShare = array(); + protected static $safeMapShare = []; /** * A map of non-encoded ascii characters. * * @var string[] */ - protected $safeMap = array(); + protected $safeMap = []; /** * Creates a new QpEncoder for the given CharacterStream. @@ -120,7 +120,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder public function __sleep() { - return array('charStream', 'filter'); + return ['charStream', 'filter']; } public function __wakeup() @@ -135,14 +135,14 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder protected function getSafeMapShareId() { - return get_class($this); + return static::class; } protected function initSafeMap() { foreach (array_merge( - array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { - $this->safeMap[$byte] = chr($byte); + [0x09, 0x20], range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) { + $this->safeMap[$byte] = \chr($byte); } } @@ -153,9 +153,9 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder * If the first line needs to be shorter, indicate the difference with * $firstLineOffset. * - * @param string $string to encode - * @param int $firstLineOffset, optional - * @param int $maxLineLength, optional 0 indicates the default of 76 chars + * @param string $string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional 0 indicates the default of 76 chars * * @return string */ @@ -167,7 +167,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder $thisLineLength = $maxLineLength - $firstLineOffset; - $lines = array(); + $lines = []; $lNo = 0; $lines[$lNo] = ''; $currentLine = &$lines[$lNo++]; @@ -200,7 +200,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder $enc = $this->encodeByteSequence($bytes, $size); $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + ($i === false ? $size : $i); + $newLineLength = $lineLen + (false === $i ? $size : $i); if ($currentLine && $newLineLength >= $thisLineLength) { $lines[$lNo] = ''; @@ -211,7 +211,7 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder $currentLine .= $enc; - if ($i === false) { + if (false === $i) { $lineLen += $size; } else { // 6 is the length of '=0D=0A'. @@ -278,10 +278,10 @@ class Swift_Encoder_QpEncoder implements Swift_Encoder */ protected function standardize($string) { - $string = str_replace(array("\t=0D=0A", ' =0D=0A', '=0D=0A'), - array("=09\r\n", "=20\r\n", "\r\n"), $string + $string = str_replace(["\t=0D=0A", ' =0D=0A', '=0D=0A'], + ["=09\r\n", "=20\r\n", "\r\n"], $string ); - switch ($end = ord(substr($string, -1))) { + switch ($end = \ord(substr($string, -1))) { case 0x09: case 0x20: $string = substr_replace($string, self::$qpMap[$end], -1); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php index bebb13494bd..7eac36813e0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -24,8 +24,6 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder /** * Creates a new Rfc2231Encoder using the given character stream instance. - * - * @param Swift_CharacterStream */ public function __construct(Swift_CharacterStream $charStream) { @@ -44,7 +42,7 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { - $lines = array(); + $lines = []; $lineCount = 0; $lines[] = ''; $currentLine = &$lines[$lineCount++]; @@ -60,8 +58,8 @@ class Swift_Encoder_Rfc2231Encoder implements Swift_Encoder while (false !== $char = $this->charStream->read(4)) { $encodedChar = rawurlencode($char); - if (0 != strlen($currentLine) - && strlen($currentLine.$encodedChar) > $thisLineLength) { + if (0 != \strlen($currentLine) + && \strlen($currentLine.$encodedChar) > $thisLineLength) { $lines[] = ''; $currentLine = &$lines[$lineCount++]; $thisLineLength = $maxLineLength; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php index 9834aa95883..18994c184f3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -27,16 +27,15 @@ class Swift_Events_CommandEvent extends Swift_Events_EventObject * * @var int[] */ - private $successCodes = array(); + private $successCodes = []; /** * Create a new CommandEvent for $source with $command. * - * @param Swift_Transport $source - * @param string $command - * @param array $successCodes + * @param string $command + * @param array $successCodes */ - public function __construct(Swift_Transport $source, $command, $successCodes = array()) + public function __construct(Swift_Transport $source, $command, $successCodes = []) { parent::__construct($source); $this->command = $command; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php index 7545404e765..b158eab462a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -17,8 +17,6 @@ interface Swift_Events_CommandListener extends Swift_Events_EventListener { /** * Invoked immediately following a command being sent. - * - * @param Swift_Events_CommandEvent $evt */ public function commandSent(Swift_Events_CommandEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php index f602608eeb6..df25a124863 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventDispatcher.php @@ -18,9 +18,6 @@ interface Swift_Events_EventDispatcher /** * Create a new SendEvent for $source and $message. * - * @param Swift_Transport $source - * @param Swift_Mime_SimpleMessage - * * @return Swift_Events_SendEvent */ public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message); @@ -28,20 +25,18 @@ interface Swift_Events_EventDispatcher /** * Create a new CommandEvent for $source and $command. * - * @param Swift_Transport $source - * @param string $command That will be executed - * @param array $successCodes That are needed + * @param string $command That will be executed + * @param array $successCodes That are needed * * @return Swift_Events_CommandEvent */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()); + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []); /** * Create a new ResponseEvent for $source and $response. * - * @param Swift_Transport $source - * @param string $response - * @param bool $valid If the response is valid + * @param string $response + * @param bool $valid If the response is valid * * @return Swift_Events_ResponseEvent */ @@ -50,8 +45,6 @@ interface Swift_Events_EventDispatcher /** * Create a new TransportChangeEvent for $source. * - * @param Swift_Transport $source - * * @return Swift_Events_TransportChangeEvent */ public function createTransportChangeEvent(Swift_Transport $source); @@ -59,25 +52,19 @@ interface Swift_Events_EventDispatcher /** * Create a new TransportExceptionEvent for $source. * - * @param Swift_Transport $source - * @param Swift_TransportException $ex - * * @return Swift_Events_TransportExceptionEvent */ public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex); /** * Bind an event listener to this dispatcher. - * - * @param Swift_Events_EventListener $listener */ public function bindEventListener(Swift_Events_EventListener $listener); /** * Dispatch the given Event to all suitable listeners. * - * @param Swift_Events_EventObject $evt - * @param string $target method + * @param string $target method */ public function dispatchEvent(Swift_Events_EventObject $evt, $target); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php index 21e7c8127d6..24a11f44e23 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/EventObject.php @@ -43,8 +43,6 @@ class Swift_Events_EventObject implements Swift_Events_Event /** * Prevent this Event from bubbling any further up the stack. - * - * @param bool $cancel, optional */ public function cancelBubble($cancel = true) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php index 5ae6c04b627..ff7c37116ba 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -32,9 +32,8 @@ class Swift_Events_ResponseEvent extends Swift_Events_EventObject /** * Create a new ResponseEvent for $source and $response. * - * @param Swift_Transport $source - * @param string $response - * @param bool $valid + * @param string $response + * @param bool $valid */ public function __construct(Swift_Transport $source, $response, $valid = false) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php index c40919d210f..85115a33811 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -17,8 +17,6 @@ interface Swift_Events_ResponseListener extends Swift_Events_EventListener { /** * Invoked immediately following a response coming back. - * - * @param Swift_Events_ResponseEvent $evt */ public function responseReceived(Swift_Events_ResponseEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php index 5dc8efb1fd6..a435691e0b0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendEvent.php @@ -42,7 +42,7 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject * * @var string[] */ - private $failedRecipients = array(); + private $failedRecipients = []; /** * The overall result as a bitmask from the class constants. @@ -53,9 +53,6 @@ class Swift_Events_SendEvent extends Swift_Events_EventObject /** * Create a new SendEvent for $source and $message. - * - * @param Swift_Transport $source - * @param Swift_Mime_SimpleMessage $message */ public function __construct(Swift_Transport $source, Swift_Mime_SimpleMessage $message) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php index d922e1bfa96..f7bf55ef56c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -17,15 +17,11 @@ interface Swift_Events_SendListener extends Swift_Events_EventListener { /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt); /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php index 815fa4d922b..6557103c99a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/SimpleEventDispatcher.php @@ -16,34 +16,28 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher { /** A map of event types to their associated listener types */ - private $eventMap = array(); + private $eventMap = []; /** Event listeners bound to this dispatcher */ - private $listeners = array(); - - /** Listeners queued to have an Event bubbled up the stack to them */ - private $bubbleQueue = array(); + private $listeners = []; /** * Create a new EventDispatcher. */ public function __construct() { - $this->eventMap = array( + $this->eventMap = [ 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener', - ); + ]; } /** * Create a new SendEvent for $source and $message. * - * @param Swift_Transport $source - * @param Swift_Mime_SimpleMessage - * * @return Swift_Events_SendEvent */ public function createSendEvent(Swift_Transport $source, Swift_Mime_SimpleMessage $message) @@ -54,13 +48,12 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Create a new CommandEvent for $source and $command. * - * @param Swift_Transport $source - * @param string $command That will be executed - * @param array $successCodes That are needed + * @param string $command That will be executed + * @param array $successCodes That are needed * * @return Swift_Events_CommandEvent */ - public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()) + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = []) { return new Swift_Events_CommandEvent($source, $command, $successCodes); } @@ -68,9 +61,8 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Create a new ResponseEvent for $source and $response. * - * @param Swift_Transport $source - * @param string $response - * @param bool $valid If the response is valid + * @param string $response + * @param bool $valid If the response is valid * * @return Swift_Events_ResponseEvent */ @@ -82,8 +74,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Create a new TransportChangeEvent for $source. * - * @param Swift_Transport $source - * * @return Swift_Events_TransportChangeEvent */ public function createTransportChangeEvent(Swift_Transport $source) @@ -94,9 +84,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Create a new TransportExceptionEvent for $source. * - * @param Swift_Transport $source - * @param Swift_TransportException $ex - * * @return Swift_Events_TransportExceptionEvent */ public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) @@ -106,8 +93,6 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Bind an event listener to this dispatcher. - * - * @param Swift_Events_EventListener $listener */ public function bindEventListener(Swift_Events_EventListener $listener) { @@ -123,34 +108,35 @@ class Swift_Events_SimpleEventDispatcher implements Swift_Events_EventDispatcher /** * Dispatch the given Event to all suitable listeners. * - * @param Swift_Events_EventObject $evt - * @param string $target method + * @param string $target method */ public function dispatchEvent(Swift_Events_EventObject $evt, $target) { - $this->prepareBubbleQueue($evt); - $this->bubble($evt, $target); + $bubbleQueue = $this->prepareBubbleQueue($evt); + $this->bubble($bubbleQueue, $evt, $target); } /** Queue listeners on a stack ready for $evt to be bubbled up it */ private function prepareBubbleQueue(Swift_Events_EventObject $evt) { - $this->bubbleQueue = array(); - $evtClass = get_class($evt); + $bubbleQueue = []; + $evtClass = \get_class($evt); foreach ($this->listeners as $listener) { - if (array_key_exists($evtClass, $this->eventMap) + if (\array_key_exists($evtClass, $this->eventMap) && ($listener instanceof $this->eventMap[$evtClass])) { - $this->bubbleQueue[] = $listener; + $bubbleQueue[] = $listener; } } + + return $bubbleQueue; } /** Bubble $evt up the stack calling $target() on each listener */ - private function bubble(Swift_Events_EventObject $evt, $target) + private function bubble(array &$bubbleQueue, Swift_Events_EventObject $evt, $target) { - if (!$evt->bubbleCancelled() && $listener = array_shift($this->bubbleQueue)) { + if (!$evt->bubbleCancelled() && $listener = array_shift($bubbleQueue)) { $listener->$target($evt); - $this->bubble($evt, $target); + $this->bubble($bubbleQueue, $evt, $target); } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php index 253165de89f..4a7492bc551 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -17,29 +17,21 @@ interface Swift_Events_TransportChangeListener extends Swift_Events_EventListene { /** * Invoked just before a Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt); /** * Invoked immediately after the Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function transportStarted(Swift_Events_TransportChangeEvent $evt); /** * Invoked just before a Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt); /** * Invoked immediately after the Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function transportStopped(Swift_Events_TransportChangeEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php index 77534e3e033..df442cc70f6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionEvent.php @@ -24,9 +24,6 @@ class Swift_Events_TransportExceptionEvent extends Swift_Events_EventObject /** * Create a new TransportExceptionEvent for $transport. - * - * @param Swift_Transport $transport - * @param Swift_TransportException $ex */ public function __construct(Swift_Transport $transport, Swift_TransportException $ex) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php index cc3c0993793..ad80eb01d0f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -17,8 +17,6 @@ interface Swift_Events_TransportExceptionListener extends Swift_Events_EventList { /** * Invoked as a TransportException is thrown in the Transport system. - * - * @param Swift_Events_TransportExceptionEvent $evt */ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php index dc2859f74a0..af0be917903 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FailoverTransport.php @@ -20,10 +20,10 @@ class Swift_FailoverTransport extends Swift_Transport_FailoverTransport * * @param Swift_Transport[] $transports */ - public function __construct($transports = array()) + public function __construct($transports = []) { - call_user_func_array( - array($this, 'Swift_Transport_FailoverTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_FailoverTransport::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.failover') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php index b0b9eb064c5..7af8471c9d7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/FileSpool.php @@ -121,7 +121,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool foreach (new DirectoryIterator($this->path) as $file) { $file = $file->getRealPath(); - if (substr($file, -16) == '.message.sending') { + if ('.message.sending' == substr($file, -16)) { $lockedtime = filectime($file); if ((time() - $lockedtime) > $timeout) { rename($file, substr($file, 0, -8)); @@ -145,7 +145,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool /* Start the transport only if there are queued files to send */ if (!$transport->isStarted()) { foreach ($directoryIterator as $file) { - if (substr($file->getRealPath(), -8) == '.message') { + if ('.message' == substr($file->getRealPath(), -8)) { $transport->start(); break; } @@ -158,7 +158,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool foreach ($directoryIterator as $file) { $file = $file->getRealPath(); - if (substr($file, -8) != '.message') { + if ('.message' != substr($file, -8)) { continue; } @@ -198,7 +198,7 @@ class Swift_FileSpool extends Swift_ConfigurableSpool // This string MUST stay FS safe, avoid special chars $base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'; $ret = ''; - $strlen = strlen($base); + $strlen = \strlen($base); for ($i = 0; $i < $count; ++$i) { $ret .= $base[random_int(0, $strlen - 1)]; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php index 6b75b52748d..efa1b1def5e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Filterable.php @@ -18,8 +18,7 @@ interface Swift_Filterable /** * Add a new StreamFilter, referenced by $key. * - * @param Swift_StreamFilter $filter - * @param string $key + * @param string $key */ public function addFilter(Swift_StreamFilter $filter, $key); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php index 56efc7593ac..379a5a17870 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -52,7 +52,7 @@ interface Swift_InputByteStream * * @param Swift_InputByteStream $is */ - public function bind(Swift_InputByteStream $is); + public function bind(self $is); /** * Remove an already bound stream. @@ -63,7 +63,7 @@ interface Swift_InputByteStream * * @param Swift_InputByteStream $is */ - public function unbind(Swift_InputByteStream $is); + public function unbind(self $is); /** * Flush the contents of the stream (empty it) and set the internal pointer diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php index c405f352b50..5452bd416a6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/IoException.php @@ -18,9 +18,8 @@ class Swift_IoException extends Swift_SwiftException /** * Create a new IoException with $message. * - * @param string $message - * @param int $code - * @param Exception $previous + * @param string $message + * @param int $code */ public function __construct($message, $code = 0, Exception $previous = null) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php index cd6f786df63..87f6a074212 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache.php @@ -38,10 +38,9 @@ interface Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param Swift_OutputByteStream $os - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param int $mode */ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php index cdd08503004..e8fef1c95d4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/ArrayKeyCache.php @@ -20,7 +20,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache * * @var array */ - private $contents = array(); + private $contents = []; /** * An InputStream for cloning. @@ -32,8 +32,6 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache /** * Create a new ArrayKeyCache with the given $stream for cloning to make * InputByteStreams. - * - * @param Swift_KeyCache_KeyCacheInputStream $stream */ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream) { @@ -64,10 +62,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache $this->contents[$nsKey][$itemKey] .= $string; break; default: - throw new Swift_SwiftException( - 'Invalid mode ['.$mode.'] used to set nsKey='. - $nsKey.', itemKey='.$itemKey - ); + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); } } @@ -76,10 +71,9 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param Swift_OutputByteStream $os - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param int $mode */ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) { @@ -87,6 +81,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache switch ($mode) { case self::MODE_WRITE: $this->clearKey($nsKey, $itemKey); + // no break case self::MODE_APPEND: if (!$this->hasKey($nsKey, $itemKey)) { $this->contents[$nsKey][$itemKey] = ''; @@ -96,10 +91,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache } break; default: - throw new Swift_SwiftException( - 'Invalid mode ['.$mode.'] used to set nsKey='. - $nsKey.', itemKey='.$itemKey - ); + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); } } @@ -108,9 +100,8 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache * * NOTE: The stream will always write in append mode. * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $writeThrough + * @param string $nsKey + * @param string $itemKey * * @return Swift_InputByteStream */ @@ -168,7 +159,7 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache { $this->prepareCache($nsKey); - return array_key_exists($itemKey, $this->contents[$nsKey]); + return \array_key_exists($itemKey, $this->contents[$nsKey]); } /** @@ -199,8 +190,8 @@ class Swift_KeyCache_ArrayKeyCache implements Swift_KeyCache */ private function prepareCache($nsKey) { - if (!array_key_exists($nsKey, $this->contents)) { - $this->contents[$nsKey] = array(); + if (!\array_key_exists($nsKey, $this->contents)) { + $this->contents[$nsKey] = []; } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php index d6a633a1512..33b6367cb8b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -43,14 +43,13 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache * * @var array */ - private $keys = array(); + private $keys = []; /** * Create a new DiskKeyCache with the given $stream for cloning to make * InputByteStreams, and the given $path to save to. * - * @param Swift_KeyCache_KeyCacheInputStream $stream - * @param string $path to save to + * @param string $path to save to */ public function __construct(Swift_KeyCache_KeyCacheInputStream $stream, $path) { @@ -81,10 +80,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); break; default: - throw new Swift_SwiftException( - 'Invalid mode ['.$mode.'] used to set nsKey='. - $nsKey.', itemKey='.$itemKey - ); + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); break; } fwrite($fp, $string); @@ -96,10 +92,9 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param Swift_OutputByteStream $os - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param int $mode * * @throws Swift_IoException */ @@ -114,10 +109,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache $fp = $this->getHandle($nsKey, $itemKey, self::POSITION_END); break; default: - throw new Swift_SwiftException( - 'Invalid mode ['.$mode.'] used to set nsKey='. - $nsKey.', itemKey='.$itemKey - ); + throw new Swift_SwiftException('Invalid mode ['.$mode.'] used to set nsKey='.$nsKey.', itemKey='.$itemKey); break; } while (false !== $bytes = $os->read(8192)) { @@ -131,9 +123,8 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache * * NOTE: The stream will always write in append mode. * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $writeThrough + * @param string $nsKey + * @param string $itemKey * * @return Swift_InputByteStream */ @@ -227,7 +218,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache */ public function clearAll($nsKey) { - if (array_key_exists($nsKey, $this->keys)) { + if (\array_key_exists($nsKey, $this->keys)) { foreach ($this->keys[$nsKey] as $itemKey => $null) { $this->clearKey($nsKey, $itemKey); } @@ -250,7 +241,7 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache if (!mkdir($cacheDir)) { throw new Swift_IoException('Failed to create cache directory '.$cacheDir); } - $this->keys[$nsKey] = array(); + $this->keys[$nsKey] = []; } } @@ -295,4 +286,9 @@ class Swift_KeyCache_DiskKeyCache implements Swift_KeyCache $this->clearAll($nsKey); } } + + public function __wakeup() + { + $this->keys = []; + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php index af80bdca6bf..be2dbba0c58 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -17,8 +17,6 @@ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream { /** * Set the KeyCache to wrap. - * - * @param Swift_KeyCache $keyCache */ public function setKeyCache(Swift_KeyCache $keyCache); @@ -38,8 +36,6 @@ interface Swift_KeyCache_KeyCacheInputStream extends Swift_InputByteStream /** * Specify a stream to write through for each write(). - * - * @param Swift_InputByteStream $is */ public function setWriteThroughStream(Swift_InputByteStream $is); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php index 4efe785648f..957b1b2a000 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/NullKeyCache.php @@ -34,10 +34,9 @@ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache * * @see MODE_WRITE, MODE_APPEND * - * @param string $nsKey - * @param string $itemKey - * @param Swift_OutputByteStream $os - * @param int $mode + * @param string $nsKey + * @param string $itemKey + * @param int $mode */ public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) { @@ -48,9 +47,8 @@ class Swift_KeyCache_NullKeyCache implements Swift_KeyCache * * NOTE: The stream will always write in append mode. * - * @param string $nsKey - * @param string $itemKey - * @param Swift_InputByteStream $writeThrough + * @param string $nsKey + * @param string $itemKey * * @return Swift_InputByteStream */ diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php index a74df434c46..03bab481ea3 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/KeyCache/SimpleKeyCacheInputStream.php @@ -29,8 +29,6 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach /** * Set the KeyCache to wrap. - * - * @param Swift_KeyCache $keyCache */ public function setKeyCache(Swift_KeyCache $keyCache) { @@ -39,8 +37,6 @@ class Swift_KeyCache_SimpleKeyCacheInputStream implements Swift_KeyCache_KeyCach /** * Specify a stream to write through for each write(). - * - * @param Swift_InputByteStream $is */ public function setWriteThroughStream(Swift_InputByteStream $is) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php index 03106e55d4e..244b5f60245 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -20,10 +20,10 @@ class Swift_LoadBalancedTransport extends Swift_Transport_LoadBalancedTransport * * @param array $transports */ - public function __construct($transports = array()) + public function __construct($transports = []) { - call_user_func_array( - array($this, 'Swift_Transport_LoadBalancedTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_LoadBalancedTransport::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.loadbalanced') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php index 3561ec6e68e..57630074cd9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer.php @@ -20,8 +20,6 @@ class Swift_Mailer /** * Create a new Mailer using $transport for delivery. - * - * @param Swift_Transport $transport */ public function __construct(Swift_Transport $transport) { @@ -54,8 +52,7 @@ class Swift_Mailer * The return value is the number of recipients who were accepted for * delivery. * - * @param Swift_Mime_SimpleMessage $message - * @param array $failedRecipients An array of failures by-reference + * @param array $failedRecipients An array of failures by-reference * * @return int The number of successful recipients. Can be 0 which indicates failure */ @@ -63,6 +60,7 @@ class Swift_Mailer { $failedRecipients = (array) $failedRecipients; + // FIXME: to be removed in 7.0 (as transport must now start itself on send) if (!$this->transport->isStarted()) { $this->transport->start(); } @@ -82,8 +80,6 @@ class Swift_Mailer /** * Register a plugin using a known unique key (e.g. myPlugin). - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php index 84dacb5f185..19aa82a9c40 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -20,12 +20,10 @@ class Swift_Mailer_ArrayRecipientIterator implements Swift_Mailer_RecipientItera * * @var array */ - private $recipients = array(); + private $recipients = []; /** * Create a new ArrayRecipientIterator from $recipients. - * - * @param array $recipients */ public function __construct(array $recipients) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php index 9aa62835b32..e3b0894d87a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -15,7 +15,7 @@ */ class Swift_MemorySpool implements Swift_Spool { - protected $messages = array(); + protected $messages = []; private $flushRetries = 3; /** diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php index 00f6e160027..5c5834e23d8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Message.php @@ -18,17 +18,17 @@ class Swift_Message extends Swift_Mime_SimpleMessage /** * @var Swift_Signers_HeaderSigner[] */ - private $headerSigners = array(); + private $headerSigners = []; /** * @var Swift_Signers_BodySigner[] */ - private $bodySigners = array(); + private $bodySigners = []; /** * @var array */ - private $savedMessage = array(); + private $savedMessage = []; /** * Create a new Message. @@ -42,8 +42,8 @@ class Swift_Message extends Swift_Mime_SimpleMessage */ public function __construct($subject = null, $body = null, $contentType = null, $charset = null) { - call_user_func_array( - array($this, 'Swift_Mime_SimpleMessage::__construct'), + \call_user_func_array( + [$this, 'Swift_Mime_SimpleMessage::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.message') ); @@ -75,9 +75,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage } /** - * Detach a signature handler from a message. - * - * @param Swift_Signer $signer + * Attach a new signature handler to the message. * * @return $this */ @@ -93,9 +91,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage } /** - * Attach a new signature handler to the message. - * - * @param Swift_Signer $signer + * Detach a signature handler from a message. * * @return $this */ @@ -122,6 +118,19 @@ class Swift_Message extends Swift_Mime_SimpleMessage return $this; } + /** + * Clear all signature handlers attached to the message. + * + * @return $this + */ + public function clearSigners() + { + $this->headerSigners = []; + $this->bodySigners = []; + + return $this; + } + /** * Get this message as a complete string. * @@ -146,8 +155,6 @@ class Swift_Message extends Swift_Mime_SimpleMessage /** * Write this message to a {@link Swift_InputByteStream}. - * - * @param Swift_InputByteStream $is */ public function toByteStream(Swift_InputByteStream $is) { @@ -202,24 +209,22 @@ class Swift_Message extends Swift_Mime_SimpleMessage */ protected function saveMessage() { - $this->savedMessage = array('headers' => array()); + $this->savedMessage = ['headers' => []]; $this->savedMessage['body'] = $this->getBody(); $this->savedMessage['children'] = $this->getChildren(); - if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->becomeMimePart()), $this->savedMessage['children'])); + if (\count($this->savedMessage['children']) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $this->savedMessage['children'])); $this->setBody(''); } } /** * save the original headers. - * - * @param array $altered */ protected function saveHeaders(array $altered) { foreach ($altered as $head) { - $lc = strtolower($head); + $lc = strtolower($head ?? ''); if (!isset($this->savedMessage['headers'][$lc])) { $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); @@ -252,7 +257,7 @@ class Swift_Message extends Swift_Mime_SimpleMessage $this->setChildren($this->savedMessage['children']); $this->restoreHeaders(); - $this->savedMessage = array(); + $this->savedMessage = []; } /** diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php index a36ce7237cf..d994373bd78 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -16,18 +16,14 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity { /** Recognized MIME types */ - private $mimeTypes = array(); + private $mimeTypes = []; /** * Create a new Attachment with $headers, $encoder and $cache. * - * @param Swift_Mime_SimpleHeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_IdGenerator $idGenerator - * @param array $mimeTypes + * @param array $mimeTypes */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array()) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) { parent::__construct($headers, $encoder, $cache, $idGenerator); $this->setDisposition('attachment'); @@ -127,8 +123,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity /** * Set the file that this attachment is for. * - * @param Swift_FileStream $file - * @param string $contentType optional + * @param string $contentType optional * * @return $this */ @@ -139,7 +134,7 @@ class Swift_Mime_Attachment extends Swift_Mime_SimpleMimeEntity if (!isset($contentType)) { $extension = strtolower(substr($file->getPath(), strrpos($file->getPath(), '.') + 1)); - if (array_key_exists($extension, $this->mimeTypes)) { + if (\array_key_exists($extension, $this->mimeTypes)) { $this->setContentType($this->mimeTypes[$extension]); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php index 8f76d70f358..b7e1e028307 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/Base64ContentEncoder.php @@ -18,10 +18,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 /** * Encode stream $in to stream $out. * - * @param Swift_OutputByteStream $os - * @param Swift_InputByteStream $is - * @param int $firstLineOffset - * @param int $maxLineLength, optional, 0 indicates the default of 76 bytes + * @param int $firstLineOffset */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { @@ -30,7 +27,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 } $remainder = 0; - $base64ReadBufferRemainderBytes = null; + $base64ReadBufferRemainderBytes = ''; // To reduce memory usage, the output buffer is streamed to the input buffer like so: // Output Stream => base64encode => wrap line length => Input Stream @@ -41,17 +38,17 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 // When the OutputStream is empty, we must flush any remainder bytes. while (true) { $readBytes = $os->read(8192); - $atEOF = ($readBytes === false); + $atEOF = (false === $readBytes); if ($atEOF) { $streamTheseBytes = $base64ReadBufferRemainderBytes; } else { $streamTheseBytes = $base64ReadBufferRemainderBytes.$readBytes; } - $base64ReadBufferRemainderBytes = null; - $bytesLength = strlen($streamTheseBytes); + $base64ReadBufferRemainderBytes = ''; + $bytesLength = \strlen($streamTheseBytes); - if ($bytesLength === 0) { // no data left to encode + if (0 === $bytesLength) { // no data left to encode break; } @@ -59,7 +56,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 // and carry over remainder 1-2 bytes to the next loop iteration if (!$atEOF) { $excessBytes = $bytesLength % 3; - if ($excessBytes !== 0) { + if (0 !== $excessBytes) { $base64ReadBufferRemainderBytes = substr($streamTheseBytes, -$excessBytes); $streamTheseBytes = substr($streamTheseBytes, 0, $bytesLength - $excessBytes); } @@ -69,7 +66,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 $encodedTransformed = ''; $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; - while ($thisMaxLineLength < strlen($encoded)) { + while ($thisMaxLineLength < \strlen($encoded)) { $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength)."\r\n"; $firstLineOffset = 0; $encoded = substr($encoded, $thisMaxLineLength); @@ -77,7 +74,7 @@ class Swift_Mime_ContentEncoder_Base64ContentEncoder extends Swift_Encoder_Base6 $remainder = 0; } - if (0 < $remainingLength = strlen($encoded)) { + if (0 < $remainingLength = \strlen($encoded)) { $remainder += $remainingLength; $encodedTransformed .= $encoded; $encoded = null; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php index 34de4ef39a4..8dfea605fde 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -16,16 +16,16 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder { /** - * @var null|string + * @var string|null */ private $charset; /** - * @param null|string $charset + * @param string|null $charset */ public function __construct($charset = null) { - $this->charset = $charset ? $charset : 'utf-8'; + $this->charset = $charset ?: 'utf-8'; } /** @@ -50,9 +50,8 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { - if ($this->charset !== 'utf-8') { - throw new RuntimeException( - sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); } $string = ''; @@ -87,9 +86,8 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { - if ($this->charset !== 'utf-8') { - throw new RuntimeException( - sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + if ('utf-8' !== $this->charset) { + throw new RuntimeException(sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); } return $this->standardize(quoted_printable_encode($string)); @@ -107,9 +105,9 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con // transform CR or LF to CRLF $string = preg_replace('~=0D(?!=0A)|(? + */ +class Swift_Mime_ContentEncoder_NullContentEncoder implements Swift_Mime_ContentEncoder +{ + /** + * The name of this encoding scheme (probably 7bit or 8bit). + * + * @var string + */ + private $name; + + /** + * Creates a new NullContentEncoder with $name (probably 7bit or 8bit). + * + * @param string $name + */ + public function __construct($name) + { + $this->name = $name; + } + + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } + + /** + * Encode stream $in to stream $out. + * + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } + + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Not used. + */ + public function charsetChanged($charset) + { + } +} diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php index 866b0c7c980..72592fc5894 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/PlainContentEncoder.php @@ -11,6 +11,10 @@ /** * Handles binary/7/8-bit Transfer Encoding in Swift Mailer. * + * When sending 8-bit content over SMTP, you should use + * Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP + * extension. + * * @author Chris Corbyn */ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_ContentEncoder @@ -33,7 +37,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten * Creates a new PlainContentEncoder with $name (probably 7bit or 8bit). * * @param string $name - * @param bool $canonical If canonicalization transformation should be done. + * @param bool $canonical if canonicalization transformation should be done */ public function __construct($name, $canonical = false) { @@ -62,10 +66,8 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten /** * Encode stream $in to stream $out. * - * @param Swift_OutputByteStream $os - * @param Swift_InputByteStream $is - * @param int $firstLineOffset ignored - * @param int $maxLineLength optional, 0 means no wrapping will occur + * @param int $firstLineOffset ignored + * @param int $maxLineLength optional, 0 means no wrapping will occur */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { @@ -82,7 +84,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten $is->write($wrapped); } - if (strlen($leftOver)) { + if (\strlen($leftOver)) { $is->write($leftOver); } } @@ -121,7 +123,7 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten $originalLines = explode($le, $string); - $lines = array(); + $lines = []; $lineCount = 0; foreach ($originalLines as $originalLine) { @@ -132,8 +134,8 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten $chunks = preg_split('/(?<=\s)/', $originalLine); foreach ($chunks as $chunk) { - if (0 != strlen($currentLine) - && strlen($currentLine.$chunk) > $length) { + if (0 != \strlen($currentLine) + && \strlen($currentLine.$chunk) > $length) { $lines[] = ''; $currentLine = &$lines[$lineCount++]; } @@ -154,8 +156,8 @@ class Swift_Mime_ContentEncoder_PlainContentEncoder implements Swift_Mime_Conten private function canonicalize($string) { return str_replace( - array("\r\n", "\r", "\n"), - array("\n", "\n", "\r\n"), + ["\r\n", "\r", "\n"], + ["\n", "\n", "\r\n"], $string ); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php index b3577dbe61f..465ffd87850 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -32,12 +32,12 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder public function __sleep() { - return array('charStream', 'filter', 'dotEscape'); + return ['charStream', 'filter', 'dotEscape']; } protected function getSafeMapShareId() { - return get_class($this).($this->dotEscape ? '.dotEscape' : ''); + return static::class.($this->dotEscape ? '.dotEscape' : ''); } protected function initSafeMap() @@ -97,7 +97,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder $enc = $this->encodeByteSequence($bytes, $size); $i = strpos($enc, '=0D=0A'); - $newLineLength = $lineLen + ($i === false ? $size : $i); + $newLineLength = $lineLen + (false === $i ? $size : $i); if ($currentLine && $newLineLength >= $thisLineLength) { $is->write($prepend.$this->standardize($currentLine)); @@ -109,14 +109,14 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder $currentLine .= $enc; - if ($i === false) { + if (false === $i) { $lineLen += $size; } else { // 6 is the length of '=0D=0A'. $lineLen = $size - strrpos($enc, '=0D=0A') - 6; } } - if (strlen($currentLine)) { + if (\strlen($currentLine)) { $is->write($prepend.$this->standardize($currentLine)); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php index 3214e1cf3fd..f3ece43aecd 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -28,16 +28,14 @@ class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_Cont private $nativeEncoder; /** - * @var null|string + * @var string|null */ private $charset; /** * Constructor. * - * @param Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder - * @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder - * @param string|null $charset + * @param string|null $charset */ public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php index 0b8526e38c3..870e7f41a93 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -11,6 +11,9 @@ /** * Handles raw Transfer Encoding in Swift Mailer. * + * When sending 8-bit content over SMTP, you should use + * Swift_Transport_Esmtp_EightBitMimeHandler to enable the 8BITMIME SMTP + * extension. * * @author Sebastiaan Stok */ @@ -33,10 +36,8 @@ class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentE /** * Encode stream $in to stream $out. * - * @param Swift_OutputByteStream $in - * @param Swift_InputByteStream $out - * @param int $firstLineOffset ignored - * @param int $maxLineLength ignored + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored */ public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php index 7835a492873..42a51770c76 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -18,13 +18,9 @@ class Swift_Mime_EmbeddedFile extends Swift_Mime_Attachment /** * Creates a new Attachment with $headers and $encoder. * - * @param Swift_Mime_SimpleHeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_IdGenerator $idGenerator - * @param array $mimeTypes optional + * @param array $mimeTypes optional */ - public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = array()) + public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $mimeTypes = []) { parent::__construct($headers, $encoder, $cache, $idGenerator, $mimeTypes); $this->setDisposition('inline'); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php index cc44a6efb97..1a952ece12c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -17,8 +17,6 @@ interface Swift_Mime_EncodingObserver { /** * Notify this observer that the observed entity's ContentEncoder has changed. - * - * @param Swift_Mime_ContentEncoder $encoder */ public function encoderChanged(Swift_Mime_ContentEncoder $encoder); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php index a8ddd272165..ca712f35aa0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -85,7 +85,7 @@ interface Swift_Mime_Header public function getFieldBody(); /** - * Get this Header rendered as a compliant string. + * Get this Header rendered as a compliant string, including trailing CRLF. * * @return string */ diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php index 83a4f2f3b2d..21c8aaabfea 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/Base64HeaderEncoder.php @@ -41,7 +41,7 @@ class Swift_Mime_HeaderEncoder_Base64HeaderEncoder extends Swift_Encoder_Base64E */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0, $charset = 'utf-8') { - if (strtolower($charset) === 'iso-2022-jp') { + if ('iso-2022-jp' === strtolower($charset ?? '')) { $old = mb_internal_encoding(); mb_internal_encoding('utf-8'); $newstring = mb_encode_mimeheader($string, $charset, $this->getName(), "\r\n"); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php index 062be7d7967..378c4805057 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -29,9 +29,9 @@ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder i { foreach (array_merge( range(0x61, 0x7A), range(0x41, 0x5A), - range(0x30, 0x39), array(0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F) + range(0x30, 0x39), [0x20, 0x21, 0x2A, 0x2B, 0x2D, 0x2F] ) as $byte) { - $this->safeMap[$byte] = chr($byte); + $this->safeMap[$byte] = \chr($byte); } } @@ -58,7 +58,7 @@ class Swift_Mime_HeaderEncoder_QpHeaderEncoder extends Swift_Encoder_QpEncoder i */ public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) { - return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"), + return str_replace([' ', '=20', "=\r\n"], ['_', '_', "\r\n"], parent::encodeString($string, $firstLineOffset, $maxLineLength) ); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php index a569f816189..25740d1155c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/AbstractHeader.php @@ -109,8 +109,6 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Set the encoder used for encoding the header. - * - * @param Swift_Mime_HeaderEncoder $encoder */ public function setEncoder(Swift_Mime_HeaderEncoder $encoder) { @@ -196,11 +194,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. * - * @param Swift_Mime_Header $header - * @param string $string as displayed - * @param string $charset of the text - * @param Swift_Mime_HeaderEncoder $encoder - * @param bool $shorten the first line to make remove for header name + * @param string $string as displayed + * @param string $charset of the text + * @param bool $shorten the first line to make remove for header name * * @return string */ @@ -214,13 +210,13 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header // .. but it is just ascii text, try escaping some characters // and make it a quoted-string if (preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $phraseStr)) { - $phraseStr = $this->escapeSpecials($phraseStr, array('"')); + $phraseStr = $this->escapeSpecials($phraseStr, ['"']); $phraseStr = '"'.$phraseStr.'"'; } else { // ... otherwise it needs encoding // Determine space remaining on line if first line if ($shorten) { - $usedLength = strlen($header->getFieldName().': '); + $usedLength = \strlen($header->getFieldName().': '); } else { $usedLength = 0; } @@ -239,9 +235,9 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header * * @return string */ - private function escapeSpecials($token, $include = array()) + private function escapeSpecials($token, $include = []) { - foreach (array_merge(array('\\'), $include) as $char) { + foreach (array_merge(['\\'], $include) as $char) { $token = str_replace($char, '\\'.$char, $token); } @@ -251,9 +247,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header /** * Encode needed word tokens within a string of input. * - * @param Swift_Mime_Header $header - * @param string $input - * @param string $usedLength optional + * @param string $input + * @param string $usedLength optional * * @return string */ @@ -276,7 +271,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header } if (-1 == $usedLength) { - $usedLength = strlen($header->getFieldName().': ') + strlen($value); + $usedLength = \strlen($header->getFieldName().': ') + \strlen($value); } $value .= $this->getTokenAsEncodedWord($token, $usedLength); @@ -310,22 +305,22 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header */ protected function getEncodableWordTokens($string) { - $tokens = array(); + $tokens = []; $encodedToken = ''; // Split at all whitespace boundaries - foreach (preg_split('~(?=[\t ])~', $string) as $token) { + foreach (preg_split('~(?=[\t ])~', $string ?? '') as $token) { if ($this->tokenNeedsEncoding($token)) { $encodedToken .= $token; } else { - if (strlen($encodedToken) > 0) { + if (\strlen($encodedToken) > 0) { $tokens[] = $encodedToken; $encodedToken = ''; } $tokens[] = $token; } } - if (strlen($encodedToken)) { + if (\strlen($encodedToken)) { $tokens[] = $encodedToken; } @@ -347,7 +342,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header if (isset($this->lang)) { $charsetDecl .= '*'.$this->lang; } - $encodingWrapperLength = strlen( + $encodingWrapperLength = \strlen( '=?'.$charsetDecl.'?'.$this->encoder->getName().'??=' ); @@ -359,10 +354,10 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header $encodedTextLines = explode("\r\n", $this->encoder->encodeString( $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->charset - ) + ) ?? '' ); - if (strtolower($this->charset) !== 'iso-2022-jp') { + if ('iso-2022-jp' !== strtolower($this->charset ?? '')) { // special encoding for iso-2022-jp using mb_encode_mimeheader foreach ($encodedTextLines as $lineNum => $line) { $encodedTextLines[$lineNum] = '=?'.$charsetDecl. @@ -383,7 +378,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header */ protected function generateTokenLines($token) { - return preg_split('~(\r\n)~', $token, -1, PREG_SPLIT_DELIM_CAPTURE); + return preg_split('~(\r\n)~', $token ?? '', -1, PREG_SPLIT_DELIM_CAPTURE); } /** @@ -431,10 +426,10 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header $string = $this->getFieldBody(); } - $tokens = array(); + $tokens = []; // Generate atoms; split at all invisible boundaries followed by WSP - foreach (preg_split('~(?=[ \t])~', $string) as $token) { + foreach (preg_split('~(?=[ \t])~', $string ?? '') as $token) { $newTokens = $this->generateTokenLines($token); foreach ($newTokens as $newToken) { $tokens[] = $newToken; @@ -455,7 +450,7 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header private function tokensToString(array $tokens) { $lineCount = 0; - $headerLines = array(); + $headerLines = []; $headerLines[] = $this->name.': '; $currentLine = &$headerLines[$lineCount++]; @@ -463,8 +458,8 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header foreach ($tokens as $i => $token) { // Line longer than specified maximum or token was just a new line if (("\r\n" == $token) || - ($i > 0 && strlen($currentLine.$token) > $this->lineLength) - && 0 < strlen($currentLine)) { + ($i > 0 && \strlen($currentLine.$token) > $this->lineLength) + && 0 < \strlen($currentLine)) { $headerLines[] = ''; $currentLine = &$headerLines[$lineCount++]; } @@ -478,4 +473,14 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header // Implode with FWS (RFC 2822, 2.2.3) return implode("\r\n", $headerLines)."\r\n"; } + + /** + * Make a deep copy of object. + */ + public function __clone() + { + if ($this->encoder) { + $this->encoder = clone $this->encoder; + } + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php index 6dcc92bfdd6..efe1dad6619 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -79,8 +79,6 @@ class Swift_Mime_Headers_DateHeader extends Swift_Mime_Headers_AbstractHeader * Set the date-time of the Date in this Header. * * If a DateTime instance is provided, it is converted to DateTimeImmutable. - * - * @param DateTimeInterface $dateTime */ public function setDateTime(DateTimeInterface $dateTime) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php index acf794479b6..4fcdff418a7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -9,6 +9,7 @@ */ use Egulias\EmailValidator\EmailValidator; +use Egulias\EmailValidator\Validation\MessageIDValidation; use Egulias\EmailValidator\Validation\RFCValidation; /** @@ -25,7 +26,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac * * @var string[] */ - private $ids = array(); + private $ids = []; /** * The strict EmailValidator. @@ -34,16 +35,18 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac */ private $emailValidator; + private $addressEncoder; + /** * Creates a new IdentificationHeader with the given $name and $id. * - * @param string $name - * @param EmailValidator $emailValidator + * @param string $name */ - public function __construct($name, EmailValidator $emailValidator) + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); } /** @@ -94,7 +97,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac */ public function setId($id) { - $this->setIds(is_array($id) ? $id : array($id)); + $this->setIds(\is_array($id) ? $id : [$id]); } /** @@ -106,7 +109,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac */ public function getId() { - if (count($this->ids) > 0) { + if (\count($this->ids) > 0) { return $this->ids[0]; } } @@ -120,7 +123,7 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac */ public function setIds(array $ids) { - $actualIds = array(); + $actualIds = []; foreach ($ids as $id) { $this->assertValidId($id); @@ -156,10 +159,10 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac public function getFieldBody() { if (!$this->getCachedValue()) { - $angleAddrs = array(); + $angleAddrs = []; foreach ($this->ids as $id) { - $angleAddrs[] = '<'.$id.'>'; + $angleAddrs[] = '<'.$this->addressEncoder->encodeString($id).'>'; } $this->setCachedValue(implode(' ', $angleAddrs)); @@ -177,7 +180,9 @@ class Swift_Mime_Headers_IdentificationHeader extends Swift_Mime_Headers_Abstrac */ private function assertValidId($id) { - if (!$this->emailValidator->isValid($id, new RFCValidation())) { + $emailValidation = class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation(); + + if (!$this->emailValidator->isValid($id, $emailValidation)) { throw new Swift_RfcComplianceException('Invalid ID given <'.$id.'>'); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php index 450e0f25b7e..ddd5e8cffb1 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -23,7 +23,7 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @var string[] */ - private $mailboxes = array(); + private $mailboxes = []; /** * The strict EmailValidator. @@ -32,18 +32,19 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader */ private $emailValidator; + private $addressEncoder; + /** * Creates a new MailboxHeader with $name. * - * @param string $name of Header - * @param Swift_Mime_HeaderEncoder $encoder - * @param EmailValidator $emailValidator + * @param string $name of Header */ - public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator) + public function __construct($name, Swift_Mime_HeaderEncoder $encoder, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->setEncoder($encoder); $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); } /** @@ -257,10 +258,10 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader */ protected function normalizeMailboxes(array $mailboxes) { - $actualMailboxes = array(); + $actualMailboxes = []; foreach ($mailboxes as $key => $value) { - if (is_string($key)) { + if (\is_string($key)) { //key is email addr $address = $key; $name = $value; @@ -327,10 +328,10 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader */ private function createNameAddressStrings(array $mailboxes) { - $strings = array(); + $strings = []; foreach ($mailboxes as $email => $name) { - $mailboxStr = $email; + $mailboxStr = $this->addressEncoder->encodeString($email); if (null !== $name) { $nameStr = $this->createDisplayNameString($name, empty($strings)); $mailboxStr = $nameStr.' <'.$mailboxStr.'>'; @@ -346,14 +347,12 @@ class Swift_Mime_Headers_MailboxHeader extends Swift_Mime_Headers_AbstractHeader * * @param string $address * - * @throws Swift_RfcComplianceException If invalid. + * @throws Swift_RfcComplianceException if invalid */ private function assertValidAddress($address) { if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException( - 'Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.' - ); + throw new Swift_RfcComplianceException('Address in mailbox given ['.$address.'] does not comply with RFC 2822, 3.6.2.'); } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php index 29277994c0a..fafb5bae21f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -12,6 +12,8 @@ * An OpenDKIM Specific Header using only raw header datas without encoding. * * @author De Cock Xavier + * + * @deprecated since SwiftMailer 6.1.0; use Swift_Signers_DKIMSigner instead. */ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header { @@ -111,7 +113,7 @@ class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header */ public function toString() { - return $this->fieldName.': '.$this->value; + return $this->fieldName.': '.$this->value."\r\n"; } /** diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php index 228946a5ee9..47c15e6c05f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -34,14 +34,12 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct * * @var string[] */ - private $params = array(); + private $params = []; /** * Creates a new ParameterizedHeader with $name. * - * @param string $name - * @param Swift_Mime_HeaderEncoder $encoder - * @param Swift_Encoder $paramEncoder, optional + * @param string $name */ public function __construct($name, Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder = null) { @@ -83,7 +81,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct */ public function setParameter($parameter, $value) { - $this->setParameters(array_merge($this->getParameters(), array($parameter => $value))); + $this->setParameters(array_merge($this->getParameters(), [$parameter => $value])); } /** @@ -97,7 +95,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct { $params = $this->getParameters(); - return isset($params[$parameter]) ? $params[$parameter] : null; + return $params[$parameter] ?? null; } /** @@ -157,7 +155,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct foreach ($this->params as $name => $value) { if (null !== $value) { // Add the semi-colon separator - $tokens[count($tokens) - 1] .= ';'; + $tokens[\count($tokens) - 1] .= ';'; $tokens = array_merge($tokens, $this->generateTokenLines( ' '.$this->createParameter($name, $value) )); @@ -181,7 +179,7 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct $encoded = false; // Allow room for parameter name, indices, "=" and DQUOTEs - $maxValueLength = $this->getMaxLineLength() - strlen($name.'=*N"";') - 1; + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'=*N"";') - 1; $firstLineOffset = 0; // If it's not already a valid parameter value... @@ -191,15 +189,15 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct if (!preg_match('/^[\x00-\x08\x0B\x0C\x0E-\x7F]*$/D', $value)) { $encoded = true; // Allow space for the indices, charset and language - $maxValueLength = $this->getMaxLineLength() - strlen($name.'*N*="";') - 1; - $firstLineOffset = strlen( + $maxValueLength = $this->getMaxLineLength() - \strlen($name.'*N*="";') - 1; + $firstLineOffset = \strlen( $this->getCharset()."'".$this->getLanguage()."'" ); } } // Encode if we need to - if ($encoded || strlen($value) > $maxValueLength) { + if ($encoded || \strlen($value) > $maxValueLength) { if (isset($this->paramEncoder)) { $value = $this->paramEncoder->encodeString( $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() @@ -211,14 +209,14 @@ class Swift_Mime_Headers_ParameterizedHeader extends Swift_Mime_Headers_Unstruct } } - $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : array($value); + $valueLines = isset($this->paramEncoder) ? explode("\r\n", $value) : [$value]; // Need to add indices - if (count($valueLines) > 1) { - $paramLines = array(); + if (\count($valueLines) > 1) { + $paramLines = []; foreach ($valueLines as $i => $line) { $paramLines[] = $name.'*'.$i. - $this->getEndOfParameterValue($line, true, $i == 0); + $this->getEndOfParameterValue($line, true, 0 == $i); } return implode(";\r\n ", $paramLines); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php index f79e19fd8b3..81b421ee7a8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -32,16 +32,18 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader */ private $emailValidator; + private $addressEncoder; + /** * Creates a new PathHeader with the given $name. * - * @param string $name - * @param EmailValidator $emailValidator + * @param string $name */ - public function __construct($name, EmailValidator $emailValidator) + public function __construct($name, EmailValidator $emailValidator, Swift_AddressEncoder $addressEncoder = null) { $this->setFieldName($name); $this->emailValidator = $emailValidator; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); } /** @@ -127,7 +129,8 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader { if (!$this->getCachedValue()) { if (isset($this->address)) { - $this->setCachedValue('<'.$this->address.'>'); + $address = $this->addressEncoder->encodeString($this->address); + $this->setCachedValue('<'.$address.'>'); } } @@ -144,9 +147,7 @@ class Swift_Mime_Headers_PathHeader extends Swift_Mime_Headers_AbstractHeader private function assertValidAddress($address) { if (!$this->emailValidator->isValid($address, new RFCValidation())) { - throw new Swift_RfcComplianceException( - 'Address set in PathHeader does not comply with addr-spec of RFC 2822.' - ); + throw new Swift_RfcComplianceException('Address set in PathHeader does not comply with addr-spec of RFC 2822.'); } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php index d9d9f5e25d3..64f160dec7c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -25,8 +25,7 @@ class Swift_Mime_Headers_UnstructuredHeader extends Swift_Mime_Headers_AbstractH /** * Creates a new SimpleHeader with $name. * - * @param string $name - * @param Swift_Mime_HeaderEncoder $encoder + * @param string $name */ public function __construct($name, Swift_Mime_HeaderEncoder $encoder) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php index 8d9452bd0f0..3ce35f27c03 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/IdGenerator.php @@ -13,6 +13,8 @@ */ class Swift_Mime_IdGenerator implements Swift_IdGenerator { + private $idRight; + /** * @param string $idRight */ @@ -46,8 +48,7 @@ class Swift_Mime_IdGenerator implements Swift_IdGenerator */ public function generateId() { - $idLeft = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); - - return $idLeft.'@'.$this->idRight; + // 32 hex values for the left part + return bin2hex(random_bytes(16)).'@'.$this->idRight; } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php index d49449fe5be..d0b2e6586b4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/MimePart.php @@ -30,11 +30,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity /** * Create a new MimePart with $headers, $encoder and $cache. * - * @param Swift_Mime_SimpleHeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_IdGenerator $idGenerator - * @param string $charset + * @param string $charset */ public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) { @@ -173,7 +169,7 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity protected function fixHeaders() { parent::fixHeaders(); - if (count($this->getChildren())) { + if (\count($this->getChildren())) { $this->setHeaderParameter('Content-Type', 'charset', null); $this->setHeaderParameter('Content-Type', 'format', null); $this->setHeaderParameter('Content-Type', 'delsp', null); @@ -193,18 +189,9 @@ class Swift_Mime_MimePart extends Swift_Mime_SimpleMimeEntity /** Encode charset when charset is not utf-8 */ protected function convertString($string) { - $charset = strtolower($this->getCharset()); - if (!in_array($charset, array('utf-8', 'iso-8859-1', 'iso-8859-15', ''))) { - // mb_convert_encoding must be the first one to check, since iconv cannot convert some words. - if (function_exists('mb_convert_encoding')) { - $string = mb_convert_encoding($string, $charset, 'utf-8'); - } elseif (function_exists('iconv')) { - $string = iconv('utf-8//TRANSLIT//IGNORE', $charset, $string); - } else { - throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your charset or install the mbstring or iconv extension).'); - } - - return $string; + $charset = strtolower($this->getCharset() ?? ''); + if (!\in_array($charset, ['utf-8', 'iso-8859-1', 'iso-8859-15', ''])) { + return mb_convert_encoding($string, $charset, 'utf-8'); } return $string; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php index e14c9d6f88e..ab3ce6b1914 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderFactory.php @@ -23,29 +23,27 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver /** The Encoder used by parameters */ private $paramEncoder; - /** The Grammar */ - private $grammar; - /** Strict EmailValidator */ private $emailValidator; /** The charset of created Headers */ private $charset; + /** Swift_AddressEncoder */ + private $addressEncoder; + /** * Creates a new SimpleHeaderFactory using $encoder and $paramEncoder. * - * @param Swift_Mime_HeaderEncoder $encoder - * @param Swift_Encoder $paramEncoder - * @param EmailValidator $emailValidator - * @param string|null $charset + * @param string|null $charset */ - public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null) + public function __construct(Swift_Mime_HeaderEncoder $encoder, Swift_Encoder $paramEncoder, EmailValidator $emailValidator, $charset = null, Swift_AddressEncoder $addressEncoder = null) { $this->encoder = $encoder; $this->paramEncoder = $paramEncoder; $this->emailValidator = $emailValidator; $this->charset = $charset; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); } /** @@ -58,7 +56,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver */ public function createMailboxHeader($name, $addresses = null) { - $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator); + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->encoder, $this->emailValidator, $this->addressEncoder); if (isset($addresses)) { $header->setFieldBodyModel($addresses); } @@ -70,8 +68,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver /** * Create a new Date header using $dateTime. * - * @param string $name - * @param DateTimeInterface|null $dateTime + * @param string $name * * @return Swift_Mime_Header */ @@ -114,9 +111,9 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver * * @return Swift_Mime_Headers_ParameterizedHeader */ - public function createParameterizedHeader($name, $value = null, $params = array()) + public function createParameterizedHeader($name, $value = null, $params = []) { - $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, (strtolower($name) == 'content-disposition') ? $this->paramEncoder : null); + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $this->encoder, ('content-disposition' == strtolower($name ?? '')) ? $this->paramEncoder : null); if (isset($value)) { $header->setFieldBodyModel($value); } @@ -185,6 +182,7 @@ class Swift_Mime_SimpleHeaderFactory implements Swift_Mime_CharsetObserver { $this->encoder = clone $this->encoder; $this->paramEncoder = clone $this->paramEncoder; + $this->addressEncoder = clone $this->addressEncoder; } /** Apply the charset to the Header */ diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php index 6f71fcac132..5195bcf48ae 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -19,13 +19,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver private $factory; /** Collection of set Headers */ - private $headers = array(); + private $headers = []; /** Field ordering details */ - private $order = array(); + private $order = []; /** List of fields which are required to be displayed */ - private $required = array(); + private $required = []; /** The charset used by Headers */ private $charset; @@ -33,8 +33,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver /** * Create a new SimpleHeaderSet with the given $factory. * - * @param Swift_Mime_SimpleHeaderFactory $factory - * @param string $charset + * @param string $charset */ public function __construct(Swift_Mime_SimpleHeaderFactory $factory, $charset = null) { @@ -69,20 +68,17 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver */ public function addMailboxHeader($name, $addresses = null) { - $this->storeHeader($name, - $this->factory->createMailboxHeader($name, $addresses)); + $this->storeHeader($name, $this->factory->createMailboxHeader($name, $addresses)); } /** * Add a new Date header using $dateTime. * - * @param string $name - * @param DateTimeInterface $dateTime + * @param string $name */ public function addDateHeader($name, DateTimeInterface $dateTime = null) { - $this->storeHeader($name, - $this->factory->createDateHeader($name, $dateTime)); + $this->storeHeader($name, $this->factory->createDateHeader($name, $dateTime)); } /** @@ -93,8 +89,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver */ public function addTextHeader($name, $value = null) { - $this->storeHeader($name, - $this->factory->createTextHeader($name, $value)); + $this->storeHeader($name, $this->factory->createTextHeader($name, $value)); } /** @@ -104,7 +99,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver * @param string $value * @param array $params */ - public function addParameterizedHeader($name, $value = null, $params = array()) + public function addParameterizedHeader($name, $value = null, $params = []) { $this->storeHeader($name, $this->factory->createParameterizedHeader($name, $value, $params)); } @@ -143,18 +138,18 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver */ public function has($name, $index = 0) { - $lowerName = strtolower($name); + $lowerName = strtolower($name ?? ''); - if (!array_key_exists($lowerName, $this->headers)) { + if (!\array_key_exists($lowerName, $this->headers)) { return false; } - if (func_num_args() < 2) { + if (\func_num_args() < 2) { // index was not specified, so we only need to check that there is at least one header value set - return (bool) count($this->headers[$lowerName]); + return (bool) \count($this->headers[$lowerName]); } - return array_key_exists($index, $this->headers[$lowerName]); + return \array_key_exists($index, $this->headers[$lowerName]); } /** @@ -166,8 +161,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver * If $index is specified, the header will be inserted into the set at this * offset. * - * @param Swift_Mime_Header $header - * @param int $index + * @param int $index */ public function set(Swift_Mime_Header $header, $index = 0) { @@ -183,13 +177,13 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver * @param string $name * @param int $index * - * @return Swift_Mime_Header + * @return Swift_Mime_Header|null */ public function get($name, $index = 0) { - $name = strtolower($name); + $name = strtolower($name ?? ''); - if (func_num_args() < 2) { + if (\func_num_args() < 2) { if ($this->has($name)) { $values = array_values($this->headers[$name]); @@ -212,7 +206,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver public function getAll($name = null) { if (!isset($name)) { - $headers = array(); + $headers = []; foreach ($this->headers as $collection) { $headers = array_merge($headers, $collection); } @@ -220,9 +214,9 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver return $headers; } - $lowerName = strtolower($name); - if (!array_key_exists($lowerName, $this->headers)) { - return array(); + $lowerName = strtolower($name ?? ''); + if (!\array_key_exists($lowerName, $this->headers)) { + return []; } return $this->headers[$lowerName]; @@ -237,7 +231,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver { $headers = $this->headers; if ($this->canSort()) { - uksort($headers, array($this, 'sortHeaders')); + uksort($headers, [$this, 'sortHeaders']); } return array_keys($headers); @@ -253,7 +247,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver */ public function remove($name, $index = 0) { - $lowerName = strtolower($name); + $lowerName = strtolower($name ?? ''); unset($this->headers[$lowerName][$index]); } @@ -264,7 +258,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver */ public function removeAll($name) { - $lowerName = strtolower($name); + $lowerName = strtolower($name ?? ''); unset($this->headers[$lowerName]); } @@ -272,8 +266,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver * Define a list of Header names as an array in the correct order. * * These Headers will be output in the given order where present. - * - * @param array $sequence */ public function defineOrdering(array $sequence) { @@ -284,8 +276,6 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver * Set a list of header names which must always be displayed when set. * * Usually headers without a field value won't be output unless set here. - * - * @param array $names */ public function setAlwaysDisplayed(array $names) { @@ -312,11 +302,11 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver $string = ''; $headers = $this->headers; if ($this->canSort()) { - uksort($headers, array($this, 'sortHeaders')); + uksort($headers, [$this, 'sortHeaders']); } foreach ($headers as $collection) { foreach ($collection as $header) { - if ($this->isDisplayed($header) || $header->getFieldBody() != '') { + if ($this->isDisplayed($header) || '' != $header->getFieldBody()) { $string .= $header->toString(); } } @@ -340,38 +330,38 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver /** Save a Header to the internal collection */ private function storeHeader($name, Swift_Mime_Header $header, $offset = null) { - if (!isset($this->headers[strtolower($name)])) { - $this->headers[strtolower($name)] = array(); + if (!isset($this->headers[strtolower($name ?? '')])) { + $this->headers[strtolower($name ?? '')] = []; } if (!isset($offset)) { - $this->headers[strtolower($name)][] = $header; + $this->headers[strtolower($name ?? '')][] = $header; } else { - $this->headers[strtolower($name)][$offset] = $header; + $this->headers[strtolower($name ?? '')][$offset] = $header; } } /** Test if the headers can be sorted */ private function canSort() { - return count($this->order) > 0; + return \count($this->order) > 0; } /** uksort() algorithm for Header ordering */ private function sortHeaders($a, $b) { - $lowerA = strtolower($a); - $lowerB = strtolower($b); - $aPos = array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; - $bPos = array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; + $lowerA = strtolower($a ?? ''); + $lowerB = strtolower($b ?? ''); + $aPos = \array_key_exists($lowerA, $this->order) ? $this->order[$lowerA] : -1; + $bPos = \array_key_exists($lowerB, $this->order) ? $this->order[$lowerB] : -1; if (-1 === $aPos && -1 === $bPos) { // just be sure to be determinist here return $a > $b ? -1 : 1; } - if ($aPos == -1) { + if (-1 == $aPos) { return 1; - } elseif ($bPos == -1) { + } elseif (-1 == $bPos) { return -1; } @@ -381,7 +371,7 @@ class Swift_Mime_SimpleHeaderSet implements Swift_Mime_CharsetObserver /** Test if the given Header is always displayed */ private function isDisplayed(Swift_Mime_Header $header) { - return array_key_exists(strtolower($header->getFieldName()), $this->required); + return \array_key_exists(strtolower($header->getFieldName() ?? ''), $this->required); } /** Notify all Headers of the new charset */ diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php index f8667954bcf..62da1650a7b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -24,16 +24,12 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Create a new SimpleMessage with $headers, $encoder and $cache. * - * @param Swift_Mime_SimpleHeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_IdGenerator $idGenerator - * @param string $charset + * @param string $charset */ public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator, $charset = null) { parent::__construct($headers, $encoder, $cache, $idGenerator, $charset); - $this->getHeaders()->defineOrdering(array( + $this->getHeaders()->defineOrdering([ 'Return-Path', 'Received', 'DKIM-Signature', @@ -50,8 +46,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart 'MIME-Version', 'Content-Type', 'Content-Transfer-Encoding', - )); - $this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From')); + ]); + $this->getHeaders()->setAlwaysDisplayed(['Date', 'Message-ID', 'From']); $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); $this->setDate(new DateTimeImmutable()); $this->setId($this->getId()); @@ -97,8 +93,6 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Set the date at which this message was created. * - * @param DateTimeInterface $dateTime - * * @return $this */ public function setDate(DateTimeInterface $dateTime) @@ -158,8 +152,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setSender($address, $name = null) { - if (!is_array($address) && isset($name)) { - $address = array($address => $name); + if (!\is_array($address) && isset($name)) { + $address = [$address => $name]; } if (!$this->setHeaderFieldModel('Sender', (array) $address)) { @@ -212,8 +206,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setFrom($addresses, $name = null) { - if (!is_array($addresses) && isset($name)) { - $addresses = array($addresses => $name); + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; } if (!$this->setHeaderFieldModel('From', (array) $addresses)) { @@ -266,8 +260,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setReplyTo($addresses, $name = null) { - if (!is_array($addresses) && isset($name)) { - $addresses = array($addresses => $name); + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; } if (!$this->setHeaderFieldModel('Reply-To', (array) $addresses)) { @@ -321,8 +315,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setTo($addresses, $name = null) { - if (!is_array($addresses) && isset($name)) { - $addresses = array($addresses => $name); + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; } if (!$this->setHeaderFieldModel('To', (array) $addresses)) { @@ -373,8 +367,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setCc($addresses, $name = null) { - if (!is_array($addresses) && isset($name)) { - $addresses = array($addresses => $name); + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; } if (!$this->setHeaderFieldModel('Cc', (array) $addresses)) { @@ -425,8 +419,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setBcc($addresses, $name = null) { - if (!is_array($addresses) && isset($name)) { - $addresses = array($addresses => $name); + if (!\is_array($addresses) && isset($name)) { + $addresses = [$addresses => $name]; } if (!$this->setHeaderFieldModel('Bcc', (array) $addresses)) { @@ -457,13 +451,13 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function setPriority($priority) { - $priorityMap = array( + $priorityMap = [ self::PRIORITY_HIGHEST => 'Highest', self::PRIORITY_HIGH => 'High', self::PRIORITY_NORMAL => 'Normal', self::PRIORITY_LOW => 'Low', self::PRIORITY_LOWEST => 'Lowest', - ); + ]; $pMapKeys = array_keys($priorityMap); if ($priority > max($pMapKeys)) { $priority = max($pMapKeys); @@ -493,7 +487,7 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart '%[1-5]' ); - return isset($priority) ? $priority : 3; + return $priority ?? 3; } /** @@ -526,13 +520,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Attach a {@link Swift_Mime_SimpleMimeEntity} such as an Attachment or MimePart. * - * @param Swift_Mime_SimpleMimeEntity $entity - * * @return $this */ public function attach(Swift_Mime_SimpleMimeEntity $entity) { - $this->setChildren(array_merge($this->getChildren(), array($entity))); + $this->setChildren(array_merge($this->getChildren(), [$entity])); return $this; } @@ -540,13 +532,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Remove an already attached entity. * - * @param Swift_Mime_SimpleMimeEntity $entity - * * @return $this */ public function detach(Swift_Mime_SimpleMimeEntity $entity) { - $newChildren = array(); + $newChildren = []; foreach ($this->getChildren() as $child) { if ($entity !== $child) { $newChildren[] = $child; @@ -559,9 +549,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Attach a {@link Swift_Mime_SimpleMimeEntity} and return it's CID source. - * This method should be used when embedding images or other data in a message. * - * @param Swift_Mime_SimpleMimeEntity $entity + * This method should be used when embedding images or other data in a message. * * @return string */ @@ -579,8 +568,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart */ public function toString() { - if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->becomeMimePart()), $children)); + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); $string = parent::toString(); $this->setChildren($children); } else { @@ -604,13 +593,11 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart /** * Write this message to a {@link Swift_InputByteStream}. - * - * @param Swift_InputByteStream $is */ public function toByteStream(Swift_InputByteStream $is) { - if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { - $this->setChildren(array_merge(array($this->becomeMimePart()), $children)); + if (\count($children = $this->getChildren()) > 0 && '' != $this->getBody()) { + $this->setChildren(array_merge([$this->becomeMimePart()], $children)); parent::toByteStream($is); $this->setChildren($children); } else { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php index 980f1cedc1c..03eaf472dd5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -43,14 +43,14 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M private $boundary; /** Mime types to be used based on the nesting level */ - private $compositeRanges = array( - 'multipart/mixed' => array(self::LEVEL_TOP, self::LEVEL_MIXED), - 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE), - 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED), - ); + private $compositeRanges = [ + 'multipart/mixed' => [self::LEVEL_TOP, self::LEVEL_MIXED], + 'multipart/alternative' => [self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE], + 'multipart/related' => [self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED], + ]; /** A set of filter rules to define what level an entity should be nested at */ - private $compoundLevelFilters = array(); + private $compoundLevelFilters = []; /** The nesting level of this entity */ private $nestingLevel = self::LEVEL_ALTERNATIVE; @@ -59,20 +59,20 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M private $cache; /** Direct descendants of this entity */ - private $immediateChildren = array(); + private $immediateChildren = []; /** All descendants of this entity */ - private $children = array(); + private $children = []; /** The maximum line length of the body of this entity */ private $maxLineLength = 78; /** The order in which alternative mime types should appear */ - private $alternativePartOrder = array( + private $alternativePartOrder = [ 'text/plain' => 1, 'text/html' => 2, 'multipart/related' => 3, - ); + ]; /** The CID of this entity */ private $id; @@ -84,20 +84,15 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M /** * Create a new SimpleMimeEntity with $headers, $encoder and $cache. - * - * @param Swift_Mime_SimpleHeaderSet $headers - * @param Swift_Mime_ContentEncoder $encoder - * @param Swift_KeyCache $cache - * @param Swift_IdGenerator $idGenerator */ public function __construct(Swift_Mime_SimpleHeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_IdGenerator $idGenerator) { - $this->cacheKey = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values $this->cache = $cache; $this->headers = $headers; $this->idGenerator = $idGenerator; $this->setEncoder($encoder); - $this->headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding')); + $this->headers->defineOrdering(['Content-Type', 'Content-Transfer-Encoding']); // This array specifies that, when the entire MIME document contains // $compoundLevel, then for each child within $level, if its Content-Type @@ -112,14 +107,14 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M // ) // ) - $this->compoundLevelFilters = array( - (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array( - self::LEVEL_ALTERNATIVE => array( + $this->compoundLevelFilters = [ + (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => [ + self::LEVEL_ALTERNATIVE => [ 'text/plain' => self::LEVEL_ALTERNATIVE, 'text/html' => self::LEVEL_RELATED, - ), - ), - ); + ], + ], + ]; $this->id = $this->idGenerator->generateId(); } @@ -168,6 +163,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M return $this->getHeaderFieldModel('Content-Type'); } + /** + * Get the Body Content-type of this entity. + * + * @return string + */ + public function getBodyContentType() + { + return $this->userContentType; + } + /** * Set the Content-type of this entity. * @@ -293,16 +298,16 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M public function setChildren(array $children, $compoundLevel = null) { // TODO: Try to refactor this logic - $compoundLevel = isset($compoundLevel) ? $compoundLevel : $this->getCompoundLevel($children); - $immediateChildren = array(); - $grandchildren = array(); + $compoundLevel = $compoundLevel ?? $this->getCompoundLevel($children); + $immediateChildren = []; + $grandchildren = []; $newContentType = $this->userContentType; foreach ($children as $child) { $level = $this->getNeededChildLevel($child, $compoundLevel); if (empty($immediateChildren)) { //first iteration - $immediateChildren = array($child); + $immediateChildren = [$child]; } else { $nextLevel = $this->getNeededChildLevel($immediateChildren[0], $compoundLevel); if ($nextLevel == $level) { @@ -311,7 +316,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M // Re-assign immediateChildren to grandchildren $grandchildren = array_merge($grandchildren, $immediateChildren); // Set new children - $immediateChildren = array($child); + $immediateChildren = [$child]; } else { $grandchildren[] = $child; } @@ -375,7 +380,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M } $this->body = $body; - if (isset($contentType)) { + if (null !== $contentType) { $this->setContentType($contentType); } @@ -395,8 +400,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M /** * Set the encoder used for the body of this entity. * - * @param Swift_Mime_ContentEncoder $encoder - * * @return $this */ public function setEncoder(Swift_Mime_ContentEncoder $encoder) @@ -420,7 +423,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M public function getBoundary() { if (!isset($this->boundary)) { - $this->boundary = '_=_swift_'.time().'_'.md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)).'_=_'; + $this->boundary = '_=_swift_'.time().'_'.bin2hex(random_bytes(16)).'_=_'; } return $this->boundary; @@ -457,8 +460,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M /** * Receive notification that the encoder of this entity or a parent entity * has changed. - * - * @param Swift_Mime_ContentEncoder $encoder */ public function encoderChanged(Swift_Mime_ContentEncoder $encoder) { @@ -522,8 +523,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M /** * Write this entire entity to a {@see Swift_InputByteStream}. - * - * @param Swift_InputByteStream */ public function toByteStream(Swift_InputByteStream $is) { @@ -535,8 +534,6 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M /** * Write this entire entity to a {@link Swift_InputByteStream}. - * - * @param Swift_InputByteStream */ protected function bodyToByteStream(Swift_InputByteStream $is) { @@ -637,7 +634,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M */ protected function fixHeaders() { - if (count($this->immediateChildren)) { + if (\count($this->immediateChildren)) { $this->setHeaderParameter('Content-Type', 'boundary', $this->getBoundary() ); @@ -726,7 +723,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M private function getNeededChildLevel($child, $compoundLevel) { - $filter = array(); + $filter = []; foreach ($this->compoundLevelFilters as $bitmask => $rules) { if (($compoundLevel & $bitmask) === $bitmask) { $filter = $rules + $filter; @@ -734,7 +731,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M } $realLevel = $child->getNestingLevel(); - $lowercaseType = strtolower($child->getContentType()); + $lowercaseType = strtolower($child->getContentType() ?? ''); if (isset($filter[$realLevel]) && isset($filter[$realLevel][$lowercaseType])) { return $filter[$realLevel][$lowercaseType]; @@ -769,7 +766,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M $shouldSort = false; foreach ($this->immediateChildren as $child) { // NOTE: This include alternative parts moved into a related part - if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE) { + if (self::LEVEL_ALTERNATIVE == $child->getNestingLevel()) { $shouldSort = true; break; } @@ -778,13 +775,13 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M // Sort in order of preference, if there is one if ($shouldSort) { // Group the messages by order of preference - $sorted = array(); + $sorted = []; foreach ($this->immediateChildren as $child) { $type = $child->getContentType(); - $level = array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; + $level = \array_key_exists($type, $this->alternativePartOrder) ? $this->alternativePartOrder[$type] : max($this->alternativePartOrder) + 1; if (empty($sorted[$level])) { - $sorted[$level] = array(); + $sorted[$level] = []; } $sorted[$level][] = $child; @@ -792,7 +789,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M ksort($sorted); - $this->immediateChildren = array_reduce($sorted, 'array_merge', array()); + $this->immediateChildren = array_reduce($sorted, 'array_merge', []); } } @@ -813,11 +810,17 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_CharsetObserver, Swift_M { $this->headers = clone $this->headers; $this->encoder = clone $this->encoder; - $this->cacheKey = md5(getmypid().'.'.time().'.'.uniqid(mt_rand(), true)); - $children = array(); + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $children = []; foreach ($this->children as $pos => $child) { $children[$pos] = clone $child; } $this->setChildren($children); } + + public function __wakeup() + { + $this->cacheKey = bin2hex(random_bytes(16)); // set 32 hex values + $this->cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php index 8fa0cbebcd2..ea97619ad69 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/MimePart.php @@ -26,8 +26,8 @@ class Swift_MimePart extends Swift_Mime_MimePart */ public function __construct($body = null, $contentType = null, $charset = null) { - call_user_func_array( - array($this, 'Swift_Mime_MimePart::__construct'), + \call_user_func_array( + [$this, 'Swift_Mime_MimePart::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('mime.part') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php index a580dfbefb6..e44b7af982f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/NullTransport.php @@ -17,8 +17,8 @@ class Swift_NullTransport extends Swift_Transport_NullTransport { public function __construct() { - call_user_func_array( - array($this, 'Swift_Transport_NullTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_NullTransport::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.null') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php index 06b3109e62c..5b1d7deefff 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/AntiFloodPlugin.php @@ -99,8 +99,6 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -108,8 +106,6 @@ class Swift_Plugins_AntiFloodPlugin implements Swift_Events_SendListener, Swift_ /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php index af060a99cc3..36451f44f1f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -30,7 +30,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, private $in = 0; /** Bound byte streams */ - private $mirrors = array(); + private $mirrors = []; /** * Not used. @@ -41,8 +41,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { @@ -52,24 +50,20 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, /** * Invoked immediately following a command being sent. - * - * @param Swift_Events_CommandEvent $evt */ public function commandSent(Swift_Events_CommandEvent $evt) { $command = $evt->getCommand(); - $this->out += strlen($command); + $this->out += \strlen($command); } /** * Invoked immediately following a response coming back. - * - * @param Swift_Events_ResponseEvent $evt */ public function responseReceived(Swift_Events_ResponseEvent $evt) { $response = $evt->getResponse(); - $this->in += strlen($response); + $this->in += \strlen($response); } /** @@ -79,7 +73,7 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, */ public function write($bytes) { - $this->out += strlen($bytes); + $this->out += \strlen($bytes); foreach ($this->mirrors as $stream) { $stream->write($bytes); } @@ -97,8 +91,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is */ public function bind(Swift_InputByteStream $is) { @@ -111,8 +103,6 @@ class Swift_Plugins_BandwidthMonitorPlugin implements Swift_Events_SendListener, * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. - * - * @param Swift_InputByteStream $is */ public function unbind(Swift_InputByteStream $is) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php index 745ee879003..93124c9a5f4 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/DecoratorPlugin.php @@ -23,10 +23,10 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ private $originalBody; /** The original headers of the message, before replacements */ - private $originalHeaders = array(); + private $originalHeaders = []; /** Bodies of children before they are replaced */ - private $originalChildBodies = array(); + private $originalChildBodies = []; /** The Message that was last replaced */ private $lastMessage; @@ -74,8 +74,6 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -98,20 +96,20 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ foreach ($message->getHeaders()->getAll() as $header) { $body = $header->getFieldBodyModel(); $count = 0; - if (is_array($body)) { - $bodyReplaced = array(); + if (\is_array($body)) { + $bodyReplaced = []; foreach ($body as $key => $value) { $count1 = 0; $count2 = 0; - $key = is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; - $value = is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; + $key = \is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; + $value = \is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; $bodyReplaced[$key] = $value; if (!$count && ($count1 || $count2)) { $count = 1; } } - } elseif (is_string($body)) { + } elseif (\is_string($body)) { $bodyReplaced = str_replace($search, $replace, $body, $count); } @@ -159,13 +157,11 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ return $this->replacements->getReplacementsFor($address); } - return isset($this->replacements[$address]) ? $this->replacements[$address] : null; + return $this->replacements[$address] ?? null; } /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { @@ -182,21 +178,21 @@ class Swift_Plugins_DecoratorPlugin implements Swift_Events_SendListener, Swift_ } if (!empty($this->originalHeaders)) { foreach ($message->getHeaders()->getAll() as $header) { - if (array_key_exists($header->getFieldName(), $this->originalHeaders)) { + if (\array_key_exists($header->getFieldName(), $this->originalHeaders)) { $header->setFieldBodyModel($this->originalHeaders[$header->getFieldName()]); } } - $this->originalHeaders = array(); + $this->originalHeaders = []; } if (!empty($this->originalChildBodies)) { $children = (array) $message->getChildren(); foreach ($children as $child) { $id = $child->getId(); - if (array_key_exists($id, $this->originalChildBodies)) { + if (\array_key_exists($id, $this->originalChildBodies)) { $child->setBody($this->originalChildBodies[$id]); } } - $this->originalChildBodies = array(); + $this->originalChildBodies = []; } $this->lastMessage = null; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php index b975d36b858..3f4dbbfa40f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -34,8 +34,6 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -51,8 +49,6 @@ class Swift_Plugins_ImpersonatePlugin implements Swift_Events_SendListener /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php index 7ddf1fd16db..e183749b7ec 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/LoggerPlugin.php @@ -20,8 +20,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ /** * Create a new LoggerPlugin using $logger. - * - * @param Swift_Plugins_Logger $logger */ public function __construct(Swift_Plugins_Logger $logger) { @@ -58,8 +56,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ /** * Invoked immediately following a command being sent. - * - * @param Swift_Events_CommandEvent $evt */ public function commandSent(Swift_Events_CommandEvent $evt) { @@ -69,8 +65,6 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ /** * Invoked immediately following a response coming back. - * - * @param Swift_Events_ResponseEvent $evt */ public function responseReceived(Swift_Events_ResponseEvent $evt) { @@ -80,52 +74,42 @@ class Swift_Plugins_LoggerPlugin implements Swift_Events_CommandListener, Swift_ /** * Invoked just before a Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) { - $transportName = get_class($evt->getSource()); + $transportName = \get_class($evt->getSource()); $this->logger->add(sprintf('++ Starting %s', $transportName)); } /** * Invoked immediately after the Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function transportStarted(Swift_Events_TransportChangeEvent $evt) { - $transportName = get_class($evt->getSource()); + $transportName = \get_class($evt->getSource()); $this->logger->add(sprintf('++ %s started', $transportName)); } /** * Invoked just before a Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) { - $transportName = get_class($evt->getSource()); + $transportName = \get_class($evt->getSource()); $this->logger->add(sprintf('++ Stopping %s', $transportName)); } /** * Invoked immediately after the Transport is stopped. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function transportStopped(Swift_Events_TransportChangeEvent $evt) { - $transportName = get_class($evt->getSource()); + $transportName = \get_class($evt->getSource()); $this->logger->add(sprintf('++ %s stopped', $transportName)); } /** * Invoked as a TransportException is thrown in the Transport system. - * - * @param Swift_Events_TransportExceptionEvent $evt */ public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php index 186b6b41bcd..6f595adaa4d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -20,7 +20,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger * * @var array */ - private $log = array(); + private $log = []; /** * Max size of the log. @@ -47,7 +47,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger public function add($entry) { $this->log[] = $entry; - while (count($this->log) > $this->size) { + while (\count($this->log) > $this->size) { array_shift($this->log); } } @@ -57,7 +57,7 @@ class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger */ public function clear() { - $this->log = array(); + $this->log = []; } /** diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php index 5ff1d9321c0..39c48ed18f5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -16,19 +16,19 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener { /** - * @var Swift_Mime_Message[] + * @var Swift_Mime_SimpleMessage[] */ private $messages; public function __construct() { - $this->messages = array(); + $this->messages = []; } /** * Get the message list. * - * @return Swift_Mime_Message[] + * @return Swift_Mime_SimpleMessage[] */ public function getMessages() { @@ -42,7 +42,7 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener */ public function countMessages() { - return count($this->messages); + return \count($this->messages); } /** @@ -50,13 +50,11 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener */ public function clear() { - $this->messages = array(); + $this->messages = []; } /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -65,8 +63,6 @@ class Swift_Plugins_MessageLogger implements Swift_Events_SendListener /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php index c19403aec61..9448594090b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/PopBeforeSmtpPlugin.php @@ -45,7 +45,8 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Create a new PopBeforeSmtpPlugin for $host and $port. * - * @param string $host + * @param string $host Hostname or IP. Literal IPv6 addresses should be + * wrapped in square brackets. * @param int $port * @param string $crypto as "tls" or "ssl" */ @@ -59,8 +60,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Set a Pop3Connection to delegate to instead of connecting directly. * - * @param Swift_Plugins_Pop_Pop3Connection $connection - * * @return $this */ public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) @@ -72,8 +71,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Bind this plugin to a specific SMTP transport instance. - * - * @param Swift_Transport */ public function bindSmtp(Swift_Transport $smtp) { @@ -135,16 +132,12 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL if (!isset($this->socket)) { if (!$socket = fsockopen( $this->getHostString(), $this->port, $errno, $errstr, $this->timeout)) { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr) - ); + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]: %s', $this->host, $errstr)); } $this->socket = $socket; if (false === $greeting = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to connect to POP3 host [%s]', trim($greeting)) - ); + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to connect to POP3 host [%s]', trim($greeting ?? ''))); } $this->assertOk($greeting); @@ -167,9 +160,7 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL } else { $this->command("QUIT\r\n"); if (!fclose($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('POP3 host [%s] connection could not be stopped', $this->host) - ); + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 host [%s] connection could not be stopped', $this->host)); } $this->socket = null; } @@ -177,8 +168,6 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL /** * Invoked just before a Transport is started. - * - * @param Swift_Events_TransportChangeEvent $evt */ public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) { @@ -216,15 +205,11 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL private function command($command) { if (!fwrite($this->socket, $command)) { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to write command [%s] to POP3 host', trim($command)) - ); + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to write command [%s] to POP3 host', trim($command ?? ''))); } if (false === $response = fgets($this->socket)) { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('Failed to read from POP3 host after command [%s]', trim($command)) - ); + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('Failed to read from POP3 host after command [%s]', trim($command ?? ''))); } $this->assertOk($response); @@ -234,17 +219,15 @@ class Swift_Plugins_PopBeforeSmtpPlugin implements Swift_Events_TransportChangeL private function assertOk($response) { - if (substr($response, 0, 3) != '+OK') { - throw new Swift_Plugins_Pop_Pop3Exception( - sprintf('POP3 command failed [%s]', trim($response)) - ); + if ('+OK' != substr($response, 0, 3)) { + throw new Swift_Plugins_Pop_Pop3Exception(sprintf('POP3 command failed [%s]', trim($response ?? ''))); } } private function getHostString() { $host = $this->host; - switch (strtolower($this->crypto)) { + switch (strtolower($this->crypto ?? '')) { case 'ssl': $host = 'ssl://'.$host; break; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php index 8d797dd117b..f7373b2424c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -27,15 +27,14 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener * * @var array */ - private $whitelist = array(); + private $whitelist = []; /** * Create a new RedirectingPlugin. * * @param mixed $recipient - * @param array $whitelist */ - public function __construct($recipient, array $whitelist = array()) + public function __construct($recipient, array $whitelist = []) { $this->recipient = $recipient; $this->whitelist = $whitelist; @@ -63,8 +62,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Set a list of regular expressions to whitelist certain recipients. - * - * @param array $whitelist */ public function setWhitelist(array $whitelist) { @@ -83,8 +80,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -113,11 +108,11 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener // Add each hard coded recipient $to = $message->getTo(); if (null === $to) { - $to = array(); + $to = []; } foreach ((array) $this->recipient as $recipient) { - if (!array_key_exists($recipient, $to)) { + if (!\array_key_exists($recipient, $to)) { $message->addTo($recipient); } } @@ -126,8 +121,7 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Filter header set against a whitelist of regular expressions. * - * @param Swift_Mime_SimpleHeaderSet $headerSet - * @param string $type + * @param string $type */ private function filterHeaderSet(Swift_Mime_SimpleHeaderSet $headerSet, $type) { @@ -139,13 +133,11 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Filtered list of addresses => name pairs. * - * @param array $recipients - * * @return array */ private function filterNameAddresses(array $recipients) { - $filtered = array(); + $filtered = []; foreach ($recipients as $address => $name) { if ($this->isWhitelisted($address)) { @@ -159,13 +151,11 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Matches address against whitelist of regular expressions. * - * @param $recipient - * * @return bool */ protected function isWhitelisted($recipient) { - if (in_array($recipient, (array) $this->recipient)) { + if (\in_array($recipient, (array) $this->recipient)) { return true; } @@ -180,8 +170,6 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php index 3a2b6657c09..b8818339722 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -24,9 +24,8 @@ interface Swift_Plugins_Reporter /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_SimpleMessage $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} */ public function notify(Swift_Mime_SimpleMessage $message, $address, $result); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php index 5ffca24c61c..c4a016520f6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ReporterPlugin.php @@ -24,8 +24,6 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener /** * Create a new ReporterPlugin using $reporter. - * - * @param Swift_Plugins_Reporter $reporter */ public function __construct(Swift_Plugins_Reporter $reporter) { @@ -41,21 +39,19 @@ class Swift_Plugins_ReporterPlugin implements Swift_Events_SendListener /** * Invoked immediately after the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { $message = $evt->getMessage(); $failures = array_flip($evt->getFailedRecipients()); foreach ((array) $message->getTo() as $address => $null) { - $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } foreach ((array) $message->getCc() as $address => $null) { - $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } foreach ((array) $message->getBcc() as $address => $null) { - $this->reporter->notify($message, $address, (array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); + $this->reporter->notify($message, $address, (\array_key_exists($address, $failures) ? Swift_Plugins_Reporter::RESULT_FAIL : Swift_Plugins_Reporter::RESULT_PASS)); } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php index 67c117ac7c2..249cffbde7b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -20,16 +20,15 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter * * @var array */ - private $failures = array(); + private $failures = []; - private $failures_cache = array(); + private $failures_cache = []; /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_SimpleMessage $message - * @param string $address - * @param int $result from {@link RESULT_PASS, RESULT_FAIL} + * @param string $address + * @param int $result from {@link RESULT_PASS, RESULT_FAIL} */ public function notify(Swift_Mime_SimpleMessage $message, $address, $result) { @@ -54,6 +53,6 @@ class Swift_Plugins_Reporters_HitReporter implements Swift_Plugins_Reporter */ public function clear() { - $this->failures = $this->failures_cache = array(); + $this->failures = $this->failures_cache = []; } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php index 525eef570a9..1cfc3f974f8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -18,9 +18,8 @@ class Swift_Plugins_Reporters_HtmlReporter implements Swift_Plugins_Reporter /** * Notifies this ReportNotifier that $address failed or succeeded. * - * @param Swift_Mime_SimpleMessage $message - * @param string $address - * @param int $result from {@see RESULT_PASS, RESULT_FAIL} + * @param string $address + * @param int $result from {@see RESULT_PASS, RESULT_FAIL} */ public function notify(Swift_Mime_SimpleMessage $message, $address, $result) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php index 77c2e8db6ec..83d3044927f 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Plugins/ThrottlerPlugin.php @@ -72,7 +72,7 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin * Create a new ThrottlerPlugin. * * @param int $rate - * @param int $mode, defaults to {@link BYTES_PER_MINUTE} + * @param int $mode defaults to {@link BYTES_PER_MINUTE} * @param Swift_Plugins_Sleeper $sleeper (only needed in testing) * @param Swift_Plugins_Timer $timer (only needed in testing) */ @@ -86,8 +86,6 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin /** * Invoked immediately before the Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function beforeSendPerformed(Swift_Events_SendEvent $evt) { @@ -119,8 +117,6 @@ class Swift_Plugins_ThrottlerPlugin extends Swift_Plugins_BandwidthMonitorPlugin /** * Invoked when a Message is sent. - * - * @param Swift_Events_SendEvent $evt */ public function sendPerformed(Swift_Events_SendEvent $evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php index 79eafde9ad9..16103e11031 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php @@ -92,7 +92,7 @@ class Swift_Preferences Swift_DependencyContainer::getInstance() ->register('mime.qpcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) ->addConstructorValue($dotEscape); return $this; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php index c129281b347..3c756436cc8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SendmailTransport.php @@ -22,8 +22,8 @@ class Swift_SendmailTransport extends Swift_Transport_SendmailTransport */ public function __construct($command = '/usr/sbin/sendmail -bs') { - call_user_func_array( - array($this, 'Swift_Transport_SendmailTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_SendmailTransport::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.sendmail') ); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php index 2d8176d905c..26c5e285c03 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signer.php @@ -11,7 +11,6 @@ /** * Base Class of Signer Infrastructure. * - * * @author Xavier De Cock */ interface Swift_Signer diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php index 8e66e18f4e0..b25c427af83 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -18,8 +18,6 @@ interface Swift_Signers_BodySigner extends Swift_Signer /** * Change the Swift_Signed_Message to apply the singing. * - * @param Swift_Message $message - * * @return self */ public function signMessage(Swift_Message $message); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php index a88daa19815..ec82dc05663 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -66,7 +66,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var array */ - protected $ignoredHeaders = array('return-path' => true); + protected $ignoredHeaders = ['return-path' => true]; /** * Signer identity. @@ -124,14 +124,14 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner * * @var array */ - protected $signedHeaders = array(); + protected $signedHeaders = []; /** * If debugHeaders is set store debugData here. * - * @var string + * @var string[] */ - private $debugHeadersData = ''; + private $debugHeadersData = []; /** * Stores the bodyHash. @@ -163,7 +163,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private $bodyCanonLine = ''; - private $bound = array(); + private $bound = []; /** * Constructor. @@ -190,7 +190,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner public function reset() { $this->headerHash = null; - $this->signedHeaders = array(); + $this->signedHeaders = []; $this->bodyHash = null; $this->bodyHashHandler = null; $this->bodyCanonIgnoreStart = 2; @@ -236,10 +236,9 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * Attach $is to this stream. + * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. - * - * @param Swift_InputByteStream $is */ public function bind(Swift_InputByteStream $is) { @@ -251,11 +250,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * Remove an already bound stream. + * * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. - * - * @param Swift_InputByteStream $is */ public function unbind(Swift_InputByteStream $is) { @@ -297,7 +295,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner break; case 'rsa-sha256': $this->hashAlgorithm = 'rsa-sha256'; - if (!defined('OPENSSL_ALGO_SHA256')) { + if (!\defined('OPENSSL_ALGO_SHA256')) { throw new Swift_SwiftException('Unable to set sha256 as it is not supported by OpenSSL.'); } break; @@ -317,7 +315,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner */ public function setBodyCanon($canon) { - if ($canon == 'relaxed') { + if ('relaxed' == $canon) { $this->bodyCanon = 'relaxed'; } else { $this->bodyCanon = 'simple'; @@ -335,7 +333,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner */ public function setHeaderCanon($canon) { - if ($canon == 'relaxed') { + if ('relaxed' == $canon) { $this->headerCanon = 'relaxed'; } else { $this->headerCanon = 'simple'; @@ -367,10 +365,10 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner */ public function setBodySignedLen($len) { - if ($len === true) { + if (true === $len) { $this->showLen = true; $this->maxLen = PHP_INT_MAX; - } elseif ($len === false) { + } elseif (false === $len) { $this->showLen = false; $this->maxLen = PHP_INT_MAX; } else { @@ -456,9 +454,9 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner public function getAlteredHeaders() { if ($this->debugHeaders) { - return array('DKIM-Signature', 'X-DebugHash'); + return ['DKIM-Signature', 'X-DebugHash']; } else { - return array('DKIM-Signature'); + return ['DKIM-Signature']; } } @@ -471,7 +469,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner */ public function ignoreHeader($header_name) { - $this->ignoredHeaders[strtolower($header_name)] = true; + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; return $this; } @@ -479,8 +477,6 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * Set the headers to sign. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return Swift_Signers_DKIMSigner */ public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) @@ -490,11 +486,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { - if ($header->getFieldBody() != '') { + if ('' != $header->getFieldBody()) { $this->addHeader($header->toString()); $this->signedHeaders[] = $header->getFieldName(); } @@ -509,32 +505,30 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner /** * Add the signature to the given Headers. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return Swift_Signers_DKIMSigner */ public function addSignature(Swift_Mime_SimpleHeaderSet $headers) { // Prepare the DKIM-Signature - $params = array('v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector); - if ($this->bodyCanon != 'simple') { + $params = ['v' => '1', 'a' => $this->hashAlgorithm, 'bh' => base64_encode($this->bodyHash ?? ''), 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'i' => $this->signerIdentity, 's' => $this->selector]; + if ('simple' != $this->bodyCanon) { $params['c'] = $this->headerCanon.'/'.$this->bodyCanon; - } elseif ($this->headerCanon != 'simple') { + } elseif ('simple' != $this->headerCanon) { $params['c'] = $this->headerCanon; } if ($this->showLen) { $params['l'] = $this->bodyLen; } - if ($this->signatureTimestamp === true) { + if (true === $this->signatureTimestamp) { $params['t'] = time(); - if ($this->signatureExpiration !== false) { + if (false !== $this->signatureExpiration) { $params['x'] = $params['t'] + $this->signatureExpiration; } } else { - if ($this->signatureTimestamp !== false) { + if (false !== $this->signatureTimestamp) { $params['t'] = $this->signatureTimestamp; } - if ($this->signatureExpiration !== false) { + if (false !== $this->signatureExpiration) { $params['x'] = $this->signatureExpiration; } } @@ -550,11 +544,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner // Add the last DKIM-Signature $tmp = $headers->getAll('DKIM-Signature'); $this->dkimHeader = end($tmp); - $this->addHeader(trim($this->dkimHeader->toString())."\r\n b=", true); + $this->addHeader(trim($this->dkimHeader->toString() ?? '')."\r\n b=", true); if ($this->debugHeaders) { - $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash)); + $headers->addTextHeader('X-DebugHash', base64_encode($this->headerHash ?? '')); } - $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash()), 73, ' '))); + $this->dkimHeader->setValue($string.' b='.trim(chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '))); return $this; } @@ -571,6 +565,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $value = str_replace("\r\n", '', $exploded[1]); $value = preg_replace("/[ \t][ \t]+/", ' ', $value); $header = $name.':'.trim($value).($is_sig ? '' : "\r\n"); + // no break case 'simple': // Nothing to do } @@ -579,9 +574,9 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner protected function canonicalizeBody($string) { - $len = strlen($string); + $len = \strlen($string); $canon = ''; - $method = ($this->bodyCanon == 'relaxed'); + $method = ('relaxed' == $this->bodyCanon); for ($i = 0; $i < $len; ++$i) { if ($this->bodyCanonIgnoreStart > 0) { --$this->bodyCanonIgnoreStart; @@ -592,11 +587,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $this->bodyCanonLastChar = "\r"; break; case "\n": - if ($this->bodyCanonLastChar == "\r") { + if ("\r" == $this->bodyCanonLastChar) { if ($method) { $this->bodyCanonSpace = false; } - if ($this->bodyCanonLine == '') { + if ('' == $this->bodyCanonLine) { ++$this->bodyCanonEmptyCounter; } else { $this->bodyCanonLine = ''; @@ -613,6 +608,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner $this->bodyCanonSpace = true; break; } + // no break default: if ($this->bodyCanonEmptyCounter > 0) { $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); @@ -633,7 +629,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner protected function endOfBody() { // Add trailing Line return if last line is non empty - if (strlen($this->bodyCanonLine) > 0) { + if (\strlen($this->bodyCanonLine) > 0) { $this->addToBodyHash("\r\n"); } $this->bodyHash = hash_final($this->bodyHashHandler, true); @@ -641,7 +637,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private function addToBodyHash($string) { - $len = strlen($string); + $len = \strlen($string); if ($len > ($new_len = ($this->maxLen - $this->bodyLen))) { $string = substr($string, 0, $new_len); $len = $new_len; @@ -653,7 +649,7 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner private function addToHeaderHash($header) { if ($this->debugHeaders) { - $this->debugHeadersData[] = trim($header); + $this->debugHeadersData[] = trim($header ?? ''); } $this->headerCanonData .= $header; } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php index 40654987f9b..5e2b67b6520 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -55,7 +55,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * * @var array */ - protected $ignoredHeaders = array(); + protected $ignoredHeaders = []; /** * Signer identity. @@ -77,7 +77,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner * * @var array */ - private $signedHeaders = array(); + private $signedHeaders = []; /** * Stores the signature header. @@ -93,8 +93,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner */ private $hashHandler; - private $hash; - private $canonData = ''; private $bodyCanonEmptyCounter = 0; @@ -107,7 +105,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner private $bodyCanonLine = ''; - private $bound = array(); + private $bound = []; /** * Constructor. @@ -131,7 +129,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner */ public function reset() { - $this->hash = null; $this->hashHandler = null; $this->bodyCanonIgnoreStart = 2; $this->bodyCanonEmptyCounter = 0; @@ -185,11 +182,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner /** * Attach $is to this stream. + * * The stream acts as an observer, receiving all data that is written. * All {@link write()} and {@link flushBuffers()} operations will be mirrored. * - * @param Swift_InputByteStream $is - * * @return $this */ public function bind(Swift_InputByteStream $is) @@ -202,12 +198,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner /** * Remove an already bound stream. + * * If $is is not bound, no errors will be raised. * If the stream currently has any buffered data it will be written to $is * before unbinding occurs. * - * @param Swift_InputByteStream $is - * * @return $this */ public function unbind(Swift_InputByteStream $is) @@ -262,7 +257,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner */ public function setCanon($canon) { - if ($canon == 'nofws') { + if ('nofws' == $canon) { $this->canon = 'nofws'; } else { $this->canon = 'simple'; @@ -322,10 +317,10 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner public function getAlteredHeaders() { if ($this->debugHeaders) { - return array('DomainKey-Signature', 'X-DebugHash'); + return ['DomainKey-Signature', 'X-DebugHash']; } - return array('DomainKey-Signature'); + return ['DomainKey-Signature']; } /** @@ -337,7 +332,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner */ public function ignoreHeader($header_name) { - $this->ignoredHeaders[strtolower($header_name)] = true; + $this->ignoredHeaders[strtolower($header_name ?? '')] = true; return $this; } @@ -345,8 +340,6 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner /** * Set the headers to sign. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return $this */ public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) @@ -357,11 +350,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { if ($headers->has($hName)) { $tmp = $headers->getAll($hName); foreach ($tmp as $header) { - if ($header->getFieldBody() != '') { + if ('' != $header->getFieldBody()) { $this->addHeader($header->toString()); $this->signedHeaders[] = $header->getFieldName(); } @@ -377,14 +370,12 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner /** * Add the signature to the given Headers. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return $this */ public function addSignature(Swift_Mime_SimpleHeaderSet $headers) { // Prepare the DomainKey-Signature Header - $params = array('a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash()), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector); + $params = ['a' => $this->hashAlgorithm, 'b' => chunk_split(base64_encode($this->getEncryptedHash() ?? ''), 73, ' '), 'c' => $this->canon, 'd' => $this->domainName, 'h' => implode(': ', $this->signedHeaders), 'q' => 'dns', 's' => $this->selector]; $string = ''; foreach ($params as $k => $v) { $string .= $k.'='.$v.'; '; @@ -407,6 +398,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $value = str_replace("\r\n", '', $exploded[1]); $value = preg_replace("/[ \t][ \t]+/", ' ', $value); $header = $name.':'.trim($value)."\r\n"; + // no break case 'simple': // Nothing to do } @@ -420,9 +412,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner protected function canonicalizeBody($string) { - $len = strlen($string); + $len = \strlen($string); $canon = ''; - $nofws = ($this->canon == 'nofws'); + $nofws = ('nofws' == $this->canon); for ($i = 0; $i < $len; ++$i) { if ($this->bodyCanonIgnoreStart > 0) { --$this->bodyCanonIgnoreStart; @@ -433,11 +425,11 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $this->bodyCanonLastChar = "\r"; break; case "\n": - if ($this->bodyCanonLastChar == "\r") { + if ("\r" == $this->bodyCanonLastChar) { if ($nofws) { $this->bodyCanonSpace = false; } - if ($this->bodyCanonLine == '') { + if ('' == $this->bodyCanonLine) { ++$this->bodyCanonEmptyCounter; } else { $this->bodyCanonLine = ''; @@ -455,6 +447,7 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner $this->bodyCanonSpace = true; break; } + // no break default: if ($this->bodyCanonEmptyCounter > 0) { $canon .= str_repeat("\r\n", $this->bodyCanonEmptyCounter); @@ -469,10 +462,9 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner protected function endOfBody() { - if (strlen($this->bodyCanonLine) > 0) { + if (\strlen($this->bodyCanonLine) > 0) { $this->addToHash("\r\n"); } - $this->hash = hash_final($this->hashHandler, true); } private function addToHash($string) diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php index 6104e34f3f5..6f5c20923dc 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -41,8 +41,6 @@ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream /** * Give the headers already given. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return self */ public function setHeaders(Swift_Mime_SimpleHeaderSet $headers); @@ -50,8 +48,6 @@ interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream /** * Add the header(s) to the headerSet. * - * @param Swift_Mime_SimpleHeaderSet $headers - * * @return self */ public function addSignature(Swift_Mime_SimpleHeaderSet $headers); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php index deb29f575f2..520bcc15e8b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -13,6 +13,8 @@ * Takes advantage of pecl extension. * * @author Xavier De Cock + * + * @deprecated since SwiftMailer 6.1.0; use Swift_Signers_DKIMSigner instead. */ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { @@ -29,7 +31,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner public function __construct($privateKey, $domainName, $selector) { - if (!extension_loaded('opendkim')) { + if (!\extension_loaded('opendkim')) { throw new Swift_SwiftException('php-opendkim extension not found'); } @@ -42,7 +44,7 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner { $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); $headerVal = $this->dkimHandler->getSignatureHeader(); - if (!$headerVal) { + if (false === $headerVal || \is_int($headerVal)) { throw new Swift_SwiftException('OpenDKIM Error: '.$this->dkimHandler->getError()); } $header->setValue($headerVal); @@ -53,14 +55,10 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner public function setHeaders(Swift_Mime_SimpleHeaderSet $headers) { - $bodyLen = $this->bodyLen; - if (is_bool($bodyLen)) { - $bodyLen = -1; - } - $hash = $this->hashAlgorithm == 'rsa-sha1' ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; - $bodyCanon = $this->bodyCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $headerCanon = $this->headerCanon == 'simple' ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; - $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); + $hash = 'rsa-sha1' == $this->hashAlgorithm ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = 'simple' == $this->bodyCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = 'simple' == $this->headerCanon ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->dkimHandler = new OpenDKIMSign($this->privateKey, $this->selector, $this->domainName, $headerCanon, $bodyCanon, $hash, -1); // Hardcode signature Margin for now $this->dkimHandler->setMargin(78); @@ -77,11 +75,11 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner $listHeaders = $headers->listAll(); foreach ($listHeaders as $hName) { // Check if we need to ignore Header - if (!isset($this->ignoredHeaders[strtolower($hName)])) { + if (!isset($this->ignoredHeaders[strtolower($hName ?? '')])) { $tmp = $headers->getAll($hName); if ($headers->has($hName)) { foreach ($tmp as $header) { - if ($header->getFieldBody() != '') { + if ('' != $header->getFieldBody()) { $htosign = $header->toString(); $this->dkimHandler->header($htosign); $this->signedHeaders[] = $header->getFieldName(); @@ -172,13 +170,13 @@ class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner if (!$this->peclLoaded) { return parent::canonicalizeBody($string); } - if (false && $this->dropFirstLF === true) { - if ($string[0] == "\r" && $string[1] == "\n") { + if (true === $this->dropFirstLF) { + if ("\r" == $string[0] && "\n" == $string[1]) { $string = substr($string, 2); } } $this->dropFirstLF = false; - if (strlen($string)) { + if (\strlen($string)) { $this->dkimHandler->body($string); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php index e2231151993..3dd3cd05f04 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -11,9 +11,9 @@ /** * MIME Message Signer used to apply S/MIME Signature/Encryption to a message. * - * * @author Romain-Geissler * @author Sebastiaan Stok + * @author Jan Flora */ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner { @@ -27,6 +27,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner protected $encryptOptions; protected $encryptCipher; protected $extraCerts = null; + protected $wrapFullMessage = false; /** * @var Swift_StreamFilters_StringReplacementFilterFactory @@ -65,7 +66,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Set the certificate location to use for signing. * - * @see http://www.php.net/manual/en/openssl.pkcs7.flags.php + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php * * @param string $certificate * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead @@ -79,7 +80,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner $this->signCertificate = 'file://'.str_replace('\\', '/', realpath($certificate)); if (null !== $privateKey) { - if (is_array($privateKey)) { + if (\is_array($privateKey)) { $this->signPrivateKey = $privateKey; $this->signPrivateKey[0] = 'file://'.str_replace('\\', '/', realpath($privateKey[0])); } else { @@ -88,9 +89,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner } $this->signOptions = $signOptions; - if (null !== $extraCerts) { - $this->extraCerts = str_replace('\\', '/', realpath($extraCerts)); - } + $this->extraCerts = $extraCerts ? realpath($extraCerts) : null; return $this; } @@ -98,8 +97,8 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner /** * Set the certificate location to use for encryption. * - * @see http://www.php.net/manual/en/openssl.pkcs7.flags.php - * @see http://nl3.php.net/manual/en/openssl.ciphers.php + * @see https://secure.php.net/manual/en/openssl.pkcs7.flags.php + * @see https://secure.php.net/manual/en/openssl.ciphers.php * * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. * @param int $cipher @@ -108,8 +107,8 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner */ public function setEncryptCertificate($recipientCerts, $cipher = null) { - if (is_array($recipientCerts)) { - $this->encryptCert = array(); + if (\is_array($recipientCerts)) { + $this->encryptCert = []; foreach ($recipientCerts as $cert) { $this->encryptCert[] = 'file://'.str_replace('\\', '/', realpath($cert)); @@ -178,9 +177,27 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner } /** - * Change the Swift_Message to apply the signing. + * Specify whether to wrap the entire MIME message in the S/MIME message. * - * @param Swift_Message $message + * According to RFC5751 section 3.1: + * In order to protect outer, non-content-related message header fields + * (for instance, the "Subject", "To", "From", and "Cc" fields), the + * sending client MAY wrap a full MIME message in a message/rfc822 + * wrapper in order to apply S/MIME security services to these header + * fields. It is up to the receiving client to decide how to present + * this "inner" header along with the unprotected "outer" header. + * + * @param bool $wrap + * + * @return $this + */ + public function setWrapFullMessage($wrap) + { + $this->wrapFullMessage = $wrap; + } + + /** + * Change the Swift_Message to apply the signing. * * @return $this */ @@ -190,17 +207,13 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner return $this; } - // Store the message using ByteStream to a file{1} - // Remove all Children - // Sign file{1}, parse the new MIME headers and set them on the primary MimeEntity - // Set the singed-body as the new body (without boundary) - - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $this->toSMimeByteStream($messageStream, $message); - $message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder')); - - $message->setChildren(array()); - $this->streamToMime($messageStream, $message); + if ($this->signThenEncrypt) { + $this->smimeSignMessage($message); + $this->smimeEncryptMessage($message); + } else { + $this->smimeEncryptMessage($message); + $this->smimeSignMessage($message); + } } /** @@ -210,102 +223,303 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner */ public function getAlteredHeaders() { - return array('Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition'); + return ['Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition']; } /** - * @param Swift_InputByteStream $inputStream - * @param Swift_Message $mimeEntity + * Sign a Swift message. */ - protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message) + protected function smimeSignMessage(Swift_Message $message) { - $mimeEntity = $this->createMessage($message); - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - - $mimeEntity->toByteStream($messageStream); - $messageStream->commit(); - - if (null !== $this->signCertificate && null !== $this->encryptCert) { - $temporaryStream = new Swift_ByteStream_TemporaryFileByteStream(); - - if ($this->signThenEncrypt) { - $this->messageStreamToSignedByteStream($messageStream, $temporaryStream); - $this->messageStreamToEncryptedByteStream($temporaryStream, $inputStream); - } else { - $this->messageStreamToEncryptedByteStream($messageStream, $temporaryStream); - $this->messageStreamToSignedByteStream($temporaryStream, $inputStream); - } - } elseif ($this->signCertificate !== null) { - $this->messageStreamToSignedByteStream($messageStream, $inputStream); - } else { - $this->messageStreamToEncryptedByteStream($messageStream, $inputStream); + // If we don't have a certificate we can't sign the message + if (null === $this->signCertificate) { + return; } - } - /** - * @param Swift_Message $message - * - * @return Swift_Message - */ - protected function createMessage(Swift_Message $message) - { - $mimeEntity = new Swift_Message('', $message->getBody(), $message->getContentType(), $message->getCharset()); - $mimeEntity->setChildren($message->getChildren()); + // Work on a clone of the original message + $signMessage = clone $message; + $signMessage->clearSigners(); - $messageHeaders = $mimeEntity->getHeaders(); - $messageHeaders->remove('Message-ID'); - $messageHeaders->remove('Date'); - $messageHeaders->remove('Subject'); - $messageHeaders->remove('MIME-Version'); - $messageHeaders->remove('To'); - $messageHeaders->remove('From'); + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $signMessage = $this->wrapMimeMessage($signMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($signMessage); + $this->copyHeaders( + $message, + $signMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } - return $mimeEntity; - } - - /** - * @param Swift_FileStream $outputStream - * @param Swift_InputByteStream $inputStream - * - * @throws Swift_IoException - */ - protected function messageStreamToSignedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $inputStream) - { + // Copy the cloned message into a temporary file stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $signMessage->toByteStream($messageStream); + $messageStream->commit(); $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $args = array($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions); - if (null !== $this->extraCerts) { - $args[] = $this->extraCerts; - } - - if (!call_user_func_array('openssl_pkcs7_sign', $args)) { + // Sign the message using openssl + if (!openssl_pkcs7_sign( + $messageStream->getPath(), + $signedMessageStream->getPath(), + $this->signCertificate, + $this->signPrivateKey, + [], + $this->signOptions, + $this->extraCerts + ) + ) { throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); } - $this->copyFromOpenSSLOutput($signedMessageStream, $inputStream); + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($signedMessageStream, $message); } /** - * @param Swift_FileStream $outputStream - * @param Swift_InputByteStream $is - * - * @throws Swift_IoException + * Encrypt a Swift message. */ - protected function messageStreamToEncryptedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $is) + protected function smimeEncryptMessage(Swift_Message $message) { + // If we don't have a certificate we can't encrypt the message + if (null === $this->encryptCert) { + return; + } + + // Work on a clone of the original message + $encryptMessage = clone $message; + $encryptMessage->clearSigners(); + + if ($this->wrapFullMessage) { + // The original message essentially becomes the body of the new + // wrapped message + $encryptMessage = $this->wrapMimeMessage($encryptMessage); + } else { + // Only keep header needed to parse the body correctly + $this->clearAllHeaders($encryptMessage); + $this->copyHeaders( + $message, + $encryptMessage, + [ + 'Content-Type', + 'Content-Transfer-Encoding', + 'Content-Disposition', + ] + ); + } + + // Convert the message content (including headers) to a string + // and place it in a temporary file + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $encryptMessage->toByteStream($messageStream); + $messageStream->commit(); $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); - if (!openssl_pkcs7_encrypt($outputStream->getPath(), $encryptedMessageStream->getPath(), $this->encryptCert, array(), 0, $this->encryptCipher)) { + // Encrypt the message + if (!openssl_pkcs7_encrypt( + $messageStream->getPath(), + $encryptedMessageStream->getPath(), + $this->encryptCert, + [], + 0, + $this->encryptCipher + ) + ) { throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); } - $this->copyFromOpenSSLOutput($encryptedMessageStream, $is); + // Parse the resulting signed message content back into the Swift message + // preserving the original headers + $this->parseSSLOutput($encryptedMessageStream, $message); } /** - * @param Swift_OutputByteStream $fromStream - * @param Swift_InputByteStream $toStream + * Copy named headers from one Swift message to another. */ + protected function copyHeaders( + Swift_Message $fromMessage, + Swift_Message $toMessage, + array $headers = [] + ) { + foreach ($headers as $header) { + $this->copyHeader($fromMessage, $toMessage, $header); + } + } + + /** + * Copy a single header from one Swift message to another. + * + * @param string $headerName + */ + protected function copyHeader(Swift_Message $fromMessage, Swift_Message $toMessage, $headerName) + { + $header = $fromMessage->getHeaders()->get($headerName); + if (!$header) { + return; + } + $headers = $toMessage->getHeaders(); + switch ($header->getFieldType()) { + case Swift_Mime_Header::TYPE_TEXT: + $headers->addTextHeader($header->getFieldName(), $header->getValue()); + break; + case Swift_Mime_Header::TYPE_PARAMETERIZED: + $headers->addParameterizedHeader( + $header->getFieldName(), + $header->getValue(), + $header->getParameters() + ); + break; + } + } + + /** + * Remove all headers from a Swift message. + */ + protected function clearAllHeaders(Swift_Message $message) + { + $headers = $message->getHeaders(); + foreach ($headers->listAll() as $header) { + $headers->removeAll($header); + } + } + + /** + * Wraps a Swift_Message in a message/rfc822 MIME part. + * + * @return Swift_MimePart + */ + protected function wrapMimeMessage(Swift_Message $message) + { + // Start by copying the original message into a message stream + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + // Create a new MIME part that wraps the original stream + $wrappedMessage = new Swift_MimePart($messageStream, 'message/rfc822'); + $wrappedMessage->setEncoder(new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')); + + return $wrappedMessage; + } + + protected function parseSSLOutput(Swift_InputByteStream $inputStream, Swift_Message $message) + { + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $this->copyFromOpenSSLOutput($inputStream, $messageStream); + + $this->streamToMime($messageStream, $message); + } + + /** + * Merges an OutputByteStream from OpenSSL to a Swift_Message. + */ + protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) + { + // Parse the stream into headers and body + list($headers, $messageStream) = $this->parseStream($fromStream); + + // Get the original message headers + $messageHeaders = $message->getHeaders(); + + // Let the stream determine the headers describing the body content, + // since the body of the original message is overwritten by the body + // coming from the stream. + // These are all content-* headers. + + // Default transfer encoding is 7bit if not set + $encoding = ''; + // Remove all existing transfer encoding headers + $messageHeaders->removeAll('Content-Transfer-Encoding'); + // See whether the stream sets the transfer encoding + if (isset($headers['content-transfer-encoding'])) { + $encoding = $headers['content-transfer-encoding']; + } + + // We use the null content encoder, since the body is already encoded + // according to the transfer encoding specified in the stream + $message->setEncoder(new Swift_Mime_ContentEncoder_NullContentEncoder($encoding)); + + // Set the disposition, if present + if (isset($headers['content-disposition'])) { + $messageHeaders->addTextHeader('Content-Disposition', $headers['content-disposition']); + } + + // Copy over the body from the stream using the content type dictated + // by the stream content + $message->setChildren([]); + $message->setBody($messageStream, $headers['content-type']); + } + + /** + * This message will parse the headers of a MIME email byte stream + * and return an array that contains the headers as an associative + * array and the email body as a string. + * + * @return array + */ + protected function parseStream(Swift_OutputByteStream $emailStream) + { + $bufferLength = 78; + $headerData = ''; + $headerBodySeparator = "\r\n\r\n"; + + $emailStream->setReadPointer(0); + + // Read out the headers section from the stream to a string + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $headerData .= $buffer; + + $headersPosEnd = strpos($headerData, $headerBodySeparator); + + // Stop reading if we found the end of the headers + if (false !== $headersPosEnd) { + break; + } + } + + // Split the header data into lines + $headerData = trim(substr($headerData, 0, $headersPosEnd)); + $headerLines = explode("\r\n", $headerData); + unset($headerData); + + $headers = []; + $currentHeaderName = ''; + + // Transform header lines into an associative array + foreach ($headerLines as $headerLine) { + // Handle headers that span multiple lines + if (false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' '.trim($headerLine ?? ''); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0] ?? ''); + $headers[$currentHeaderName] = trim($header[1] ?? ''); + } + + // Read the entire email body into a byte stream + $bodyStream = new Swift_ByteStream_TemporaryFileByteStream(); + + // Skip the header and separator and point to the body + $emailStream->setReadPointer($headersPosEnd + \strlen($headerBodySeparator)); + + while (false !== ($buffer = $emailStream->read($bufferLength))) { + $bodyStream->write($buffer); + } + + $bodyStream->commit(); + + return [$headers, $bodyStream]; + } + protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) { $bufferLength = 4096; @@ -325,93 +539,4 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner $toStream->commit(); } - - /** - * Merges an OutputByteStream to Swift_Message. - * - * @param Swift_OutputByteStream $fromStream - * @param Swift_Message $message - */ - protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) - { - $bufferLength = 78; - $headerData = ''; - - $fromStream->setReadPointer(0); - - while (($buffer = $fromStream->read($bufferLength)) !== false) { - $headerData .= $buffer; - - if (false !== strpos($buffer, "\r\n\r\n")) { - break; - } - } - - $headersPosEnd = strpos($headerData, "\r\n\r\n"); - $headerData = trim($headerData); - $headerData = substr($headerData, 0, $headersPosEnd); - $headerLines = explode("\r\n", $headerData); - unset($headerData); - - $headers = array(); - $currentHeaderName = ''; - - foreach ($headerLines as $headerLine) { - // Line separated - if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { - $headers[$currentHeaderName] .= ' '.trim($headerLine); - continue; - } - - $header = explode(':', $headerLine, 2); - $currentHeaderName = strtolower($header[0]); - $headers[$currentHeaderName] = trim($header[1]); - } - - $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); - $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); - $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); - - $messageHeaders = $message->getHeaders(); - - // No need to check for 'application/pkcs7-mime', as this is always base64 - if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) { - if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $headers['content-type'], $contentTypeData)) { - throw new Swift_SwiftException('Failed to find Boundary parameter'); - } - - $boundary = trim($contentTypeData['1'], '"'); - - // Skip the header and CRLF CRLF - $fromStream->setReadPointer($headersPosEnd + 4); - - while (false !== ($buffer = $fromStream->read($bufferLength))) { - $messageStream->write($buffer); - } - - $messageStream->commit(); - - $messageHeaders->remove('Content-Transfer-Encoding'); - $message->setContentType($headers['content-type']); - $message->setBoundary($boundary); - $message->setBody($messageStream); - } else { - $fromStream->setReadPointer($headersPosEnd + 4); - - if (null === $this->headerFactory) { - $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory'); - } - - $message->setContentType($headers['content-type']); - $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding'])); - $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition'])); - - while (false !== ($buffer = $fromStream->read($bufferLength))) { - $messageStream->write($buffer); - } - - $messageStream->commit(); - $message->setBody($messageStream); - } - } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php index 011c03ab188..56b62323ad7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -23,22 +23,23 @@ class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport { /** - * Create a new SmtpTransport, optionally with $host, $port and $security. - * * @param string $host * @param int $port - * @param string $security + * @param string|null $encryption SMTP encryption mode: + * - null for plain SMTP (no encryption), + * - 'tls' for SMTP with STARTTLS (best effort encryption), + * - 'ssl' for SMTPS = SMTP over TLS (always encrypted). */ - public function __construct($host = 'localhost', $port = 25, $security = null) + public function __construct($host = 'localhost', $port = 25, $encryption = null) { - call_user_func_array( - array($this, 'Swift_Transport_EsmtpTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_EsmtpTransport::__construct'], Swift_DependencyContainer::getInstance() ->createDependenciesFor('transport.smtp') - ); + ); $this->setHost($host); $this->setPort($port); - $this->setEncryption($security); + $this->setEncryption($encryption); } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php index f92567ba021..c08e0fb17d5 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -17,8 +17,6 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport { /** * Create a new SpoolTransport. - * - * @param Swift_Spool $spool */ public function __construct(Swift_Spool $spool) { @@ -27,8 +25,8 @@ class Swift_SpoolTransport extends Swift_Transport_SpoolTransport $arguments[] = $spool; - call_user_func_array( - array($this, 'Swift_Transport_SpoolTransport::__construct'), + \call_user_func_array( + [$this, 'Swift_Transport_SpoolTransport::__construct'], $arguments ); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php index ba1f6d323fc..7e5ddf1b7da 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/ByteArrayReplacementFilter.php @@ -17,9 +17,6 @@ */ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilter { - /** The needle(s) to search for */ - private $search; - /** The replacement(s) to make */ private $replace; @@ -27,7 +24,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt private $index; /** The Search Tree */ - private $tree = array(); + private $tree = []; /** Gives the size of the largest search */ private $treeMaxLen = 0; @@ -42,26 +39,25 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt */ public function __construct($search, $replace) { - $this->search = $search; - $this->index = array(); - $this->tree = array(); - $this->replace = array(); - $this->repSize = array(); + $this->index = []; + $this->tree = []; + $this->replace = []; + $this->repSize = []; $tree = null; $i = null; $last_size = $size = 0; foreach ($search as $i => $search_element) { - if ($tree !== null) { - $tree[-1] = min(count($replace) - 1, $i - 1); + if (null !== $tree) { + $tree[-1] = min(\count($replace) - 1, $i - 1); $tree[-2] = $last_size; } $tree = &$this->tree; - if (is_array($search_element)) { + if (\is_array($search_element)) { foreach ($search_element as $k => $char) { $this->index[$char] = true; if (!isset($tree[$char])) { - $tree[$char] = array(); + $tree[$char] = []; } $tree = &$tree[$char]; } @@ -70,27 +66,27 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt } else { $last_size = 1; if (!isset($tree[$search_element])) { - $tree[$search_element] = array(); + $tree[$search_element] = []; } $tree = &$tree[$search_element]; $size = max($last_size, $size); $this->index[$search_element] = true; } } - if ($i !== null) { - $tree[-1] = min(count($replace) - 1, $i); + if (null !== $i) { + $tree[-1] = min(\count($replace) - 1, $i); $tree[-2] = $last_size; $this->treeMaxLen = $size; } foreach ($replace as $rep) { - if (!is_array($rep)) { - $rep = array($rep); + if (!\is_array($rep)) { + $rep = [$rep]; } $this->replace[] = $rep; } - for ($i = count($this->replace) - 1; $i >= 0; --$i) { + for ($i = \count($this->replace) - 1; $i >= 0; --$i) { $this->replace[$i] = $rep = $this->filter($this->replace[$i], $i); - $this->repSize[$i] = count($rep); + $this->repSize[$i] = \count($rep); } } @@ -118,12 +114,12 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt */ public function filter($buffer, $minReplaces = -1) { - if ($this->treeMaxLen == 0) { + if (0 == $this->treeMaxLen) { return $buffer; } - $newBuffer = array(); - $buf_size = count($buffer); + $newBuffer = []; + $buf_size = \count($buffer); $last_size = 0; for ($i = 0; $i < $buf_size; ++$i) { $search_pos = $this->tree; @@ -141,7 +137,7 @@ class Swift_StreamFilters_ByteArrayReplacementFilter implements Swift_StreamFilt } } // We got a complete pattern - elseif ($last_found !== PHP_INT_MAX) { + elseif (PHP_INT_MAX !== $last_found) { // Adding replacement datas to output buffer $rep_size = $this->repSize[$last_found]; for ($j = 0; $j < $rep_size; ++$j) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php index f60f0cf8218..783b8896dd7 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -16,7 +16,7 @@ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_ReplacementFilterFactory { /** Lazy-loaded filters */ - private $filters = array(); + private $filters = []; /** * Create a new StreamFilter to replace $search with $replace in a string. @@ -30,11 +30,11 @@ class Swift_StreamFilters_StringReplacementFilterFactory implements Swift_Replac { if (!isset($this->filters[$search][$replace])) { if (!isset($this->filters[$search])) { - $this->filters[$search] = array(); + $this->filters[$search] = []; } if (!isset($this->filters[$search][$replace])) { - $this->filters[$search][$replace] = array(); + $this->filters[$search][$replace] = []; } $this->filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php index db3d31093ef..15e68b18e79 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/SwiftException.php @@ -18,9 +18,8 @@ class Swift_SwiftException extends Exception /** * Create a new SwiftException with $message. * - * @param string $message - * @param int $code - * @param Exception $previous + * @param string $message + * @param int $code */ public function __construct($message, $code = 0, Exception $previous = null) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php index f6214b7bfc5..bc324e8685a 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport.php @@ -61,8 +61,9 @@ interface Swift_Transport * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * This is the responsibility of the send method to start the transport if needed. + * + * @param string[] $failedRecipients An array of failures by-reference * * @return int */ @@ -70,8 +71,6 @@ interface Swift_Transport /** * Register a plugin in the Transport. - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php index 34c3323fdba..d2dbd7a66a0 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php @@ -27,6 +27,14 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** The event dispatching layer */ protected $eventDispatcher; + protected $addressEncoder; + + /** Whether the PIPELINING SMTP extension is enabled (RFC 2920) */ + protected $pipelining = null; + + /** The pipelined commands waiting for response */ + protected $pipeline = []; + /** Source Ip */ protected $sourceIp; @@ -36,14 +44,13 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** * Creates a new EsmtpTransport using the given I/O buffer. * - * @param Swift_Transport_IoBuffer $buf - * @param Swift_Events_EventDispatcher $dispatcher - * @param string $localDomain + * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) { - $this->eventDispatcher = $dispatcher; $this->buffer = $buf; + $this->eventDispatcher = $dispatcher; + $this->addressEncoder = $addressEncoder ?? new Swift_AddressEncoder_IdnAddressEncoder(); $this->setLocalDomain($localDomain); } @@ -63,7 +70,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport */ public function setLocalDomain($domain) { - if (substr($domain, 0, 1) !== '[') { + if ('[' !== substr($domain, 0, 1)) { if (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { $domain = '['.$domain.']'; } elseif (filter_var($domain, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { @@ -109,6 +116,16 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport return $this->sourceIp; } + public function setAddressEncoder(Swift_AddressEncoder $addressEncoder) + { + $this->addressEncoder = $addressEncoder; + } + + public function getAddressEncoder() + { + return $this->addressEncoder; + } + /** * Start the SMTP connection. */ @@ -154,13 +171,16 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int */ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { + if (!$this->isStarted()) { + $this->start(); + } + $sent = 0; $failedRecipients = (array) $failedRecipients; @@ -172,31 +192,24 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } if (!$reversePath = $this->getReversePath($message)) { - $this->throwException(new Swift_TransportException( - 'Cannot send message without a sender address' - ) - ); + $this->throwException(new Swift_TransportException('Cannot send message without a sender address')); } $to = (array) $message->getTo(); $cc = (array) $message->getCc(); - $tos = array_merge($to, $cc); $bcc = (array) $message->getBcc(); + $tos = array_merge($to, $cc, $bcc); - $message->setBcc(array()); + $message->setBcc([]); try { $sent += $this->sendTo($message, $reversePath, $tos, $failedRecipients); - $sent += $this->sendBcc($message, $reversePath, $bcc, $failedRecipients); - } catch (Exception $e) { + } finally { $message->setBcc($bcc); - throw $e; } - $message->setBcc($bcc); - if ($evt) { - if ($sent == count($to) + count($cc) + count($bcc)) { + if ($sent == \count($to) + \count($cc) + \count($bcc)) { $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); } elseif ($sent > 0) { $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); @@ -226,7 +239,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } try { - $this->executeCommand("QUIT\r\n", array(221)); + $this->executeCommand("QUIT\r\n", [221]); } catch (Swift_TransportException $e) { } @@ -253,7 +266,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport $this->start(); } - $this->executeCommand("NOOP\r\n", array(250)); + $this->executeCommand("NOOP\r\n", [250]); } catch (Swift_TransportException $e) { try { $this->stop(); @@ -268,8 +281,6 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** * Register a plugin. - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin) { @@ -281,7 +292,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport */ public function reset() { - $this->executeCommand("RSET\r\n", array(250)); + $this->executeCommand("RSET\r\n", [250], $failures, true); } /** @@ -299,22 +310,46 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport * * If no response codes are given, the response will not be validated. * If codes are given, an exception will be thrown on an invalid response. + * If the command is RCPT TO, and the pipeline is non-empty, no exception + * will be thrown; instead the failing address is added to $failures. * * @param string $command * @param int[] $codes * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO * - * @return string + * @return string|null The server response, or null if pipelining is enabled */ - public function executeCommand($command, $codes = array(), &$failures = null) + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) { $failures = (array) $failures; $seq = $this->buffer->write($command); - $response = $this->getFullResponse($seq); if ($evt = $this->eventDispatcher->createCommandEvent($this, $command, $codes)) { $this->eventDispatcher->dispatchEvent($evt, 'commandSent'); } - $this->assertResponseCode($response, $codes); + + $this->pipeline[] = [$command, $seq, $codes, $address]; + + if ($pipeline && $this->pipelining) { + return null; + } + + $response = null; + + while ($this->pipeline) { + list($command, $seq, $codes, $address) = array_shift($this->pipeline); + $response = $this->getFullResponse($seq); + try { + $this->assertResponseCode($response, $codes); + } catch (Swift_TransportException $e) { + if ($this->pipeline && $address) { + $failures[] = $address; + } else { + $this->throwException($e); + } + } + } return $response; } @@ -322,51 +357,53 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** Read the opening SMTP greeting */ protected function readGreeting() { - $this->assertResponseCode($this->getFullResponse(0), array(220)); + $this->assertResponseCode($this->getFullResponse(0), [220]); } /** Send the HELO welcome */ protected function doHeloCommand() { $this->executeCommand( - sprintf("HELO %s\r\n", $this->domain), array(250) + sprintf("HELO %s\r\n", $this->domain), [250] ); } /** Send the MAIL FROM command */ protected function doMailFromCommand($address) { + $address = $this->addressEncoder->encodeString($address); $this->executeCommand( - sprintf("MAIL FROM:<%s>\r\n", $address), array(250) + sprintf("MAIL FROM:<%s>\r\n", $address), [250], $failures, true ); } /** Send the RCPT TO command */ protected function doRcptToCommand($address) { + $address = $this->addressEncoder->encodeString($address); $this->executeCommand( - sprintf("RCPT TO:<%s>\r\n", $address), array(250, 251, 252) + sprintf("RCPT TO:<%s>\r\n", $address), [250, 251, 252], $failures, true, $address ); } /** Send the DATA command */ - protected function doDataCommand() + protected function doDataCommand(&$failedRecipients) { - $this->executeCommand("DATA\r\n", array(354)); + $this->executeCommand("DATA\r\n", [354], $failedRecipients); } /** Stream the contents of the message over the buffer */ protected function streamMessage(Swift_Mime_SimpleMessage $message) { - $this->buffer->setWriteTranslations(array("\r\n." => "\r\n..")); + $this->buffer->setWriteTranslations(["\r\n." => "\r\n.."]); try { $message->toByteStream($this->buffer); $this->buffer->flushBuffers(); } catch (Swift_TransportException $e) { $this->throwException($e); } - $this->buffer->setWriteTranslations(array()); - $this->executeCommand("\r\n.\r\n", array(250)); + $this->buffer->setWriteTranslations([]); + $this->executeCommand("\r\n.\r\n", [250]); } /** Determine the best-use reverse path for this message */ @@ -406,8 +443,12 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport /** Throws an Exception if a response code is incorrect */ protected function assertResponseCode($response, $wanted) { + if (!$response) { + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response')); + } + list($code) = sscanf($response, '%3d'); - $valid = (empty($wanted) || in_array($code, $wanted)); + $valid = (empty($wanted) || \in_array($code, $wanted)); if ($evt = $this->eventDispatcher->createResponseEvent($this, $response, $valid)) { @@ -415,12 +456,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } if (!$valid) { - $this->throwException( - new Swift_TransportException( - 'Expected response code '.implode('/', $wanted).' but got code '. - '"'.$code.'", with message "'.$response.'"', - $code) - ); + $this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code)); } } @@ -436,10 +472,7 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } catch (Swift_TransportException $e) { $this->throwException($e); } catch (Swift_IoException $e) { - $this->throwException( - new Swift_TransportException( - $e->getMessage()) - ); + $this->throwException(new Swift_TransportException($e->getMessage(), 0, $e)); } return $response; @@ -456,11 +489,16 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport ++$sent; } catch (Swift_TransportException $e) { $failedRecipients[] = $forwardPath; + } catch (Swift_AddressEncoderException $e) { + $failedRecipients[] = $forwardPath; } } - if ($sent != 0) { - $this->doDataCommand(); + if (0 != $sent) { + $sent += \count($failedRecipients); + $this->doDataCommand($failedRecipients); + $sent -= \count($failedRecipients); + $this->streamMessage($message); } else { $this->reset(); @@ -480,20 +518,6 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport $failedRecipients); } - /** Send a message to all Bcc: recipients */ - private function sendBcc(Swift_Mime_SimpleMessage $message, $reversePath, array $bcc, array &$failedRecipients) - { - $sent = 0; - foreach ($bcc as $forwardPath => $name) { - $message->setBcc(array($forwardPath => $name)); - $sent += $this->doMailTransaction( - $message, $reversePath, array($forwardPath), $failedRecipients - ); - } - - return $sent; - } - /** * Destructor. */ @@ -504,4 +528,14 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport } catch (Exception $e) { } } + + public function __sleep() + { + throw new \BadMethodCallException('Cannot serialize '.__CLASS__); + } + + public function __wakeup() + { + throw new \BadMethodCallException('Cannot unserialize '.__CLASS__); + } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php index 26c2d745a95..bb3a1615096 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -26,29 +26,23 @@ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport } /** - * Try to authenticate the user with $username and $password. - * - * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password - * - * @return bool + * {@inheritdoc} */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { - $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", array(334)); + $challenge = $agent->executeCommand("AUTH CRAM-MD5\r\n", [334]); $challenge = base64_decode(substr($challenge, 4)); $message = base64_encode( $username.' '.$this->getResponse($password, $challenge) - ); - $agent->executeCommand(sprintf("%s\r\n", $message), array(235)); + ); + $agent->executeCommand(sprintf("%s\r\n", $message), [235]); return true; } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", array(250)); + $agent->executeCommand("RSET\r\n", [250]); - return false; + throw $e; } } @@ -62,16 +56,16 @@ class Swift_Transport_Esmtp_Auth_CramMd5Authenticator implements Swift_Transport */ private function getResponse($secret, $challenge) { - if (strlen($secret) > 64) { + if (\strlen($secret) > 64) { $secret = pack('H32', md5($secret)); } - if (strlen($secret) < 64) { - $secret = str_pad($secret, 64, chr(0)); + if (\strlen($secret) < 64) { + $secret = str_pad($secret, 64, \chr(0)); } - $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64); - $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64); + $k_ipad = substr($secret, 0, 64) ^ str_repeat(\chr(0x36), 64); + $k_opad = substr($secret, 0, 64) ^ str_repeat(\chr(0x5C), 64); $inner = pack('H32', md5($k_ipad.$challenge)); $digest = md5($k_opad.$inner); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php index 6ab6e3337e2..0b9d81b8ad6 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -26,26 +26,20 @@ class Swift_Transport_Esmtp_Auth_LoginAuthenticator implements Swift_Transport_E } /** - * Try to authenticate the user with $username and $password. - * - * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password - * - * @return bool + * {@inheritdoc} */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { - $agent->executeCommand("AUTH LOGIN\r\n", array(334)); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334)); - $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235)); + $agent->executeCommand("AUTH LOGIN\r\n", [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($username ?? '')), [334]); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($password ?? '')), [235]); return true; } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", array(250)); + $agent->executeCommand("RSET\r\n", [250]); - return false; + throw $e; } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php index 7b8608d4a1b..41931fdd226 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -31,63 +31,57 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es } /** - * Try to authenticate the user with $username and $password. - * - * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password - * - * @return bool + * {@inheritdoc} * * @throws \LogicException */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { - if (!function_exists('openssl_encrypt')) { + if (!\function_exists('openssl_encrypt')) { throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); } - if (!function_exists('bcmul')) { + if (!\function_exists('bcmul')) { throw new LogicException('The BCMath functions must be enabled to use the NTLM authenticator.'); } try { // execute AUTH command and filter out the code at the beginning // AUTH NTLM xxxx - $response = base64_decode(substr(trim($this->sendMessage1($agent)), 4)); + $response = base64_decode(substr(trim($this->sendMessage1($agent) ?? ''), 4)); // extra parameters for our unit cases - $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); - $client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8); + $timestamp = \func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), '1000')); + $client = \func_num_args() > 4 ? func_get_arg(4) : random_bytes(8); // Message 3 response $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); return true; } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", array(250)); + $agent->executeCommand("RSET\r\n", [250]); - return false; + throw $e; } } protected function si2bin($si, $bits = 32) { $bin = null; - if ($si >= -pow(2, $bits - 1) && ($si <= pow(2, $bits - 1))) { + if ($si >= -2 ** ($bits - 1) && ($si <= 2 ** ($bits - 1))) { // positive or zero if ($si >= 0) { $bin = base_convert($si, 10, 2); // pad to $bits bit - $bin_length = strlen($bin); + $bin_length = \strlen($bin); if ($bin_length < $bits) { $bin = str_repeat('0', $bits - $bin_length).$bin; } } else { // negative - $si = -$si - pow(2, $bits); + $si = -$si - 2 ** $bits; $bin = base_convert($si, 10, 2); - $bin_length = strlen($bin); + $bin_length = \strlen($bin); if ($bin_length > $bits) { $bin = str_repeat('1', $bits - $bin_length).$bin; } @@ -100,15 +94,13 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es /** * Send our auth message and returns the response. * - * @param Swift_Transport_SmtpAgent $agent - * * @return string SMTP Response */ protected function sendMessage1(Swift_Transport_SmtpAgent $agent) { $message = $this->createMessage1(); - return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), array(334)); + return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), [334]); } /** @@ -131,7 +123,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $targetInfoBlock = substr($responseHex, $offset); list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); - return array( + return [ $challenge, $context, $targetInfoH, @@ -142,14 +134,12 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $DNSServerName, hex2bin($targetInfoBlock), $terminatorByte, - ); + ]; } /** * Read the blob information in from message2. * - * @param $block - * * @return array */ protected function readSubBlock($block) @@ -157,9 +147,9 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es // remove terminatorByte cause it's always the same $block = substr($block, 0, -8); - $length = strlen($block); + $length = \strlen($block); $offset = 0; - $data = array(); + $data = []; while ($offset < $length) { $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; $offset += 8; @@ -167,7 +157,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $offset += $blockLength * 2; } - if (count($data) == 3) { + if (3 == \count($data)) { $data[] = $data[2]; $data[2] = ''; } @@ -180,13 +170,12 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es /** * Send our final message with all our data. * - * @param string $response Message 1 response (message 2) - * @param string $username - * @param string $password - * @param string $timestamp - * @param string $client - * @param Swift_Transport_SmtpAgent $agent - * @param bool $v2 Use version2 of the protocol + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client + * @param bool $v2 Use version2 of the protocol * * @return string */ @@ -210,7 +199,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); - return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), array(235)); + return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), [235]); } /** @@ -294,18 +283,18 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es */ protected function getDomainAndUsername($name) { - if (strpos($name, '\\') !== false) { + if (false !== strpos($name, '\\')) { return explode('\\', $name); } if (false !== strpos($name, '@')) { list($user, $domain) = explode('@', $name); - return array($domain, $user); + return [$domain, $user]; } // no domain passed - return array('', $name); + return ['', $name]; } /** @@ -375,7 +364,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $binary = $this->si2bin($time, 64); // create 64 bit binary string $timestamp = ''; for ($i = 0; $i < 8; ++$i) { - $timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8))); + $timestamp .= \chr(bindec(substr($binary, -(($i + 1) * 8), 8))); } return $timestamp; @@ -396,7 +385,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es { $lmPass = '00'; // by default 00 // if $password > 15 than we can't use this method - if (strlen($password) <= 15) { + if (\strlen($password) <= 15) { $ntlmHash = $this->md4Encrypt($password); $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username).$domain)); @@ -436,21 +425,21 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es protected function createDesKey($key) { - $material = array(bin2hex($key[0])); - $len = strlen($key); + $material = [bin2hex($key[0])]; + $len = \strlen($key); for ($i = 1; $i < $len; ++$i) { list($high, $low) = str_split(bin2hex($key[$i])); - $v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); + $v = $this->castToByte(\ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf).dechex(hexdec($low) & 0xf)), $i)); $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte } - $material[] = str_pad(substr(dechex($this->castToByte(ord($key[6]) << 1)), -2), 2, '0'); + $material[] = str_pad(substr(dechex($this->castToByte(\ord($key[6]) << 1)), -2), 2, '0'); // odd parity foreach ($material as $k => $v) { $b = $this->castToByte(hexdec($v)); - $needsParity = (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) + $needsParity = 0 == (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) - ^ $this->uRShift($b, 1)) & 0x01) == 0; + ^ $this->uRShift($b, 1)) & 0x01); list($high, $low) = str_split($v); if ($needsParity) { @@ -476,7 +465,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es */ protected function createSecurityBuffer($value, $offset, $is16 = false) { - $length = strlen(bin2hex($value)); + $length = \strlen(bin2hex($value)); $length = $is16 ? $length / 2 : $length; $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); @@ -495,7 +484,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; - return array($length, $offset); + return [$length, $offset]; } /** @@ -521,7 +510,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es */ protected function uRShift($a, $b) { - if ($b == 0) { + if (0 == $b) { return $a; } @@ -548,22 +537,6 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es return $byte; } - /** - * Create random bytes. - * - * @param $length - * - * @return string - */ - protected function getRandomBytes($length) - { - $bytes = openssl_random_pseudo_bytes($length, $strong); - if (false !== $bytes && true === $strong) { - return $bytes; - } - throw new RuntimeException('OpenSSL did not produce a secure random number.'); - } - /** ENCRYPTION ALGORITHMS */ /** @@ -590,7 +563,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es protected function md5Encrypt($key, $msg) { $blocksize = 64; - if (strlen($key) > $blocksize) { + if (\strlen($key) > $blocksize) { $key = pack('H*', md5($key)); } @@ -608,13 +581,13 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es * * @return string * - * @see http://php.net/manual/en/ref.hash.php + * @see https://secure.php.net/manual/en/ref.hash.php */ protected function md4Encrypt($input) { $input = $this->convertTo16bit($input); - return function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + return \function_exists('hash') ? hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); } /** @@ -639,8 +612,8 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es echo substr($message, 0, 16)." NTLMSSP Signature
    \n"; echo $messageId." Type Indicator
    \n"; - if ($messageId == '02000000') { - $map = array( + if ('02000000' == $messageId) { + $map = [ 'Challenge', 'Context', 'Target Information Security Buffer', @@ -651,14 +624,14 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es 'DNS Server Name', 'BLOB', 'Target Information Terminator', - ); + ]; $data = $this->parseMessage2(hex2bin($message)); foreach ($map as $key => $value) { echo bin2hex($data[$key]).' - '.$data[$key].' ||| '.$value."
    \n"; } - } elseif ($messageId == '03000000') { + } elseif ('03000000' == $messageId) { $i = 0; $data[$i++] = substr($message, 24, 16); list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); @@ -683,7 +656,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es $data[$i++] = substr($message, $lmOffset, $lmLength); $data[$i] = substr($message, $ntmlOffset, $ntmlLength); - $map = array( + $map = [ 'LM Response Security Buffer', 'NTLM Response Security Buffer', 'Target Name Security Buffer', @@ -696,7 +669,7 @@ class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Es 'Workstation Name Data', 'LM Response Data', 'NTLM Response Data', - ); + ]; foreach ($map as $key => $value) { echo $data[$key].' - '.hex2bin($data[$key]).' ||| '.$value."
    \n"; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php index 43219f93445..41d0a50a82b 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -26,25 +26,19 @@ class Swift_Transport_Esmtp_Auth_PlainAuthenticator implements Swift_Transport_E } /** - * Try to authenticate the user with $username and $password. - * - * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password - * - * @return bool + * {@inheritdoc} */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) { try { - $message = base64_encode($username.chr(0).$username.chr(0).$password); - $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235)); + $message = base64_encode($username.\chr(0).$username.\chr(0).$password); + $agent->executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), [235]); return true; } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", array(250)); + $agent->executeCommand("RSET\r\n", [250]); - return false; + throw $e; } } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php index d1a4cc3d774..859f22f3d5e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -36,25 +36,19 @@ class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport } /** - * Try to authenticate the user with $email and $token. - * - * @param Swift_Transport_SmtpAgent $agent - * @param string $email - * @param string $token - * - * @return bool + * {@inheritdoc} */ public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) { try { $param = $this->constructXOAuth2Params($email, $token); - $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", array(235)); + $agent->executeCommand('AUTH XOAUTH2 '.$param."\r\n", [235]); return true; } catch (Swift_TransportException $e) { - $agent->executeCommand("RSET\r\n", array(250)); + $agent->executeCommand("RSET\r\n", [250]); - return false; + throw $e; } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php index 94387f01a2e..53a90a87383 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -9,7 +9,7 @@ */ /** - * An ESMTP handler for AUTH support. + * An ESMTP handler for AUTH support (RFC 5248). * * @author Chris Corbyn */ @@ -20,7 +20,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler * * @var Swift_Transport_Esmtp_Authenticator[] */ - private $authenticators = array(); + private $authenticators = []; /** * The username for authentication. @@ -48,7 +48,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler * * @var string[] */ - private $esmtpParams = array(); + private $esmtpParams = []; /** * Create a new AuthHandler with $authenticators for support. @@ -143,7 +143,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler /** * Get the name of the ESMTP extension this handles. * - * @return bool + * @return string */ public function getHandledKeyword() { @@ -169,19 +169,26 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler { if ($this->username) { $count = 0; + $errors = []; foreach ($this->getAuthenticatorsForAgent() as $authenticator) { - if (in_array(strtolower($authenticator->getAuthKeyword()), - array_map('strtolower', $this->esmtpParams))) { + if (\in_array(strtolower($authenticator->getAuthKeyword() ?? ''), array_map('strtolower', $this->esmtpParams))) { ++$count; - if ($authenticator->authenticate($agent, $this->username, $this->password)) { - return; + try { + if ($authenticator->authenticate($agent, $this->username, $this->password)) { + return; + } + } catch (Swift_TransportException $e) { + // keep the error message, but tries the other authenticators + $errors[] = [$authenticator->getAuthKeyword(), $e->getMessage()]; } } } - throw new Swift_TransportException( - 'Failed to authenticate on SMTP server with username "'. - $this->username.'" using '.$count.' possible authenticators' - ); + + $message = 'Failed to authenticate on SMTP server with username "'.$this->username.'" using '.$count.' possible authenticators.'; + foreach ($errors as $error) { + $message .= ' Authenticator '.$error[0].' returned '.$error[1].'.'; + } + throw new Swift_TransportException($message); } } @@ -190,7 +197,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler */ public function getMailParams() { - return array(); + return []; } /** @@ -198,13 +205,13 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler */ public function getRcptParams() { - return array(); + return []; } /** * Not used. */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false) + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) { } @@ -229,7 +236,7 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler */ public function exposeMixinMethods() { - return array('setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode'); + return ['setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode']; } /** @@ -242,19 +249,17 @@ class Swift_Transport_Esmtp_AuthHandler implements Swift_Transport_EsmtpHandler /** * Returns the authenticator list for the given agent. * - * @param Swift_Transport_SmtpAgent $agent - * * @return array */ protected function getAuthenticatorsForAgent() { - if (!$mode = strtolower($this->auth_mode)) { + if (!$mode = strtolower($this->auth_mode ?? '')) { return $this->authenticators; } foreach ($this->authenticators as $authenticator) { - if (strtolower($authenticator->getAuthKeyword()) == $mode) { - return array($authenticator); + if (strtolower($authenticator->getAuthKeyword() ?? '') == $mode) { + return [$authenticator]; } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php index 12a9abf8199..f692a6fe40d 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -25,11 +25,12 @@ interface Swift_Transport_Esmtp_Authenticator /** * Try to authenticate the user with $username and $password. * - * @param Swift_Transport_SmtpAgent $agent - * @param string $username - * @param string $password + * @param string $username + * @param string $password * - * @return bool + * @return bool true if authentication worked (returning false is deprecated, throw a Swift_TransportException instead) + * + * @throws Swift_TransportException Allows the message to bubble up when authentication was not successful */ public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php new file mode 100644 index 00000000000..63f70866939 --- /dev/null +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/EightBitMimeHandler.php @@ -0,0 +1,113 @@ +encoding = $encoding; + } + + /** + * Get the name of the ESMTP extension this handles. + * + * @return string + */ + public function getHandledKeyword() + { + return '8BITMIME'; + } + + /** + * Not used. + */ + public function setKeywordParams(array $parameters) + { + } + + /** + * Not used. + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + } + + /** + * Get params which are appended to MAIL FROM:<>. + * + * @return string[] + */ + public function getMailParams() + { + return ['BODY='.$this->encoding]; + } + + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } + + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } + + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } + + /** + * Not used. + */ + public function resetState() + { + } +} diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php new file mode 100644 index 00000000000..7d0252a01bf --- /dev/null +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/Esmtp/SmtpUtf8Handler.php @@ -0,0 +1,107 @@ +. + * + * @return string[] + */ + public function getMailParams() + { + return ['SMTPUTF8']; + } + + /** + * Not used. + */ + public function getRcptParams() + { + return []; + } + + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false) + { + } + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } + + /** + * Not used. + */ + public function exposeMixinMethods() + { + return []; + } + + /** + * Not used. + */ + public function resetState() + { + } +} diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php index c17ef8feb3b..b8ea36e2fa8 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpHandler.php @@ -18,7 +18,7 @@ interface Swift_Transport_EsmtpHandler /** * Get the name of the ESMTP extension this handles. * - * @return bool + * @return string */ public function getHandledKeyword(); @@ -59,7 +59,7 @@ interface Swift_Transport_EsmtpHandler * @param string[] $failedRecipients to collect failures * @param bool $stop to be set true by-reference if the command is now sent */ - public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false); + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = [], &$failedRecipients = null, &$stop = false); /** * Returns +1, -1 or 0 according to the rules for usort(). diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php index 56d9c748769..36545f51feb 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -20,21 +20,21 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * * @var Swift_Transport_EsmtpHandler[] */ - private $handlers = array(); + private $handlers = []; /** * ESMTP capabilities. * * @var string[] */ - private $capabilities = array(); + private $capabilities = []; /** * Connection buffer parameters. * * @var array */ - private $params = array( + private $params = [ 'protocol' => 'tcp', 'host' => 'localhost', 'port' => 25, @@ -42,26 +42,26 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo 'blocking' => 1, 'tls' => false, 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, - 'stream_context_options' => array(), - ); + 'stream_context_options' => [], + ]; /** * Creates a new EsmtpTransport using the given I/O buffer. * - * @param Swift_Transport_IoBuffer $buf * @param Swift_Transport_EsmtpHandler[] $extensionHandlers - * @param Swift_Events_EventDispatcher $dispatcher * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) { - parent::__construct($buf, $dispatcher, $localDomain); + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); $this->setExtensionHandlers($extensionHandlers); } /** * Set the host to connect to. * + * Literal IPv6 addresses should be wrapped in square brackets. + * * @param string $host * * @return $this @@ -141,7 +141,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo */ public function setEncryption($encryption) { - $encryption = strtolower($encryption); + $encryption = strtolower($encryption ?? ''); if ('tls' == $encryption) { $this->params['protocol'] = 'tcp'; $this->params['tls'] = true; @@ -190,6 +190,8 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo /** * Sets the source IP. * + * IPv6 addresses should be wrapped in square brackets. + * * @param string $source * * @return $this @@ -208,7 +210,36 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo */ public function getSourceIp() { - return isset($this->params['sourceIp']) ? $this->params['sourceIp'] : null; + return $this->params['sourceIp'] ?? null; + } + + /** + * Sets whether SMTP pipelining is enabled. + * + * By default, support is auto-detected using the PIPELINING SMTP extension. + * Use this function to override that in the unlikely event of compatibility + * issues. + * + * @param bool $enabled + * + * @return $this + */ + public function setPipelining($enabled) + { + $this->pipelining = $enabled; + + return $this; + } + + /** + * Returns whether SMTP pipelining is enabled. + * + * @return bool|null a boolean if pipelining is explicitly enabled or disabled, + * or null if support is auto-detected + */ + public function getPipelining() + { + return $this->pipelining; } /** @@ -220,7 +251,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo */ public function setExtensionHandlers(array $handlers) { - $assoc = array(); + $assoc = []; foreach ($handlers as $handler) { $assoc[$handler->getHandledKeyword()] = $handler; } @@ -252,10 +283,12 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo * @param string $command * @param int[] $codes * @param string[] $failures An array of failures by-reference + * @param bool $pipeline Do not wait for response + * @param string $address the address, if command is RCPT TO * - * @return string + * @return string|null The server response, or null if pipelining is enabled */ - public function executeCommand($command, $codes = array(), &$failures = null) + public function executeCommand($command, $codes = [], &$failures = null, $pipeline = false, $address = null) { $failures = (array) $failures; $stopSignal = false; @@ -269,19 +302,19 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo } } - return parent::executeCommand($command, $codes, $failures); + return parent::executeCommand($command, $codes, $failures, $pipeline, $address); } /** Mixin handling method for ESMTP handlers */ public function __call($method, $args) { foreach ($this->handlers as $handler) { - if (in_array(strtolower($method), + if (\in_array(strtolower($method), array_map('strtolower', (array) $handler->exposeMixinMethods()) )) { - $return = call_user_func_array(array($handler, $method), $args); + $return = \call_user_func_array([$handler, $method], $args); // Allow fluid method calls - if (null === $return && substr($method, 0, 3) == 'set') { + if (null === $return && 'set' == substr($method, 0, 3)) { return $this; } else { return $return; @@ -302,7 +335,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo { try { $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), array(250) + sprintf("EHLO %s\r\n", $this->domain), [250] ); } catch (Swift_TransportException $e) { return parent::doHeloCommand(); @@ -310,7 +343,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo if ($this->params['tls']) { try { - $this->executeCommand("STARTTLS\r\n", array(220)); + $this->executeCommand("STARTTLS\r\n", [220]); if (!$this->buffer->startTLS()) { throw new Swift_TransportException('Unable to connect with TLS encryption'); @@ -318,7 +351,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo try { $response = $this->executeCommand( - sprintf("EHLO %s\r\n", $this->domain), array(250) + sprintf("EHLO %s\r\n", $this->domain), [250] ); } catch (Swift_TransportException $e) { return parent::doHeloCommand(); @@ -329,6 +362,10 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo } $this->capabilities = $this->getCapabilities($response); + if (!isset($this->pipelining)) { + $this->pipelining = isset($this->capabilities['PIPELINING']); + } + $this->setHandlerParams(); foreach ($this->getActiveHandlers() as $handler) { $handler->afterEhlo($this); @@ -338,43 +375,45 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo /** Overridden to add Extension support */ protected function doMailFromCommand($address) { + $address = $this->addressEncoder->encodeString($address); $handlers = $this->getActiveHandlers(); - $params = array(); + $params = []; foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getMailParams()); } $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( - sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), array(250) + sprintf("MAIL FROM:<%s>%s\r\n", $address, $paramStr), [250], $failures, true ); } /** Overridden to add Extension support */ protected function doRcptToCommand($address) { + $address = $this->addressEncoder->encodeString($address); $handlers = $this->getActiveHandlers(); - $params = array(); + $params = []; foreach ($handlers as $handler) { $params = array_merge($params, (array) $handler->getRcptParams()); } $paramStr = !empty($params) ? ' '.implode(' ', $params) : ''; $this->executeCommand( - sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), array(250, 251, 252) + sprintf("RCPT TO:<%s>%s\r\n", $address, $paramStr), [250, 251, 252], $failures, true, $address ); } /** Determine ESMTP capabilities by function group */ private function getCapabilities($ehloResponse) { - $capabilities = array(); - $ehloResponse = trim($ehloResponse); + $capabilities = []; + $ehloResponse = trim($ehloResponse ?? ''); $lines = explode("\r\n", $ehloResponse); array_shift($lines); foreach ($lines as $line) { if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { $keyword = strtoupper($matches[1]); $paramStr = strtoupper(ltrim($matches[2], ' =')); - $params = !empty($paramStr) ? explode(' ', $paramStr) : array(); + $params = !empty($paramStr) ? explode(' ', $paramStr) : []; $capabilities[$keyword] = $params; } } @@ -386,7 +425,7 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo private function setHandlerParams() { foreach ($this->handlers as $keyword => $handler) { - if (array_key_exists($keyword, $this->capabilities)) { + if (\array_key_exists($keyword, $this->capabilities)) { $handler->setKeywordParams($this->capabilities[$keyword]); } } @@ -395,9 +434,9 @@ class Swift_Transport_EsmtpTransport extends Swift_Transport_AbstractSmtpTranspo /** Get ESMTP handlers which are currently ok to use */ private function getActiveHandlers() { - $handlers = array(); + $handlers = []; foreach ($this->handlers as $keyword => $handler) { - if (array_key_exists($keyword, $this->capabilities)) { + if (\array_key_exists($keyword, $this->capabilities)) { $handlers[] = $handler; } } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php index 94151f89fef..1a4b4754f07 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -33,7 +33,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran */ public function ping() { - $maxTransports = count($this->transports); + $maxTransports = \count($this->transports); for ($i = 0; $i < $maxTransports && $transport = $this->getNextTransport(); ++$i) { if ($transport->ping()) { @@ -43,7 +43,7 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran } } - return count($this->transports) > 0; + return \count($this->transports) > 0; } /** @@ -52,14 +52,13 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int */ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - $maxTransports = count($this->transports); + $maxTransports = \count($this->transports); $sent = 0; $this->lastUsedTransport = null; @@ -80,10 +79,8 @@ class Swift_Transport_FailoverTransport extends Swift_Transport_LoadBalancedTran } } - if (count($this->transports) == 0) { - throw new Swift_TransportException( - 'All Transports in FailoverTransport failed, or no Transports available' - ); + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in FailoverTransport failed, or no Transports available'); } return $sent; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php index af97adf1f8f..50f1e5e403c 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -25,8 +25,6 @@ interface Swift_Transport_IoBuffer extends Swift_InputByteStream, Swift_OutputBy * Perform any initialization needed, using the given $params. * * Parameters will vary depending upon the type of IoBuffer used. - * - * @param array $params */ public function initialize(array $params); diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php index dc6a2149bab..0b5ba9d304e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/LoadBalancedTransport.php @@ -20,14 +20,14 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport * * @var Swift_Transport[] */ - private $deadTransports = array(); + private $deadTransports = []; /** * The Transports which are used in rotation. * * @var Swift_Transport[] */ - protected $transports = array(); + protected $transports = []; /** * The Transport used in the last successful send operation. @@ -49,7 +49,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport public function setTransports(array $transports) { $this->transports = $transports; - $this->deadTransports = array(); + $this->deadTransports = []; } /** @@ -79,7 +79,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport */ public function isStarted() { - return count($this->transports) > 0; + return \count($this->transports) > 0; } /** @@ -111,7 +111,7 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport } } - return count($this->transports) > 0; + return \count($this->transports) > 0; } /** @@ -120,14 +120,13 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int */ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = null) { - $maxTransports = count($this->transports); + $maxTransports = \count($this->transports); $sent = 0; $this->lastUsedTransport = null; @@ -146,10 +145,8 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport } } - if (count($this->transports) == 0) { - throw new Swift_TransportException( - 'All Transports in LoadBalancedTransport failed, or no Transports available' - ); + if (0 == \count($this->transports)) { + throw new Swift_TransportException('All Transports in LoadBalancedTransport failed, or no Transports available'); } return $sent; @@ -157,8 +154,6 @@ class Swift_Transport_LoadBalancedTransport implements Swift_Transport /** * Register a plugin. - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php index dc38078c3c3..7d910db5a58 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -61,8 +61,7 @@ class Swift_Transport_NullTransport implements Swift_Transport /** * Sends the given message. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int The number of sent emails */ @@ -81,9 +80,9 @@ class Swift_Transport_NullTransport implements Swift_Transport } $count = ( - count((array) $message->getTo()) - + count((array) $message->getCc()) - + count((array) $message->getBcc()) + \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()) ); return $count; @@ -91,8 +90,6 @@ class Swift_Transport_NullTransport implements Swift_Transport /** * Register a plugin. - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php index 807538505bf..65a434d1173 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -24,23 +24,21 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * * @var array */ - private $params = array( + private $params = [ 'timeout' => 30, 'blocking' => 1, 'command' => '/usr/sbin/sendmail -bs', 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, - ); + ]; /** * Create a new SendmailTransport with $buf for I/O. * - * @param Swift_Transport_IoBuffer $buf - * @param Swift_Events_EventDispatcher $dispatcher - * @param string $localDomain + * @param string $localDomain */ - public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1') + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher, $localDomain = '127.0.0.1', Swift_AddressEncoder $addressEncoder = null) { - parent::__construct($buf, $dispatcher, $localDomain); + parent::__construct($buf, $dispatcher, $localDomain, $addressEncoder); } /** @@ -93,8 +91,7 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran * NOTE: If using 'sendmail -t' you will not be aware of any failures until * they bounce (i.e. send() will always return 100% success). * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int */ @@ -114,24 +111,24 @@ class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTran } if (false === strpos($command, ' -f')) { - $command .= ' -f'.escapeshellarg($this->getReversePath($message)); + $command .= ' -f'.escapeshellarg($this->getReversePath($message) ?? ''); } - $buffer->initialize(array_merge($this->params, array('command' => $command))); + $buffer->initialize(array_merge($this->params, ['command' => $command])); if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { - $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n..")); + $buffer->setWriteTranslations(["\r\n" => "\n", "\n." => "\n.."]); } else { - $buffer->setWriteTranslations(array("\r\n" => "\n")); + $buffer->setWriteTranslations(["\r\n" => "\n"]); } - $count = count((array) $message->getTo()) - + count((array) $message->getCc()) - + count((array) $message->getBcc()) + $count = \count((array) $message->getTo()) + + \count((array) $message->getCc()) + + \count((array) $message->getBcc()) ; $message->toByteStream($buffer); $buffer->flushBuffers(); - $buffer->setWriteTranslations(array()); + $buffer->setWriteTranslations([]); $buffer->terminate(); if ($evt) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php index 90e913f8edb..e8ce65c2648 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SmtpAgent.php @@ -32,5 +32,5 @@ interface Swift_Transport_SmtpAgent * @param int[] $codes * @param string[] $failures An array of failures by-reference */ - public function executeCommand($command, $codes = array(), &$failures = null); + public function executeCommand($command, $codes = [], &$failures = null); } diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php index 9a1d07115e3..0cb6a5b80a9 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/SpoolTransport.php @@ -33,8 +33,6 @@ class Swift_Transport_SpoolTransport implements Swift_Transport /** * Sets the spool object. * - * @param Swift_Spool $spool - * * @return $this */ public function setSpool(Swift_Spool $spool) @@ -89,8 +87,7 @@ class Swift_Transport_SpoolTransport implements Swift_Transport /** * Sends the given message. * - * @param Swift_Mime_SimpleMessage $message - * @param string[] $failedRecipients An array of failures by-reference + * @param string[] $failedRecipients An array of failures by-reference * * @return int The number of sent e-mail's */ @@ -115,8 +112,6 @@ class Swift_Transport_SpoolTransport implements Swift_Transport /** * Register a plugin. - * - * @param Swift_Events_EventListener $plugin */ public function registerPlugin(Swift_Events_EventListener $plugin) { diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php index bc6ed5a34b4..70782ada044 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -25,18 +25,16 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn private $out; /** Buffer initialization parameters */ - private $params = array(); + private $params = []; /** The ReplacementFilterFactory */ private $replacementFactory; /** Translations performed on data being streamed into the buffer */ - private $translations = array(); + private $translations = []; /** * Create a new StreamBuffer using $replacementFactory for transformations. - * - * @param Swift_ReplacementFilterFactory $replacementFactory */ public function __construct(Swift_ReplacementFilterFactory $replacementFactory) { @@ -47,8 +45,6 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn * Perform any initialization needed, using the given $params. * * Parameters will vary depending upon the type of IoBuffer used. - * - * @param array $params */ public function initialize(array $params) { @@ -91,7 +87,11 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn public function startTLS() { - return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); + // STREAM_CRYPTO_METHOD_TLS_CLIENT only allow tls1.0 connections (some php versions) + // To support modern tls we allow explicit tls1.0, tls1.1, tls1.2 + // Ssl3 and older are not allowed because they are vulnerable + // @TODO make tls arguments configurable + return stream_socket_enable_crypto($this->stream, true, STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); } /** @@ -160,14 +160,10 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn { if (isset($this->out) && !feof($this->out)) { $line = fgets($this->out); - if (strlen($line) == 0) { + if (0 == \strlen($line)) { $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { - throw new Swift_IoException( - 'Connection to '. - $this->getReadConnectionDescription(). - ' Timed Out' - ); + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); } } @@ -192,14 +188,10 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn { if (isset($this->out) && !feof($this->out)) { $ret = fread($this->out, $length); - if (strlen($ret) == 0) { + if (0 == \strlen($ret)) { $metas = stream_get_meta_data($this->out); if ($metas['timed_out']) { - throw new Swift_IoException( - 'Connection to '. - $this->getReadConnectionDescription(). - ' Timed Out' - ); + throw new Swift_IoException('Connection to '.$this->getReadConnectionDescription().' Timed Out'); } } @@ -224,7 +216,7 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn protected function doCommit($bytes) { if (isset($this->in)) { - $bytesToWrite = strlen($bytes); + $bytesToWrite = \strlen($bytes); $totalBytesWritten = 0; while ($totalBytesWritten < $bytesToWrite) { @@ -255,7 +247,7 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn if (!empty($this->params['timeout'])) { $timeout = $this->params['timeout']; } - $options = array(); + $options = []; if (!empty($this->params['sourceIp'])) { $options['socket']['bindto'] = $this->params['sourceIp'].':0'; } @@ -264,13 +256,16 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn $options = array_merge($options, $this->params['stream_context_options']); } $streamContext = stream_context_create($options); - $this->stream = @stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); - if (false === $this->stream) { - throw new Swift_TransportException( - 'Connection could not be established with host '.$this->params['host']. - ' ['.$errstr.' #'.$errno.']' - ); + + set_error_handler(function ($type, $msg) { + throw new Swift_TransportException('Connection could not be established with host '.$this->params['host'].' :'.$msg); + }); + try { + $this->stream = stream_socket_client($host.':'.$this->params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext); + } finally { + restore_error_handler(); } + if (!empty($this->params['blocking'])) { stream_set_blocking($this->stream, 1); } else { @@ -287,18 +282,16 @@ class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableIn private function establishProcessConnection() { $command = $this->params['command']; - $descriptorSpec = array( - 0 => array('pipe', 'r'), - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w'), - ); - $pipes = array(); + $descriptorSpec = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + $pipes = []; $this->stream = proc_open($command, $descriptorSpec, $pipes); stream_set_blocking($pipes[2], 0); if ($err = stream_get_contents($pipes[2])) { - throw new Swift_TransportException( - 'Process could not be started ['.$err.']' - ); + throw new Swift_TransportException('Process could not be started ['.$err.']'); } $this->in = &$pipes[0]; $this->out = &$pipes[1]; diff --git a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php index 4ae2412e62a..c7417455b3e 100644 --- a/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php +++ b/htdocs/includes/swiftmailer/lib/classes/Swift/TransportException.php @@ -18,9 +18,8 @@ class Swift_TransportException extends Swift_IoException /** * Create a new TransportException with $message. * - * @param string $message - * @param int $code - * @param Exception $previous + * @param string $message + * @param int $code */ public function __construct($message, $code = 0, Exception $previous = null) { diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php index 6023448e85e..9d94d774014 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/cache_deps.php @@ -12,11 +12,11 @@ Swift_DependencyContainer::getInstance() ->register('cache.array') ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') - ->withDependencies(array('cache.inputstream')) + ->withDependencies(['cache.inputstream']) ->register('cache.disk') ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') - ->withDependencies(array('cache.inputstream', 'tempdir')) + ->withDependencies(['cache.inputstream', 'tempdir']) ->register('cache.inputstream') ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream') diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php index 4ce9c7cbbc5..307756c89f3 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/mime_deps.php @@ -13,101 +13,105 @@ Swift_DependencyContainer::getInstance() // As SERVER_NAME can come from the user in certain configurations, check that // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) === '' ? $_SERVER['SERVER_NAME'] : 'swift.generated') + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated') ->register('mime.idgenerator') ->asSharedInstanceOf('Swift_Mime_IdGenerator') - ->withDependencies(array( + ->withDependencies([ 'mime.idgenerator.idright', - )) + ]) ->register('mime.message') ->asNewInstanceOf('Swift_Mime_SimpleMessage') - ->withDependencies(array( + ->withDependencies([ 'mime.headerset', - 'mime.qpcontentencoder', + 'mime.textcontentencoder', 'cache', 'mime.idgenerator', 'properties.charset', - )) + ]) ->register('mime.part') ->asNewInstanceOf('Swift_Mime_MimePart') - ->withDependencies(array( + ->withDependencies([ 'mime.headerset', - 'mime.qpcontentencoder', + 'mime.textcontentencoder', 'cache', 'mime.idgenerator', 'properties.charset', - )) + ]) ->register('mime.attachment') ->asNewInstanceOf('Swift_Mime_Attachment') - ->withDependencies(array( + ->withDependencies([ 'mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.idgenerator', - )) + ]) ->addConstructorValue($swift_mime_types) ->register('mime.embeddedfile') ->asNewInstanceOf('Swift_Mime_EmbeddedFile') - ->withDependencies(array( + ->withDependencies([ 'mime.headerset', 'mime.base64contentencoder', 'cache', 'mime.idgenerator', - )) + ]) ->addConstructorValue($swift_mime_types) ->register('mime.headerfactory') ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') - ->withDependencies(array( - 'mime.qpheaderencoder', - 'mime.rfc2231encoder', - 'email.validator', - 'properties.charset', - )) + ->withDependencies([ + 'mime.qpheaderencoder', + 'mime.rfc2231encoder', + 'email.validator', + 'properties.charset', + 'address.idnaddressencoder', + ]) ->register('mime.headerset') ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') - ->withDependencies(array('mime.headerfactory', 'properties.charset')) + ->withDependencies(['mime.headerfactory', 'properties.charset']) ->register('mime.qpheaderencoder') ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') - ->withDependencies(array('mime.charstream')) + ->withDependencies(['mime.charstream']) ->register('mime.base64headerencoder') ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') - ->withDependencies(array('mime.charstream')) + ->withDependencies(['mime.charstream']) ->register('mime.charstream') ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') - ->withDependencies(array('mime.characterreaderfactory', 'properties.charset')) + ->withDependencies(['mime.characterreaderfactory', 'properties.charset']) ->register('mime.bytecanonicalizer') ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') - ->addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A))) - ->addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A))) + ->addConstructorValue([[0x0D, 0x0A], [0x0D], [0x0A]]) + ->addConstructorValue([[0x0A], [0x0A], [0x0D, 0x0A]]) ->register('mime.characterreaderfactory') ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') + ->register('mime.textcontentencoder') + ->asAliasOf('mime.qpcontentencoder') + ->register('mime.safeqpcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') - ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + ->withDependencies(['mime.charstream', 'mime.bytecanonicalizer']) ->register('mime.rawcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') ->register('mime.nativeqpcontentencoder') - ->withDependencies(array('properties.charset')) + ->withDependencies(['properties.charset']) ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') ->register('mime.qpcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') - ->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset')) + ->withDependencies(['mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset']) ->register('mime.7bitcontentencoder') ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') @@ -124,7 +128,7 @@ Swift_DependencyContainer::getInstance() ->register('mime.rfc2231encoder') ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') - ->withDependencies(array('mime.charstream')) + ->withDependencies(['mime.charstream']) ; unset($swift_mime_types); diff --git a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php index 15772abb255..34a63c78e51 100644 --- a/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php +++ b/htdocs/includes/swiftmailer/lib/dependency_maps/transport_deps.php @@ -5,24 +5,25 @@ Swift_DependencyContainer::getInstance() // As SERVER_NAME can come from the user in certain configurations, check that // it does not contain forbidden characters (see RFC 952 and RFC 2181). Use // preg_replace() instead of preg_match() to prevent DoS attacks with long host names. - ->asValue(!empty($_SERVER['SERVER_NAME']) && preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) === '' ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') + ->asValue(!empty($_SERVER['SERVER_NAME']) && '' === preg_replace('/(?:^\[)?[a-zA-Z0-9-:\]_]+\.?/', '', $_SERVER['SERVER_NAME']) ? trim($_SERVER['SERVER_NAME'], '[]') : '127.0.0.1') ->register('transport.smtp') ->asNewInstanceOf('Swift_Transport_EsmtpTransport') - ->withDependencies(array( + ->withDependencies([ 'transport.buffer', - array('transport.authhandler'), + 'transport.smtphandlers', 'transport.eventdispatcher', 'transport.localdomain', - )) + 'address.idnaddressencoder', + ]) ->register('transport.sendmail') ->asNewInstanceOf('Swift_Transport_SendmailTransport') - ->withDependencies(array( + ->withDependencies([ 'transport.buffer', 'transport.eventdispatcher', 'transport.localdomain', - )) + ]) ->register('transport.loadbalanced') ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') @@ -32,27 +33,40 @@ Swift_DependencyContainer::getInstance() ->register('transport.spool') ->asNewInstanceOf('Swift_Transport_SpoolTransport') - ->withDependencies(array('transport.eventdispatcher')) + ->withDependencies(['transport.eventdispatcher']) ->register('transport.null') ->asNewInstanceOf('Swift_Transport_NullTransport') - ->withDependencies(array('transport.eventdispatcher')) + ->withDependencies(['transport.eventdispatcher']) ->register('transport.buffer') ->asNewInstanceOf('Swift_Transport_StreamBuffer') - ->withDependencies(array('transport.replacementfactory')) + ->withDependencies(['transport.replacementfactory']) + + ->register('transport.smtphandlers') + ->asArray() + ->withDependencies(['transport.authhandler']) ->register('transport.authhandler') ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') - ->withDependencies(array( - array( - 'transport.crammd5auth', - 'transport.loginauth', - 'transport.plainauth', - 'transport.ntlmauth', - 'transport.xoauth2auth', - ), - )) + ->withDependencies(['transport.authhandlers']) + + ->register('transport.authhandlers') + ->asArray() + ->withDependencies([ + 'transport.crammd5auth', + 'transport.loginauth', + 'transport.plainauth', + 'transport.ntlmauth', + 'transport.xoauth2auth', + ]) + + ->register('transport.smtputf8handler') + ->asNewInstanceOf('Swift_Transport_Esmtp_SmtpUtf8Handler') + + ->register('transport.8bitmimehandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_EightBitMimeHandler') + ->addConstructorValue('8BITMIME') ->register('transport.crammd5auth') ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') @@ -74,4 +88,10 @@ Swift_DependencyContainer::getInstance() ->register('transport.replacementfactory') ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') + + ->register('address.idnaddressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_IdnAddressEncoder') + + ->register('address.utf8addressencoder') + ->asNewInstanceOf('Swift_AddressEncoder_Utf8AddressEncoder') ; diff --git a/htdocs/includes/swiftmailer/lib/mime_types.php b/htdocs/includes/swiftmailer/lib/mime_types.php index b42c1cc1a3e..72c6fd2afa6 100644 --- a/htdocs/includes/swiftmailer/lib/mime_types.php +++ b/htdocs/includes/swiftmailer/lib/mime_types.php @@ -17,7 +17,7 @@ // You may add or take away what you like (lowercase required) -$swift_mime_types = array( +$swift_mime_types = [ '3dml' => 'text/vnd.in3d.3dml', '3ds' => 'image/x-3ds', '3g2' => 'video/3gpp2', @@ -1004,4 +1004,4 @@ $swift_mime_types = array( 'zirz' => 'application/vnd.zul', 'zmm' => 'application/vnd.handheld-entertainment+xml', '123' => 'application/vnd.lotus-1-2-3', -); +]; diff --git a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php index 85f2d69f21c..ad8fd2aa0d5 100644 --- a/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php +++ b/htdocs/includes/swiftmailer/lib/swiftmailer_generate_mimes_config.php @@ -1,8 +1,8 @@ #!/usr/bin/php 'application/x-php', 'php3' => 'application/x-php', 'php4' => 'application/x-php', @@ -95,7 +95,7 @@ function generateUpToDateMimeArray() 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'xml' => 'application/xml', - ); + ]; // wrap array for generating file foreach ($valid_mime_types_preset as $extension => $mime_type) { @@ -103,17 +103,14 @@ function generateUpToDateMimeArray() $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; } - // collect extensions - $valid_extensions = array(); - // all extensions from second match foreach ($matches[2] as $i => $extensions) { // explode multiple extensions from string - $extensions = explode(' ', strtolower($extensions)); + $extensions = explode(' ', strtolower($extensions ?? '')); // force array for foreach - if (!is_array($extensions)) { - $extensions = array($extensions); + if (!\is_array($extensions)) { + $extensions = [$extensions]; } foreach ($extensions as $extension) { @@ -121,10 +118,7 @@ function generateUpToDateMimeArray() $mime_type = $matches[1][$i]; // check if string length lower than 10 - if (strlen($extension) < 10) { - // add extension - $valid_extensions[] = $extension; - + if (\strlen($extension) < 10) { if (!isset($valid_mime_types[$mime_type])) { // generate array for mimetype to extension resolver (only first match) $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; @@ -145,29 +139,24 @@ function generateUpToDateMimeArray() // get all matching extensions from match foreach ((array) $node->glob['pattern'] as $extension) { // skip none glob extensions - if (strpos($extension, '.') === false) { + if (false === strpos($extension ?? '', '.')) { continue; } // remove get only last part - $extension = explode('.', strtolower($extension)); + $extension = explode('.', strtolower($extension ?? '')); $extension = end($extension); - - // maximum length in database column - if (strlen($extension) <= 9) { - $valid_extensions[] = $extension; - } } if (isset($node->glob['pattern'][0])) { // mime type - $mime_type = strtolower((string) $node['type']); + $mime_type = strtolower((string) $node['type'] ?? ''); // get first extension - $extension = strtolower(trim($node->glob['ddpattern'][0], '*.')); + $extension = strtolower(trim($node->glob['ddpattern'][0] ?? '', '*.')); // skip none glob extensions and check if string length between 1 and 10 - if (strpos($extension, '.') !== false || strlen($extension) < 1 || strlen($extension) > 9) { + if (false !== strpos($extension, '.') || \strlen($extension) < 1 || \strlen($extension) > 9) { continue; } @@ -184,7 +173,7 @@ function generateUpToDateMimeArray() ksort($valid_mime_types); // combine mime types and extensions array - $output = "$preamble\$swift_mime_types = array(\n ".implode($valid_mime_types, ",\n ")."\n);"; + $output = "$preamble\$swift_mime_types = array(\n ".implode(",\n ", $valid_mime_types)."\n);"; // write mime_types.php config file @file_put_contents('./mime_types.php', $output); From 20f4b5389b00dec1807f32ca050651cc38b860e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 17:39:28 +0100 Subject: [PATCH 0197/1091] Fix the experimental feature to manage session in database --- ChangeLog | 2 +- htdocs/conf/conf.php.example | 18 +++- htdocs/core/lib/phpsessionindb.lib.php | 120 +++++++++++++++++++------ htdocs/main.inc.php | 9 +- htdocs/master.inc.php | 10 +-- 5 files changed, 119 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..f6fe916c13b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -133,7 +133,7 @@ NEW: printFieldListFrom hook call on several lists NEW: Use lang selector when using a field key 'lang' in modulebuilder NEW: we need to be able to put more filters on deleteByParentField() function NEW: make it easier to set the `keyword`, `keywords` and `description` attributes of an ecm file object - +NEW: Experimental feature to manage user sessions in database Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 7bb58d6b701..6bf2873b50c 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -282,18 +282,21 @@ $dolibarr_nocsrfcheck='0'; // If set to 1, you will be able to define some command line in the internale Job scheduler module. // Default value: '0' // Examples: '1' +// $dolibarr_cron_allow_cli='0'; // dolibarr_mailing_limit_sendbyweb -// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on OS level. +// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on system level. // Default value: '25' // Examples: '-1' (sending by web is forbidden) +// // $dolibarr_mailing_limit_sendbyweb='25'; // dolibarr_mailing_limit_sendbycli -// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on OS level. +// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on system level. // Default value: '0' (no hard limit, use soft database value if exists) // Examples: '-1' (sending by cli is forbidden) +// // $dolibarr_mailing_limit_sendbycli='0'; // MAIN_ANTIVIRUS_COMMAND (as a constant) @@ -308,6 +311,17 @@ $dolibarr_cron_allow_cli='0'; // Example: '--fdpass'; // define('MAIN_ANTIVIRUS_PARAM', '--fdpass'); +// php_session_save_handler +// Try to use the Dolibarr internal session handler that uses a database instead of the PHP handler (experimental). +// If you enable this feature to 'db', you may also want to enable the following constants: +// $dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass +// $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_type = $dolibarr_main_db_port +// Default value: '' +// Example: 'db'; +// +// $php_session_save_handler=''; + + //################## // Other diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 132036ba23d..71711eb6ba6 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -29,15 +29,29 @@ /** * The session open handler called by PHP whenever a session is initialized. * - * @param string $database_name Database NamedConstraint - * @param string $table_name Table name + * @param string $save_path Value of session.save_path into php.ini + * @param string $session_name Session name (Example: 'DOLSESSID_xxxxxx') * @return boolean Always true */ -function dolSessionOpen($database_name, $table_name) +function dolSessionOpen($save_path, $session_name) { - global $conf, $dbsession; + global $dbsession; - $dbsession = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + global $dolibarr_main_db_type, $dolibarr_main_db_host; + global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port; + + global $dolibarr_session_db_type, $dolibarr_session_db_host; + global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port; + + if (empty($dolibarr_session_db_type)) { $dolibarr_session_db_type = $dolibarr_main_db_type; } + if (empty($dolibarr_session_db_host)) { $dolibarr_session_db_host = $dolibarr_main_db_host; } + if (empty($dolibarr_session_db_user)) { $dolibarr_session_db_user = $dolibarr_main_db_user; } + if (empty($dolibarr_session_db_pass)) { $dolibarr_session_db_pass = $dolibarr_main_db_pass; } + if (empty($dolibarr_session_db_name)) { $dolibarr_session_db_name = $dolibarr_main_db_name; } + if (empty($dolibarr_session_db_port)) { $dolibarr_session_db_port = $dolibarr_main_db_port; } + //var_dump('open '.$database_name.' '.$table_name); + + $dbsession = getDoliDBInstance($dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port); return true; } @@ -51,8 +65,10 @@ function dolSessionOpen($database_name, $table_name) function dolSessionRead($sess_id) { global $dbsession; + global $sessionlastvalueread; + global $sessionidfound; - $sql = "SELECT session_variable FROM ".MAIN_DB_PREFIX."session"; + $sql = "SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX."session"; $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; // Execute the query @@ -60,10 +76,16 @@ function dolSessionRead($sess_id) $num_rows = $dbsession->num_rows($resql); if ($num_rows == 0) { // No session found - return an empty string + $sessionlastvalueread = ''; + $sessionidfound = ''; return ''; } else { // Found a session - return the serialized string $obj = $dbsession->fetch_object($resql); + $sessionlastvalueread = $obj->session_variable; + $sessionidfound = $obj->session_id; + //var_dump($sessionlastvalueread); + //var_dump($sessionidfound); return $obj->session_variable; } } @@ -79,42 +101,84 @@ function dolSessionRead($sess_id) function dolSessionWrite($sess_id, $val) { global $dbsession; + global $sessionlastvalueread; + global $sessionidfound; - $time_stamp = dol_now(); + /*var_dump('write '.$sess_id); + var_dump($val); + var_dump('sessionlastvalueread='.$sessionlastvalueread.' sessionidfound='.$sessionidfound); + */ - $sql = "SELECT session_id FROM ".MAIN_DB_PREFIX."session"; - $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + //$sessionlastvalueread=''; + if ($sessionlastvalueread != $val) { + $time_stamp = dol_now(); - // Execute the query - $resql = $dbsession->query($sql); - $num_rows = $dbsession->num_rows($resql); - if ($num_rows == 0) { - // No session found, insert a new one - $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; - $insert_query .= "(session_id, session_variable, last_accessed)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."')"; - $dbsession->query($insert_query); - } else { - // Existing session found - Update the session variables - $update_query = "UPDATE ".MAIN_DB_PREFIX."session"; - $update_query .= "SET session_variable = '".$dbsession->escape($val)."',"; - $update_query .= " last_accessed = '".$dbsession->idate($time_stamp)."'"; - $update_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; - $dbsession->query($update_query); + if (empty($sessionidfound)) { + // No session found, insert a new one + $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; + $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + + $result = $dbsession->query($insert_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } else { + if ($sessionidfound != $sess_id) { + // oops. How can this happen ? + dol_print_error($dbsession, 'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?'); + return false; + } + /*$sql = "SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX."session"; + $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + + // Execute the query + $resql = $dbsession->query($sql); + $num_rows = $dbsession->num_rows($resql); + if ($num_rows == 0) { + // No session found, insert a new one + $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; + $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + var_dump($insert_query); + $result = $dbsession->query($insert_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } else { + */ + // Existing session found - Update the session variables + $update_query = "UPDATE ".MAIN_DB_PREFIX."session"; + $update_query .= " SET session_variable = '".$dbsession->escape($val)."',"; + $update_query .= " last_accessed = '".$dbsession->idate($time_stamp)."',"; + $update_query .= " remote_ip = '".$dbsession->escape(getUserRemoteIP())."',"; + $update_query .= " user_agent = '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."'"; + $update_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + + $result = $dbsession->query($update_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } } + return true; } /** * This function is executed on shutdown of the session. * - * @param string $sess_id Session ID * @return boolean Always returns true. */ -function dolSessionClose($sess_id) +function dolSessionClose() { global $dbsession; + //var_dump('close'); + $dbsession->close(); return true; @@ -130,6 +194,8 @@ function dolSessionDestroy($sess_id) { global $dbsession; + //var_dump('destroy'); + $delete_query = "DELETE FROM ".MAIN_DB_PREFIX."session"; $delete_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; $dbsession->query($delete_query); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a15b17b8566..a1bc165ee49 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -272,10 +272,10 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { } } - // Set the handler of session -if (ini_get('session.save_handler') == 'user') { - require_once 'core/lib/phpsessionindb.lib.php'; +// if (ini_get('session.save_handler') == 'user') +if ($php_session_save_handler == 'db') { + require_once 'core/lib/phpsessionin'.$php_session_save_handler.'.lib.php'; } // Init session. Name of session is specific to Dolibarr instance. @@ -294,7 +294,8 @@ if (!empty($_COOKIE[$sessiontimeout])) { if (!defined('NOSESSION')) { session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. session_name($sessionname); - session_start(); + session_start(); // This call the open and read of session handler + //exit; // this exist generates a call to write and close } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index e04adb4ee86..7a92402224b 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -161,9 +161,10 @@ if (!defined('NOREQUIREDB')) { } // Now database connexion is known, so we can forget password -//unset($dolibarr_main_db_pass); // We comment this because this constant is used in a lot of pages +//unset($dolibarr_main_db_pass); // We comment this because this constant is used in some other pages unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump + /* * Object $user */ @@ -171,9 +172,9 @@ if (!defined('NOREQUIREUSER')) { $user = new User($db); } + /* * Load object $conf - * After this, all parameters conf->global->CONSTANTS are loaded */ // By default conf->entity is 1, but we change this if we ask another value. @@ -190,15 +191,12 @@ if (session_id() && !empty($_SESSION["dol_entity"])) { // For public page with MultiCompany module $conf->entity = constant('DOLENTITY'); } - // Sanitize entity if (!is_numeric($conf->entity)) { $conf->entity = 1; } - -//print "We work with data into entity instance number '".$conf->entity."'"; - // Here we read database (llx_const table) and define $conf->global->XXX var. +//print "We work with data into entity instance number '".$conf->entity."'"; $conf->setValues($db); // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. From 6f22827ff2c2f40fe255813e59ff90bc00236c54 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 8 Dec 2021 09:33:42 +0100 Subject: [PATCH 0198/1091] fix stuff --- htdocs/hrm/lib/hrm_skillrank.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php index 78a53823c2d..5872ec6f037 100644 --- a/htdocs/hrm/lib/hrm_skillrank.lib.php +++ b/htdocs/hrm/lib/hrm_skillrank.lib.php @@ -113,7 +113,7 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode // On charge les différentes notes possibles pour la compétence $fk_skill $skilldet = new Skilldet($db); - $Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); + $Lines = $skilldet->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); if (!is_array($Lines) && $Lines<0) { setEventMessages($skilldet->error, $skilldet->errors, 'errors'); From 386771cffc96106afb570f96867db49a60ab660b Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Wed, 8 Dec 2021 14:21:42 +0100 Subject: [PATCH 0199/1091] fix display contat line on list --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 7397cf8b61f..113fc5e74f7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -418,7 +418,7 @@ if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type From b4de28f1db88b1767f2891d49c504632fdeb6a88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 14:36:34 +0100 Subject: [PATCH 0200/1091] Update index.php --- htdocs/compta/facture/stats/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index c100263ac7f..ba787b46307 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -380,11 +380,11 @@ foreach ($data as $val) { print '
    0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.price(price2num($val['total'], 'MT'), 1).''.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.price(price2num($val['avg'], 'MT'), 1).''.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%'.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%
    '; print $linktoprod; print "'; print $linktoprod; print "
    '; print ''; + // Reception ref if ($conf->reception->enabled) { print ''; } - + // Product print ''; print ''; print ''; @@ -1181,9 +1194,14 @@ if ($id > 0 || !empty($ref)) { print "\n"; + while ($i < $num) { $objp = $db->fetch_object($resql); + $tmpproduct->id = $objp->fk_product; + $tmpproduct->ref = $objp->ref; + $tmpproduct->label = $objp->label; + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print ' @@ -1194,6 +1212,7 @@ if ($id > 0 || !empty($ref)) { print ''; + // Reception ref if (!empty($conf->reception->enabled)) { print '"; } + // Product print '\n"; print ''; From 9b65bb2085b8ef70f89d42bc600e298b428615a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:29:16 +0100 Subject: [PATCH 0204/1091] Update list.php --- htdocs/contact/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1672bdd3f7f..45454485b70 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -95,8 +95,8 @@ $search_roles = GETPOST("search_roles", 'array'); $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); -if ($search_status == '') $search_status = 1; // always display active customer first -if ($search_no_email == '') $search_no_email = -1; +if ($search_status === '') $search_status = 1; // always display active customer first +if ($search_no_email === '') $search_no_email = -1; $optioncss = GETPOST('optioncss', 'alpha'); From 8ff0d1f366c15c56b6aab6fb74b7108ebc0cf35e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:49:52 +0100 Subject: [PATCH 0205/1091] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dd05038f968..4d9c5f49440 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1169,8 +1169,10 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) */ function dol_string_unaccent($str) { + global $conf; + if (utf8_check($str)) { - if (extension_loaded('intl')) { + if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); return $transliterator->transliterate($str); } From 74ecb0792575424571a6c26dab22374b09f3e63d Mon Sep 17 00:00:00 2001 From: atm-florian Date: Wed, 8 Dec 2021 16:03:21 +0100 Subject: [PATCH 0206/1091] FIX: printFieldListWhere called twice (at different locations) for the same SQL query, can result in syntax errors --- htdocs/product/stock/replenish.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index c925d7f0f62..64f77eead74 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -505,11 +505,6 @@ if ($includeproductswithoutdesiredqty == 'on') { $includeproductswithoutdesiredqtychecked = 'checked'; } -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); From 6501bb7cbff1a4583cb5db7351727896dc8f9ba8 Mon Sep 17 00:00:00 2001 From: habot-it <58470575+habot-it@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:43:11 +0100 Subject: [PATCH 0207/1091] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 762605b8e1e..587bcdcdfbc 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1148,7 +1148,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs'=>$outputlangs); $action = ''; $hookmanager->executeHooks('pdf_pagefoot', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint) and $hidefreetext == 0) { + if (!empty($hookmanager->resPrint) && $hidefreetext == 0) { $mycustomfooter = $hookmanager->resPrint; $mycustomfooterheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); From af6e21910d8e62524db3848cde71333aeb86f990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 16:47:46 +0100 Subject: [PATCH 0208/1091] FIX #19536 --- htdocs/core/lib/ticket.lib.php | 6 +++--- htdocs/opensurvey/fonctions.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 16b39354de9..25da4bdacfc 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -178,16 +178,16 @@ function showDirectPublicLink($object) /** * Generate a random id * - * @param int $car Length of string to generate key + * @param int $car Length of string to generate key * @return string */ function generate_random_id($car = 16) { $string = ""; $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; - srand((double) microtime() * 1000000); + mt_srand((double) microtime() * 1000000); for ($i = 0; $i < $car; $i++) { - $string .= $chaine[rand() % strlen($chaine)]; + $string .= $chaine[mt_rand() % strlen($chaine)]; } return $string; } diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 3d8d76c5c1e..f844921720b 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -206,7 +206,7 @@ function getUrlSondage($id, $admin = false) /** * Generate a random id * - * @param string $car Char to generate key + * @param int $car Length of string to generate key * @return string */ function dol_survey_random($car) From 8f7b222764ce2cd10bd0fcba6a34fdb1431365b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:37:07 +0100 Subject: [PATCH 0209/1091] Fix phpcs --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 6b627e51ab6..f8e5726d344 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2070,7 +2070,7 @@ class ExtraFields continue; } if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') { - //when unticking boolean field, it's not set in POST + //when unticking boolean field, it's not set in POST continue; } From 9d11d265ec95d6180a6c5e969d35d6959245b085 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:37:52 +0100 Subject: [PATCH 0210/1091] Fix phpcs --- htdocs/product/stock/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d1bd49629c6..440e082e8ff 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -183,7 +183,7 @@ if (empty($reshook)) { $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { $error++; } From 51e7484d55a848311923e758bb341bc10aefd1d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:49:57 +0100 Subject: [PATCH 0211/1091] Fix var not defined --- htdocs/expedition/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index fe09a4c521d..b49a464faba 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2041,9 +2041,10 @@ if ($action == 'create') { print "\n"; print ''; + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); - $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); @@ -2103,7 +2104,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => !empty($outputlangs) ? $outputlangs: ''); + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); From 90cff6aed91fb9214c7d2b418847105c79f10a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:50:42 +0100 Subject: [PATCH 0212/1091] Update list.php --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index fb8ba3b8990..1665b1a43c0 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -253,7 +253,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && sis_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { From 22c271966d4f409f698746fe311d1180f82709d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 19:14:02 +0100 Subject: [PATCH 0213/1091] Fix the existing method dolEscapeXML should be enough. --- .../class/bonprelevement.class.php | 56 ++++++------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index f25fcf1e397..365969436dd 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -121,26 +121,6 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - /** - * Remove any illegal characters for SEPA - * - * @param string $str String to remove illegal chars - * @return string Cleaned string - * - */ - public static function removeIllegalChars($str) - { - /* - Valid XML Characters: - a b c d e f g h i j k l m n o p q r s t u v w x y z - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - 0 1 2 3 4 5 6 7 8 9 - / – ? : ( ) . , ‘ + - Space - */ - return preg_replace('/[^A-Za-z0-9 \.,\-\/\+():?]/', '', dol_string_unaccent($str)); - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal @@ -1572,7 +1552,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1688,7 +1668,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1938,11 +1918,11 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($this->removeIllegalChars($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; } @@ -1989,11 +1969,11 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($this->removeIllegalChars($row_nom))).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; } @@ -2161,16 +2141,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2227,16 +2207,16 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; From 646ba34f89a320c9d613a601bf9724dc3ec48984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 19:15:35 +0100 Subject: [PATCH 0214/1091] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4d9c5f49440..9202cc89466 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1170,7 +1170,7 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) function dol_string_unaccent($str) { global $conf; - + if (utf8_check($str)) { if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); From d0413f423fea63ce36f81dbd8e0def4459dbf052 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:33:00 +0100 Subject: [PATCH 0215/1091] FIX - Missing one html conversion --- htdocs/core/lib/pdf.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 686a442ec2f..22316ab1b08 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,6 +1413,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { + if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { + str_replace("\n",'
    ', $desc); + } if ($idprod) { // Check if description must be output if (!empty($object->element)) { From 1123bf3cde436caafd38b07255cfe8959d6e327b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 9 Dec 2021 09:34:00 +0100 Subject: [PATCH 0216/1091] =?UTF-8?q?Fix=20#18586=20:=20special=20char=20"?= =?UTF-8?q?=E2=80=A6"=20not=20allowed=20in=20XML=20file=20and=20added=20by?= =?UTF-8?q?=20dol=5Ftrunc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/prelevement/class/bonprelevement.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 721d7c10111..92c0db1f55e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1936,7 +1936,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1968,7 +1968,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; return $XML_DEBITOR; @@ -1978,7 +1978,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.round($row_somme, 2).''.$CrLf; @@ -2015,7 +2015,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; return $XML_CREDITOR; From f74077a2e73a5b1c2ddae4a3269c2e28df0ba4cf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Dec 2021 08:35:12 +0000 Subject: [PATCH 0217/1091] Fixing style errors. --- htdocs/core/lib/pdf.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 22316ab1b08..0e1164bce30 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,8 +1413,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { - if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - str_replace("\n",'
    ', $desc); + if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { + str_replace("\n", '
    ', $desc); } if ($idprod) { // Check if description must be output From abd984bc14057244f47700cc4deeb7223a75310f Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:39:22 +0100 Subject: [PATCH 0218/1091] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0e1164bce30..bda030187b3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1414,7 +1414,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - str_replace("\n", '
    ', $desc); + $desc = str_replace("\n", '
    ', $desc); } if ($idprod) { // Check if description must be output From 7ce60099588336097aa573f004f451c13cf87170 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 09:53:32 +0100 Subject: [PATCH 0219/1091] Removed deprecated option --- htdocs/compta/paiement/list.php | 5 +---- htdocs/fourn/paiement/list.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f5160c51757..0d928cf188f 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -528,10 +528,7 @@ while ($i < min($num, $limit)) { // Date if (!empty($arrayfields['p.datep']['checked'])) { - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) { - $dateformatforpayment = 'dayhour'; - } + $dateformatforpayment = 'dayhour'; print '
    '; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 5c76c1dddd0..f9df30c2f54 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -497,10 +497,7 @@ while ($i < min($num, $limit)) { // Date if (!empty($arrayfields['p.datep']['checked'])) { - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) { - $dateformatforpayment = 'dayhour'; - } + $dateformatforpayment = 'dayhour'; print ''; if (!$i) { $totalarray['nbfield']++; From 92a0c9e4fba7513969da026eebf30b230a59f624 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 10:00:42 +0100 Subject: [PATCH 0220/1091] Fix sql error in repair.php --- htdocs/install/repair.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index ad3a3ca13a3..4aba1d10c4b 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1178,9 +1178,9 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { $listofmods = ''; foreach ($conf->modules as $key => $val) { - $listofmods .= ($listofmods ? ',' : '')."'".$val."'"; + $listofmods .= ($listofmods ? ',' : '')."'".$db->escape($val)."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods).') AND id > 100000'; + $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods, 1).') AND id > 100000'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); From 10984260052e26aa47c756220d7432b28ee074d4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Dec 2021 10:31:02 +0100 Subject: [PATCH 0221/1091] FIX wrong syntax of sql request --- htdocs/core/class/html.formaccounting.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index fbfde88198b..dc6e6d8c6cd 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -456,7 +456,7 @@ class FormAccounting extends Form $sql = "SELECT code_compta, code_compta_fournisseur, nom as name"; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " WHERE entity IN (".getEntity('societe').")"; - $sql .= " AND client IN (1,3) OR fournisseur = 1"; + $sql .= " AND (client IN (1,3) OR fournisseur = 1)"; $resql = $this->db->query($sql); if ($resql) { From b5d1ea4629381216edf750580b74b9188bccc251 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:07:38 +0100 Subject: [PATCH 0222/1091] FIX select too large into addrights (pb of missing parenthesis) --- htdocs/core/modules/DolibarrModules.class.php | 28 ++++++++++--------- htdocs/user/class/user.class.php | 13 +++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 1ed58b2905a..b90ea227037 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1736,10 +1736,10 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it /** * Adds access rights * - * @param int $reinitadminperms If 1, we also grant them to all admin users - * @param int $force_entity Force current entity - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int Error count (0 if OK) + * @param int $reinitadminperms If 1, we also grant them to all admin users + * @param int $force_entity Force current entity + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int Error count (0 if OK) */ public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) { @@ -1761,16 +1761,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if ($resql) { $obj = $this->db->fetch_object($resql); + if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + // If the module is active foreach ($this->rights as $key => $value) { - $r_id = $this->rights[$key][0]; + $r_id = $this->rights[$key][0]; // permission id in llx_rights_def (not unique because primary key is couple id-entity) $r_desc = $this->rights[$key][1]; $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : ''; - $r_modul = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; + $r_modul = empty($this->rights_class) ? strtolower($this->name) : $this->rights_class; if (empty($r_type)) { $r_type = 'w'; @@ -1823,21 +1826,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // If we want to init permissions on admin users if ($reinitadminperms) { - if (!class_exists('User')) { - include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); + $resqlseladmin = $this->db->query($sql, 1); + if ($resqlseladmin) { $num = $this->db->num_rows($resqlseladmin); $i = 0; while ($i < $num) { - $obj2 = $this->db->fetch_object($resqlseladmin); - dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + $obj2 = $this->db->fetch_object($resqlseladmin); + dol_syslog(get_class($this)."::insert_permissions Add permission id '.$r_id.' to user id=".$obj2->rowid); - $tmpuser = new User($this->db); - $result = $tmpuser->fetch($obj2->rowid); + $tmpuser = new User($this->db); + $result = $tmpuser->fetch($obj2->rowid); if ($result > 0) { $tmpuser->addrights($r_id, '', '', 0, 1); } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1780c73fc69..58a38e8380b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -786,9 +786,10 @@ class User extends CommonObject { global $conf, $user, $langs; - $entity = (!empty($entity) ? $entity : $conf->entity); + $entity = (empty($entity) ? $conf->entity : $entity); + + dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity, $notrigger for user id=".$this->id); - dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity"); $error = 0; $whereforadd = ''; @@ -797,7 +798,7 @@ class User extends CommonObject if (!empty($rid)) { $module = $perms = $subperms = ''; - // Si on a demande ajout d'un droit en particulier, on recupere les caracteristiques (module, perms et subperms) de ce droit. + // If we ask to add a given permission, we first load properties of this permission (module, perms and subperms). $sql = "SELECT module, perms, subperms"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE id = ".((int) $rid); @@ -817,9 +818,9 @@ class User extends CommonObject dol_print_error($this->db); } - // Where pour la liste des droits a ajouter + // Define the where for the permission to add $whereforadd = "id=".((int) $rid); - // Ajout des droits induits + // Add also inherited permissions if (!empty($subperms)) { $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))"; } elseif (!empty($perms)) { @@ -848,7 +849,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($whereforadd) && $whereforadd != 'allmodules') { - $sql .= " AND ".$whereforadd; + $sql .= " AND (".$whereforadd.")"; // Note: parenthesis are important because wheretoand can contains OR. Also note that $whereforadd is already sanitized } $result = $this->db->query($sql); From a9bdefa3587bb05b6b94523ebc91e1260db48f5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:12:40 +0100 Subject: [PATCH 0223/1091] FIX select too large into addrights (pb of missing parenthesis) --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 09bb34ddef3..be1db952aa0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -738,7 +738,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($whereforadd) && $whereforadd != 'allmodules') { - $sql .= " AND ".$whereforadd; + $sql .= " AND (".$whereforadd.")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized } $result = $this->db->query($sql); @@ -864,7 +864,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($wherefordel) && $wherefordel != 'allmodules') { - $sql .= " AND ".$wherefordel; + $sql .= " AND (".$wherefordel.")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized } // avoid admin can remove his own important rights From 0c2dce372f71b5c7e6ebc55ad1318a3acb94d2df Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Thu, 9 Dec 2021 11:24:03 +0100 Subject: [PATCH 0224/1091] FIX In the card of a direct debit FIX In the card of a direct debit, if you change the limit, it gets disordered and vice versa --- htdocs/compta/prelevement/card.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 8a232377ab7..95d30becd03 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -382,6 +382,9 @@ if ($id > 0 || $ref) { $i = 0; $urladd = "&id=".urlencode($id); + if ($limit > 0 && $limit != $conf->liste_limit) { + $urladd .= '&limit='.urlencode($limit); + } print ''."\n"; print ''; @@ -392,6 +395,12 @@ if ($id > 0 || $ref) { if (!empty($limit)) { print ''; } + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table From 93356d9dc4f3bfb7595966eb0e0a42cf323e0a5a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Dec 2021 10:25:58 +0000 Subject: [PATCH 0225/1091] Fixing style errors. --- htdocs/compta/prelevement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 95d30becd03..c29cadf564d 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -383,7 +383,7 @@ if ($id > 0 || $ref) { $urladd = "&id=".urlencode($id); if ($limit > 0 && $limit != $conf->liste_limit) { - $urladd .= '&limit='.urlencode($limit); + $urladd .= '&limit='.urlencode($limit); } print ''."\n"; From 7ea8b7851a03f0d5c67e35f190a3146917dbe4a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:56:54 +0100 Subject: [PATCH 0226/1091] Code comment --- htdocs/user/class/user.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2bb07dab48b..467a572193e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1075,12 +1075,14 @@ class User extends CommonObject // First user permissions $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; - $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; - $sql .= ", ".MAIN_DB_PREFIX."rights_def as r"; + $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur,"; + $sql .= " ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.id = ur.fk_id"; if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) { + // on old version, we use entity defined into table r $sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")"; } else { + // we must now use entity into table ur $sql .= " AND ur.entity = ".((int) $conf->entity); } $sql .= " AND ur.fk_user= ".((int) $this->id); From ecf98530bb6fa1d74dada6490feabcf2460c4213 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 12:42:04 +0100 Subject: [PATCH 0227/1091] Debug SEPA payment module --- htdocs/compta/bank/card.php | 4 +- htdocs/compta/prelevement/create.php | 89 +++++++++++++++++----------- htdocs/langs/en_US/withdrawals.lang | 2 +- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index fddd0ee2493..9f000786b7f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1067,12 +1067,12 @@ if ($action == 'create') { if ($conf->prelevement->enabled) { print '
    '; - print ''; + print ''; } if ($conf->paymentbybanktransfer->enabled) { print ''; - print ''; + print ''; } print ''; print ''; From f3da457b2be58ea9181983f6294ac6089eb826f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 14:26:28 +0100 Subject: [PATCH 0244/1091] Clean comment --- htdocs/core/bookmarks_page.php | 2 +- htdocs/core/multicompany_page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index 32e2be230b9..11f8b884762 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -58,7 +58,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Bookmarks"); // URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a bookmark selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php index ad1d8934dbb..4a3bcba51fb 100644 --- a/htdocs/core/multicompany_page.php +++ b/htdocs/core/multicompany_page.php @@ -81,7 +81,7 @@ if (GETPOST('acction', 'aZ') == 'switchentity') { $title = $langs->trans("Multicompanies"); // URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page +$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); From dcd8c0f53d58552882696375cb6ee6deb103a097 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 14:50:20 +0100 Subject: [PATCH 0245/1091] css --- htdocs/admin/company.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a10fab3b8c2..04f516374c6 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -381,9 +381,8 @@ print ''.$langs->trans("CompanyFundationDesc", $lang print "

    \n"; -/** - * Edit parameters - */ +// Edit parameters + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; } } diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index e041516a292..b6b6aa2596c 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -61,7 +61,7 @@ CKEDITOR.editorConfig = function( config ) ['Undo','Redo','-','Find','Replace'], ['CreateDiv','ShowBlocks'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor','Image','Table','HorizontalRule','SpecialChar'], @@ -75,7 +75,7 @@ CKEDITOR.editorConfig = function( config ) ['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone ['Undo','Redo','-','Find','Replace'], ['Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Image','Table','HorizontalRule','SpecialChar'], diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index acd38268f8f..83f124f2f2c 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -61,7 +61,7 @@ CKEDITOR.editorConfig = function( config ) ['Undo','Redo','-','Find','Replace'], ['CreateDiv','ShowBlocks'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor','Image','Table','HorizontalRule','SpecialChar'], @@ -75,7 +75,7 @@ CKEDITOR.editorConfig = function( config ) ['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone ['Undo','Redo','-','Find','Replace'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Image','Table','HorizontalRule','SpecialChar'], From 49853adf82edef706d389d5fe275559708cf1eb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 09:35:27 +0100 Subject: [PATCH 0263/1091] Fix pb with cache --- htdocs/core/bookmarks_page.php | 12 ++++++++++++ htdocs/core/get_menudiv.php | 12 ++++++++++++ htdocs/core/modules/modHRM.class.php | 8 ++------ htdocs/core/search_page.php | 12 ++++++++++++ htdocs/hrm/css/radio_js_number.css | 18 ------------------ htdocs/theme/eldy/global.inc.php | 23 +++++++++++++++++++++++ htdocs/theme/md/style.css.php | 23 +++++++++++++++++++++++ 7 files changed, 84 insertions(+), 24 deletions(-) delete mode 100644 htdocs/hrm/css/radio_js_number.css diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index 9915a259570..9c3b5abb266 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -55,6 +55,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Bookmarks"); // URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index e04971ce8c3..77b0416956b 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -81,6 +81,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public, must-revalidate'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index a72479115c5..3e75f8efcd5 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -85,13 +85,9 @@ class modHRM extends DolibarrModules // Set this to 1 if module has its own theme directory (theme) 'theme' => 0, // Set this to relative path of css file if module has its own css file - 'css' => array( - '/hrm/css/radio_js_number.css', - ), + 'css' => array(), // Set this to relative path of js file if module must load a js on all pages - 'js' => array( - // '/hrm/js/hrm.js.php', - ), + 'js' => array(), // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 0341c1116ef..4f6911497e4 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -55,6 +55,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Search"); // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/hrm/css/radio_js_number.css b/htdocs/hrm/css/radio_js_number.css deleted file mode 100644 index 320b0ddc1f2..00000000000 --- a/htdocs/hrm/css/radio_js_number.css +++ /dev/null @@ -1,18 +0,0 @@ -.radio_js_bloc_number { - display:inline-block; - padding:5px 7px; - min-width:20px; - border-radius:3px; - border:1px solid #ccc; - background:#eee; - color:#555; - cursor:pointer; - margin:2px; - text-align:center; -} -.radio_js_bloc_number.selected { - transition:0.2s ease background; - background:#888; - color:#fff; - border-color:#555; -} \ No newline at end of file diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fedb4f9d67e..d8bd4673d5c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6967,6 +6967,29 @@ div.clipboardCPValue.hidewithsize { } +/* ============================================================================== */ +/* CSS style used for hrm skill/rank (may be we can remove this) */ +/* ============================================================================== */ + +.radio_js_bloc_number { + display:inline-block; + padding:5px 7px; + min-width:20px; + border-radius:3px; + border:1px solid #ccc; + background:#eee; + color:#555; + cursor:pointer; + margin:2px; + text-align:center; +} +.radio_js_bloc_number.selected { + transition:0.2s ease background; + background:#888; + color:#fff; + border-color:#555; +} + /* ============================================================================== */ /* CSS style used for small screen */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 79d7c929927..6805f2c620e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6854,6 +6854,29 @@ div.clipboardCPValue.hidewithsize { } +/* ============================================================================== */ +/* CSS style used for hrm skill/rank (may be we can remove this) */ +/* ============================================================================== */ + +.radio_js_bloc_number { + display:inline-block; + padding:5px 7px; + min-width:20px; + border-radius:3px; + border:1px solid #ccc; + background:#eee; + color:#555; + cursor:pointer; + margin:2px; + text-align:center; +} +.radio_js_bloc_number.selected { + transition:0.2s ease background; + background:#888; + color:#fff; + border-color:#555; +} + /* ============================================================================== */ /* CSS style used for small screen */ From df9b337a571dabf74c7d476639d92e1575df6956 Mon Sep 17 00:00:00 2001 From: Je2fb <46494485+Je2fb@users.noreply.github.com> Date: Mon, 13 Dec 2021 09:44:00 +0100 Subject: [PATCH 0264/1091] Fix #19418 --- htdocs/core/class/html.formadmin.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 4196fb32b68..bab9ab61b57 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -75,7 +75,7 @@ class FormAdmin // If the language to select is not inside the list of available language and empty value is not available, we must find // an alternative as the language code to pre-select (to avoid to have first element in list pre-selected). - if ($selected && !in_array($selected, $langs_available) && empty($showempty)) { + if ($selected && !isset($langs_available[$selected]) && empty($showempty)) { $tmparray = explode('_', $selected); if (!empty($tmparray[1])) { $selected = getLanguageCodeFromCountryCode($tmparray[1]); From c9ae805e7a76d420e64e2c3ea1c110ea00968ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Mon, 13 Dec 2021 10:43:02 +0100 Subject: [PATCH 0265/1091] Change constant --- htdocs/takepos/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 1b9799efec4..5797f52053d 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1190,7 +1190,7 @@ if (!empty($conf->global->TAKEPOS_WEIGHING_SCALE)) { global->TAKEPOS_NO_CATEGORY == 1) { + if ($conf->global->TAKEPOS_HIDE_CATEGORY == 1) { print '
    '.$langs->trans("Reception").''.$langs->trans("Product").''.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").'
    '; if (!empty($objp->fk_reception)) { @@ -1205,8 +1224,16 @@ if ($id > 0 || !empty($ref)) { print "'; - print ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; + if (empty($conf->cache['product'][$objp->fk_product])) { + $tmpproduct = new Product($db); + $tmpproduct->fetch($objp->fk_product); + $conf->cache['product'][$objp->fk_product] = $tmpproduct; + } else { + $tmpproduct = $conf->cache['product'][$objp->fk_product]; + } + print $tmpproduct->getNomUrl(1); print ' - '.$objp->label; print "'.dol_print_date($db->jdate($objp->datec), 'day').'
    '.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'
    '.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')
    '.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')
    '.$langs->trans("BankAccountDomiciliation").''; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 42bf73eaae6..3f00a4f0660 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -45,9 +45,12 @@ $type = GETPOST('type', 'aZ09'); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list + $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); $id_bankaccount = GETPOST('id_bankaccount', 'int'); +$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -67,6 +70,8 @@ if ($type == 'bank-transfer') { $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } +$error = 0; + /* * Actions @@ -92,8 +97,10 @@ if (empty($reshook)) { if ($action == 'create') { $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); - if ($id_bankaccount != $conf->global->{$default_account}) { - $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default + //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit; + + if ($id_bankaccount != $conf->global->$default_account) { + $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default } require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -104,44 +111,39 @@ if (empty($reshook)) { ) { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); - exit; + $action = ''; + $error++; } - $delayindays = 0; - if ($type != 'bank-transfer') { - $delayindays = $conf->global->PRELEVEMENT_ADDDAYS; - } else { - $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; - } $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); - if ($result < 0) { - setEventMessages($bprev->error, $bprev->errors, 'errors'); - } elseif ($result == 0) { - $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); - setEventMessages($mesg, null, 'errors'); - $mesg .= '
    '."\n"; - foreach ($bprev->invoice_in_error as $key => $val) { - $mesg .= ''.$val."
    \n"; - } - } else { - if ($type != 'bank-transfer') { - $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}'); - $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); - setEventMessages($texttoshow, null); + if (!$error) { + // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); + if ($result < 0) { + setEventMessages($bprev->error, $bprev->errors, 'errors'); + } elseif ($result == 0) { + $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); + setEventMessages($mesg, null, 'errors'); + $mesg .= '
    '."\n"; + foreach ($bprev->invoice_in_error as $key => $val) { + $mesg .= ''.$val."
    \n"; + } } else { - $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}'); - $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); - setEventMessages($texttoshow, null); - } + if ($type != 'bank-transfer') { + $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}'); + $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); + setEventMessages($texttoshow, null); + } else { + $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}'); + $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); + setEventMessages($texttoshow, null); + } - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id); - exit; + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type)); + exit; + } } } $objectclass = "BonPrelevement"; @@ -250,11 +252,25 @@ if ($nb) { } print $title; print img_picto('', 'bank_account'); - print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1); + + $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); + + print $form->select_comptes($conf->global->$default_account, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1); print ' - '; + if (empty($executiondate)) { + $delayindays = 0; + if ($type != 'bank-transfer') { + $delayindays = $conf->global->PRELEVEMENT_ADDDAYS; + } else { + $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; + } + + $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd'); + } + print $langs->trans('ExecutionDate').' '; - $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $datere = $executiondate; print $form->selectDate($datere, 're'); @@ -276,7 +292,8 @@ if ($nb) { if ($type == 'bank-transfer') { $title = $langs->trans("CreateFileForPaymentByBankTransfer"); } - print ''.$title."\n"; + print ''."\n"; + print ''."\n"; } } else { if ($mysoc->isInEEC()) { diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index a3773a427a1..7b18c1a0d70 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -80,7 +80,7 @@ StatusMotif7=Judicial Decision StatusMotif8=Other reason CreateForSepaFRST=Create direct debit file (SEPA FRST) CreateForSepaRCUR=Create direct debit file (SEPA RCUR) -CreateAll=Create direct debit file (all) +CreateAll=Create direct debit file CreateFileForPaymentByBankTransfer=Create file for credit transfer CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA) CreateGuichet=Only office From 6b9636c3b8e1cc9ad1699f167a507b4897e12688 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 12:54:08 +0100 Subject: [PATCH 0228/1091] FIX deletion of direct debit or credit transfer --- htdocs/compta/prelevement/card.php | 4 +++- htdocs/core/lib/security.lib.php | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index a2de75123a0..d35061363a4 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -67,6 +67,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist')); $type = $object->type; + if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { @@ -86,9 +87,10 @@ if ($reshook < 0) { if (empty($reshook)) { if ($action == 'confirm_delete') { + $savtype = $object->type; $res = $object->delete($user); if ($res > 0) { - if ($object->type == 'bank-transfer') { + if ($savtype == 'bank-transfer') { header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); } else { header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 58d69842f66..80150a5c53e 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -566,6 +566,14 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (empty($user->rights->adherent->supprimer)) { $deleteok = 0; } + } elseif ($feature == 'paymentbybanktransfer') { + if (empty($user->rights->paymentbybanktransfer->create)) { // There is no delete permission + $deleteok = 0; + } + } elseif ($feature == 'prelevement') { + if (empty($user->rights->prelevement->bons->creer)) { // There is no delete permission + $deleteok = 0; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels foreach ($feature2 as $subfeature) { if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { From 9462481e83641ac260419d428bfef06c6f61b0bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 14:51:35 +0100 Subject: [PATCH 0229/1091] Doc --- htdocs/compta/prelevement/card.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index d35061363a4..2ec611e99c2 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -99,7 +99,7 @@ if (empty($reshook)) { } } - // Seems to no be used and replaced with $action == 'infocredit' + // Seems to not be used and replaced with $action == 'infocredit' if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') { if ($object->statut == 2) { $res = -1; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ebdf4825551..05a51afacdb 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -28,7 +28,7 @@ //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu From 8b2002fbfb755ca55ab4aee813a9dd76618b090e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 9 Dec 2021 15:17:18 +0100 Subject: [PATCH 0230/1091] Fix php 8.0 warnings of modulebuilder --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/modulebuilder/template/class/myobject.class.php | 8 ++++---- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 4 ++-- htdocs/modulebuilder/template/myobject_document.php | 2 +- htdocs/modulebuilder/template/myobject_note.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2e8ca8540d5..f4dcf711b65 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8528,7 +8528,7 @@ abstract class CommonObject } } } else { - $queryarray[$field] = $this->{$field}; + $queryarray[$field] = !empty($this->{$field}) ? $this->{$field} : 0; } if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6e5d6efcff4..ca9de1cc5ab 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -362,7 +362,7 @@ class MyObject extends CommonObject if (!$error) { // copy external contacts if same company - if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { if ($this->copy_linked_contact($object, 'external') < 0) { $error++; } @@ -918,19 +918,19 @@ class MyObject extends CommonObject if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) { + if (!empty($obj->fk_user_author)) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) { + if (!empty($obj->fk_user_valid)) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index add786498b2..b7d3fcfaa80 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -129,7 +129,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->mymodule->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ebdf4825551..c8959444449 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -92,7 +92,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new MyObject($db); @@ -505,7 +505,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd); /* if ($permissiontoadd) { diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 5e8d09db179..e77fec58167 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -98,7 +98,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index d1c4e4c8837..6733919289b 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -98,7 +98,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->mymodule->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php From d80f83caf47599e64a8a0c5d59f6be972b42815c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 17:19:31 +0100 Subject: [PATCH 0231/1091] Clean code --- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c9566b73e62..e56e3b32666 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -700,7 +700,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $sql .= ', p.ref DESC'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e03438b4e3b..e71b5ae9edd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -633,7 +633,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 02ce893b96d..7456a13146d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -815,7 +815,7 @@ if (!$sall) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 ".$hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 526fb05dc64..8d0a5e40cc6 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -383,7 +383,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a1db1826684..d966a94769d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -209,7 +209,7 @@ class FactureFournisseur extends CommonInvoice /** * @var int ID */ - public $fk_account; + public $fk_account; // default bank account public $mode_reglement_id; public $mode_reglement_code; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index e29b928140e..8b83048d8d3 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -655,7 +655,7 @@ if (!$search_all) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 9f1150d2194..e4965533440 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -349,7 +349,7 @@ $sql = preg_replace('/,\s*$/', '', $sql); /* $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; */ // Count total nb of records diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3e4a1eeb9f3..ed18ec208f0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -209,10 +209,10 @@ class Societe extends CommonObject 'mode_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>295), 'cond_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>300), 'mode_reglement_supplier' =>array('type'=>'integer', 'label'=>'Mode reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>305), + 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>308), 'outstanding_limit' =>array('type'=>'double(24,8)', 'label'=>'OutstandingBill', 'enabled'=>1, 'visible'=>-1, 'position'=>310, 'isameasure'=>1), 'order_min_amount' =>array('type'=>'double(24,8)', 'label'=>'Order min amount', 'enabled'=>'!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)', 'visible'=>-1, 'position'=>315, 'isameasure'=>1), 'supplier_order_min_amount' =>array('type'=>'double(24,8)', 'label'=>'Supplier order min amount', 'enabled'=>'!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)', 'visible'=>-1, 'position'=>320, 'isameasure'=>1), - 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>325), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'Fk shipping method', 'enabled'=>1, 'visible'=>-1, 'position'=>330), 'tva_assuj' =>array('type'=>'tinyint(4)', 'label'=>'Tva assuj', 'enabled'=>1, 'visible'=>-1, 'position'=>335), 'localtax1_assuj' =>array('type'=>'tinyint(4)', 'label'=>'Localtax1 assuj', 'enabled'=>1, 'visible'=>-1, 'position'=>340), From baabfd380fd6ba863f8d3cd28cb3511db15e77b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 17:25:06 +0100 Subject: [PATCH 0232/1091] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index bda030187b3..ba2e0b1039e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,9 +1413,6 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { - if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - $desc = str_replace("\n", '
    ', $desc); - } if ($idprod) { // Check if description must be output if (!empty($object->element)) { @@ -1431,12 +1428,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } From 783ddcc6716052556970206af718d42000206fb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 18:01:44 +0100 Subject: [PATCH 0233/1091] Fix phpcs --- htdocs/install/repair.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 4aba1d10c4b..9ce982cb458 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1180,7 +1180,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { foreach ($conf->modules as $key => $val) { $listofmods .= ($listofmods ? ',' : '')."'".$db->escape($val)."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods, 1).') AND id > 100000'; + $sql = "SELECT id, libelle as label, module from ".MAIN_DB_PREFIX."rights_def WHERE module NOT IN (".$db->sanitize($listofmods, 1).") AND id > 100000"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1191,7 +1191,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { if ($obj->id > 0) { print '
    Found line with id '.$obj->id.', label "'.$obj->label.'" of module "'.$obj->module.'" to delete'; if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') { - $sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id; + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE id = ".((int) $obj->id); $resqldelete = $db->query($sqldelete); if (!$resqldelete) { dol_print_error($db); From c37377626eb83e07653f0c122ce7c038477efcc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 19:43:23 +0100 Subject: [PATCH 0234/1091] Revert change --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f4dcf711b65..f2471d122af 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8528,7 +8528,9 @@ abstract class CommonObject } } } else { - $queryarray[$field] = !empty($this->{$field}) ? $this->{$field} : 0; + // Note: If $this->{$field} is not defined, it means there is a bug into definition of ->fields or a missing declaration of property + // We should keep the warning generated by this because it is a bug somewhere else in code, not here. + $queryarray[$field] = $this->{$field}; } if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { From 20a3fab437c4d118bedabcb0cfe411fe24baa60b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 20:58:23 +0100 Subject: [PATCH 0235/1091] Fix pb when several output hooks --- htdocs/core/class/hookmanager.class.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index c113f2c3bb9..d1b1e08710e 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -146,7 +146,7 @@ class HookManager * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0 if we want to keep standard actions, >0 uf we want to stop/replace standard actions (at least one > 0 and replacement will be done), <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. */ @@ -242,6 +242,7 @@ class HookManager $this->resArray = array(); $this->resNbOfHooks = 0; + // Here, the value for $method and $hooktype are given. // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted = array(); $resaction = 0; @@ -265,7 +266,7 @@ class HookManager $this->resNbOfHooks++; - $modulealreadyexecuted[$module] = $module; // Use the $currentcontext in method to avoid running twice + $modulealreadyexecuted[$module] = $module; // Clean class (an error may have been set from a previous call of another method for same module/hook) $actionclassinstance->error = 0; @@ -274,6 +275,7 @@ class HookManager dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', object id='.$object->id : '').((is_object($object) && property_exists($object, 'element')) ? ', object element='.$object->element : ''), LOG_DEBUG); // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; + // Note: The hook can use the $currentcontext in its code to avoid to be ran twice or be ran for one given context only $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') { @@ -310,7 +312,8 @@ class HookManager } //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); - $resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) + $resactiontmp = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) + $resaction += $resactiontmp; if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) { $this->resArray = array_merge($this->resArray, $actionclassinstance->results); @@ -318,23 +321,23 @@ class HookManager if (!empty($actionclassinstance->resprints)) { $this->resPrint .= $actionclassinstance->resprints; } - if (is_numeric($resaction) && $resaction < 0) { + if (is_numeric($resactiontmp) && $resactiontmp < 0) { $error++; $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); } - // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string - if (!is_array($resaction) && !is_numeric($resaction)) { + + // TODO dead code to remove (do not disable this, but fix your hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string + if (!is_array($resactiontmp) && !is_numeric($resactiontmp)) { dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); if (empty($actionclassinstance->resprints)) { - $this->resPrint .= $resaction; - $resaction = 0; + $this->resPrint .= $resactiontmp; } } } - //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
    \n"; + //print "After hook context=".$context." ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
    \n"; unset($actionclassinstance->results); unset($actionclassinstance->resprints); From 0027335e3bd3f8fb3fe07611982be1b7160bdbf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 03:25:07 +0100 Subject: [PATCH 0236/1091] Fix regression --- htdocs/core/lib/pdf.lib.php | 8 ++------ test/phpunit/PdfDocTest.php | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 668ba11b58e..735e6892fcd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1418,10 +1418,6 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description long of product line if (!empty($desc) && ($desc != $label)) { - if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice .= '__N__'; - } - if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); @@ -1547,7 +1543,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Adding the descriptions if they are filled $desccateg = $cate->description; if ($desccateg) { - $libelleproduitservice .= '__N__'.$desccateg; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desccateg); } } } @@ -1572,7 +1568,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } $libelleproduitservice .= '
    '.$period.''; } else { - $libelleproduitservice .= "__N__".$period; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); } //print $libelleproduitservice; } diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index f7181f8a4f9..35350c3bdae 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -160,11 +160,11 @@ class PdfDocTest extends PHPUnit\Framework\TestCase $result=pdf_getlinedesc($localobject, 0, $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, "PINKDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)"); + $this->assertEquals("PINKDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)", $result); $result=doc_getlinedesc($localobject->lines[0], $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, "PINKDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); + $this->assertEquals("PINKDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)", $result); } /** From 8cdc5726a0aae8cf6f9ff232ef385ae6725b533c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 10:26:20 +0100 Subject: [PATCH 0237/1091] Fix column length --- htdocs/core/lib/phpsessionindb.lib.php | 4 ++-- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_session.sql | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 71711eb6ba6..8001b3ece60 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -117,7 +117,7 @@ function dolSessionWrite($sess_id, $val) // No session found, insert a new one $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape(substr($_SERVER['HTTP_USER_AGENT'], 0, 255))."')"; $result = $dbsession->query($insert_query); if (!$result) { @@ -140,7 +140,7 @@ function dolSessionWrite($sess_id, $val) // No session found, insert a new one $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape(substr($_SERVER['HTTP_USER_AGENT'], 0, 255)."')"; var_dump($insert_query); $result = $dbsession->query($insert_query); if (!$result) { diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index f3f92b39dae..5ec019cf253 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -475,3 +475,4 @@ ALTER TABLE llx_propal ADD COLUMN online_sign_name varchar(64); ALTER TABLE llx_entrepot ADD COLUMN warehouse_usage integer DEFAULT 1; +ALTER TABLE llx_session MODIFY COLUMN user_agent VARCHAR(255) NULL; diff --git a/htdocs/install/mysql/tables/llx_session.sql b/htdocs/install/mysql/tables/llx_session.sql index 5be31733c22..c466bda72dd 100644 --- a/htdocs/install/mysql/tables/llx_session.sql +++ b/htdocs/install/mysql/tables/llx_session.sql @@ -24,5 +24,5 @@ create table llx_session last_accessed datetime NOT NULL, fk_user integer NOT NULL, remote_ip varchar(64) NULL, - user_agent varchar(128) NULL + user_agent varchar(255) NULL )ENGINE=innodb; From 0fc9be27bc902312a4dad41bcc217294310190e2 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 10 Dec 2021 11:26:19 +0100 Subject: [PATCH 0238/1091] Fix #19545 : supplier order modification --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 616cda0376f..0ee5a80ce58 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2007,7 +2007,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 1, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= ''; } else { From b609c579b6140d5e97ec67fedbd7c3da5ce814a1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 10 Dec 2021 11:40:25 +0100 Subject: [PATCH 0239/1091] FIX : postgresql compatibility, "" as is not authorized --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 944b5761bf6..16cbf52613f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1836,7 +1836,7 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; From 9fbe0dee9be10e73343843d4bae4ce7c2f6ccd42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 12:36:51 +0100 Subject: [PATCH 0240/1091] Fix trans --- htdocs/core/lib/security.lib.php | 2 ++ htdocs/langs/en_US/errors.lang | 1 + htdocs/main.inc.php | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 80150a5c53e..1b8e91f78e5 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -909,9 +909,11 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { + $langs->loadLangs(array("errors")); if ($user->login) { print $langs->trans("CurrentLogin").': '.$user->login.'
    '; print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users")); + print $langs->trans("ErrorForbidden4"); } else { print $langs->trans("ErrorForbidden3"); } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0c0c3c7699d..cb0d4f1def0 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -111,6 +111,7 @@ ErrorFailedToLoadRSSFile=Fails to get RSS feed. Try to add constant MAIN_SIMPLEX ErrorForbidden=Access denied.
    You try to access to a page, area or feature of a disabled module or without being in an authenticated session or that is not allowed to your user. ErrorForbidden2=Permission for this login can be defined by your Dolibarr administrator from menu %s->%s. ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...). +ErrorForbidden4=Note: clear your browser cookies to destroy existing sessions for this login. ErrorNoImagickReadimage=Class Imagick is not found in this PHP. No preview can be available. Administrators can disable this tab from menu Setup - Display. ErrorRecordAlreadyExists=Record already exists ErrorLabelAlreadyExists=This label already exists diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 05ec2b969b3..3e06d0a2a2d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1166,7 +1166,7 @@ if (!defined('NOLOGIN')) { // Check if user is active if ($user->statut < 1) { // If not active, we refuse the user - $langs->load("other"); + $langs->loadLangs(array("errors", "other")); dol_syslog("Authentication KO as login is disabled", LOG_NOTICE); accessforbidden($langs->trans("ErrorLoginDisabled")); exit; From 4d1e247a5c9f8b0ed328921afaa2c513cffa8f7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 12:51:00 +0100 Subject: [PATCH 0241/1091] Trans --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index a8ec90a47ab..a8942bd337f 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -404,7 +404,7 @@ PMPValueShort=WAP mandatoryperiod=Mandatory periods mandatoryPeriodNeedTobeSet=Note: Period (start and end date) must be defined mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period -mandatoryHelper=Message to the user on the need to enter a start date and an end date on a service when creating / validating an invoice, commercial proposal, sales order.
    This action is not blocking in the process of confirmation +mandatoryHelper=Check this if you want a message to the user when creating / validating an invoice, commercial proposal, sales order without entering a start and end date on lines with this service.
    Note that the message is a warning and not a blocking error. DefaultBOM=Default BOM DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. Rank=Rank From b2611e4cdb087dedc14a5aa231c54986f54fe90f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 13:56:51 +0100 Subject: [PATCH 0242/1091] CSS --- htdocs/comm/action/index.php | 1 + htdocs/core/class/html.form.class.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/multicompany_page.php | 2 +- htdocs/core/search_page.php | 2 +- htdocs/theme/md/style.css.php | 3 +++ 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 5f7349fab3c..8696bbc82d4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -217,6 +217,7 @@ if ($action == 'delete_action') { /* * View */ + $parameters = array( 'socid' => $socid, 'status' => $status, diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 364ca716aeb..705f007a7f1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2080,7 +2080,7 @@ class Form if ($num) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname); + $out = ajax_combobox($htmlname).$out; } } else { dol_print_error($this->db); diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 84be9ff8e0f..e04971ce8c3 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -84,7 +84,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a menu page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 667a2808f58..69e83326707 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -73,11 +73,11 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
    '; // Type - print ''; $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { // We use an option here because it adds bugs when used on agenda page "peruser" and "list" $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } + print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500'); print '
    '; diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php index 5c55efc78db..ad1d8934dbb 100644 --- a/htdocs/core/multicompany_page.php +++ b/htdocs/core/multicompany_page.php @@ -81,7 +81,7 @@ if (GETPOST('acction', 'aZ') == 'switchentity') { $title = $langs->trans("Multicompanies"); // URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 2b82501208a..0341c1116ef 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -58,7 +58,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Search"); // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a search page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f9750df7fb6..f8abcceb51c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1058,6 +1058,9 @@ body[class*="colorblind-"] .text-success{ font-size: 1.5em; vertical-align: text-bottom; } +.fawidth30 { + width: 20px; +} .floatnone { float: none !important; } From 611bae4c3a2faf41a03fc3ebb474104a6926fe94 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Fri, 10 Dec 2021 14:20:04 +0100 Subject: [PATCH 0243/1091] FIX - unasigned variable $action given to hook printOriginObjectSubLine --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2471d122af..03a9d518021 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4855,7 +4855,7 @@ abstract class CommonObject */ public function printOriginLinesList($restrictlist = '', $selectedLines = array()) { - global $langs, $hookmanager, $conf, $form; + global $langs, $hookmanager, $conf, $form, $action; print '
    '.$langs->trans('Ref').'
    '; - if (count($object->linesmvt) > 0) { + print '
    '; + print '
    '; + $total_debit = 0; $total_credit = 0; @@ -670,8 +671,14 @@ if ($action == 'create') { print ''; print ''; } else { - $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; + $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); + print ''; print ''; print ''; - print ''; } print "\n"; @@ -733,12 +748,16 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; + print ''; print ''; } - print '
    '.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''; + if ($resultfetch > 0) { + $accountingaccount->getNomUrl(0, 1, 1, '', 0); + } else { + print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + } + print ''.length_accounta($line->subledger_account); if ($line->subledger_label) { print ' - '.$line->subledger_label.''; @@ -681,11 +688,15 @@ if ($action == 'create') { print ''.price($line->debit).''.price($line->credit).''; + print ''; if (empty($line->date_export) && empty($line->date_validation)) { print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; print img_edit('', 0, 'class="marginrightonly"'); print '  '; + } else { + print ''; + print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); + print '  '; } if (empty($line->date_validation)) { @@ -696,9 +707,13 @@ if ($action == 'create') { print ''; print img_delete(); + print ''; + } else { + print ''; + print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); + print ''; } - print ''; print '
    '; + print ''; + print '
    '; } + print '
    '; + print ''; + if ($mode == '_tmp' && $action == '') { print '
    '; print '
    '; @@ -753,8 +772,9 @@ if ($action == 'create') { print "
    "; } - print ''; } + + print ''; } } else { print load_fiche_titre($langs->trans("NoRecords")); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 01487ba3e83..8781bc13f86 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -387,7 +387,8 @@ SaleExport=Export sale SaleEEC=Sale in EEC SaleEECWithVAT=Sale in EEC with a VAT not null, so we suppose this is NOT an intracommunautary sale and the suggested account is the standard product account. SaleEECWithoutVATNumber=Sale in EEC with no VAT but the VAT ID of thirdparty is not defined. We fallback on the product account for standard sales. You can fix the VAT ID of thirdparty or the product account if needed. - +ForbiddenTransactionAlreadyExported=Forbidden: The transaction has been validated and/or exported. +ForbiddenTransactionAlreadyValidated=Forbidden: The transaction has been validated. ## Dictionary Range=Range of accounting account Calculated=Calculated diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d8bd4673d5c..da23e60498c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -884,6 +884,10 @@ body[class*="colorblind-"] .text-success{ .editfieldlang:hover { color: var(--colortexttitle) !important; } +a.editfielda.nohover *:hover:before { + color: #ccc !important; +} + .fawidth30 { width: 20px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6805f2c620e..8873149a9be 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1050,6 +1050,9 @@ body[class*="colorblind-"] .text-success{ .editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { color: var(--colortexttitle) !important; } +a.editfielda.nohover *:hover:before { + color: #ccc !important; +} .size15x { font-size: 1.5em !important; } .fa-toggle-on, .fa-toggle-off, .size2x { font-size: 2em; } From 6d94c6150b4d481cfd80c6aa24e6eb160c3c1b79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 17:56:28 +0100 Subject: [PATCH 0272/1091] FIX sign of unit price into the supplier credit note --- htdocs/fourn/class/fournisseur.facture.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d966a94769d..6dd88d68374 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2147,10 +2147,12 @@ class FactureFournisseur extends CommonInvoice $line->context = $this->context; $line->description = $desc; - $line->subprice = $pu_ht; - $line->pu_ht = $pu_ht; - $line->pu_ttc = $pu_ttc; - $line->qty = $qty; + + $line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $line->pu_ht = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $line->pu_ttc = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ttc) : $pu_ttc); // For credit note, unit price always negative, always positive otherwise + $line->remise_percent = $remise_percent; $line->ref_supplier = $ref_supplier; @@ -2163,11 +2165,13 @@ class FactureFournisseur extends CommonInvoice $line->localtax2_tx = $txlocaltax2; $line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; + $line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); $line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); $line->total_localtax1 = $total_localtax1; $line->total_localtax2 = $total_localtax2; $line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); + $line->fk_product = $idproduct; $line->product_type = $product_type; $line->info_bits = $info_bits; From d0bc32047d974b0410bc39d76b3d1496a2357312 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 18:11:17 +0100 Subject: [PATCH 0273/1091] FIX Create and clone negative social contribution --- htdocs/compta/sociales/class/chargesociales.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index c18d83ec52c..431f0bcba72 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -198,7 +198,7 @@ class ChargeSociales extends CommonObject $newamount = price2num($this->amount, 'MT'); // Validation of parameters - if (!($newamount > 0) || empty($this->date_ech) || empty($this->periode)) { + if ($newamount == 0 || empty($this->date_ech) || empty($this->periode)) { return false; } From 582caf0e7a72c01d0da9df764aaa5ad466e22a15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 19:04:25 +0100 Subject: [PATCH 0274/1091] FIX message for automatic binding not clear of what was done or not --- htdocs/accountancy/customer/index.php | 8 ++++++-- htdocs/accountancy/expensereport/index.php | 4 +++- htdocs/accountancy/supplier/index.php | 6 +++++- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/fr_FR/accountancy.lang | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2b7e624676f..e2ed822e35a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -93,7 +93,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { */ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { - // Clean database + // Clean database by removing binding done on non existing or no more existing accounts $db->begin(); $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; @@ -119,6 +119,8 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind @@ -277,6 +279,8 @@ if ($action == 'validatehistory') { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; + } else { + $nbbinddone++; } } @@ -288,7 +292,7 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 61b942e99bd..0987afb0c6a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -131,8 +131,10 @@ if ($action == 'validatehistory') { $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { + $nbbinddone = $db->affected_rows($resql1); + $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 406701d2500..1a0c8909829 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -117,6 +117,8 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind @@ -273,6 +275,8 @@ if ($action == 'validatehistory') { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; + } else { + $nbbinddone++; } } @@ -284,7 +288,7 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8781bc13f86..b9f84588079 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible ValidateHistory=Bind Automatically -AutomaticBindingDone=Automatic binding done +AutomaticBindingDone=Automatic bindings done (%s) ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 5ac5b2b5d10..675e9ac338e 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Valider les mouvements DescValidateMovements=Toute modification ou suppression d'écriture, de lettrage et de suppression sera interdite. Toutes les entrées pour un exercice doivent être validées, sinon la fermeture ne sera pas possible ValidateHistory=Lier automatiquement -AutomaticBindingDone=Liaison automatique faite +AutomaticBindingDone=Liaisons automatiques faites (%s) ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas détruire de compte comptable car il est utilisé MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s| Crédit = %s From cf05f38e5417f4cd7989db995a329229901c647e Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Mon, 13 Dec 2021 19:56:06 +0100 Subject: [PATCH 0275/1091] Update functions.lib.php Change exists to isset in price2num --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 01e8acf4896..0084a4a33c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4784,7 +4784,7 @@ function price2num($amount, $rounding = '', $option = 0) $nbofdectoround = ''; if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; + elseif ($rounding == 'MS') $nbofdectoround = !isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; elseif ($rounding == 'CR') $nbofdectoround = 8; elseif (is_numeric($rounding)) $nbofdectoround = $rounding; //print "RR".$amount.' - '.$nbofdectoround.'
    '; From 8c844c96dfd4b21ec3b4c3e14c7efb4db16fc94f Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Mon, 13 Dec 2021 20:33:42 +0100 Subject: [PATCH 0276/1091] Update card_presend.tpl.php Add hidden feature ORDER_SUPPLIER_EMAIL_SENDER as sender address for purchase order emails --- htdocs/core/tpl/card_presend.tpl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index aaaa043e39b..27a4172c27e 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -147,6 +147,11 @@ if ($action == 'presend') $formmail->fromname = ''; $formmail->fromtype = 'special'; } + if ($object->element === 'order_supplier' && !empty($conf->global->ORDER_SUPPLIER_EMAIL_SENDER)) { + $formmail->frommail = $conf->global->ORDER_SUPPLIER_EMAIL_SENDER; + $formmail->fromname = ''; + $formmail->fromtype = 'special'; + } $formmail->trackid=$trackid; if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set From 9bc2a561bcf79ba2e247206f5c6411a403742d12 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 14 Dec 2021 10:52:16 +0100 Subject: [PATCH 0277/1091] ok --- htdocs/admin/ihm.php | 8 ++++ htdocs/core/lib/usergroups.lib.php | 65 ++++++++++++++++++++++++---- htdocs/langs/en_US/admin.lang | 1 + htdocs/theme/eldy/btn.inc.php | 7 --- htdocs/theme/eldy/global.inc.php | 4 +- htdocs/theme/eldy/style.css.php | 6 ++- htdocs/theme/eldy/theme_vars.inc.php | 2 + htdocs/theme/md/btn.inc.php | 5 --- htdocs/theme/md/style.css.php | 9 +++- htdocs/theme/md/theme_vars.inc.php | 2 + 10 files changed, 83 insertions(+), 26 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 697f8fa2130..ea675ed9001 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -5,6 +5,7 @@ * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Alexandre Spangaro + * Copyright (C) 2021 Anthony Berton * * 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 @@ -199,6 +200,13 @@ if ($action == 'update') { } else { dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); } + + $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BTNACTION'), array())))); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_BTNACTION', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_BTNACTION', $val, 'chaine', 0, '', $conf->entity); + } } if ($mode == 'dashboard') { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index accbd84ba8c..9ee6afa182e 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2017 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2021 Anthony Berton * * 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 @@ -859,15 +860,15 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) // Use Checked if ($foruserprofile) { /* Must first change option to choose color of highlight instead of yes or no. - print '
    '.$langs->trans("HighlightLinesOnMouseHover").'global->THEME_ELDY_USE_HOVER?" checked":"").'> '.$langs->trans("UsePersonalValue").''; - print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; - print '
    '.$langs->trans("HighlightLinesOnMouseHover").'global->THEME_ELDY_USE_HOVER?" checked":"").'> '.$langs->trans("UsePersonalValue").''; + print '   ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; + print '
    '.$langs->trans("TopMenuBackgroundColor").''.($conf->global->THEME_ELDY_TOPMENU_BACK1?$conf->global->THEME_ELDY_BTNACTION:$langs->trans("Default")).'conf->THEME_ELDY_BTNACTION)?" checked":""); + print (empty($dolibarr_main_demo) && $edit)?'':' disabled="disabled"'; // Disabled for demo + print '> '.$langs->trans("UsePersonalValue").''; + if ($edit) + { + print $formother->selectColor(colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BTNACTION,array()),''),'THEME_ELDY_BTNACTION','',1).' '; + } + else + { + $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BTNACTION,array()),''); + if ($color) print ''; + else print ''; + } + if ($edit) print '
    ('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; + print '
    '.$langs->trans("BtnActionColor").''; + if ($edit) { + print $formother->selectColor(colorArrayToHex(colorStringToArray((!empty($conf->global->THEME_ELDY_BTNACTION) ? $conf->global->THEME_ELDY_BTNACTION : ''), array()), ''), 'THEME_ELDY_BTNACTION', '', 1, '', '', 'colorbtnaction').' '; + } else { + $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_BTNACTION, array()), ''); + if ($color) { + print ''; + } else { + //print ''; + //print ''.$langs->trans("Default").''; + print $langs->trans("Default"); + } + } + print '   '.$langs->trans("Default").': '.$default.' '; + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); + print '
    '; print ''; + //print $langs->trans("StockMovement"); + print '
    '; + $valuetoshow = $obj->qty_stock; + // For inventory not yet close, we overwrite with the real value in stock now if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { if ($conf->productbatch->enabled && $product_static->hasbatch()) { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty; } else { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real; } - } else { - $valuetoshow = $obj->qty_stock; } print price2num($valuetoshow, 'MS'); print ''; @@ -891,9 +938,16 @@ if ($object->id > 0) { print ''; print ''; + print ''; print $obj->qty_view; // qty found print ''; + if ($obj->fk_movement > 0) { + $stockmovment = new MouvementStock($db); + $stockmovment->fetch($obj->fk_movement); + print $stockmovment->getNomUrl(1, 'movements'); + } + print '
    '; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print '
    '; print '
    '.($object->remise_percent ? ''.$object->remise_percent.'%' : '').''; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print '
    '; print ''; @@ -488,7 +488,7 @@ if ($object->id > 0) { dol_print_error($db, $object->error); } if ($amount_discount > 0) { - print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; } //else print $langs->trans("DiscountNone"); print ''; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index b2900e65575..cdd8fefc4b0 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2021 Laurent Destailleur * * 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 @@ -38,18 +38,30 @@ if ($user->socid > 0) { } $backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'aplha'); +$action = GETPOST('action', 'aZ09'); + +// Security check +if ($user->socid > 0) { + $id = $user->socid; +} +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); /* * Actions */ -if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; +if ($cancel) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } else { + $action = ''; + } } -if (GETPOST('action', 'aZ09') == 'setremise') { +if ($action == 'setremise') { $object = new Societe($db); $object->fetch($id); @@ -74,11 +86,6 @@ if (GETPOST('action', 'aZ09') == 'setremise') { } } -// Security check -if ($user->socid > 0) { - $id = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); /* diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 38e1967c11b..4373f09fdb7 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -40,8 +40,8 @@ if (!isset($absolute_creditnote)) { } // Relative and absolute discounts -$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; -$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; +$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; +$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; $viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; $fixedDiscount = $thirdparty->remise_percent; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 16e89850ae4..fd3ec1fa34f 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -297,7 +297,7 @@ if ($object->id > 0) { print $langs->trans("CustomerRelativeDiscountShort"); print ''; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''.($object->remise_supplier_percent ? ''.$object->remise_supplier_percent.'%' : '').''; @@ -310,7 +310,7 @@ if ($object->id > 0) { print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; @@ -320,7 +320,7 @@ if ($object->id > 0) { dol_print_error($db, $object->error); } if ($amount_discount > 0) { - print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; } //else print $langs->trans("DiscountNone"); print ''; From 9465edd8ec34aed0199986b64256ce40151a033f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 14:09:56 +0100 Subject: [PATCH 0302/1091] Add warning making payment if pending direct debit or credit trans --- htdocs/compta/paiement.php | 26 ++++++++++++++++++++++++- htdocs/fourn/facture/paiement.php | 30 +++++++++++++++++++++++++++-- htdocs/langs/en_US/withdrawals.lang | 2 ++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index b68374b84b9..cf0fb079fcb 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -726,7 +726,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; // Remain to take or to pay back - print ''.price($sign * $remaintopay).''; + print ''; + print price($sign * $remaintopay); + if (!empty($conf->prelevement->enabled)) { + $numdirectdebitopen = 0; + $totaldirectdebit = 0; + $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE fk_facture = ".((int) $objp->facid); + $sql .= " AND pfd.traite = 0"; + $sql .= " AND pfd.ext_payment_id IS NULL"; + + $result_sql = $db->query($sql); + if ($result_sql) { + $obj = $db->fetch_object($result_sql); + $numdirectdebitopen = $obj->nb; + $totaldirectdebit = $obj->amount; + } else { + dol_print_error($db); + } + if ($numdirectdebitopen) { + $langs->load("withdrawals"); + print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip'); + } + } + print ''; //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); // Amount diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index ba7027b28ee..08a5d2f3c44 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -519,7 +519,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes } // Group by because we have a total - $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef, f.date_lim_reglement'; + $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,'; + $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,'; + $sql .= ' f.datef, f.date_lim_reglement'; // Sort invoices by date and serial number: the older one comes first $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; @@ -685,7 +687,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''; - print ''.price($sign * $remaintopay).''; + print ''; + print price($sign * $remaintopay); + if (!empty($conf->paymentbybanktransfer->enabled)) { + $numdirectdebitopen = 0; + $totaldirectdebit = 0; + $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid); + $sql .= " AND pfd.traite = 0"; + $sql .= " AND pfd.ext_payment_id IS NULL"; + + $result_sql = $db->query($sql); + if ($result_sql) { + $obj = $db->fetch_object($result_sql); + $numdirectdebitopen = $obj->nb; + $totaldirectdebit = $obj->amount; + } else { + dol_print_error($db); + } + if ($numdirectdebitopen) { + $langs->load("withdrawals"); + print img_warning($langs->trans("WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip'); + } + } + print ''; // Amount print ''; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7b18c1a0d70..68ac879c510 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -150,3 +150,5 @@ ModeWarning=Option for real mode was not set, we stop after this simulation ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use. ErrorICSmissing=Missing ICS in Bank account %s TotalAmountOfdirectDebitOrderDiffersFromSumOfLines=Total amount of direct debit order differs from sum of lines +WarningSomeDirectDebitOrdersAlreadyExists=Warning: There is already some pending Direct Debit orders (%s) requested for an amount of %s +WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s \ No newline at end of file From a5b8d0cd4bab0e7f299ca5d9d42214410bf7505a Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 16 Dec 2021 15:41:13 +0100 Subject: [PATCH 0303/1091] FIX Take into consideration work leave over serveral months --- htdocs/holiday/month_report.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 0444157704b..b71bea7bd34 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -84,7 +84,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; $sql .= " WHERE cp.rowid > 0"; $sql .= " AND cp.statut = 3"; // Approved -$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " AND ("; +$sql .= " (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " OR"; +// For work leave over several months +$sql .= " (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month)."' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month)."') "; +$sql .= " )"; $sql .= " ORDER BY u.lastname, cp.date_debut"; $resql = $db->query($sql); From d92535ec5982f88f1c502ea10b5b51899a278556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 15:41:23 +0100 Subject: [PATCH 0304/1091] FIX Debug transfert in accountancy for expense report --- .../class/accountingaccount.class.php | 2 +- htdocs/accountancy/customer/index.php | 16 ++-- htdocs/accountancy/expensereport/index.php | 77 +++++++++++++------ htdocs/accountancy/expensereport/lines.php | 3 +- htdocs/accountancy/supplier/index.php | 12 ++- htdocs/expensereport/card.php | 18 ++++- .../class/expensereport.class.php | 4 +- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/fr_FR/accountancy.lang | 2 +- 9 files changed, 95 insertions(+), 41 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 730e52c805a..cdfa3602e73 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -166,7 +166,7 @@ class AccountingAccount extends CommonObject * * @param int $rowid Id * @param string $account_number Account number - * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account + * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active chart of account * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index e2ed822e35a..62f613a940b 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -120,6 +120,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $notpossible = 0; $db->begin(); @@ -156,14 +157,13 @@ if ($action == 'validatehistory') { } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; // the main table $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); @@ -174,8 +174,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql .= " AND l.product_type <= 2"; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } @@ -256,7 +255,7 @@ if ($action == 'validatehistory') { $suggestedid = 0; $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accountingAccountArray, 'customer'); - if (!is_array($return) && $return<0) { + if (!is_array($return) && $return < 0) { setEventMessage($accountingAccount->error, 'errors'); } else { $suggestedid = $return['suggestedid']; @@ -282,17 +281,22 @@ if ($action == 'validatehistory') { } else { $nbbinddone++; } + } else { + $notpossible++; } $i++; } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } } if ($error) { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 0987afb0c6a..37abd56a21d 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -99,42 +99,69 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $notpossible = 0; + $db->begin(); // Now make the binding - if ($db->type == 'pgsql') { - $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; - $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; - $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; - if ($validatemonth && $validateyear) { - $sql1 .= dolSqlDateFilter('date', 0, $validatemonth, $validateyear); - } - } else { - $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; - $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; - $sql1 .= " AND erd.fk_code_ventilation = 0"; - if ($validatemonth && $validateyear) { - $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); - } + $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id"; + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.entity =".((int) $conf->entity); + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as syst ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND syst.active = 1,'; + $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er"; + $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity); + $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; + if ($validatemonth && $validateyear) { + $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); } dol_syslog('htdocs/accountancy/expensereport/index.php'); - $resql1 = $db->query($sql1); - if (!$resql1) { + $result = $db->query($sql1); + if (!$result) { $error++; - $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { - $nbbinddone = $db->affected_rows($resql1); + $num_lines = $db->num_rows($result); + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + $lineid = $objp->rowid; + $suggestedid = $objp->suggestedid; + + if ($suggestedid > 0) { + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND rowid = ".((int) $lineid); + + $resqlupdate = $db->query($sqlupdate); + if (!$resqlupdate) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } else { + $nbbinddone++; + } + } else { + $notpossible++; + } + + $i++; + } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } + } + + if ($error) { + $db->rollback(); + } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } @@ -157,7 +184,7 @@ print '
    '; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index b262f85367a..fb3bf1a6e04 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -394,11 +394,12 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Accounting account affected - print ''; + print ''; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; + print ''; print ""; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1a0c8909829..51c9e66cebe 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -118,6 +118,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $notpossible = 0; $db->begin(); @@ -154,7 +155,6 @@ if ($action == 'validatehistory') { } else { $sql .= " s.accountancy_code_buy as company_code_buy"; } - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -172,8 +172,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql .= " AND l.product_type <= 2"; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } @@ -278,17 +277,22 @@ if ($action == 'validatehistory') { } else { $nbbinddone++; } + } else { + $notpossible++; } $i++; } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } } if ($error) { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 38f7703f744..db358964f16 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2094,8 +2094,22 @@ if ($action == 'create') { print ''; } + $titlealt = ''; + if (!empty($conf->accounting->enabled)) { + $accountingaccount = new AccountingAccount($db); + $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1); + //$titlealt .= ''; + $titlealt .= $langs->trans("AccountancyCode").': '; + if ($resaccountingaccount > 0) { + $titlealt .= $accountingaccount->account_number; + } else { + $titlealt .= $langs->trans("NotFound"); + } + //$titlealt .= ''; + } + // Type of fee - print ''; + print ''; $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); print $labeltype; print ''; @@ -2109,8 +2123,10 @@ if ($action == 'create') { // Comment print ''.dol_nl2br($line->comments).''; + // VAT rate print ''.vatrate($line->vatrate.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true).''; + // Unit price HT print ''; if (!empty($line->value_unit_ht)) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 877a7c79ade..d5695c7e49a 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -999,7 +999,7 @@ class ExpenseReport extends CommonObject $sql .= ' de.fk_ecm_files,'; $sql .= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql .= ' de.total_localtax1, de.total_localtax2, de.rule_warning_message,'; - $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; + $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees, ctf.accountancy_code as accountancy_code_type_fees,'; $sql .= ' p.ref as ref_projet, p.title as title_projet'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; @@ -1043,6 +1043,7 @@ class ExpenseReport extends CommonObject $deplig->type_fees_code = empty($objp->code_type_fees) ? 'TF_OTHER' : $objp->code_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees; + $deplig->type_fees_accountancy_code = $objp->accountancy_code_type_fees; $deplig->tva_tx = $objp->tva_tx; $deplig->vatrate = $objp->tva_tx; @@ -2579,6 +2580,7 @@ class ExpenseReportLine public $type_fees_code; public $type_fees_libelle; + public $type_fees_accountancy_code; public $projet_ref; public $projet_title; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index b9f84588079..7999d46363e 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible ValidateHistory=Bind Automatically -AutomaticBindingDone=Automatic bindings done (%s) +AutomaticBindingDone=Automatic bindings done (%s) - Automatic binding not possible for some record (%s) ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 675e9ac338e..f5b9b5dcf3e 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Valider les mouvements DescValidateMovements=Toute modification ou suppression d'écriture, de lettrage et de suppression sera interdite. Toutes les entrées pour un exercice doivent être validées, sinon la fermeture ne sera pas possible ValidateHistory=Lier automatiquement -AutomaticBindingDone=Liaisons automatiques faites (%s) +AutomaticBindingDone=Liaisons automatiques faites (%s) - Liaison automatique non possible pour certains cas (%s) ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas détruire de compte comptable car il est utilisé MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s| Crédit = %s From 8c73ef4bbf52bd39d176fed9851f341d53cefb79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 16:30:42 +0100 Subject: [PATCH 0305/1091] Fix menu perm --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8f73eb5a88c..ebeb4ab40f7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1618,7 +1618,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire); if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_oder->enabled) || !empty($conf->supplier_invoice->enabled)) { - $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); + $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire || $user->rights->product->lire); } // Categories if (!empty($conf->categorie->enabled)) { From f8e6befe35771ceeec75e091c5b5e274029b29e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 16:47:11 +0100 Subject: [PATCH 0306/1091] Fix link on user --- htdocs/supplier_proposal/list.php | 14 +++++++++++--- htdocs/user/class/user.class.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a64ac94b169..4c92387a613 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -302,7 +302,7 @@ $sql .= " p.rowid as project_id, p.ref as project_ref,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; } -$sql .= " u.firstname, u.lastname, u.photo, u.login"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as status, u.admin, u.employee, u.email as uemail"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -1092,12 +1092,20 @@ if ($resql) { $userstatic->id = $obj->fk_user_author; $userstatic->login = $obj->login; + $userstatic->status = $obj->status; + $userstatic->lastname = $obj->name; + $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->admin = $obj->admin; + $userstatic->ref = $obj->fk_user_author; + $userstatic->employee = $obj->employee; + $userstatic->email = $obj->uemail; // Author if (!empty($arrayfields['u.login']['checked'])) { print ''; - if ($userstatic->id) { - print $userstatic->getLoginUrl(1); + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); } else { print ' '; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 467a572193e..d5fc9c8ece2 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2797,7 +2797,7 @@ class User extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut(isset($this->statut) ? $this->statut : $this->status, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From bef1afc7b89842cb7f4d6ce2fffa7e778ef73e0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:01:15 +0100 Subject: [PATCH 0307/1091] Clean code --- htdocs/admin/fckeditor.php | 3 ++- htdocs/core/modules/modFckeditor.class.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 19367c8b50d..51247ac0b35 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -159,11 +159,12 @@ if (empty($conf->use_javascript_ajax)) { continue; } + $constante = 'FCKEDITOR_ENABLE_'.$const; + print ''."\n"; print ''; print ''.img_object("", $picto[$const]).''; print ''.$langs->trans($desc).''; print ''; - $constante = 'FCKEDITOR_ENABLE_'.$const; $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 3dfd0f233e5..8c30d8a0a51 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -69,8 +69,8 @@ class modFckeditor extends DolibarrModules // Constants $this->const = array(); - $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)"); - $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note"); + $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for the fields descriptions of elements (except products/services)"); + $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for the fields description of products/services"); $this->const[2] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings"); $this->const[3] = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities"); $this->const[4] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature"); From dc1118a3dfaebac1f5a217357b1032c08625550c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:04:25 +0100 Subject: [PATCH 0308/1091] Update info.php --- htdocs/compta/facture/info.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 340dfda2957..e08b237d5ea 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -38,31 +38,30 @@ $langs->loadLangs(array('companies', 'bills')); $id = GETPOST("facid", "int"); $ref = GETPOST("ref", 'alpha'); +$object = new Facture($db); +$object->fetch($id, $ref); + /* * View */ -$object = new Facture($db); -$object->fetch($id, $ref); -$object->fetch_thirdparty(); - -$object->info($object->id); - -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; - llxFooter(); - exit; -} - $form = new Form($db); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); +if (empty($object->id)) { + $langs->load('errors'); + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; + llxFooter(); + exit; +} + +$object->fetch_thirdparty(); +$object->info($object->id); + $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); From e9b7fd0ef875943e09a5d1b9932dd1d3a1c79b16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:05:12 +0100 Subject: [PATCH 0309/1091] Update info.php --- htdocs/compta/facture/info.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index e08b237d5ea..abfbfabea21 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -39,7 +39,9 @@ $id = GETPOST("facid", "int"); $ref = GETPOST("ref", 'alpha'); $object = new Facture($db); -$object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} /* From c5bdb7b4d8c685d1e2bd3c88b62cb86ce71c72bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:29:04 +0100 Subject: [PATCH 0310/1091] Revert "Update card_presend.tpl.php" --- htdocs/core/tpl/card_presend.tpl.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 93b17b6dc86..7cc95c81fe0 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -143,13 +143,6 @@ if ($action == 'presend') { $formmail->fromtype = 'special'; } - $formmail->trackid=$trackid; - if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid); - } - $formmail->trackid = $trackid; From cf01018a90b6dc3b37631fd174951bf4a1003246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:42:09 +0100 Subject: [PATCH 0311/1091] Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 527d6acd9e6..283b8fc5146 100644 --- a/ChangeLog +++ b/ChangeLog @@ -147,7 +147,7 @@ Following changes may create regressions for some external modules, but were nec * Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed * ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required -* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' iso 'myobject', +* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' instead of 'myobject', you can use hook 'setLinkedObjectSourceTargetType' to set your usual targettype From 6c053abfd991f9b092c1d44dfe15db7115d25926 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:58:08 +0100 Subject: [PATCH 0312/1091] Standardize code --- htdocs/mrp/class/mo.class.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cdad4e71968..2e7b4186a87 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1319,19 +1319,15 @@ class Mo extends CommonObject if (!empty($this->lines)) { foreach ($this->lines as $line) { - /*if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) - { - if (empty($line->fk_parent_line)) - { - $parameters = array('line'=>$line, 'i'=>$i); - $action = ''; - $result = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $reshook = 0; + if (is_object($hookmanager)) { + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); + if (!empty($line->fk_parent_line)) { $parameters['fk_parent_line'] = $line->fk_parent_line; } + $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } - else - {*/ + if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); - //} + } $i++; } From 517355972aa052d0633338862925eb94a0bf618a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 19:01:11 +0100 Subject: [PATCH 0313/1091] Fix duplicate table for online signature --- htdocs/core/class/commonobject.class.php | 2 +- .../mysql/tables/llx_online_signatures.sql | 29 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_online_signatures.sql diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a83cfae3000..94bea1e56b4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5308,7 +5308,7 @@ abstract class CommonObject // Set the public "share" key $setsharekey = false; if ($this->element == 'propal') { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + $useonlinesignature = 1; // Replace this with 1 when feature to make online signature is ok if ($useonlinesignature) { $setsharekey = true; } diff --git a/htdocs/install/mysql/tables/llx_online_signatures.sql b/htdocs/install/mysql/tables/llx_online_signatures.sql deleted file mode 100644 index fbba814dd4d..00000000000 --- a/htdocs/install/mysql/tables/llx_online_signatures.sql +++ /dev/null @@ -1,29 +0,0 @@ --- ============================================================================ --- Copyright (C) 2017 Laurent Destailleur --- --- 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 --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- ============================================================================ - -create table llx_onlinesignature -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - object_type varchar(32) NOT NULL, - object_id integer NOT NULL, - datec datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - name varchar(255) NOT NULL, - ip varchar(128), - pathoffile varchar(255) -)ENGINE=innodb; From 6024e779766a71665149b6e179833047ca724d95 Mon Sep 17 00:00:00 2001 From: Anthony Berton Date: Thu, 16 Dec 2021 19:43:42 +0100 Subject: [PATCH 0314/1091] --butactionbg --- htdocs/theme/eldy/global.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ec40936601a..da23e60498c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -211,7 +211,7 @@ input, select { margin-top: 1px; } #mainbody input.button:not(.buttongen):not(.bordertransp), #mainbody a.button:not(.buttongen):not(.bordertransp) { - background: rgb(); + background: var(--butactionbg); color: #FFF !important; border-radius: 3px; border-collapse: collapse; @@ -358,7 +358,7 @@ a.butStatus { padding-right: 5px; background-color: transparent; color: var(--colortext) !important; - border: 2px solid rgb() !important; + border: 2px solid var( --butactionbg) !important; margin: 0 0.45em !important; } From 3895438b85f8dd552e293ecc4e7b02dd31bfe7b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 23:53:05 +0100 Subject: [PATCH 0315/1091] Fix responsive --- htdocs/core/class/html.form.class.php | 2 +- htdocs/product/stats/card.php | 9 ++++++--- htdocs/theme/eldy/global.inc.php | 4 ++++ htdocs/theme/md/style.css.php | 27 +++++++++++++++++++-------- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1d63bbaf332..0525ad6f3c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2347,7 +2347,7 @@ class Form $out .= img_picto($langs->trans("Search"), 'search'); } } - $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); } diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 463297f043a..f45a851ecad 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -192,20 +192,20 @@ if ($result || !($id > 0)) { // Type print ''.$langs->trans("Type").''; $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('type', $array, $type); + print $form->selectarray('type', $array, $type, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print ''; // Product print ''.$langs->trans("ProductOrService").''; print img_picto('', 'product', 'class="pictofixedwidth"'); - print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500'); + print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', ($conf->dol_optimize_smallscreen ? 1 : 0), array(), 0, '1', 0, 'widthcentpercentminusx maxwidth400'); print ''; // Tag if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; $moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth300'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth400'); print $moreforfilter; print ''; } @@ -465,7 +465,9 @@ if ($result || !($id > 0)) { $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh'); $linktoregenerate .= ''; + // Show graph + print '
    '; print ''; // Label print ''; print '
    '; @@ -478,6 +480,7 @@ if ($result || !($id > 0)) { print $graphfiles[$key]['output']; print '
    '; + print '
    '; if ($i % 2 == 0) { print "\n".'
    '."\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e413623fb0c..11cf7f8e867 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -7249,6 +7249,10 @@ div.clipboardCPValue.hidewithsize { padding-left: 12px; padding-right: 12px; } + + .a-mesure, .a-mesure-disabled { + text-align: center; + } } @media only screen and (max-width: 320px) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a2a68168e8e..570a4eaa6b3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -688,8 +688,8 @@ input[type=checkbox], input[type=radio] { input:-moz-placeholder { color:#ccc; } input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } -fieldset { - border: 1px solid #AAAAAA !important; +fieldset { + border: 1px solid #AAAAAA !important; padding-inline-start: 2em; padding-inline-end: 2em; } @@ -2959,8 +2959,8 @@ div.vmenu, td.vmenu { .searchform { padding-top: 10px; } .searchform .bordertransp { border: 0; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { - white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; } span.vmenudisabled, font.vmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } a.vmenu:link, a.vmenu:visited { @@ -2968,8 +2968,8 @@ a.vmenu:link, a.vmenu:visited { } a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #202020; margin: 1px 1px 1px 8px; } -span.vsmenudisabled, font.vsmenudisabled { - font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; +span.vsmenudisabled, font.vsmenudisabled { + font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; } a.vsmenu:link, a.vsmenu:visited { color: var(--colortextbackvmenu); @@ -2978,7 +2978,7 @@ a.vsmenu:link, a.vsmenu:visited { span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { - text-align: ; font-weight: normal; color: #999; text-decoration: none; + text-align: ; font-weight: normal; color: #999; text-decoration: none; } .helppresentcircle { @@ -6997,7 +6997,7 @@ div.clipboardCPValue.hidewithsize { border-right: 1px solid rgba(0,0,0,0.3); top: auto; } - + div#tmenu_tooltip { display:none; @@ -7070,6 +7070,17 @@ div.clipboardCPValue.hidewithsize { boerder-right: unset; padding-left: 5px; } + + .a-mesure, .a-mesure-disabled { + display: block; + margin-bottom: 6px; + padding-left: 12px; + padding-right: 12px; + } + + .a-mesure, .a-mesure-disabled { + text-align: center; + } } From f3430d94d5fe6736d28a5c75144a10dad06652d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 00:48:13 +0100 Subject: [PATCH 0316/1091] css --- htdocs/admin/dav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 9edc123a784..e12848e3de1 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -123,12 +123,12 @@ if ($action == 'edit') { print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; foreach ($arrayofparameters as $key => $val) { - print ''; + print ''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $label = $langs->trans($key); if ($key == 'DAV_RESTICT_ON_IP') { $label = $langs->trans("RESTRICT_ON_IP"); - $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); + $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample").''; } print $form->textwithpicto($label, $tooltiphelp); print ''; From 90f25ab21ac0759c4119386f654d87f5979b6ea8 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Fri, 17 Dec 2021 12:09:14 +0700 Subject: [PATCH 0317/1091] FIX supplier_proposal when line update price U.P change 0 modify --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index ea10b4d7137..b239b6cc3da 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -725,6 +725,7 @@ class SupplierProposal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + $pu = $pu_ht = $tabprice[3]; // MultiCurrency $multicurrency_total_ht = $tabprice[16]; From fcb10df5704cec71b64f857a26593b0a1e2199d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 09:54:03 +0100 Subject: [PATCH 0318/1091] Fix size of origintype --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_stock_mouvement.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 263e94e4575..cd24a252a04 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -479,3 +479,4 @@ ALTER TABLE llx_session MODIFY COLUMN user_agent VARCHAR(255) NULL; ALTER TABLE llx_inventorydet ADD COLUMN fk_movement integer NULL; +ALTER TABLE llx_stock_mouvement MODIFY COLUMN origintype varchar(64); diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement.sql b/htdocs/install/mysql/tables/llx_stock_mouvement.sql index 2cd094c1b05..ec3465a6c2d 100644 --- a/htdocs/install/mysql/tables/llx_stock_mouvement.sql +++ b/htdocs/install/mysql/tables/llx_stock_mouvement.sql @@ -35,7 +35,7 @@ create table llx_stock_mouvement inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking) fk_project integer, fk_origin integer, - origintype varchar(32), + origintype varchar(64), model_pdf varchar(255), fk_projet integer NOT NULL DEFAULT 0 )ENGINE=innodb; From e60f65db7d417ae8a96fffb50ff2e06c003d6fda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 10:00:10 +0100 Subject: [PATCH 0319/1091] Trans --- htdocs/product/popuprop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 32a2cd08cc9..dbffe79d0c0 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -30,7 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array('commande', 'propal', 'bills', 'other')); +$langs->loadLangs(array('commande', 'propal', 'bills', 'other', 'products')); $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); From dfbd03140cfba9e3235a90d0ca0a058b6af7c2a8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 17 Dec 2021 11:10:08 +0100 Subject: [PATCH 0320/1091] FIX: manage multientity in ticket public page by querystring --- htdocs/public/ticket/create_ticket.php | 8 +++++- htdocs/public/ticket/index.php | 11 +++++---- htdocs/public/ticket/list.php | 20 +++++++++------ htdocs/public/ticket/view.php | 26 ++++++++++++-------- htdocs/ticket/class/actions_ticket.class.php | 3 +++ 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 1a11b16d1ea..9efa561341e 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -47,6 +47,12 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; @@ -342,7 +348,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $messagetoshow = str_replace(array('{s1}', '{s2}'), array(''.$object->track_id.'', ''.$object->ref.''), $messagetoshow); setEventMessages($messagetoshow, null, 'warnings'); setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); - header("Location: index.php"); + header("Location: index.php".(!empty($entity) && !empty($conf->multicompany->enabled)?'?entity='.$entity:'')); exit; } } else { diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 6abeb5f8b12..83acf828893 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -40,7 +40,6 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); @@ -54,6 +53,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + + + // Load translation files required by the page $langs->loadLangs(array('companies', 'other', 'ticket', 'errors')); @@ -77,7 +79,6 @@ if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print $langs->trans('TicketPublicInterfaceForbidden'); exit; } - $arrayofjs = array(); $arrayofcss = array('/ticket/css/styles.css.php'); @@ -86,9 +87,9 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); print ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 4fbfd29106a..ef16b716db2 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -40,6 +40,13 @@ if (!defined('NOBROWSERNOTIF')) { } // If this page is public (can be called outside logged session) +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -154,10 +161,6 @@ if ($action == "view_ticketlist") { } } -//$object->doActions($action); - - - /* * View */ @@ -215,6 +218,9 @@ if ($action == "view_ticketlist") { $filter = array(); $param = 'action=view_ticketlist'; + if (!empty($entity) && !empty($conf->multicompany->enabled)) { + $param .= '&entity='.$entity; + } // Definition of fields for list $arrayfields = array( @@ -392,7 +398,7 @@ if ($action == "view_ticketlist") { print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); // Search bar - print '
    '."\n"; + print ''."\n"; print ''; print ''; print ''; @@ -674,7 +680,7 @@ if ($action == "view_ticketlist") { print ''; print '
    '; - print '