2
0
forked from Wavyzz/dolibarr

Merge branch 'develop' into Technical-debts-7

This commit is contained in:
Laurent Destailleur
2024-01-23 19:08:53 +01:00
committed by GitHub
56 changed files with 890 additions and 507 deletions

View File

@@ -9821,20 +9821,21 @@ class Form
}
/**
* Return HTML code to output a photo
* Return HTML code to output a photo
*
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param object $object Object containing data to retrieve file name
* @param int $width Width of photo
* @param int $height Height of photo (auto if 0)
* @param int $caneditfield Add edit fields
* @param string $cssclass CSS name to use on img for photo
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int $addlinktofullsize Add link to fullsize image
* @param int $cache 1=Accept to use image in cache
* @param string $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param object $object Object containing data to retrieve file name
* @param int $width Width of photo
* @param int $height Height of photo (auto if 0)
* @param int $caneditfield Add edit fields
* @param string $cssclass CSS name to use on img for photo
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int $addlinktofullsize Add link to fullsize image
* @param int $cache 1=Accept to use image in cache
* @param string $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
* @see getImagePublicURLOfObject()
*/
public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '', $noexternsourceoverwrite = 0)
{
@@ -10374,7 +10375,8 @@ class Form
global $langs;
$out = '';
$sql = "SELECT id, code, label FROM " . $this->db->prefix() . "c_type_fees";
$sql = "SELECT id, code, label";
$sql .= " FROM ".$this->db->prefix()."c_type_fees";
$sql .= " WHERE active = 1";
$resql = $this->db->query($sql);
@@ -10397,6 +10399,8 @@ class Form
$out .= '<option ' . ($selected == $obj->{$field} ? 'selected="selected"' : '') . ' value="' . $obj->{$field} . '">' . ($key != $obj->code ? $key : $obj->label) . '</option>';
}
$out .= '</select>';
$out .= ajax_combobox('select_'.$htmlname);
} else {
dol_print_error($this->db);
}

View File

@@ -130,14 +130,16 @@ class FormSetup
/**
* generateOutput
* Generate the form (in read or edit mode depending on $editMode)
*
* @param bool $editMode true will display output on edit mod
* @return string html output
* @param bool $hideTitle True to hide the first title line
* @return string Html output
*/
public function generateOutput($editMode = false)
public function generateOutput($editMode = false, $hideTitle = false)
{
global $hookmanager, $action, $langs;
global $hookmanager, $action;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$parameters = array(
@@ -166,7 +168,7 @@ class FormSetup
}
// generate output table
$out .= $this->generateTableOutput($editMode);
$out .= $this->generateTableOutput($editMode, $hideTitle);
$reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutputButton', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
@@ -177,12 +179,12 @@ class FormSetup
if ($reshook > 0) {
return $hookmanager->resPrint;
} elseif ($editMode) {
$out .= '<br>'; // Todo : remove this <br/> by adding style to form-setup-button-container css class in all themes
$out .= '<div class="form-setup-button-container center">'; // Todo : remove .center by adding style to form-setup-button-container css class in all themes
$out.= $this->htmlOutputMoreButton;
$out .= '<input class="button button-save" type="submit" value="' . $this->langs->trans("Save") . '">'; // Todo fix dolibarr style for <button and use <button instead of input
$out .= ' &nbsp;&nbsp; ';
$out .= '<a class="button button-cancel" type="submit" href="' . $this->formAttributes['action'] . '">'.$langs->trans('Cancel').'</a>';
/*$out .= ' &nbsp;&nbsp; ';
$out .= '<a class="button button-cancel" type="submit" href="' . $this->formAttributes['action'] . '">'.$this->langs->trans('Cancel').'</a>';
*/
$out .= '</div>';
}
@@ -199,10 +201,11 @@ class FormSetup
/**
* generateTableOutput
*
* @param bool $editMode true will display output on edit mod
* @return string html output
* @param bool $editMode True will display output on edit modECM
* @param bool $hideTitle True to hide the first title line
* @return string Html output
*/
public function generateTableOutput($editMode = false)
public function generateTableOutput($editMode = false, $hideTitle = false)
{
global $hookmanager, $action;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@@ -219,12 +222,14 @@ class FormSetup
return $hookmanager->resPrint;
} else {
$out = '<table class="noborder centpercent">';
$out .= '<thead>';
$out .= '<tr class="liste_titre">';
$out .= ' <td>' . $this->langs->trans("Parameter") . '</td>';
$out .= ' <td>' . $this->langs->trans("Value") . '</td>';
$out .= '</tr>';
$out .= '</thead>';
if (empty($hideTitle)) {
$out .= '<thead>';
$out .= '<tr class="liste_titre">';
$out .= ' <td>' . $this->langs->trans("Parameter") . '</td>';
$out .= ' <td>' . $this->langs->trans("Value") . '</td>';
$out .= '</tr>';
$out .= '</thead>';
}
// Sort items before render
$this->sortingItems();
@@ -444,12 +449,12 @@ class FormSetup
/**
* Create a new item
* the tagret is useful with hooks : that allow externals modules to add setup items on good place
* The tagret is useful with hooks : that allow externals modules to add setup items on good place
*
* @param string $confKey the conf key used in database
* @param string $targetItemKey target item used to place the new item beside
* @param bool $insertAfterTarget insert before or after target item ?
* @return FormSetupItem the new setup item created
* @return FormSetupItem the new setup item created
*/
public function newItem($confKey, $targetItemKey = '', $insertAfterTarget = false)
{
@@ -685,7 +690,7 @@ class FormSetupItem
}
/**
* reload conf value from databases is an alias of loadValueFromConf
* Reload conf value from databases is an alias of loadValueFromConf
*
* @deprecated
* @return bool
@@ -906,7 +911,7 @@ class FormSetupItem
*/
public function generateInputFieldText()
{
if (empty($this->fieldAttr)) {
if (empty($this->fieldAttr) || empty($this->fieldAttr['class'])) {
$this->fieldAttr['class'] = 'flat '.(empty($this->cssClass) ? 'minwidth200' : $this->cssClass);
}
return '<input '.FormSetup::generateAttributesStringFromArray($this->fieldAttr).' />';
@@ -940,6 +945,7 @@ class FormSetupItem
/**
* generate input field for categories
*
* @return string
*/
public function generateInputFieldCategories()
@@ -950,7 +956,12 @@ class FormSetupItem
$tmp = explode(':', $this->type);
$out = img_picto('', 'category', 'class="pictofixedwidth"');
$out .= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort'));
$label = 'Categories';
if ($this->type == 'customer') {
$label = 'CustomersProspectsCategoriesShort';
}
$out .= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans($label));
return $out;
}

View File

@@ -946,13 +946,13 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
}
/**
* Return value of a param into GET or POST supervariable.
* Return the value of a $_GET or $_POST supervariable, converted into integer.
* Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder']
* Note: The property $user->default_values is loaded by main.php when loading the user.
*
* @param string $paramname Name of parameter to found
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
* @return int Value found (int)
* @param string $paramname Name of the $_GET or $_POST parameter
* @param int $method Type of method (0 = $_GET then $_POST, 1 = only $_GET, 2 = only $_POST, 3 = $_POST then $_GET)
* @return int Value converted into integer
*/
function GETPOSTINT($paramname, $method = 0)
{
@@ -960,6 +960,20 @@ function GETPOSTINT($paramname, $method = 0)
}
/**
* Return the value of a $_GET or $_POST supervariable, converted into float.
*
* @param string $paramname Name of the $_GET or $_POST parameter
* @param string|int $rounding Type of rounding ('', 'MU', 'MT, 'MS', 'CU', 'CT', integer) {@see price2num()}
* @return float Value converted into float
*/
function GETPOSTFLOAT($paramname, $rounding = '')
{
// price2num() is used to sanitize any valid user input (such as "1 234.5", "1 234,5", "1'234,5", "1·234,5", "1,234.5", etc.)
return (float) price2num(GETPOST($paramname), $rounding, 2);
}
/**
* Return a sanitized or empty value after checking value against a rule.
*

View File

@@ -557,7 +557,7 @@ function showWebsiteTemplates(Website $website)
print '<tr class="liste_titre"><th class="titlefield">';
print $form->textwithpicto($langs->trans("Templates"), $langs->trans("ThemeDir").' : '.join(", ", $dirthemes));
print ' ';
print '<a href="'.$_SERVER["PHP_SELF"].'?website='.urlencode($website->ref).'&importsite=1" target="_blank" rel="noopener noreferrer external">';
print '<a href="'.$_SERVER["PHP_SELF"].'?website='.urlencode($website->ref).'&importsite=1" rel="noopener noreferrer external">';
print img_picto('', 'refresh');
print '</a>';
print '</th>';
@@ -570,7 +570,7 @@ function showWebsiteTemplates(Website $website)
print '<tr><td colspan="'.$colspan.'">';
print '<table class="nobordernopadding centpercent"><tr><td><div class="center">';
print '<table class="nobordernopadding centpercent"><tr><td><div class="display-flex">';
if (count($dirthemes)) {
$i = 0;
@@ -592,7 +592,7 @@ function showWebsiteTemplates(Website $website)
continue;
}
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px; margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
$templatedir = $dirtheme."/".$subdir;
$file = $dirtheme."/".$subdirwithoutzip.".jpg";
@@ -632,6 +632,11 @@ function showWebsiteTemplates(Website $website)
$i++;
}
}
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
print '<div class="inline-block center flex-item" style="min-width: 250px; max-width: 400px;margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;"></div>';
}
}
}

View File

@@ -43,25 +43,7 @@ function check_user_password_http($usertotest, $passwordtotest, $entitytotest)
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
/*
$tmpuser = new User($db);
$tmpuser->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1));
$now = dol_now();
if ($tmpuser->datestartvalidity && $db->jdate($tmpuser->datestartvalidity) >= $now) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}
if ($tmpuser->dateendvalidity && $db->jdate($tmpuser->dateendvalidity) <= dol_get_first_hour($now)) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}
*/
// Note: Test on date validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
}
return $login;

View File

@@ -162,26 +162,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest)
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
/*
$tmpuser = new User($db);
$tmpuser->fetch('', $login, '', 1, ($entitytotest > 0 ? $entitytotest : -1));
$now = dol_now();
if ($tmpuser->datestartvalidity && $db->jdate($tmpuser->datestartvalidity) >= $now) {
$ldap->unbind();
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}
if ($tmpuser->dateendvalidity && $db->jdate($tmpuser->dateendvalidity) <= dol_get_first_hour($now)) {
$ldap->unbind();
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}*/
// Note: Test on date validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
// ldap2dolibarr synchronisation
if ($login && !empty($conf->ldap->enabled) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization

View File

@@ -80,20 +80,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
// Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
/* $now = dol_now();
if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}
if ($obj->dateendvalidity && $db->jdate($obj->dateendvalidity) < dol_get_first_hour($now)) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
} */
// Note: Test on date validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
$login = $obj->login;
}
}

View File

@@ -98,20 +98,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
// Note: Test on validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
/* $now = dol_now();
if ($obj->datestartvalidity && $db->jdate($obj->datestartvalidity) > $now) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
}
if ($obj->dateendvalidity && $db->jdate($obj->dateendvalidity) < dol_get_first_hour($now)) {
// Load translation files required by the page
$langs->loadLangs(array('main', 'errors'));
$_SESSION["dol_loginmesg"] = $langs->transnoentitiesnoconv("ErrorLoginDateValidity");
return '--bad-login-validity--';
} */
// Note: Test on date validity is done later natively with isNotIntoValidityDateRange() by core after calling checkLoginPassEntity() that call this method
$login = $obj->login;
}
}

View File

@@ -116,7 +116,7 @@ class mod_sn_standard extends ModeleNumRefBatch
*
* @param Societe $objsoc Object thirdparty
* @param Productlot $object Object we need next value for
* @return string Value if KO, <0 if KO
* @return string|int String if OK, <0 if KO
*/
public function getNextValue($objsoc, $object)
{

View File

@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassw
class modGeneratePassNone extends ModeleGenPassword
{
/**
* @var int ID
* @var string ID
*/
public $id;
@@ -40,7 +40,7 @@ class modGeneratePassNone extends ModeleGenPassword
/**
* Minimum length (text visible by end user)
*
* @var string
* @var int
*/
public $length;

View File

@@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassw
class modGeneratePassPerso extends ModeleGenPassword
{
/**
* @var int ID
* @var string ID
*/
public $id;
@@ -42,7 +42,7 @@ class modGeneratePassPerso extends ModeleGenPassword
/**
* Minimum length (text visible by end user)
*
* @var string
* @var int
*/
public $length;
@@ -102,12 +102,12 @@ class modGeneratePassPerso extends ModeleGenPassword
$this->Ambi = array("1", "I", "l", "|", "O", "0");
$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
$this->length2 = $tabConf[0];
$this->length2 = (int) $tabConf[0];
$this->NbMaj = $tabConf[1];
$this->NbNum = $tabConf[2];
$this->NbSpe = $tabConf[3];
$this->NbRepeat = $tabConf[4];
$this->WithoutAmbi = $tabConf[5];
$this->WithoutAmbi = (int) $tabConf[5];
}
/**

View File

@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassw
class modGeneratePassStandard extends ModeleGenPassword
{
/**
* @var int ID
* @var string ID
*/
public $id;
@@ -40,7 +40,7 @@ class modGeneratePassStandard extends ModeleGenPassword
/**
* Minimum length (text visible by end user)
*
* @var string
* @var int
*/
public $length;