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. 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); 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) 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)."'"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a91bf80f76a..28f2ad34333 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5126,7 +5126,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; } 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 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; }