trimParameters
This commit is contained in:
parent
ab0f842db6
commit
b950043618
@ -77,31 +77,18 @@ class Cchargesociales
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->libelle)) {
|
||||
$this->libelle = trim($this->libelle);
|
||||
}
|
||||
if (isset($this->deductible)) {
|
||||
$this->deductible = trim($this->deductible);
|
||||
}
|
||||
if (isset($this->active)) {
|
||||
$this->active = trim($this->active);
|
||||
}
|
||||
if (isset($this->code)) {
|
||||
$this->code = trim($this->code);
|
||||
}
|
||||
if (isset($this->fk_pays)) {
|
||||
$this->fk_pays = trim($this->fk_pays);
|
||||
}
|
||||
if (isset($this->module)) {
|
||||
$this->module = trim($this->module);
|
||||
}
|
||||
if (isset($this->accountancy_code)) {
|
||||
$this->accountancy_code = trim($this->accountancy_code);
|
||||
}
|
||||
|
||||
|
||||
// Clean parameters
|
||||
$this->trimParameters(
|
||||
array(
|
||||
'libelle',
|
||||
'deductible',
|
||||
'active',
|
||||
'code',
|
||||
'fk_pays',
|
||||
'module',
|
||||
'accountancy_code',
|
||||
)
|
||||
);
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
@ -7324,7 +7324,7 @@ abstract class CommonObject
|
||||
$comment = new Comment($this->db);
|
||||
$result=$comment->fetchAllFor($this->element, $this->id);
|
||||
if ($result<0) {
|
||||
$this->errors=array_merge($this->errors,$comment->errors);
|
||||
$this->errors=array_merge($this->errors, $comment->errors);
|
||||
return -1;
|
||||
} else {
|
||||
$this->comments = $comment->comments;
|
||||
@ -7341,4 +7341,20 @@ abstract class CommonObject
|
||||
{
|
||||
return count($this->comments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim object parameters
|
||||
* @param string[] $parameters array of parameters to trim
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function trimParameters($parameters)
|
||||
{
|
||||
if (!is_array($parameters)) return;
|
||||
foreach ($parameters as $parameter) {
|
||||
if (isset($this->$parameter)) {
|
||||
$this->$parameter = trim($this->$parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user