mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28:19 +01:00
Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into 20.0
This commit is contained in:
@@ -1339,7 +1339,10 @@ function dol_include_once($relpath, $classname = '')
|
||||
* Return path of url or filesystem. Can check into alternate dir or alternate dir + main dir depending on value of $returnemptyifnotfound.
|
||||
*
|
||||
* @param string $path Relative path to file (if mode=0) or relative url (if mode=1). Ie: mydir/myfile, ../myfile
|
||||
* @param int $type 0=Used for a Filesystem path, 1=Used for an URL path (output relative), 2=Used for an URL path (output full path using same host that current url), 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
|
||||
* @param int $type 0=Used for a Filesystem path,
|
||||
* 1=Used for an URL path (output relative),
|
||||
* 2=Used for an URL path (output full path using same host that current url),
|
||||
* 3=Used for an URL path (output full path using host defined into $dolibarr_main_url_root of conf file)
|
||||
* @param int $returnemptyifnotfound 0:If $type==0 and if file was not found into alternate dir, return default path into main dir (no test on it)
|
||||
* 1:If $type==0 and if file was not found into alternate dir, return empty string
|
||||
* 2:If $type==0 and if file was not found into alternate dir, test into main dir, return default path if found, empty string if not found
|
||||
@@ -1410,11 +1413,9 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
|
||||
if (@file_exists($dirroot.'/'.$regs[1])) { // avoid [php:warn]
|
||||
if ($type == 1) {
|
||||
$res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
|
||||
}
|
||||
if ($type == 2) {
|
||||
} elseif ($type == 2) {
|
||||
$res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
|
||||
}
|
||||
if ($type == 3) {
|
||||
} elseif ($type == 3) {
|
||||
/*global $dolibarr_main_url_root;*/
|
||||
|
||||
// Define $urlwithroot
|
||||
@@ -6615,10 +6616,11 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
|
||||
if (dol_strlen($decpart) > $nbdecimal) {
|
||||
$nbdecimal = dol_strlen($decpart);
|
||||
}
|
||||
// Si on depasse max
|
||||
$max_nbdecimal = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'));
|
||||
if ($trunc && $nbdecimal > $max_nbdecimal) {
|
||||
$nbdecimal = $max_nbdecimal;
|
||||
|
||||
// If nbdecimal is higher than max to show
|
||||
$nbdecimalmaxshown = (int) str_replace('...', '', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'));
|
||||
if ($trunc && $nbdecimal > $nbdecimalmaxshown) {
|
||||
$nbdecimal = $nbdecimalmaxshown;
|
||||
if (preg_match('/\.\.\./i', getDolGlobalString('MAIN_MAX_DECIMALS_SHOWN'))) {
|
||||
// If output is truncated, we show ...
|
||||
$end = '...';
|
||||
@@ -12260,13 +12262,14 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
|
||||
* @param string $text Optional : short label on button. Can be escaped HTML content or full simple text.
|
||||
* @param string $actionType 'default', 'danger', 'email', 'clone', 'cancel', 'delete', ...
|
||||
*
|
||||
* @param string|array<int,array{lang:string,enabled:bool,perm:bool,label:string,url:string}> $url Url for link or array of subbutton description
|
||||
* @param string|array<int,array{lang:string,enabled:bool,perm:bool,label:string,url:string,urlroot:string}> $url Url for link or array of subbutton description
|
||||
*
|
||||
* Example when an array is used: $arrayforbutaction = array(
|
||||
* 10 => array('lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
|
||||
* 20 => array('lang'=>'orders', 'enabled'=>isModEnabled("order"), 'perm'=>$user->hasRight('commande', 'creer'), 'label' => 'CreateOrder', 'url'=>'/commande/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
|
||||
* 30 => array('lang'=>'bills', 'enabled'=>isModEnabled("invoice"), 'perm'=>$user->hasRight('facture', 'creer'), 'label' => 'CreateBill', 'url'=>'/compta/facture/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
|
||||
* );
|
||||
* Example when an array is used:
|
||||
* $arrayforbutaction = array(
|
||||
* 10 => array('attr' => array('class'=>''), 'lang'=>'propal', 'enabled'=>isModEnabled("propal"), 'perm'=>$user->hasRight('propal', 'creer'), 'label' => 'AddProp', 'url'=>'/comm/propal/card.php?action=create&projectid='.$object->id.'&socid='.$object->socid),
|
||||
* 20 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleAction', 'urlroot'=>dol_build_patch('/mymodule/mypage.php?action=create')),
|
||||
* 30 => array('attr' => array('class'=>''), 'lang'=>'mymodule', 'enabled'=>isModEnabled("mymodule"), 'perm'=>$user->hasRight('mymodule', 'write'), 'label' => 'MyModuleOtherAction', 'urlraw' => '# || external Url || javascript: || tel: || mailto:' ),
|
||||
* ); );
|
||||
* @param string $id Attribute id of action button. Example 'action-delete'. This can be used for full ajax confirm if this code is reused into the ->formconfirm() method.
|
||||
* @param int|boolean $userRight User action right
|
||||
* // phpcs:disable
|
||||
@@ -12283,7 +12286,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
|
||||
* 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key
|
||||
* 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key
|
||||
* 'modal' => true, // true|false to display dialog as a modal (with dark background)
|
||||
* 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background)
|
||||
* 'isDropDrown' => false, // true|false to display dialog as a dropdown list (css dropdown-item with dark background)
|
||||
* ],
|
||||
* ]
|
||||
* // phpcs:enable
|
||||
@@ -12313,11 +12316,11 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
||||
$text = $button['text'] ?? '';
|
||||
$actionType = $button['actionType'] ?? '';
|
||||
$tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
|
||||
$id = $button['$id'] ?? '';
|
||||
$id = $button['id'] ?? '';
|
||||
$userRight = $button['perm'] ?? 1;
|
||||
$params = $button['$params'] ?? [];
|
||||
$button['params'] = $button['params'] ?? [];
|
||||
|
||||
$out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $params);
|
||||
$out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
@@ -12330,8 +12333,21 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
||||
if (!empty($subbutton['lang'])) {
|
||||
$langs->load($subbutton['lang']);
|
||||
}
|
||||
$tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], array('isDropDown' => true));
|
||||
|
||||
if (!empty($subbutton['urlraw'])) {
|
||||
$tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
|
||||
} else {
|
||||
$tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
|
||||
$tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
|
||||
}
|
||||
|
||||
$subbuttonparam = array();
|
||||
if (!empty($subbutton['attr'])) {
|
||||
$subbuttonparam['attr'] = $subbutton['attr'];
|
||||
}
|
||||
$subbuttonparam['isDropDown'] = (empty($params['isDropDown']) ? ($subbutton['isDropDown']??false) : $params['isDropDown']);
|
||||
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, $subbutton['id'] ?? '', $subbutton['perm'], $subbuttonparam);
|
||||
}
|
||||
$out .= "</div>";
|
||||
$out .= "</div>";
|
||||
@@ -12340,8 +12356,15 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
||||
if (!empty($subbutton['lang'])) {
|
||||
$langs->load($subbutton['lang']);
|
||||
}
|
||||
$tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage']));
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm']);
|
||||
|
||||
if (!empty($subbutton['urlraw'])) {
|
||||
$tmpurl = $subbutton['urlraw']; // Use raw url, no url completion, use only what developer send
|
||||
} else {
|
||||
$tmpurl = !empty($subbutton['urlroot']) ? $subbutton['urlroot'] : $subbutton['url'];
|
||||
$tmpurl = dolCompletUrlForDropdownButton($tmpurl, $params, empty($subbutton['urlroot']));
|
||||
}
|
||||
|
||||
$out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], $params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12350,7 +12373,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
||||
|
||||
// Here, $url is a simple link
|
||||
|
||||
if (!empty($params['isDropdown'])) {
|
||||
if (!empty($params['isDropdown']) || !empty($params['isDropDown'])) { // Use the dropdown-item style (not for action button)
|
||||
$class = "dropdown-item";
|
||||
} else {
|
||||
$class = 'butAction';
|
||||
@@ -12473,6 +12496,42 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An function to complete dropdown url in dolGetButtonAction
|
||||
*
|
||||
* @param string $url the Url to complete
|
||||
* @param array|array<string> $params params of dolGetButtonAction function
|
||||
* @param bool $addDolUrlRoot to add root url
|
||||
* @return string
|
||||
*/
|
||||
function dolCompletUrlForDropdownButton(string $url, array $params, bool $addDolUrlRoot = true)
|
||||
{
|
||||
if (empty($url)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$parsedUrl = parse_url($url);
|
||||
if ((isset($parsedUrl['scheme']) && in_array($parsedUrl['scheme'], ['javascript', 'mailto', 'tel'])) || strpos($url, '#') === 0) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if (!empty($parsedUrl['query'])) {
|
||||
// Use parse_str() function to parse the string passed via URL
|
||||
parse_str($parsedUrl['query'], $urlQuery);
|
||||
if (!isset($urlQuery['backtopage']) && isset($params['backtopage'])) {
|
||||
$url.= '&backtopage='.urlencode($params['backtopage']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($parsedUrl['scheme']) && $addDolUrlRoot) {
|
||||
$url = DOL_URL_ROOT.$url;
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add space between dolGetButtonTitle
|
||||
*
|
||||
@@ -13340,7 +13399,7 @@ function forgeSQLFromUniversalSearchCriteria($filter, &$errorstr = '', $noand =
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
if ($filter === '') {
|
||||
if (is_null($filter) || !is_string($filter) || $filter === '') {
|
||||
return '';
|
||||
}
|
||||
if (!preg_match('/^\(.*\)$/', $filter)) { // If $filter does not start and end with ()
|
||||
|
||||
Reference in New Issue
Block a user