From 06c7e015bb5502dafc029e0a7bcf2a6bd6f52b17 Mon Sep 17 00:00:00 2001 From: Can Arslan <138895927+mc2rcanarslan@users.noreply.github.com> Date: Wed, 3 Jan 2024 15:38:26 -0700 Subject: [PATCH 01/19] FIX: Undefined property: Task::$fk_parent --- htdocs/projet/ganttview.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 145152d0089..dcf43bcdd1e 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -282,7 +282,7 @@ if (count($tasksarray) > 0) { foreach ($tasksarray as $key => $val) { // Task array are sorted by "project, position, date" $task->fetch($val->id, ''); - $idparent = ($val->fk_parent ? $val->fk_parent : '-'.$val->fk_project); // If start with -, id is a project id + $idparent = ($val->fk_task_parent ? $val->fk_task_parent : '-'.$val->fk_project); // If start with -, id is a project id $tasks[$taskcursor]['task_id'] = $val->id; $tasks[$taskcursor]['task_alternate_id'] = ($taskcursor + 1); // An id that has same order than position (required by ganttchart) @@ -294,7 +294,7 @@ if (count($tasksarray) > 0) { $tasks[$taskcursor]['task_position'] = $val->rang; $tasks[$taskcursor]['task_planned_workload'] = $val->planned_workload; - if ($val->fk_parent != 0 && $task->hasChildren() > 0) { + if ($val->fk_task_parent != 0 && $task->hasChildren() > 0) { $tasks[$taskcursor]['task_is_group'] = 1; $tasks[$taskcursor]['task_css'] = 'ggroupblack'; //$tasks[$taskcursor]['task_css'] = 'gtaskblue'; From 43fceaf468f19e9714bbf296da4c611c68357301 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 4 Jan 2024 11:47:43 +0100 Subject: [PATCH 02/19] fix: pregmatch all always return empty array, muxt be tested like in findHtmlImages --- htdocs/core/class/CMailFile.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 7b0af81a62c..c801af3ad10 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1752,14 +1752,13 @@ class CMailFile { // Build the array of image extensions $extensions = array_keys($this->image_types); - // We search (into mail body this->html), if we find some strings like "... file=xxx.img" // For example when: // $matches = array(); preg_match_all('/(?:"|\')([^"\']+\.('.implode('|', $extensions).'))(?:"|\')/Ui', $this->html, $matches); // If "xxx.ext" or 'xxx.ext' found - if (!empty($matches)) { + if (!empty($matches) && !empty($matches[1])) { $i = 0; // We are interested in $matches[1] only (the second set of parenthesis into regex) foreach ($matches[1] as $full) { @@ -1790,7 +1789,6 @@ class CMailFile $i++; } } - if (!empty($this->html_images)) { $inline = array(); From 053e0981adde798960c93bfebd48d225a681d964 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 4 Jan 2024 11:49:10 +0100 Subject: [PATCH 03/19] fix: pregmatch all always return empty array, muxt be tested like in findHtmlImages --- htdocs/core/class/CMailFile.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c801af3ad10..da861fbfb0d 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1752,6 +1752,7 @@ class CMailFile { // Build the array of image extensions $extensions = array_keys($this->image_types); + // We search (into mail body this->html), if we find some strings like "... file=xxx.img" // For example when: // @@ -1789,6 +1790,7 @@ class CMailFile $i++; } } + if (!empty($this->html_images)) { $inline = array(); From 609867495681e9d744788c4b5a0cb0a027733cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 6 Jan 2024 10:24:11 +0100 Subject: [PATCH 04/19] fix wrong directory --- htdocs/bom/lib/bom.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 50532de6e36..3f9f736e02d 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2023 Frédéric France * * 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 @@ -113,7 +113,7 @@ function bomPrepareHead($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->bom->dir_output."/bom/".dol_sanitizeFileName($object->ref); + $upload_dir = $conf->bom->dir_output."/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id; From bd77c11d416c26de407d133897741d484be6a493 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Jan 2024 13:31:28 +0100 Subject: [PATCH 05/19] Fix class not loaded on mobile. --- htdocs/accountancy/bookkeeping/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 651afe93562..2609ffb29bf 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -330,7 +330,7 @@ if ($action == 'valid') { * View */ -$html = new Form($db); +$form = new Form($db); $formaccounting = new FormAccounting($db); $title = $langs->trans("CreateMvts"); @@ -339,7 +339,7 @@ llxHeader('', $title); // Confirmation to delete the command if ($action == 'delete') { - $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1); print $formconfirm; } @@ -374,7 +374,7 @@ if ($action == 'create') { print ''; print ''.$langs->trans("Docdate").''; print ''; - print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print $form->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); print ''; print ''; From ca05d756442d9750e23d1b4070142ffe40036b89 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jan 2024 11:11:20 +0100 Subject: [PATCH 06/19] Fix warning message --- htdocs/comm/mailing/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index aaa946fd2fe..5133f7de65c 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -901,14 +901,14 @@ if ($action == 'create') { $text = ''; - if (isset($conf->global->MAILING_LIMIT_SENDBYDAY) && $conf->global->MAILING_LIMIT_SENDBYDAY >= 0) { - $text .= $langs->trans('WarningLimitSendByDay', $conf->global->MAILING_LIMIT_SENDBYDAY); + if (getDolGlobalInt('MAILING_LIMIT_SENDBYDAY') > 0) { + $text .= $langs->trans('WarningLimitSendByDay', getDolGlobalInt('MAILING_LIMIT_SENDBYDAY')); $text .= '

'; } $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { + if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || getDolGlobalInt('MAILING_LIMIT_SENDBYCLI') >= 0) { $text .= '

'; $text .= $langs->trans("MailingNeedCommand"); $text .= '
'; From ffd309e24ea324409e398b40510bc68c68f734a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jan 2024 11:27:54 +0100 Subject: [PATCH 07/19] Fix missing notes for contacts --- htdocs/core/modules/modSociete.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 4863dcbdc09..46e4b4dcd58 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -314,7 +314,8 @@ class modSociete extends DolibarrModules 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.default_lang'=>"Text", 's.canvas' => "Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", - 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", + 's.tva_intra'=>"Text", 's.capital'=>"Numeric", + 's.note_private'=>"Text", 's.note_public'=>"Text", 't.code'=>"List:c_typent:libelle:code", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", @@ -368,11 +369,13 @@ class modSociete extends DolibarrModules 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction', 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town", 'd.nom'=>'State', 'r.nom'=>'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", + 'c.note_private'=>'NotePrivate', 'c.note_public'=>"NotePublic", 'c.statut'=>"Status", 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", 's.client'=>'Customer', 's.fournisseur'=>'Supplier', 's.address'=>'Address', 's.zip'=>"Zip", 's.town'=>"Town", 's.phone'=>'Phone', 's.email'=>"Email", + 'c.note_private'=>'NotePrivate', 'c.note_public'=>"NotePublic", 't.code'=>"ThirdPartyType" ); // Add multicompany field From 1f2d1a2df253732c6dec0d3479dc4c84cf99e963 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jan 2024 11:43:54 +0100 Subject: [PATCH 08/19] Fix color and dates are missings in export categories --- htdocs/core/modules/modCategorie.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index ed84a7e9c4b..b52f0e33960 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -165,7 +165,7 @@ class modCategorie extends DolibarrModules } // Definition of vars - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel"); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.type'=>"Type", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification"); $this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.type'=>"Numeric", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text'); $this->export_entities_array[$r] = array(); // We define here only fields that use another picto $this->export_help_array[$r] = array('cat.type'=>$typeexample); @@ -182,7 +182,7 @@ class modCategorie extends DolibarrModules $this->export_icon[$r] = $this->picto; $this->export_enabled[$r] = 'isModEnabled("product") || isModEnabled("service")'; $this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label'); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref', 'p.label'=>'Label'); $this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 'p.label'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'); // We define here only fields that use another picto @@ -209,6 +209,7 @@ class modCategorie extends DolibarrModules $this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire")); $this->export_fields_array[$r] = array( 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", + 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_fournisseur'=>"SupplierCode", 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", @@ -256,6 +257,7 @@ class modCategorie extends DolibarrModules $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "export")); $this->export_fields_array[$r] = array( 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", + 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix", 's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", @@ -330,6 +332,7 @@ class modCategorie extends DolibarrModules $this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "contact", "export")); $this->export_fields_array[$r] = array( 'cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategoryID", 'pcat.label'=>"ParentCategoryLabel", + 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid' => 'ContactId', 'civ.label' => 'UserTitle', 'p.lastname' => 'LastName', 'p.firstname' => 'Firstname', 'p.address' => 'Address', 'p.zip' => 'Zip', 'p.town' => 'Town', 'c.code' => 'CountryCode', 'c.label' => 'Country', 'p.birthday' => 'DateOfBirth', 'p.poste' => 'PostOrFunction', @@ -387,7 +390,7 @@ class modCategorie extends DolibarrModules $this->export_icon[$r] = $this->picto; $this->export_enabled[$r] = "isModEnabled('project')"; $this->export_permission[$r] = array(array("categorie", "lire"), array("projet", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name"); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'ProjectId', 'p.ref'=>'Ref', 's.rowid'=>"IdThirdParty", 's.nom'=>"Name"); $this->export_TypeFields_array[$r] = array('cat.rowid'=>'Numeric', 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.ref'=>'Text', 's.rowid'=>"Numeric", 's.nom'=>"Text"); $this->export_entities_array[$r] = array('p.rowid'=>'project', 'p.ref'=>'project', 's.rowid'=>"company", 's.nom'=>"company"); // We define here only fields that use another picto @@ -413,7 +416,7 @@ class modCategorie extends DolibarrModules $this->export_icon[$r] = $this->picto; $this->export_enabled[$r] = 'isModEnabled("user")'; $this->export_permission[$r] = array(array("categorie", "lire"), array("user", "export")); - $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'p.rowid'=>'UserID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname'); + $this->export_fields_array[$r] = array('cat.rowid'=>"CategId", 'cat.label'=>"Label", 'cat.description'=>"Description", 'cat.fk_parent'=>"ParentCategory", 'pcat.label'=>"ParentCategoryLabel", 'cat.color'=>"Color", 'cat.date_creation'=>"DateCreation", 'cat.tms'=>"DateLastModification", 'p.rowid'=>'UserID', 'p.login'=>'Login', 'p.lastname'=>'Lastname', 'p.firstname'=>'Firstname'); $this->export_TypeFields_array[$r] = array('cat.rowid'=>"Numeric", 'cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'Numeric', 'pcat.label'=>'Text', 'p.rowid'=>'Numeric', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'user', 'p.login'=>'user', 'p.lastname'=>'user', 'p.firstname'=>'user'); // We define here only fields that use another picto From 1628a48bde0d9ddef3c7f5dde73921b3a68a3aa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jan 2024 12:19:57 +0100 Subject: [PATCH 09/19] FIX Keep a link to enable a 'always_enabled' module to solve pb. --- htdocs/admin/modules.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index af7327dcf68..19a34b5ad4f 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -933,7 +933,12 @@ if ($mode == 'common' || $mode == 'commonkanban') { } else { // Module not yet activated // Set $codeenabledisable if (!empty($objMod->always_enabled)) { - // Should never happened + // A 'always_enabled' module should not never be disabled. If this happen, we keep a link to reenable it. + $codeenabledisable .= ''."\n"; + $codeenabledisable .= 'trans("Disabled"), 'switch_off'); + $codeenabledisable .= "\n"; } elseif (!empty($objMod->disabled)) { $codeenabledisable .= $langs->trans("Disabled"); } else { From 834a7a078a85d7ca5acb529f64768f3efbe391b5 Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 8 Jan 2024 18:21:37 +0100 Subject: [PATCH 10/19] Fix: vcard - add missing db argument in call to dol_print_error # Fix: vcard - add missing db argument in call to dol_print_error The first argument is the DoliDB object --- htdocs/contact/vcard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index d366d1c2b17..33818122a4f 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -41,7 +41,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); $result = $contact->fetch($id); if ($result <= 0) { - dol_print_error($contact->error); + dol_print_error($db, $contact->error); exit; } From 728bfeadbaa20cc894fd2f0ed4ed26b6d0ab51ae Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 8 Jan 2024 22:10:00 +0100 Subject: [PATCH 11/19] Perf: Optimise dol_mimetype # Perf: Optimise dol_mimetype All preg_match() calls were executed even if they are all exclusive. --- htdocs/core/lib/functions.lib.php | 232 ++++++++++++------------------ 1 file changed, 92 insertions(+), 140 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b706c895368..7a19c53f477 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10870,374 +10870,326 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.rtx$/i', $tmpfile)) { + } elseif (preg_match('/\.rtx$/i', $tmpfile)) { $mime = 'text/richtext'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.csv$/i', $tmpfile)) { + } elseif (preg_match('/\.csv$/i', $tmpfile)) { $mime = 'text/csv'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.tsv$/i', $tmpfile)) { + } elseif (preg_match('/\.tsv$/i', $tmpfile)) { $mime = 'text/tab-separated-values'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { + } elseif (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.ini$/i', $tmpfile)) { + } elseif (preg_match('/\.ini$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'ini'; $famime = 'file-text-o'; - } - if (preg_match('/\.md$/i', $tmpfile)) { + } elseif (preg_match('/\.md$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'md'; $famime = 'file-text-o'; - } - if (preg_match('/\.css$/i', $tmpfile)) { + } elseif (preg_match('/\.css$/i', $tmpfile)) { $mime = 'text/css'; $imgmime = 'css.png'; $srclang = 'css'; $famime = 'file-text-o'; - } - if (preg_match('/\.lang$/i', $tmpfile)) { + } elseif (preg_match('/\.lang$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'lang'; $famime = 'file-text-o'; - } + } // phpcs:ignore // Certificate files - if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { + elseif (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } + } // phpcs:ignore // XML based (HTML/XML/XAML) - if (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { + elseif (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { $mime = 'text/html'; $imgmime = 'html.png'; $srclang = 'html'; $famime = 'file-text-o'; - } - if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { + } elseif (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xml'; $famime = 'file-text-o'; - } - if (preg_match('/\.xaml$/i', $tmpfile)) { + } elseif (preg_match('/\.xaml$/i', $tmpfile)) { $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; - } + } // phpcs:ignore // Languages - if (preg_match('/\.bas$/i', $tmpfile)) { + elseif (preg_match('/\.bas$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; $famime = 'file-code-o'; - } - if (preg_match('/\.(c)$/i', $tmpfile)) { + } elseif (preg_match('/\.(c)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'c'; $famime = 'file-code-o'; - } - if (preg_match('/\.(cpp)$/i', $tmpfile)) { + } elseif (preg_match('/\.(cpp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cpp'; $famime = 'file-code-o'; - } - if (preg_match('/\.cs$/i', $tmpfile)) { + } elseif (preg_match('/\.cs$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; - } - if (preg_match('/\.(h)$/i', $tmpfile)) { + } elseif (preg_match('/\.(h)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'h'; $famime = 'file-code-o'; - } - if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { + } elseif (preg_match('/\.(java|jsp)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'java'; $famime = 'file-code-o'; - } - if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { + } elseif (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; - } - if (preg_match('/\.phtml$/i', $tmpfile)) { + } elseif (preg_match('/\.phtml$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; - } - if (preg_match('/\.(pl|pm)$/i', $tmpfile)) { + } elseif (preg_match('/\.(pl|pm)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'pl.png'; $srclang = 'perl'; $famime = 'file-code-o'; - } - if (preg_match('/\.sql$/i', $tmpfile)) { + } elseif (preg_match('/\.sql$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'sql'; $famime = 'file-code-o'; - } - if (preg_match('/\.js$/i', $tmpfile)) { + } elseif (preg_match('/\.js$/i', $tmpfile)) { $mime = 'text/x-javascript'; $imgmime = 'jscript.png'; $srclang = 'js'; $famime = 'file-code-o'; - } + } // phpcs:ignore // Open office - if (preg_match('/\.odp$/i', $tmpfile)) { + elseif (preg_match('/\.odp$/i', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.presentation'; $imgmime = 'ooffice.png'; $famime = 'file-powerpoint-o'; - } - if (preg_match('/\.ods$/i', $tmpfile)) { + } elseif (preg_match('/\.ods$/i', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.spreadsheet'; $imgmime = 'ooffice.png'; $famime = 'file-excel-o'; - } - if (preg_match('/\.odt$/i', $tmpfile)) { + } elseif (preg_match('/\.odt$/i', $tmpfile)) { $mime = 'application/vnd.oasis.opendocument.text'; $imgmime = 'ooffice.png'; $famime = 'file-word-o'; - } + } // phpcs:ignore // MS Office - if (preg_match('/\.mdb$/i', $tmpfile)) { + elseif (preg_match('/\.mdb$/i', $tmpfile)) { $mime = 'application/msaccess'; $imgmime = 'mdb.png'; $famime = 'file-o'; - } - if (preg_match('/\.doc[xm]?$/i', $tmpfile)) { + } elseif (preg_match('/\.doc[xm]?$/i', $tmpfile)) { $mime = 'application/msword'; $imgmime = 'doc.png'; $famime = 'file-word-o'; - } - if (preg_match('/\.dot[xm]?$/i', $tmpfile)) { + } elseif (preg_match('/\.dot[xm]?$/i', $tmpfile)) { $mime = 'application/msword'; $imgmime = 'doc.png'; $famime = 'file-word-o'; - } - if (preg_match('/\.xlt(x)?$/i', $tmpfile)) { + } elseif (preg_match('/\.xlt(x)?$/i', $tmpfile)) { $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; - } - if (preg_match('/\.xla(m)?$/i', $tmpfile)) { + } elseif (preg_match('/\.xla(m)?$/i', $tmpfile)) { $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; - } - if (preg_match('/\.xls$/i', $tmpfile)) { + } elseif (preg_match('/\.xls$/i', $tmpfile)) { $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; - } - if (preg_match('/\.xls[bmx]$/i', $tmpfile)) { + } elseif (preg_match('/\.xls[bmx]$/i', $tmpfile)) { $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; - } - if (preg_match('/\.pps[mx]?$/i', $tmpfile)) { + } elseif (preg_match('/\.pps[mx]?$/i', $tmpfile)) { $mime = 'application/vnd.ms-powerpoint'; $imgmime = 'ppt.png'; $famime = 'file-powerpoint-o'; - } - if (preg_match('/\.ppt[mx]?$/i', $tmpfile)) { + } elseif (preg_match('/\.ppt[mx]?$/i', $tmpfile)) { $mime = 'application/x-mspowerpoint'; $imgmime = 'ppt.png'; $famime = 'file-powerpoint-o'; - } + } // phpcs:ignore // Other - if (preg_match('/\.pdf$/i', $tmpfile)) { + elseif (preg_match('/\.pdf$/i', $tmpfile)) { $mime = 'application/pdf'; $imgmime = 'pdf.png'; $famime = 'file-pdf-o'; - } + } // phpcs:ignore // Scripts - if (preg_match('/\.bat$/i', $tmpfile)) { + elseif (preg_match('/\.bat$/i', $tmpfile)) { $mime = 'text/x-bat'; $imgmime = 'script.png'; $srclang = 'dos'; $famime = 'file-code-o'; - } - if (preg_match('/\.sh$/i', $tmpfile)) { + } elseif (preg_match('/\.sh$/i', $tmpfile)) { $mime = 'text/x-sh'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; - } - if (preg_match('/\.ksh$/i', $tmpfile)) { + } elseif (preg_match('/\.ksh$/i', $tmpfile)) { $mime = 'text/x-ksh'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; - } - if (preg_match('/\.bash$/i', $tmpfile)) { + } elseif (preg_match('/\.bash$/i', $tmpfile)) { $mime = 'text/x-bash'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; - } + } // phpcs:ignore // Images - if (preg_match('/\.ico$/i', $tmpfile)) { + elseif (preg_match('/\.ico$/i', $tmpfile)) { $mime = 'image/x-icon'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) { + } elseif (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) { $mime = 'image/jpeg'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.png$/i', $tmpfile)) { + } elseif (preg_match('/\.png$/i', $tmpfile)) { $mime = 'image/png'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.gif$/i', $tmpfile)) { + } elseif (preg_match('/\.gif$/i', $tmpfile)) { $mime = 'image/gif'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.bmp$/i', $tmpfile)) { + } elseif (preg_match('/\.bmp$/i', $tmpfile)) { $mime = 'image/bmp'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.(tif|tiff)$/i', $tmpfile)) { + } elseif (preg_match('/\.(tif|tiff)$/i', $tmpfile)) { $mime = 'image/tiff'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.svg$/i', $tmpfile)) { + } elseif (preg_match('/\.svg$/i', $tmpfile)) { $mime = 'image/svg+xml'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } - if (preg_match('/\.webp$/i', $tmpfile)) { + } elseif (preg_match('/\.webp$/i', $tmpfile)) { $mime = 'image/webp'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } + } // phpcs:ignore // Calendar - if (preg_match('/\.vcs$/i', $tmpfile)) { + elseif (preg_match('/\.vcs$/i', $tmpfile)) { $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; - } - if (preg_match('/\.ics$/i', $tmpfile)) { + } elseif (preg_match('/\.ics$/i', $tmpfile)) { $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; - } + } // phpcs:ignore // Other - if (preg_match('/\.torrent$/i', $tmpfile)) { + elseif (preg_match('/\.torrent$/i', $tmpfile)) { $mime = 'application/x-bittorrent'; $imgmime = 'other.png'; $famime = 'file-o'; - } + } // phpcs:ignore // Audio - if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { + elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { $mime = 'audio'; $imgmime = 'audio.png'; $famime = 'file-audio-o'; - } + } // phpcs:ignore // Video - if (preg_match('/\.mp4$/i', $tmpfile)) { + elseif (preg_match('/\.mp4$/i', $tmpfile)) { $mime = 'video/mp4'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.ogv$/i', $tmpfile)) { + } elseif (preg_match('/\.ogv$/i', $tmpfile)) { $mime = 'video/ogg'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.webm$/i', $tmpfile)) { + } elseif (preg_match('/\.webm$/i', $tmpfile)) { $mime = 'video/webm'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.avi$/i', $tmpfile)) { + } elseif (preg_match('/\.avi$/i', $tmpfile)) { $mime = 'video/x-msvideo'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.divx$/i', $tmpfile)) { + } elseif (preg_match('/\.divx$/i', $tmpfile)) { $mime = 'video/divx'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.xvid$/i', $tmpfile)) { + } elseif (preg_match('/\.xvid$/i', $tmpfile)) { $mime = 'video/xvid'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } - if (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) { + } elseif (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) { $mime = 'video'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } + } // phpcs:ignore // Archive - if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { + elseif (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { + // application/xxx where zzz is zip, ... $mime = 'archive'; $imgmime = 'archive.png'; $famime = 'file-archive-o'; - } // application/xxx where zzz is zip, ... + } // phpcs:ignore // Exe - if (preg_match('/\.(exe|com)$/i', $tmpfile)) { + elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { $mime = 'application/octet-stream'; $imgmime = 'other.png'; $famime = 'file-o'; - } + } // phpcs:ignore // Lib - if (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { + elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { $mime = 'library'; $imgmime = 'library.png'; $famime = 'file-o'; - } + } // phpcs:ignore // Err - if (preg_match('/\.err$/i', $tmpfile)) { + elseif (preg_match('/\.err$/i', $tmpfile)) { $mime = 'error'; $imgmime = 'error.png'; $famime = 'file-text-o'; - } + } // phpcs:ignore - // Return string - if ($mode == 1) { - $tmp = explode('/', $mime); - return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]); - } - if ($mode == 2) { - return $imgmime; - } - if ($mode == 3) { - return $srclang; - } - if ($mode == 4) { - return $famime; + // Return mimetype string + switch ((int) $mode) { + case 1: + $tmp = explode('/', $mime); + return (!empty($tmp[1]) ? $tmp[1] : $tmp[0]); + case 2: + return $imgmime; + case 3: + return $srclang; + case 4: + return $famime; } return $mime; } From 1964a3e595ddd1da95429a911f5c37ddd13cc8f0 Mon Sep 17 00:00:00 2001 From: William Mead Date: Tue, 9 Jan 2024 15:09:07 +0100 Subject: [PATCH 12/19] Added notification information on intervention done confirmation message --- htdocs/fichinter/card.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 0f83e21ea93..05d87138630 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1139,7 +1139,14 @@ if ($action == 'create') { // Confirm done if ($action == 'classifydone') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseIntervention'), $langs->trans('ConfirmCloseIntervention'), 'confirm_done', '', 0, 1); + $text = $langs->trans('ConfirmCloseIntervention'); + if (isModEnabled('notification')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('FICHINTER_CLOSE', $object->socid, $object); + } + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseIntervention'), $text, 'confirm_done', '', 0, 1); } // Confirm back to draft From c2f3ce14911ad8e42421d39b4f62ba6b95edf4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9?= Date: Tue, 9 Jan 2024 15:38:35 +0100 Subject: [PATCH 13/19] FIX: BarCode Header not well displayed --- htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 0d380ce1537..a274baa5823 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -135,7 +135,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator // Top if ($header != '') { $pdf->SetXY($_PosX + $xleft, $_PosY + 1); // Only 1 mm and not ytop for top text - $pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); + $pdf->Cell(2 * strlen($header), $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C'); } $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); From 5684813476c02c3c6cb92f38b4c949836d5a73c5 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 9 Jan 2024 20:39:04 +0100 Subject: [PATCH 14/19] Fix: Do not reuse from scope as foreach key Phan report: Variable used in loop was also used in an outer loop. --- htdocs/core/lib/modulebuilder.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 47ff2aa6f74..032f5fbb696 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -1167,7 +1167,7 @@ function updateDictionaryInFile($module, $file, $dicts) $dicData .= "array(" . implode(",", $conditions) . ")"; } elseif ($key === 'tabhelp') { $helpItems = array(); - foreach ($value as $key => $helpValue) { + foreach ($value as $helpValue) { $helpItems[] = "array('code'=>\$langs->trans('".$helpValue['code']."'), 'field2' => 'field2tooltip')"; } $dicData .= "array(" . implode(",", $helpItems) . ")"; From c13228efe8d574218cdb79c5b7478cd89d74fef4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 9 Jan 2024 20:32:31 +0100 Subject: [PATCH 15/19] Fix #yogosha19828 --- build/makepack-dolibarr.pl | 6 + dev/dolibarr_changes.txt | 8 + htdocs/includes/sabre/sabre/dav/bin/build.php | 169 ------- .../sabre/sabre/dav/bin/googlecode_upload.py | 248 ----------- .../sabre/sabre/dav/bin/migrateto20.php | 414 ------------------ .../sabre/sabre/dav/bin/migrateto21.php | 166 ------- .../sabre/sabre/dav/bin/migrateto30.php | 161 ------- .../sabre/sabre/dav/bin/migrateto32.php | 258 ----------- .../sabre/sabre/dav/bin/naturalselection | 140 ------ htdocs/includes/sabre/sabre/dav/bin/sabredav | 2 - .../includes/sabre/sabre/dav/bin/sabredav.php | 51 --- htdocs/includes/sabre/sabre/event/bin/.empty | 0 htdocs/includes/sabre/sabre/http/bin/.empty | 0 .../sabre/sabre/vobject/bin/bench.php | 12 - .../vobject/bin/bench_freebusygenerator.php | 53 --- .../vobject/bin/bench_manipulatevcard.php | 64 --- .../sabre/vobject/bin/fetch_windows_zones.php | 48 -- .../sabre/sabre/vobject/bin/generate_vcards | 241 ---------- .../vobject/bin/generateicalendardata.php | 87 ---- .../sabre/vobject/bin/mergeduplicates.php | 160 ------- .../sabre/sabre/vobject/bin/rrulebench.php | 32 -- .../includes/sabre/sabre/vobject/bin/vobject | 27 -- htdocs/includes/sabre/sabre/xml/bin/.empty | 0 23 files changed, 14 insertions(+), 2333 deletions(-) delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/build.php delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/googlecode_upload.py delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/migrateto20.php delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/migrateto21.php delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/migrateto30.php delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/migrateto32.php delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/naturalselection delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/sabredav delete mode 100755 htdocs/includes/sabre/sabre/dav/bin/sabredav.php delete mode 100644 htdocs/includes/sabre/sabre/event/bin/.empty delete mode 100644 htdocs/includes/sabre/sabre/http/bin/.empty delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/bench.php delete mode 100644 htdocs/includes/sabre/sabre/vobject/bin/bench_freebusygenerator.php delete mode 100644 htdocs/includes/sabre/sabre/vobject/bin/bench_manipulatevcard.php delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/fetch_windows_zones.php delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/generate_vcards delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/generateicalendardata.php delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/mergeduplicates.php delete mode 100644 htdocs/includes/sabre/sabre/vobject/bin/rrulebench.php delete mode 100755 htdocs/includes/sabre/sabre/vobject/bin/vobject delete mode 100644 htdocs/includes/sabre/sabre/xml/bin/.empty diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 5862f3f2970..3dda8035dc4 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -636,6 +636,12 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/autoload.php`; + + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/bin`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/bin`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/*/bin`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/*/*/bin`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/*/*/*/bin`; } # Build package for each target diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index a2a99bdfd5a..a87d5de3207 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -41,6 +41,14 @@ With protected $connector; +SABRE: +------ +rm -fr ./htdocs/includes/sabre/sabre/bin; +rm -fr ./htdocs/includes/sabre/sabre/*/bin; +rm -fr ./htdocs/includes/sabre/sabre/*/*/bin; +rm -fr ./htdocs/includes/sabre/sabre/*/*/*/bin; +rm -fr ./htdocs/includes/sabre/sabre/*/*/*/*/bin; + NUSOAP: ------- diff --git a/htdocs/includes/sabre/sabre/dav/bin/build.php b/htdocs/includes/sabre/sabre/dav/bin/build.php deleted file mode 100755 index 4dd25d9c959..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/build.php +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env php - [ - 'init', 'test', 'clean', - ], - 'markrelease' => [ - 'init', 'test', 'clean', - ], - 'clean' => [], - 'test' => [ - 'composerupdate', - ], - 'init' => [], - 'composerupdate' => [], - ]; - -$default = 'buildzip'; - -$baseDir = __DIR__.'/../'; -chdir($baseDir); - -$currentTask = $default; -if ($argc > 1) { - $currentTask = $argv[1]; -} -$version = null; -if ($argc > 2) { - $version = $argv[2]; -} - -if (!isset($tasks[$currentTask])) { - echo 'Task not found: ', $currentTask, "\n"; - exit(1); -} - -// Creating the dependency graph -$newTaskList = []; -$oldTaskList = [$currentTask => true]; - -while (count($oldTaskList) > 0) { - foreach ($oldTaskList as $task => $foo) { - if (!isset($tasks[$task])) { - echo 'Dependency not found: '.$task, "\n"; - exit(1); - } - $dependencies = $tasks[$task]; - - $fullFilled = true; - foreach ($dependencies as $dependency) { - if (isset($newTaskList[$dependency])) { - // Already in the fulfilled task list. - continue; - } else { - $oldTaskList[$dependency] = true; - $fullFilled = false; - } - } - if ($fullFilled) { - unset($oldTaskList[$task]); - $newTaskList[$task] = 1; - } - } -} - -foreach (array_keys($newTaskList) as $task) { - echo 'task: '.$task, "\n"; - call_user_func($task); - echo "\n"; -} - -function init() -{ - global $version; - if (!$version) { - include __DIR__.'/../vendor/autoload.php'; - $version = Sabre\DAV\Version::VERSION; - } - - echo ' Building sabre/dav '.$version, "\n"; -} - -function clean() -{ - global $baseDir; - echo " Removing build files\n"; - $outputDir = $baseDir.'/build/SabreDAV'; - if (is_dir($outputDir)) { - system('rm -r '.$baseDir.'/build/SabreDAV'); - } -} - -function composerupdate() -{ - global $baseDir; - echo " Updating composer packages to latest version\n\n"; - system('cd '.$baseDir.'; composer update'); -} - -function test() -{ - global $baseDir; - - echo " Running all unittests.\n"; - echo " This may take a while.\n\n"; - system(__DIR__.'/phpunit --configuration '.$baseDir.'/tests/phpunit.xml.dist --stop-on-failure', $code); - if (0 != $code) { - echo "PHPUnit reported error code $code\n"; - exit(1); - } -} - -function buildzip() -{ - global $baseDir, $version; - echo " Generating composer.json\n"; - - $input = json_decode(file_get_contents(__DIR__.'/../composer.json'), true); - $newComposer = [ - 'require' => $input['require'], - 'config' => [ - 'bin-dir' => './bin', - ], - 'prefer-stable' => true, - 'minimum-stability' => 'alpha', - ]; - unset( - $newComposer['require']['sabre/vobject'], - $newComposer['require']['sabre/http'], - $newComposer['require']['sabre/uri'], - $newComposer['require']['sabre/event'] - ); - $newComposer['require']['sabre/dav'] = $version; - mkdir('build/SabreDAV'); - file_put_contents('build/SabreDAV/composer.json', json_encode($newComposer, JSON_PRETTY_PRINT)); - - echo " Downloading dependencies\n"; - system('cd build/SabreDAV; composer install -n', $code); - if (0 !== $code) { - echo "Composer reported error code $code\n"; - exit(1); - } - - echo " Removing pointless files\n"; - unlink('build/SabreDAV/composer.json'); - unlink('build/SabreDAV/composer.lock'); - - echo " Moving important files to the root of the project\n"; - - $fileNames = [ - 'CHANGELOG.md', - 'LICENSE', - 'README.md', - 'examples', - ]; - foreach ($fileNames as $fileName) { - echo " $fileName\n"; - rename('build/SabreDAV/vendor/sabre/dav/'.$fileName, 'build/SabreDAV/'.$fileName); - } - - // - - echo "\n"; - echo "Zipping the sabredav distribution\n\n"; - system('cd build; zip -qr sabredav-'.$version.'.zip SabreDAV'); - - echo 'Done.'; -} diff --git a/htdocs/includes/sabre/sabre/dav/bin/googlecode_upload.py b/htdocs/includes/sabre/sabre/dav/bin/googlecode_upload.py deleted file mode 100755 index caafd5dedac..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/googlecode_upload.py +++ /dev/null @@ -1,248 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 2007 Google Inc. All Rights Reserved. -# Author: danderson@google.com (David Anderson) -# -# Script for uploading files to a Google Code project. -# -# This is intended to be both a useful script for people who want to -# streamline project uploads and a reference implementation for -# uploading files to Google Code projects. -# -# To upload a file to Google Code, you need to provide a path to the -# file on your local machine, a small summary of what the file is, a -# project name, and a valid account that is a member or owner of that -# project. You can optionally provide a list of labels that apply to -# the file. The file will be uploaded under the same name that it has -# in your local filesystem (that is, the "basename" or last path -# component). Run the script with '--help' to get the exact syntax -# and available options. -# -# Note that the upload script requests that you enter your -# googlecode.com password. This is NOT your Gmail account password! -# This is the password you use on googlecode.com for committing to -# Subversion and uploading files. You can find your password by going -# to http://code.google.com/hosting/settings when logged in with your -# Gmail account. If you have already committed to your project's -# Subversion repository, the script will automatically retrieve your -# credentials from there (unless disabled, see the output of '--help' -# for details). -# -# If you are looking at this script as a reference for implementing -# your own Google Code file uploader, then you should take a look at -# the upload() function, which is the meat of the uploader. You -# basically need to build a multipart/form-data POST request with the -# right fields and send it to https://PROJECT.googlecode.com/files . -# Authenticate the request using HTTP Basic authentication, as is -# shown below. -# -# Licensed under the terms of the Apache Software License 2.0: -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Questions, comments, feature requests and patches are most welcome. -# Please direct all of these to the Google Code users group: -# http://groups.google.com/group/google-code-hosting - -"""Google Code file uploader script. -""" - -__author__ = 'danderson@google.com (David Anderson)' - -import httplib -import os.path -import optparse -import getpass -import base64 -import sys - - -def upload(file, project_name, user_name, password, summary, labels=None): - """Upload a file to a Google Code project's file server. - - Args: - file: The local path to the file. - project_name: The name of your project on Google Code. - user_name: Your Google account name. - password: The googlecode.com password for your account. - Note that this is NOT your global Google Account password! - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - - Returns: a tuple: - http_status: 201 if the upload succeeded, something else if an - error occurred. - http_reason: The human-readable string associated with http_status - file_url: If the upload succeeded, the URL of the file on Google - Code, None otherwise. - """ - # The login is the user part of user@gmail.com. If the login provided - # is in the full user@domain form, strip it down. - if user_name.endswith('@gmail.com'): - user_name = user_name[:user_name.index('@gmail.com')] - - form_fields = [('summary', summary)] - if labels is not None: - form_fields.extend([('label', l.strip()) for l in labels]) - - content_type, body = encode_upload_request(form_fields, file) - - upload_host = '%s.googlecode.com' % project_name - upload_uri = '/files' - auth_token = base64.b64encode('%s:%s'% (user_name, password)) - headers = { - 'Authorization': 'Basic %s' % auth_token, - 'User-Agent': 'Googlecode.com uploader v0.9.4', - 'Content-Type': content_type, - } - - server = httplib.HTTPSConnection(upload_host) - server.request('POST', upload_uri, body, headers) - resp = server.getresponse() - server.close() - - if resp.status == 201: - location = resp.getheader('Location', None) - else: - location = None - return resp.status, resp.reason, location - - -def encode_upload_request(fields, file_path): - """Encode the given fields and file into a multipart form body. - - fields is a sequence of (name, value) pairs. file is the path of - the file to upload. The file will be uploaded to Google Code with - the same file name. - - Returns: (content_type, body) ready for httplib.HTTP instance - """ - BOUNDARY = '----------Googlecode_boundary_reindeer_flotilla' - CRLF = '\r\n' - - body = [] - - # Add the metadata about the upload first - for key, value in fields: - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="%s"' % key, - '', - value, - ]) - - # Now add the file itself - file_name = os.path.basename(file_path) - f = open(file_path, 'rb') - file_content = f.read() - f.close() - - body.extend( - ['--' + BOUNDARY, - 'Content-Disposition: form-data; name="filename"; filename="%s"' - % file_name, - # The upload server determines the mime-type, no need to set it. - 'Content-Type: application/octet-stream', - '', - file_content, - ]) - - # Finalize the form body - body.extend(['--' + BOUNDARY + '--', '']) - - return 'multipart/form-data; boundary=%s' % BOUNDARY, CRLF.join(body) - - -def upload_find_auth(file_path, project_name, summary, labels=None, - user_name=None, password=None, tries=3): - """Find credentials and upload a file to a Google Code project's file server. - - file_path, project_name, summary, and labels are passed as-is to upload. - - Args: - file_path: The local path to the file. - project_name: The name of your project on Google Code. - summary: A small description for the file. - labels: an optional list of label strings with which to tag the file. - config_dir: Path to Subversion configuration directory, 'none', or None. - user_name: Your Google account name. - tries: How many attempts to make. - """ - - while tries > 0: - if user_name is None: - # Read username if not specified or loaded from svn config, or on - # subsequent tries. - sys.stdout.write('Please enter your googlecode.com username: ') - sys.stdout.flush() - user_name = sys.stdin.readline().rstrip() - if password is None: - # Read password if not loaded from svn config, or on subsequent tries. - print 'Please enter your googlecode.com password.' - print '** Note that this is NOT your Gmail account password! **' - print 'It is the password you use to access Subversion repositories,' - print 'and can be found here: http://code.google.com/hosting/settings' - password = getpass.getpass() - - status, reason, url = upload(file_path, project_name, user_name, password, - summary, labels) - # Returns 403 Forbidden instead of 401 Unauthorized for bad - # credentials as of 2007-07-17. - if status in [httplib.FORBIDDEN, httplib.UNAUTHORIZED]: - # Rest for another try. - user_name = password = None - tries = tries - 1 - else: - # We're done. - break - - return status, reason, url - - -def main(): - parser = optparse.OptionParser(usage='googlecode-upload.py -s SUMMARY ' - '-p PROJECT [options] FILE') - parser.add_option('-s', '--summary', dest='summary', - help='Short description of the file') - parser.add_option('-p', '--project', dest='project', - help='Google Code project name') - parser.add_option('-u', '--user', dest='user', - help='Your Google Code username') - parser.add_option('-w', '--password', dest='password', - help='Your Google Code password') - parser.add_option('-l', '--labels', dest='labels', - help='An optional list of comma-separated labels to attach ' - 'to the file') - - options, args = parser.parse_args() - - if not options.summary: - parser.error('File summary is missing.') - elif not options.project: - parser.error('Project name is missing.') - elif len(args) < 1: - parser.error('File to upload not provided.') - elif len(args) > 1: - parser.error('Only one file may be specified.') - - file_path = args[0] - - if options.labels: - labels = options.labels.split(',') - else: - labels = None - - status, reason, url = upload_find_auth(file_path, options.project, - options.summary, labels, - options.user, options.password) - if url: - print 'The file was uploaded successfully.' - print 'URL: %s' % url - return 0 - else: - print 'An error occurred. Your file was not uploaded.' - print 'Google Code upload server said: %s (%s)' % (reason, status) - return 1 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/htdocs/includes/sabre/sabre/dav/bin/migrateto20.php b/htdocs/includes/sabre/sabre/dav/bin/migrateto20.php deleted file mode 100755 index fb24fe599d1..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/migrateto20.php +++ /dev/null @@ -1,414 +0,0 @@ -#!/usr/bin/env php -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - -$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); - -switch ($driver) { - case 'mysql': - echo "Detected MySQL.\n"; - break; - case 'sqlite': - echo "Detected SQLite.\n"; - break; - default: - echo 'Error: unsupported driver: '.$driver."\n"; - exit(-1); -} - -foreach (['calendar', 'addressbook'] as $itemType) { - $tableName = $itemType.'s'; - $tableNameOld = $tableName.'_old'; - $changesTable = $itemType.'changes'; - - echo "Upgrading '$tableName'\n"; - - // The only cross-db way to do this, is to just fetch a single record. - $row = $pdo->query("SELECT * FROM $tableName LIMIT 1")->fetch(); - - if (!$row) { - echo "No records were found in the '$tableName' table.\n"; - echo "\n"; - echo "We're going to rename the old table to $tableNameOld (just in case).\n"; - echo "and re-create the new table.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec("RENAME TABLE $tableName TO $tableNameOld"); - switch ($itemType) { - case 'calendar': - $pdo->exec(" - CREATE TABLE calendars ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principaluri VARCHAR(100), - displayname VARCHAR(100), - uri VARCHAR(200), - synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', - description TEXT, - calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', - calendarcolor VARCHAR(10), - timezone TEXT, - components VARCHAR(20), - transparent TINYINT(1) NOT NULL DEFAULT '0', - UNIQUE(principaluri, uri) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); - break; - case 'addressbook': - $pdo->exec(" - CREATE TABLE addressbooks ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principaluri VARCHAR(255), - displayname VARCHAR(255), - uri VARCHAR(200), - description TEXT, - synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', - UNIQUE(principaluri, uri) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - "); - break; - } - break; - - case 'sqlite': - $pdo->exec("ALTER TABLE $tableName RENAME TO $tableNameOld"); - - switch ($itemType) { - case 'calendar': - $pdo->exec(' - CREATE TABLE calendars ( - id integer primary key asc, - principaluri text, - displayname text, - uri text, - synctoken integer, - description text, - calendarorder integer, - calendarcolor text, - timezone text, - components text, - transparent bool - ); - '); - break; - case 'addressbook': - $pdo->exec(' - CREATE TABLE addressbooks ( - id integer primary key asc, - principaluri text, - displayname text, - uri text, - description text, - synctoken integer - ); - '); - - break; - } - break; - } - echo "Creation of 2.0 $tableName table is complete\n"; - } else { - // Checking if there's a synctoken field already. - if (array_key_exists('synctoken', $row)) { - echo "The 'synctoken' field already exists in the $tableName table.\n"; - echo "It's likely you already upgraded, so we're simply leaving\n"; - echo "the $tableName table alone\n"; - } else { - echo "1.8 table schema detected\n"; - switch ($driver) { - case 'mysql': - $pdo->exec("ALTER TABLE $tableName ADD synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1'"); - $pdo->exec("ALTER TABLE $tableName DROP ctag"); - $pdo->exec("UPDATE $tableName SET synctoken = '1'"); - break; - case 'sqlite': - $pdo->exec("ALTER TABLE $tableName ADD synctoken integer"); - $pdo->exec("UPDATE $tableName SET synctoken = '1'"); - echo "Note: there's no easy way to remove fields in sqlite.\n"; - echo "The ctag field is no longer used, but it's kept in place\n"; - break; - } - - echo "Upgraded '$tableName' to 2.0 schema.\n"; - } - } - - try { - $pdo->query("SELECT * FROM $changesTable LIMIT 1"); - - echo "'$changesTable' already exists. Assuming that this part of the\n"; - echo "upgrade was already completed.\n"; - } catch (Exception $e) { - echo "Creating '$changesTable' table.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec(" - CREATE TABLE $changesTable ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARCHAR(200) NOT NULL, - synctoken INT(11) UNSIGNED NOT NULL, - {$itemType}id INT(11) UNSIGNED NOT NULL, - operation TINYINT(1) NOT NULL, - INDEX {$itemType}id_synctoken ({$itemType}id, synctoken) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - "); - break; - case 'sqlite': - $pdo->exec(" - - CREATE TABLE $changesTable ( - id integer primary key asc, - uri text, - synctoken integer, - {$itemType}id integer, - operation bool - ); - - "); - $pdo->exec("CREATE INDEX {$itemType}id_synctoken ON $changesTable ({$itemType}id, synctoken);"); - break; - } - } -} - -try { - $pdo->query('SELECT * FROM calendarsubscriptions LIMIT 1'); - - echo "'calendarsubscriptions' already exists. Assuming that this part of the\n"; - echo "upgrade was already completed.\n"; -} catch (Exception $e) { - echo "Creating calendarsubscriptions table.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec(" -CREATE TABLE calendarsubscriptions ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - uri VARCHAR(200) NOT NULL, - principaluri VARCHAR(100) NOT NULL, - source TEXT, - displayname VARCHAR(100), - refreshrate VARCHAR(10), - calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', - calendarcolor VARCHAR(10), - striptodos TINYINT(1) NULL, - stripalarms TINYINT(1) NULL, - stripattachments TINYINT(1) NULL, - lastmodified INT(11) UNSIGNED, - UNIQUE(principaluri, uri) -); - "); - break; - case 'sqlite': - $pdo->exec(' - -CREATE TABLE calendarsubscriptions ( - id integer primary key asc, - uri text, - principaluri text, - source text, - displayname text, - refreshrate text, - calendarorder integer, - calendarcolor text, - striptodos bool, - stripalarms bool, - stripattachments bool, - lastmodified int -); - '); - - $pdo->exec('CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);'); - break; - } -} - -try { - $pdo->query('SELECT * FROM propertystorage LIMIT 1'); - - echo "'propertystorage' already exists. Assuming that this part of the\n"; - echo "upgrade was already completed.\n"; -} catch (Exception $e) { - echo "Creating propertystorage table.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec(' -CREATE TABLE propertystorage ( - id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - path VARBINARY(1024) NOT NULL, - name VARBINARY(100) NOT NULL, - value MEDIUMBLOB -); - '); - $pdo->exec(' -CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100)); - '); - break; - case 'sqlite': - $pdo->exec(' -CREATE TABLE propertystorage ( - id integer primary key asc, - path TEXT, - name TEXT, - value TEXT -); - '); - $pdo->exec(' -CREATE UNIQUE INDEX path_property ON propertystorage (path, name); - '); - - break; - } -} - -echo "Upgrading cards table to 2.0 schema\n"; - -try { - $create = false; - $row = $pdo->query('SELECT * FROM cards LIMIT 1')->fetch(); - if (!$row) { - $random = mt_rand(1000, 9999); - echo "There was no data in the cards table, so we're re-creating it\n"; - echo "The old table will be renamed to cards_old$random, just in case.\n"; - - $create = true; - - switch ($driver) { - case 'mysql': - $pdo->exec("RENAME TABLE cards TO cards_old$random"); - break; - case 'sqlite': - $pdo->exec("ALTER TABLE cards RENAME TO cards_old$random"); - break; - } - } -} catch (Exception $e) { - echo "Exception while checking cards table. Assuming that the table does not yet exist.\n"; - echo 'Debug: ', $e->getMessage(), "\n"; - $create = true; -} - -if ($create) { - switch ($driver) { - case 'mysql': - $pdo->exec(' -CREATE TABLE cards ( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - addressbookid INT(11) UNSIGNED NOT NULL, - carddata MEDIUMBLOB, - uri VARCHAR(200), - lastmodified INT(11) UNSIGNED, - etag VARBINARY(32), - size INT(11) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - - '); - break; - - case 'sqlite': - $pdo->exec(' -CREATE TABLE cards ( - id integer primary key asc, - addressbookid integer, - carddata blob, - uri text, - lastmodified integer, - etag text, - size integer -); - '); - break; - } -} else { - switch ($driver) { - case 'mysql': - $pdo->exec(' - ALTER TABLE cards - ADD etag VARBINARY(32), - ADD size INT(11) UNSIGNED NOT NULL; - '); - break; - - case 'sqlite': - $pdo->exec(' - ALTER TABLE cards ADD etag text; - ALTER TABLE cards ADD size integer; - '); - break; - } - echo "Reading all old vcards and populating etag and size fields.\n"; - $result = $pdo->query('SELECT id, carddata FROM cards'); - $stmt = $pdo->prepare('UPDATE cards SET etag = ?, size = ? WHERE id = ?'); - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - $stmt->execute([ - md5($row['carddata']), - strlen($row['carddata']), - $row['id'], - ]); - } -} - -echo "Upgrade to 2.0 schema completed.\n"; diff --git a/htdocs/includes/sabre/sabre/dav/bin/migrateto21.php b/htdocs/includes/sabre/sabre/dav/bin/migrateto21.php deleted file mode 100755 index 2c15b0a217e..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/migrateto21.php +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/env php -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - -$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); - -switch ($driver) { - case 'mysql': - echo "Detected MySQL.\n"; - break; - case 'sqlite': - echo "Detected SQLite.\n"; - break; - default: - echo 'Error: unsupported driver: '.$driver."\n"; - exit(-1); -} - -echo "Upgrading 'calendarobjects'\n"; -$addUid = false; -try { - $result = $pdo->query('SELECT * FROM calendarobjects LIMIT 1'); - $row = $result->fetch(\PDO::FETCH_ASSOC); - - if (!$row) { - echo "No data in table. Going to try to add the uid field anyway.\n"; - $addUid = true; - } elseif (array_key_exists('uid', $row)) { - echo "uid field exists. Assuming that this part of the migration has\n"; - echo "Already been completed.\n"; - } else { - echo "2.0 schema detected.\n"; - $addUid = true; - } -} catch (Exception $e) { - echo "Could not find a calendarobjects table. Skipping this part of the\n"; - echo "upgrade.\n"; -} - -if ($addUid) { - switch ($driver) { - case 'mysql': - $pdo->exec('ALTER TABLE calendarobjects ADD uid VARCHAR(200)'); - break; - case 'sqlite': - $pdo->exec('ALTER TABLE calendarobjects ADD uid TEXT'); - break; - } - - $result = $pdo->query('SELECT id, calendardata FROM calendarobjects'); - $stmt = $pdo->prepare('UPDATE calendarobjects SET uid = ? WHERE id = ?'); - $counter = 0; - - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - try { - $vobj = \Sabre\VObject\Reader::read($row['calendardata']); - } catch (\Exception $e) { - echo "Warning! Item with id $row[id] could not be parsed!\n"; - continue; - } - $uid = null; - $item = $vobj->getBaseComponent(); - if (!isset($item->UID)) { - echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n"; - continue; - } - $uid = (string) $item->UID; - $stmt->execute([$uid, $row['id']]); - ++$counter; - } -} - -echo "Creating 'schedulingobjects'\n"; - -switch ($driver) { - case 'mysql': - $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects -( - id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - principaluri VARCHAR(255), - calendardata MEDIUMBLOB, - uri VARCHAR(200), - lastmodified INT(11) UNSIGNED, - etag VARCHAR(32), - size INT(11) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - '); - break; - - case 'sqlite': - $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects ( - id integer primary key asc, - principaluri text, - calendardata blob, - uri text, - lastmodified integer, - etag text, - size integer -) -'); - break; -} - -echo "Done.\n"; - -echo "Upgrade to 2.1 schema completed.\n"; diff --git a/htdocs/includes/sabre/sabre/dav/bin/migrateto30.php b/htdocs/includes/sabre/sabre/dav/bin/migrateto30.php deleted file mode 100755 index 9798cadd259..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/migrateto30.php +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env php -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - -$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); - -switch ($driver) { - case 'mysql': - echo "Detected MySQL.\n"; - break; - case 'sqlite': - echo "Detected SQLite.\n"; - break; - default: - echo 'Error: unsupported driver: '.$driver."\n"; - exit(-1); -} - -echo "Upgrading 'propertystorage'\n"; -$addValueType = false; -try { - $result = $pdo->query('SELECT * FROM propertystorage LIMIT 1'); - $row = $result->fetch(\PDO::FETCH_ASSOC); - - if (!$row) { - echo "No data in table. Going to re-create the table.\n"; - $random = mt_rand(1000, 9999); - echo "Renaming propertystorage -> propertystorage_old$random and creating new table.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old'.$random); - $pdo->exec(' - CREATE TABLE propertystorage ( - id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, - path VARBINARY(1024) NOT NULL, - name VARBINARY(100) NOT NULL, - valuetype INT UNSIGNED, - value MEDIUMBLOB - ); - '); - $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path(600), name(100));'); - break; - case 'sqlite': - $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old'.$random); - $pdo->exec(' -CREATE TABLE propertystorage ( - id integer primary key asc, - path text, - name text, - valuetype integer, - value blob -);'); - - $pdo->exec('CREATE UNIQUE INDEX path_property_'.$random.' ON propertystorage (path, name);'); - break; - } - } elseif (array_key_exists('valuetype', $row)) { - echo "valuetype field exists. Assuming that this part of the migration has\n"; - echo "Already been completed.\n"; - } else { - echo "2.1 schema detected. Going to perform upgrade.\n"; - $addValueType = true; - } -} catch (Exception $e) { - echo "Could not find a propertystorage table. Skipping this part of the\n"; - echo "upgrade.\n"; - echo $e->getMessage(), "\n"; -} - -if ($addValueType) { - switch ($driver) { - case 'mysql': - $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT UNSIGNED'); - break; - case 'sqlite': - $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT'); - - break; - } - - $pdo->exec('UPDATE propertystorage SET valuetype = 1 WHERE valuetype IS NULL '); -} - -echo "Migrating vcardurl\n"; - -$result = $pdo->query('SELECT id, uri, vcardurl FROM principals WHERE vcardurl IS NOT NULL'); -$stmt1 = $pdo->prepare('INSERT INTO propertystorage (path, name, valuetype, value) VALUES (?, ?, 3, ?)'); - -while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { - // Inserting the new record - $stmt1->execute([ - 'addressbooks/'.basename($row['uri']), - '{http://calendarserver.org/ns/}me-card', - serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])), - ]); - - echo serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])); -} - -echo "Done.\n"; -echo "Upgrade to 3.0 schema completed.\n"; diff --git a/htdocs/includes/sabre/sabre/dav/bin/migrateto32.php b/htdocs/includes/sabre/sabre/dav/bin/migrateto32.php deleted file mode 100755 index 09ac55d13ee..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/migrateto32.php +++ /dev/null @@ -1,258 +0,0 @@ -#!/usr/bin/env php -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - -$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); - -switch ($driver) { - case 'mysql': - echo "Detected MySQL.\n"; - break; - case 'sqlite': - echo "Detected SQLite.\n"; - break; - default: - echo 'Error: unsupported driver: '.$driver."\n"; - exit(-1); -} - -echo "Creating 'calendarinstances'\n"; -$addValueType = false; -try { - $result = $pdo->query('SELECT * FROM calendarinstances LIMIT 1'); - $result->fetch(\PDO::FETCH_ASSOC); - echo "calendarinstances exists. Assuming this part of the migration has already been done.\n"; -} catch (Exception $e) { - echo "calendarinstances does not yet exist. Creating table and migrating data.\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec(<<exec(' -INSERT INTO calendarinstances - ( - calendarid, - principaluri, - access, - displayname, - uri, - description, - calendarorder, - calendarcolor, - transparent - ) -SELECT - id, - principaluri, - 1, - displayname, - uri, - description, - calendarorder, - calendarcolor, - transparent -FROM calendars -'); - break; - case 'sqlite': - $pdo->exec(<<exec(' -INSERT INTO calendarinstances - ( - calendarid, - principaluri, - access, - displayname, - uri, - description, - calendarorder, - calendarcolor, - transparent - ) -SELECT - id, - principaluri, - 1, - displayname, - uri, - description, - calendarorder, - calendarcolor, - transparent -FROM calendars -'); - break; - } -} -try { - $result = $pdo->query('SELECT * FROM calendars LIMIT 1'); - $row = $result->fetch(\PDO::FETCH_ASSOC); - - if (!$row) { - echo "Source table is empty.\n"; - $migrateCalendars = true; - } - - $columnCount = count($row); - if (3 === $columnCount) { - echo "The calendars table has 3 columns already. Assuming this part of the migration was already done.\n"; - $migrateCalendars = false; - } else { - echo 'The calendars table has '.$columnCount." columns.\n"; - $migrateCalendars = true; - } -} catch (Exception $e) { - echo "calendars table does not exist. This is a major problem. Exiting.\n"; - exit(-1); -} - -if ($migrateCalendars) { - $calendarBackup = 'calendars_3_1_'.$backupPostfix; - echo "Backing up 'calendars' to '", $calendarBackup, "'\n"; - - switch ($driver) { - case 'mysql': - $pdo->exec('RENAME TABLE calendars TO '.$calendarBackup); - break; - case 'sqlite': - $pdo->exec('ALTER TABLE calendars RENAME TO '.$calendarBackup); - break; - } - - echo "Creating new calendars table.\n"; - switch ($driver) { - case 'mysql': - $pdo->exec(<<exec(<<exec(<<0): - print "Bytes to go before we hit threshold:", bytes - else: - print "Threshold exceeded with:", -bytes, "bytes" - dir = os.listdir(cacheDir) - dir2 = [] - for file in dir: - path = cacheDir + '/' + file - dir2.append({ - "path" : path, - "atime": os.stat(path).st_atime, - "size" : os.stat(path).st_size - }) - - dir2.sort(lambda x,y: int(x["atime"]-y["atime"])) - - filesunlinked = 0 - gainedspace = 0 - - # Left is the amount of bytes that need to be freed up - # The default is the 'min_erase setting' - left = min_erase - - # If the min_erase setting is lower than the amount of bytes over - # the threshold, we use that number instead. - if left < -bytes : - left = -bytes - - print "Need to delete at least:", left; - - for file in dir2: - - # Only deleting files if we're not simulating - if not simulate: os.unlink(file["path"]) - left = int(left - file["size"]) - gainedspace = gainedspace + file["size"] - filesunlinked = filesunlinked + 1 - - if(left<0): - break - - print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace) - - - time.sleep(sleep) - - - -def main(): - parser = OptionParser( - version="naturalselection v0.3", - description="Cache directory manager. Deletes cache entries based on accesstime and free space thresholds.\n" + - "This utility is distributed alongside SabreDAV.", - usage="usage: %prog [options] cacheDirectory", - ) - parser.add_option( - '-s', - dest="simulate", - action="store_true", - help="Don't actually make changes, but just simulate the behaviour", - ) - parser.add_option( - '-r','--runs', - help="How many times to check before exiting. -1 is infinite, which is the default", - type="int", - dest="runs", - default=-1 - ) - parser.add_option( - '-n','--interval', - help="Sleep time in seconds (default = 5)", - type="int", - dest="sleep", - default=5 - ) - parser.add_option( - '-l','--threshold', - help="Threshold in bytes (default = 10737418240, which is 10GB)", - type="int", - dest="threshold", - default=10737418240 - ) - parser.add_option( - '-m', '--min-erase', - help="Minimum number of bytes to erase when the threshold is reached. " + - "Setting this option higher will reduce the number of times the cache directory will need to be scanned. " + - "(the default is 1073741824, which is 1GB.)", - type="int", - dest="min_erase", - default=1073741824 - ) - - options,args = parser.parse_args() - if len(args)<1: - parser.error("This utility requires at least 1 argument") - cacheDir = args[0] - - print "Natural Selection" - print "Cache directory:", cacheDir - free = getfreespace(cacheDir); - print "Current free disk space:", free - - runs = options.runs; - while runs!=0 : - run( - cacheDir, - sleep=options.sleep, - simulate=options.simulate, - threshold=options.threshold, - min_erase=options.min_erase - ) - if runs>0: - runs = runs - 1 - -if __name__ == '__main__' : - main() diff --git a/htdocs/includes/sabre/sabre/dav/bin/sabredav b/htdocs/includes/sabre/sabre/dav/bin/sabredav deleted file mode 100755 index 032371ba8bc..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/sabredav +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -php -S 0.0.0.0:8080 `dirname $0`/sabredav.php diff --git a/htdocs/includes/sabre/sabre/dav/bin/sabredav.php b/htdocs/includes/sabre/sabre/dav/bin/sabredav.php deleted file mode 100755 index 71047b8f8b9..00000000000 --- a/htdocs/includes/sabre/sabre/dav/bin/sabredav.php +++ /dev/null @@ -1,51 +0,0 @@ -stream = fopen('php://stdout', 'w'); - } - - public function log($msg) - { - fwrite($this->stream, $msg."\n"); - } -} - -$log = new CliLog(); - -if ('cli-server' !== php_sapi_name()) { - exit('This script is intended to run on the built-in php webserver'); -} - -// Finding composer - -$paths = [ - __DIR__.'/../vendor/autoload.php', - __DIR__.'/../../../autoload.php', -]; - -foreach ($paths as $path) { - if (file_exists($path)) { - include $path; - break; - } -} - -use Sabre\DAV; - -// Root -$root = new DAV\FS\Directory(getcwd()); - -// Setting up server. -$server = new DAV\Server($root); - -// Browser plugin -$server->addPlugin(new DAV\Browser\Plugin()); - -$server->exec(); diff --git a/htdocs/includes/sabre/sabre/event/bin/.empty b/htdocs/includes/sabre/sabre/event/bin/.empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/includes/sabre/sabre/http/bin/.empty b/htdocs/includes/sabre/sabre/http/bin/.empty deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/includes/sabre/sabre/vobject/bin/bench.php b/htdocs/includes/sabre/sabre/vobject/bin/bench.php deleted file mode 100755 index 0a2736fa6d5..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/bench.php +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env php -parse->start(); - -$vcal = Sabre\VObject\Reader::read(fopen($inputFile, 'r')); - -$bench->parse->stop(); - -$repeat = 100; -$start = new \DateTime('2000-01-01'); -$end = new \DateTime('2020-01-01'); -$timeZone = new \DateTimeZone('America/Toronto'); - -$bench->fb->start(); - -for ($i = 0; $i < $repeat; ++$i) { - $fb = new Sabre\VObject\FreeBusyGenerator($start, $end, $vcal, $timeZone); - $results = $fb->getResult(); -} -$bench->fb->stop(); - -echo $bench,"\n"; - -function formatMemory($input) -{ - if (strlen($input) > 6) { - return round($input / (1024 * 1024)).'M'; - } elseif (strlen($input) > 3) { - return round($input / 1024).'K'; - } -} - -unset($input, $splitter); - -echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n"; -echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n"; diff --git a/htdocs/includes/sabre/sabre/vobject/bin/bench_manipulatevcard.php b/htdocs/includes/sabre/sabre/vobject/bin/bench_manipulatevcard.php deleted file mode 100644 index df6d9f23d66..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/bench_manipulatevcard.php +++ /dev/null @@ -1,64 +0,0 @@ -parse->start(); - $vcard = $splitter->getNext(); - $bench->parse->pause(); - - if (!$vcard) { - break; - } - - $bench->manipulate->start(); - $vcard->{'X-FOO'} = 'Random new value!'; - $emails = []; - if (isset($vcard->EMAIL)) { - foreach ($vcard->EMAIL as $email) { - $emails[] = (string) $email; - } - } - $bench->manipulate->pause(); - - $bench->serialize->start(); - $vcard2 = $vcard->serialize(); - $bench->serialize->pause(); - - $vcard->destroy(); -} - -echo $bench,"\n"; - -function formatMemory($input) -{ - if (strlen($input) > 6) { - return round($input / (1024 * 1024)).'M'; - } elseif (strlen($input) > 3) { - return round($input / 1024).'K'; - } -} - -unset($input, $splitter); - -echo 'peak memory usage: '.formatMemory(memory_get_peak_usage()), "\n"; -echo 'current memory usage: '.formatMemory(memory_get_usage()), "\n"; diff --git a/htdocs/includes/sabre/sabre/vobject/bin/fetch_windows_zones.php b/htdocs/includes/sabre/sabre/vobject/bin/fetch_windows_zones.php deleted file mode 100755 index 2361dc3093f..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/fetch_windows_zones.php +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env php -xpath('//mapZone') as $mapZone) { - $from = (string) $mapZone['other']; - $to = (string) $mapZone['type']; - - list($to) = explode(' ', $to, 2); - - if (!isset($map[$from])) { - $map[$from] = $to; - } -} - -ksort($map); -echo "Writing to: $outputFile\n"; - -$f = fopen($outputFile, 'w'); -fwrite($f, " testdata.vcf - -HI; - - fwrite(STDERR, $help); - exit(2); -} - -$count = (int)$argv[1]; -if ($count < 1) { - fwrite(STDERR, "Count must be at least 1\n"); - exit(2); -} - -fwrite(STDERR, "sabre/vobject " . Version::VERSION . "\n"); -fwrite(STDERR, "Generating " . $count . " vcards in vCard 4.0 format\n"); - -/** - * The following list is just some random data we compiled from various - * sources online. - * - * Very little thought went into compiling this list, and certainly nothing - * political or ethical. - * - * We would _love_ more additions to this to add more variation to this list. - * - * Send us PR's and don't be shy adding your own first and last name for fun. - */ - -$sets = array( - "nl" => array( - "country" => "Netherlands", - "boys" => array( - "Anno", - "Bram", - "Daan", - "Evert", - "Finn", - "Jayden", - "Jens", - "Jesse", - "Levi", - "Lucas", - "Luuk", - "Milan", - "René", - "Sem", - "Sibrand", - "Willem", - ), - "girls" => array( - "Celia", - "Emma", - "Fenna", - "Geke", - "Inge", - "Julia", - "Lisa", - "Lotte", - "Mila", - "Sara", - "Sophie", - "Tess", - "Zoë", - ), - "last" => array( - "Bakker", - "Bos", - "De Boer", - "De Groot", - "De Jong", - "De Vries", - "Jansen", - "Janssen", - "Meyer", - "Mulder", - "Peters", - "Smit", - "Van Dijk", - "Van den Berg", - "Visser", - "Vos", - ), - ), - "us" => array( - "country" => "United States", - "boys" => array( - "Aiden", - "Alexander", - "Charles", - "David", - "Ethan", - "Jacob", - "James", - "Jayden", - "John", - "Joseph", - "Liam", - "Mason", - "Michael", - "Noah", - "Richard", - "Robert", - "Thomas", - "William", - ), - "girls" => array( - "Ava", - "Barbara", - "Chloe", - "Dorothy", - "Elizabeth", - "Emily", - "Emma", - "Isabella", - "Jennifer", - "Lily", - "Linda", - "Margaret", - "Maria", - "Mary", - "Mia", - "Olivia", - "Patricia", - "Roxy", - "Sophia", - "Susan", - "Zoe", - ), - "last" => array( - "Smith", - "Johnson", - "Williams", - "Jones", - "Brown", - "Davis", - "Miller", - "Wilson", - "Moore", - "Taylor", - "Anderson", - "Thomas", - "Jackson", - "White", - "Harris", - "Martin", - "Thompson", - "Garcia", - "Martinez", - "Robinson", - ), - ), -); - -$current = 0; - -$r = function($arr) { - - return $arr[mt_rand(0,count($arr)-1)]; - -}; - -$bdayStart = strtotime('-85 years'); -$bdayEnd = strtotime('-20 years'); - -while($current < $count) { - - $current++; - fwrite(STDERR, "\033[100D$current/$count"); - - $country = array_rand($sets); - $gender = mt_rand(0,1)?'girls':'boys'; - - $vcard = new Component\VCard(array( - 'VERSION' => '4.0', - 'FN' => $r($sets[$country][$gender]) . ' ' . $r($sets[$country]['last']), - 'UID' => UUIDUtil::getUUID(), - )); - - $bdayRatio = mt_rand(0,9); - - if($bdayRatio < 2) { - // 20% has a birthday property with a full date - $dt = new \DateTime('@' . mt_rand($bdayStart, $bdayEnd)); - $vcard->add('BDAY', $dt->format('Ymd')); - - } elseif ($bdayRatio < 3) { - // 10% we only know the month and date of - $dt = new \DateTime('@' . mt_rand($bdayStart, $bdayEnd)); - $vcard->add('BDAY', '--' . $dt->format('md')); - } - if ($result = $vcard->validate()) { - ob_start(); - echo "\nWe produced an invalid vcard somehow!\n"; - foreach($result as $message) { - echo " " . $message['message'] . "\n"; - } - fwrite(STDERR, ob_get_clean()); - } - echo $vcard->serialize(); - -} - -fwrite(STDERR,"\nDone.\n"); diff --git a/htdocs/includes/sabre/sabre/vobject/bin/generateicalendardata.php b/htdocs/includes/sabre/sabre/vobject/bin/generateicalendardata.php deleted file mode 100755 index 019ed97450e..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/generateicalendardata.php +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env php -add('VEVENT'); - $event->DTSTART = 'bla'; - $event->SUMMARY = 'Event #'.$ii; - $event->UID = md5(microtime(true)); - - $doctorRandom = mt_rand(1, 1000); - - switch ($doctorRandom) { - // All-day event - case 1: - $event->DTEND = 'bla'; - $dtStart = clone $currentDate; - $dtEnd = clone $currentDate; - $dtEnd->modify('+'.mt_rand(1, 3).' days'); - $event->DTSTART->setDateTime($dtStart); - $event->DTSTART['VALUE'] = 'DATE'; - $event->DTEND->setDateTime($dtEnd); - break; - case 2: - $event->RRULE = 'FREQ=DAILY;COUNT='.mt_rand(1, 10); - // no break intentional - default: - $dtStart = clone $currentDate; - $dtStart->setTime(mt_rand(1, 23), mt_rand(0, 59), mt_rand(0, 59)); - $event->DTSTART->setDateTime($dtStart); - $event->DURATION = 'PT'.mt_rand(1, 3).'H'; - break; - } - - $currentDate->modify('+ '.mt_rand(0, 3).' days'); -} -fwrite(STDERR, "Validating\n"); - -$result = $calendar->validate(); -if ($result) { - fwrite(STDERR, "Errors!\n"); - fwrite(STDERR, print_r($result, true)); - exit(-1); -} - -fwrite(STDERR, "Serializing this beast\n"); - -echo $calendar->serialize(); - -fwrite(STDERR, "done.\n"); diff --git a/htdocs/includes/sabre/sabre/vobject/bin/mergeduplicates.php b/htdocs/includes/sabre/sabre/vobject/bin/mergeduplicates.php deleted file mode 100755 index 31b2c14ab61..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/mergeduplicates.php +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env php - 0, - 'No FN property' => 0, - 'Ignored duplicates' => 0, - 'Merged values' => 0, - 'Error' => 0, - 'Unique cards' => 0, - 'Total written' => 0, -]; - -function writeStats() -{ - global $stats; - foreach ($stats as $name => $value) { - echo str_pad($name, 23, ' ', STR_PAD_RIGHT), str_pad($value, 6, ' ', STR_PAD_LEFT), "\n"; - } - // Moving cursor back a few lines. - echo "\033[".count($stats).'A'; -} - -function write($vcard) -{ - global $stats, $output; - - ++$stats['Total written']; - fwrite($output, $vcard->serialize()."\n"); -} - -while ($vcard = $splitter->getNext()) { - ++$stats['Total vcards']; - writeStats(); - - $fn = isset($vcard->FN) ? (string) $vcard->FN : null; - - if (empty($fn)) { - // Immediately write this vcard, we don't compare it. - ++$stats['No FN property']; - ++$stats['Unique cards']; - write($vcard); - $vcard->destroy(); - continue; - } - - if (!isset($collectedNames[$fn])) { - $collectedNames[$fn] = $vcard; - ++$stats['Unique cards']; - continue; - } else { - // Starting comparison for all properties. We only check if properties - // in the current vcard exactly appear in the earlier vcard as well. - foreach ($vcard->children() as $newProp) { - if (in_array($newProp->name, $ignoredProperties)) { - // We don't care about properties such as UID and REV. - continue; - } - $ok = false; - foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) { - if ($compareProp->serialize() === $newProp->serialize()) { - $ok = true; - break; - } - } - - if (!$ok) { - if ('EMAIL' === $newProp->name || 'TEL' === $newProp->name) { - // We're going to make another attempt to find this - // property, this time just by value. If we find it, we - // consider it a success. - foreach ($collectedNames[$fn]->select($newProp->name) as $compareProp) { - if ($compareProp->getValue() === $newProp->getValue()) { - $ok = true; - break; - } - } - - if (!$ok) { - // Merging the new value in the old vcard. - $collectedNames[$fn]->add(clone $newProp); - $ok = true; - ++$stats['Merged values']; - } - } - } - - if (!$ok) { - // echo $newProp->serialize() . " does not appear in earlier vcard!\n"; - ++$stats['Error']; - if ($debug) { - fwrite($debug, "Missing '".$newProp->name."' property in duplicate. Earlier vcard:\n".$collectedNames[$fn]->serialize()."\n\nLater:\n".$vcard->serialize()."\n\n"); - } - - $vcard->destroy(); - continue 2; - } - } - } - - $vcard->destroy(); - ++$stats['Ignored duplicates']; -} - -foreach ($collectedNames as $vcard) { - // Overwriting any old PRODID - $vcard->PRODID = '-//Sabre//Sabre VObject '.Version::VERSION.'//EN'; - write($vcard); - writeStats(); -} - -echo str_repeat("\n", count($stats)), "\nDone.\n"; diff --git a/htdocs/includes/sabre/sabre/vobject/bin/rrulebench.php b/htdocs/includes/sabre/sabre/vobject/bin/rrulebench.php deleted file mode 100644 index 69008002e33..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/rrulebench.php +++ /dev/null @@ -1,32 +0,0 @@ -parse->start(); - -echo "Parsing.\n"; -$vobj = Sabre\VObject\Reader::read(fopen($inputFile, 'r')); - -$bench->parse->stop(); - -echo "Expanding.\n"; -$bench->expand->start(); - -$vobj->expand(new DateTime($startDate), new DateTime($endDate)); - -$bench->expand->stop(); - -echo $bench,"\n"; diff --git a/htdocs/includes/sabre/sabre/vobject/bin/vobject b/htdocs/includes/sabre/sabre/vobject/bin/vobject deleted file mode 100755 index 2aca7e72965..00000000000 --- a/htdocs/includes/sabre/sabre/vobject/bin/vobject +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env php -main($argv)); - diff --git a/htdocs/includes/sabre/sabre/xml/bin/.empty b/htdocs/includes/sabre/sabre/xml/bin/.empty deleted file mode 100644 index e69de29bb2d..00000000000 From 10a13dd906d015a6f892179b5ea5092e2cb17684 Mon Sep 17 00:00:00 2001 From: MDW Date: Tue, 9 Jan 2024 22:25:56 +0100 Subject: [PATCH 16/19] Fix: Do not reuse same variable names in inner scope foreach. # Fix: Do not reuse same variable names in inner scope foreach. Phan reports: PhanPluginLoopVariableReuse: Variable used in loop was also used in an outer loop --- htdocs/holiday/define_holiday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index d50c088c161..29f8e4a9368 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -534,7 +534,7 @@ if (count($typeleaves) == 0) { foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { if ($key == 'cp.nbHoliday') { - foreach ($typeleaves as $key => $val) { + foreach ($typeleaves as $leave_key => $leave_val) { $colspan++; } } else { From 4fa4694a34b03a36f4384e4c10dabb0dfa42538b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Jan 2024 11:23:44 +0100 Subject: [PATCH 17/19] Fix closing form --- htdocs/societe/project.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index bdd222c4a6d..f491db5d48b 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -173,7 +173,6 @@ if ($socid) { } print ''; - print ''; print dol_get_fiche_end(); @@ -194,7 +193,10 @@ if ($socid) { include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton); - print ''; + + if (empty($conf->dol_optimize_smallscreen)) { + print ''; + } } // End of page From 2f46ffec3ac587dd8e15f0c64e9a12c8c9b53201 Mon Sep 17 00:00:00 2001 From: "christian.humpel" Date: Wed, 10 Jan 2024 14:05:46 +0100 Subject: [PATCH 18/19] clean and include fk_unit in api for BomLine. --- htdocs/bom/class/api_boms.class.php | 6 ++++-- htdocs/bom/class/bom.class.php | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 2147f7be1ba..776bcd54b7f 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -350,7 +350,8 @@ class Boms extends DolibarrApi $request_data->efficiency, $request_data->position, $request_data->fk_bom_child, - $request_data->import_key + $request_data->import_key, + $request_data->fk_unit ); if ($updateRes > 0) { @@ -395,7 +396,8 @@ class Boms extends DolibarrApi $request_data->disable_stock_change, $request_data->efficiency, $request_data->position, - $request_data->import_key + $request_data->import_key, + $request_data->fk_unit ); if ($updateRes > 0) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 1e761324c7f..a5778a17511 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1739,13 +1739,25 @@ class BOMLine extends CommonObjectLine * @var string description */ public $description; + + /** + * @var double qty + */ public $qty; /** * @var int qty frozen */ public $qty_frozen; + + /** + * @var int disable stock change + */ public $disable_stock_change; + + /** + * @var double efficiency + */ public $efficiency; /** @@ -1769,12 +1781,16 @@ class BOMLine extends CommonObjectLine */ public $unit_cost = 0; - /** * @var Bom array of Bom in line */ public $childBom = array(); + /** + * @var int Service unit + */ + public $fk_unit; + /** * @var int Service Workstation */ From 64eff062f2588827b6e1006e7edabb4530dcb852 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Jan 2024 15:10:15 +0100 Subject: [PATCH 19/19] Clean code --- htdocs/core/lib/functions.lib.php | 66 ++++++++----------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 586a63527b8..151b24110b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10906,15 +10906,11 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $imgmime = 'text.png'; $srclang = 'lang'; $famime = 'file-text-o'; - } // phpcs:ignore - // Certificate files - elseif (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { + } elseif (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { // Certificate files $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; - } // phpcs:ignore - // XML based (HTML/XML/XAML) - elseif (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { + } elseif (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { // XML based (HTML/XML/XAML) $mime = 'text/html'; $imgmime = 'html.png'; $srclang = 'html'; @@ -10929,9 +10925,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; - } // phpcs:ignore - // Languages - elseif (preg_match('/\.bas$/i', $tmpfile)) { + } elseif (preg_match('/\.bas$/i', $tmpfile)) { // Languages $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; @@ -10986,9 +10980,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $imgmime = 'jscript.png'; $srclang = 'js'; $famime = 'file-code-o'; - } // phpcs:ignore - // Open office - elseif (preg_match('/\.odp$/i', $tmpfile)) { + } elseif (preg_match('/\.odp$/i', $tmpfile)) { // Open office $mime = 'application/vnd.oasis.opendocument.presentation'; $imgmime = 'ooffice.png'; $famime = 'file-powerpoint-o'; @@ -11000,9 +10992,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'application/vnd.oasis.opendocument.text'; $imgmime = 'ooffice.png'; $famime = 'file-word-o'; - } // phpcs:ignore - // MS Office - elseif (preg_match('/\.mdb$/i', $tmpfile)) { + } elseif (preg_match('/\.mdb$/i', $tmpfile)) { // MS Office $mime = 'application/msaccess'; $imgmime = 'mdb.png'; $famime = 'file-o'; @@ -11038,15 +11028,11 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'application/x-mspowerpoint'; $imgmime = 'ppt.png'; $famime = 'file-powerpoint-o'; - } // phpcs:ignore - // Other - elseif (preg_match('/\.pdf$/i', $tmpfile)) { + } elseif (preg_match('/\.pdf$/i', $tmpfile)) { // Other $mime = 'application/pdf'; $imgmime = 'pdf.png'; $famime = 'file-pdf-o'; - } // phpcs:ignore - // Scripts - elseif (preg_match('/\.bat$/i', $tmpfile)) { + } elseif (preg_match('/\.bat$/i', $tmpfile)) { // Scripts $mime = 'text/x-bat'; $imgmime = 'script.png'; $srclang = 'dos'; @@ -11066,9 +11052,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; - } // phpcs:ignore - // Images - elseif (preg_match('/\.ico$/i', $tmpfile)) { + } elseif (preg_match('/\.ico$/i', $tmpfile)) { // Images $mime = 'image/x-icon'; $imgmime = 'image.png'; $famime = 'file-image-o'; @@ -11100,9 +11084,7 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'image/webp'; $imgmime = 'image.png'; $famime = 'file-image-o'; - } // phpcs:ignore - // Calendar - elseif (preg_match('/\.vcs$/i', $tmpfile)) { + } elseif (preg_match('/\.vcs$/i', $tmpfile)) { // Calendar $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; @@ -11110,21 +11092,15 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; - } // phpcs:ignore - // Other - elseif (preg_match('/\.torrent$/i', $tmpfile)) { + } elseif (preg_match('/\.torrent$/i', $tmpfile)) { // Other $mime = 'application/x-bittorrent'; $imgmime = 'other.png'; $famime = 'file-o'; - } // phpcs:ignore - // Audio - elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { + } elseif (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { // Audio $mime = 'audio'; $imgmime = 'audio.png'; $famime = 'file-audio-o'; - } // phpcs:ignore - // Video - elseif (preg_match('/\.mp4$/i', $tmpfile)) { + } elseif (preg_match('/\.mp4$/i', $tmpfile)) { // Video $mime = 'video/mp4'; $imgmime = 'video.png'; $famime = 'file-video-o'; @@ -11152,32 +11128,24 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $mime = 'video'; $imgmime = 'video.png'; $famime = 'file-video-o'; - } // phpcs:ignore - // Archive - elseif (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { + } elseif (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh|zst)$/i', $tmpfile)) { // Archive // application/xxx where zzz is zip, ... $mime = 'archive'; $imgmime = 'archive.png'; $famime = 'file-archive-o'; - } // phpcs:ignore - // Exe - elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { + } elseif (preg_match('/\.(exe|com)$/i', $tmpfile)) { // Exe $mime = 'application/octet-stream'; $imgmime = 'other.png'; $famime = 'file-o'; - } // phpcs:ignore - // Lib - elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { + } elseif (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { // Lib $mime = 'library'; $imgmime = 'library.png'; $famime = 'file-o'; - } // phpcs:ignore - // Err - elseif (preg_match('/\.err$/i', $tmpfile)) { + } elseif (preg_match('/\.err$/i', $tmpfile)) { // phpcs:ignore $mime = 'error'; $imgmime = 'error.png'; $famime = 'file-text-o'; - } // phpcs:ignore + } // Return mimetype string switch ((int) $mode) {