diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 0bc620c41bfde62660eab15b293def68907d0a2a..96fef57e7cffb5eb795d99c4fe3a2571c55f8347 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -187,29 +187,30 @@ $texthelp=$langs->trans("PageUrlForDefaultValues"); if ($mode == 'createform') $texthelp.=$langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php'); else $texthelp.=$langs->trans("PageUrlForDefaultValuesList", 'societe/list.php'); $texturl=$form->textwithpicto($langs->trans("Url"), $texthelp); -print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'defaulturl','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($texturl,$_SERVER["PHP_SELF"],'page,param','',$param,'',$sortfield,$sortorder); $texthelp=$langs->trans("TheKeyIsTheNameOfHtmlField"); if ($mode != 'sortorder') $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); else $textkey=$form->textwithpicto($langs->trans("Key"), $texthelp); -print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'defaultkey','',$param,'',$sortfield,$sortorder); +print_liste_field_titre($textkey,$_SERVER["PHP_SELF"],'param','',$param,'',$sortfield,$sortorder); if ($mode != 'sortorder') { $texthelp=$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; // See list into GETPOST $texthelp.='__USERID__<br>'; + $texthelp.='__SUPERVISORID__<br>'; $texthelp.='__MYCOUNTRYID__<br>'; $texthelp.='__DAY__<br>'; $texthelp.='__MONTH__<br>'; $texthelp.='__YEAR__<br>'; if (! empty($conf->multicompany->enabled)) $texthelp.='__ENTITYID__<br>'; - $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp); + $textvalue=$form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, ''); } else { $texthelp='ASC or DESC'; $textvalue=$form->textwithpicto($langs->trans("SortOrder"), $texthelp); } -print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'defaultvalue', '', $param, '', $sortfield, $sortorder); +print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],'entity,page','',$param,'',$sortfield,$sortorder); print '<td align="center"></td>'; print "</tr>\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d430a8ea53b46aacb94043a294f8fdfccd25abd3..7743da27c2d759e37d9dafe183d1f0860bc9100e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -253,17 +253,35 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:''); // Management of default values - if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + if (! isset($_GET['sortfield'])) // If we did a click on a field so sort, we do no appl default values { - $relativepathstring = preg_replace('/\.[a-z]+$/', '', $_SERVER["PHP_SELF"]); - if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); - $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); - $relativepathstring = preg_replace('/^\//', '', $relativepathstring); - $relativepathstring=dol_string_nospecial($relativepathstring, '-'); - // $relativepathstring is now string that identify the page: '_societe_card', '_agenda_card', ... - $keyfordefaultvalue = 'MAIN_DEFAULT_FOR_'.$relativepathstring.'_'.$paramname; - global $conf; - if (isset($conf->global->$keyfordefaultvalue)) $out = $conf->global->$keyfordefaultvalue; + if (! empty($_GET['action']) && $_GET['action'] == 'create' && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]['createform']); + if (isset($user->default_values[$relativepathstring]['createform'][$paramname])) $out = $user->default_values[$relativepathstring]['createform'][$paramname]; + } + } + // Management of default search_filters + elseif (preg_match('/list.php$/', $_SERVER["PHP_SELF"]) && ! empty($paramname) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname])) + { + $relativepathstring = $_SERVER["PHP_SELF"]; + if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring); + $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); + $relativepathstring = preg_replace('/^\//', '', $relativepathstring); + global $user; + if (! empty($user->default_values)) // $user->default_values defined from menu default values, and values loaded not at first + { + //var_dump($user->default_values[$relativepathstring]); + if (isset($user->default_values[$relativepathstring]['filters'][$paramname])) $out = $user->default_values[$relativepathstring]['filters'][$paramname]; + } + } } } elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:''; @@ -303,6 +321,11 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL) global $user; $out = $user->id; } + elseif ($reg[1] == 'SUPERVISORID') + { + global $user; + $out = $user->fk_user; + } elseif ($reg[1] == 'ENTITYID') { global $conf; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index af23343398b3cf1235abf460a432f224f12473bd..1bfa5c0230ca9931660f8c241e744692a81156dc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -428,7 +428,7 @@ ClickToShowDescription=Click to show description DependsOn=This module need the module(s) RequiredBy=This module is required by module(s) TheKeyIsTheNameOfHtmlField=The key is the name of the html field. This need to have technical knowledges to read the content of the HTML page to get the key name of a field. -PageUrlForDefaultValues=You must enter here the relative url of the page. Examples: +PageUrlForDefaultValues=You must enter here the relative url of the page. If you include parameters in URL, the default values will be effective if all parameters are set to same value. Examples: PageUrlForDefaultValuesCreate=<br>For form to create a new thirdparty, it is <strong>%s</strong> PageUrlForDefaultValuesList=<br>For page that list thirdparties, it is <strong>%s</strong> GoIntoTranslationMenuToChangeThis=A translation has been found for the key with this code, so to change this value, you must edit it fom Home-Setup-translation. diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index ebb99eb9807bef47b06f219893ba98cfc5e1f468..61e5199947979891e38dfef6559ab75b510b1e84 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -180,7 +180,7 @@ if (! defined('NOREQUIREDB')) //print "Will work with data into entity instance number '".$conf->entity."'"; - // Here we read database (llx_const table and llx_default_values) and define $conf->global->XXX var. + // Here we read database (llx_const table) and define $conf->global->XXX var. $conf->setValues($db); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index a3006d6ebcd3dfda85216c58f5426f3e31590601..f23c8aca0b6857495f1e91c3da2ecb95800dff93 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -376,7 +376,7 @@ class User extends CommonObject { if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) { - $user->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; + $this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; } } $this->db->free($resql); @@ -387,7 +387,7 @@ class User extends CommonObject return -3; } } - + return 1; }