Merge pull request #15207 from frederic34/patch-11
Mutualise code, introduce MAIN_ALL_TOWN_TO_UPPER
This commit is contained in:
commit
8c646cdf4f
@ -589,9 +589,7 @@ class Adherent extends CommonObject
|
||||
$this->town = ($this->town ? $this->town : $this->town);
|
||||
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
|
||||
$this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
|
||||
$this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
|
||||
|
||||
|
||||
@ -353,9 +353,7 @@ class Contact extends CommonObject
|
||||
// Clean parameters
|
||||
$this->lastname = $this->lastname ?trim($this->lastname) : trim($this->name);
|
||||
$this->firstname = trim($this->firstname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
$this->setUpperOrLowerCase();
|
||||
if (empty($this->socid)) $this->socid = 0;
|
||||
if (empty($this->priv)) $this->priv = 0;
|
||||
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
|
||||
@ -464,10 +462,6 @@ class Contact extends CommonObject
|
||||
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
|
||||
|
||||
// Clean parameters
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
|
||||
$this->lastname = trim($this->lastname) ?trim($this->lastname) : trim($this->lastname);
|
||||
$this->firstname = trim($this->firstname);
|
||||
$this->email = trim($this->email);
|
||||
@ -478,8 +472,9 @@ class Contact extends CommonObject
|
||||
$this->skype = trim($this->skype);
|
||||
$this->photo = trim($this->photo);
|
||||
$this->fax = trim($this->fax);
|
||||
$this->zip = (empty($this->zip) ? '' : $this->zip);
|
||||
$this->town = (empty($this->town) ? '' : $this->town);
|
||||
$this->zip = (empty($this->zip) ? '' : trim($this->zip));
|
||||
$this->town = (empty($this->town) ? '' : trim($this->town));
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
|
||||
if (empty($this->statut)) $this->statut = 0;
|
||||
if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility
|
||||
|
||||
@ -569,6 +569,28 @@ abstract class CommonObject
|
||||
return dol_trunc($ret, $maxlen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to upper or ucwords/lower if needed
|
||||
*
|
||||
* @return void;
|
||||
*/
|
||||
public function setUpperOrLowerCase()
|
||||
{
|
||||
global $conf;
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) {
|
||||
$this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
$this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
$this->name = dol_ucwords(dol_strtolower($this->name));
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) {
|
||||
$this->lastname = dol_strtoupper($this->lastname);
|
||||
$this->name = dol_strtoupper($this->name);
|
||||
}
|
||||
if (!empty($conf->global->MAIN_ALL_TOWN_TO_UPPER)) {
|
||||
$this->town = dol_strtoupper($this->town);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
|
||||
@ -789,8 +789,7 @@ class Societe extends CommonObject
|
||||
// Clean parameters
|
||||
if (empty($this->status)) $this->status = 0;
|
||||
$this->name = $this->name ?trim($this->name) : trim($this->nom);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name);
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->nom = $this->name; // For backward compatibility
|
||||
if (empty($this->client)) $this->client = 0;
|
||||
if (empty($this->fournisseur)) $this->fournisseur = 0;
|
||||
@ -1094,8 +1093,6 @@ class Societe extends CommonObject
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name = dol_ucwords(dol_strtolower($this->name));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->name = dol_strtoupper($this->name);
|
||||
// Clean parameters
|
||||
$this->id = $id;
|
||||
$this->entity = ((isset($this->entity) && is_numeric($this->entity)) ? $this->entity : $conf->entity);
|
||||
@ -1106,6 +1103,7 @@ class Societe extends CommonObject
|
||||
$this->address = $this->address ?trim($this->address) : trim($this->address);
|
||||
$this->zip = $this->zip ?trim($this->zip) : trim($this->zip);
|
||||
$this->town = $this->town ?trim($this->town) : trim($this->town);
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->state_id = trim($this->state_id);
|
||||
$this->country_id = ($this->country_id > 0) ? $this->country_id : 0;
|
||||
$this->phone = trim($this->phone);
|
||||
|
||||
@ -1122,25 +1122,19 @@ class User extends CommonObject
|
||||
global $mysoc;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->login = trim($this->login);
|
||||
if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value
|
||||
|
||||
dol_syslog(get_class($this)."::create login=".$this->login.", user=".(is_object($user) ? $user->id : ''), LOG_DEBUG);
|
||||
|
||||
// Check parameters
|
||||
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email))
|
||||
{
|
||||
if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorBadEMail", $this->email);
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->login))
|
||||
{
|
||||
if (empty($this->login)) {
|
||||
$langs->load("errors");
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
|
||||
return -1;
|
||||
@ -1467,11 +1461,6 @@ class User extends CommonObject
|
||||
dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember.", nosyncmemberpass=".$nosyncmemberpass);
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
|
||||
|
||||
$this->lastname = trim($this->lastname);
|
||||
$this->firstname = trim($this->firstname);
|
||||
$this->employee = $this->employee ? $this->employee : 0;
|
||||
@ -1479,9 +1468,10 @@ class User extends CommonObject
|
||||
$this->gender = trim($this->gender);
|
||||
$this->pass = trim($this->pass);
|
||||
$this->api_key = trim($this->api_key);
|
||||
$this->address = $this->address ?trim($this->address) : trim($this->address);
|
||||
$this->zip = $this->zip ?trim($this->zip) : trim($this->zip);
|
||||
$this->town = $this->town ?trim($this->town) : trim($this->town);
|
||||
$this->address = $this->address ? trim($this->address) : trim($this->address);
|
||||
$this->zip = $this->zip ? trim($this->zip) : trim($this->zip);
|
||||
$this->town = $this->town ? trim($this->town) : trim($this->town);
|
||||
$this->setUpperOrLowerCase();
|
||||
$this->state_id = trim($this->state_id);
|
||||
$this->country_id = ($this->country_id > 0) ? $this->country_id : 0;
|
||||
$this->office_phone = trim($this->office_phone);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user