From 7298e427694e044816f9f4513a30f150cbebe4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Aug 2024 03:19:13 +0200 Subject: [PATCH 1/7] fix phpdoc (#30668) * fix phpdoc * Update utils_diff.class.php --- htdocs/core/class/utils_diff.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/utils_diff.class.php b/htdocs/core/class/utils_diff.class.php index bcc06609ff9..3a36b9e38bc 100644 --- a/htdocs/core/class/utils_diff.class.php +++ b/htdocs/core/class/utils_diff.class.php @@ -371,8 +371,8 @@ class Diff * @param array}> $diff the diff array * @param string $indentation indentation to add to every line of the generated HTML * @param string $separator the separator between lines - * @param string $index the current index, passes by reference - * @param string $type the type of line + * @param int $index the current index, passed by reference + * @param int<0,2> $type the type of line * @return string HTML string */ private static function getCellContent($diff, $indentation, $separator, &$index, $type) From fce1c6f328a0f434ee1181bfa11fbf948334e4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Aug 2024 03:31:02 +0200 Subject: [PATCH 2/7] NEW add hook dolibarrDelConst (#30672) --- htdocs/core/lib/admin.lib.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 016906d0430..becaa9b03e4 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -580,12 +580,26 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler */ function dolibarr_del_const($db, $name, $entity = 1) { - global $conf; + global $conf, $hookmanager; if (empty($name)) { dol_print_error(null, 'Error call dolibar_del_const with parameter name empty'); return -1; } + if (! is_object($hookmanager)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + } + + $parameters = array( + 'name' => $name, + 'entity' => $entity, + ); + + $reshook = $hookmanager->executeHooks('dolibarrDelConst', $parameters); // Note that $action and $object may have been modified by some hooks + if ($reshook != 0) { + return $reshook; + } $sql = "DELETE FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE (".$db->decrypt('name')." = '".$db->escape($name)."'"; From 0340f0db8d3a8552709a00afcf998efa7ed1c3a3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Aug 2024 04:18:02 +0200 Subject: [PATCH 3/7] Fix phpstan --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 08207add827..a8de28cf7ba 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5113,7 +5113,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $srco 'grip_title', 'grip', 'listlight', 'note', 'on', 'off', 'playdisabled', 'printer', 'resize', 'sign-out', 'stats', 'switch_on', 'switch_on_red', 'switch_off', 'uparrow', '1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected' ); - if (!isset($arrayconvpictotomarginleftonly[$pictowithouttext])) { + if (!array_key_exists($pictowithouttext, $arrayconvpictotomarginleftonly)) { $marginleftonlyshort = 0; } From 42a79c3dc002ded87f0b7110efe0ddb6cad19c25 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 20 Aug 2024 09:44:07 +0200 Subject: [PATCH 4/7] Update api_recruitments.class.php with pagination (#30677) * Update api_recruitments.class.php with pagination * Update api_recruitments.class.php --------- Co-authored-by: Laurent Destailleur --- .../class/api_recruitments.class.php | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php index 4d509928372..bfa82e27155 100644 --- a/htdocs/recruitment/class/api_recruitments.class.php +++ b/htdocs/recruitment/class/api_recruitments.class.php @@ -123,7 +123,6 @@ class Recruitments extends DolibarrApi return $this->_cleanObjectDatas($this->candidature); } - /** * List jobpositions * @@ -135,13 +134,14 @@ class Recruitments extends DolibarrApi * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of order objects * * @throws RestException * * @url GET /jobposition/ */ - public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') + public function indexJobPosition($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false) { $obj_ret = array(); $tmpobject = new RecruitmentJobPosition($this->db); @@ -186,6 +186,9 @@ class Recruitments extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -212,6 +215,23 @@ class Recruitments extends DolibarrApi throw new RestException(503, 'Error when retrieving jobposition list: '.$this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } @@ -225,13 +245,15 @@ class Recruitments extends DolibarrApi * @param int $limit Limit for list * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0* * @return array Array of order objects * * @throws RestException * * @url GET /candidature/ */ - public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function indexCandidature($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false) { global $db, $conf; @@ -278,6 +300,9 @@ class Recruitments extends DolibarrApi } } + //this query will return total orders with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -296,7 +321,7 @@ class Recruitments extends DolibarrApi $obj = $this->db->fetch_object($result); $tmp_object = new RecruitmentCandidature($this->db); if ($tmp_object->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($tmp_object); + $obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($tmp_object), $properties); } $i++; } @@ -304,6 +329,23 @@ class Recruitments extends DolibarrApi throw new RestException(503, 'Error when retrieving candidature list: '.$this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } From 3b2207ca2f3552bede6581022fdcb5153b849c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alo=C3=AFs=20Micard?= Date: Tue, 20 Aug 2024 09:46:42 +0200 Subject: [PATCH 5/7] Add docker installation instructions (#30684) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2152d970a62..b81d632a728 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,10 @@ You can use any web server supporting PHP (Apache, Nginx, ...) and a supported d - Follow the installer instructions;;; +### Using Docker images + +Dolibarr is also available as a [Docker image](https://hub.docker.com/r/dolibarr/dolibarr). Installation instructions are available [here](https://github.com/Dolibarr/dolibarr-docker). + ### Using ready to use SaaS/Cloud offers If you lack the time to install it yourself, consider exploring commercial 'ready-to-use' Cloud offerings (refer to https://saas.dolibarr.org). Keep in mind that this third option comes with associated costs. From 5ed0d017e03211c5e0c629218564ca278d203c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Aug 2024 09:46:59 +0200 Subject: [PATCH 6/7] fix phpdoc (#30685) --- htdocs/core/lib/project.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 8c5ceb8656b..dd5d927662b 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1157,7 +1157,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t * Output a task line into a pertime input mode * * @param string $inc Line number (start to 0, then increased by recursive call) - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param User|null $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) @@ -1378,7 +1378,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec * Output a task line into a pertime input mode * * @param string $inc Line number (start to 0, then increased by recursive call) - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param User|null $fuser Restrict list to user if defined * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call) @@ -1777,7 +1777,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr * @param string $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $projectsrole Array of roles user has on project @@ -2177,7 +2177,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ * @param string $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined - * @param string $parent Id of parent task to show (0 to show all) + * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines (list of tasks but we will show only if we have a specific role on task) * @param int $level Level (start to 0, then increased/decrease by recursive call) * @param string $projectsrole Array of roles user has on project From 0166b6c0e9bd79b5e21b130adc07c24720f0ae71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bagnol?= Date: Tue, 20 Aug 2024 09:51:27 +0200 Subject: [PATCH 7/7] # FIX truncate mail server error message to fit to database (mailling module) (#30534) * truncate mail server error message to fit to database * fix typo * substr under DB->escape --------- Co-authored-by: Laurent Destailleur --- htdocs/comm/mailing/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 8971aaa6ec8..30a33c53654 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -427,7 +427,7 @@ if (empty($reshook)) { dol_syslog("comm/mailing/card.php: error for #".$iforemailloop.($mail->error ? ' - '.$mail->error : ''), LOG_WARNING); $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid); + $sql .= " SET statut=-1, error_text='".$db->escape(substr($mail->error, 0, 255))."', date_envoi='".$db->idate($now)."' WHERE rowid=".((int) $obj->rowid); $resql2 = $db->query($sql); if (!$resql2) { dol_print_error($db);