Skip to content

Commit

Permalink
Merge pull request #11303 from atm-florian/10.0
Browse files Browse the repository at this point in the history
fix various little stuff from scrutinizer (undeclared vriable, misspelling variable, mistype declaration)
  • Loading branch information
eldy committed Jun 7, 2019
2 parents 63e205c + ed2d943 commit 0edd94c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 40 deletions.
9 changes: 0 additions & 9 deletions htdocs/accountancy/class/bookkeeping.class.php
Expand Up @@ -202,9 +202,6 @@ public function create(User $user, $notrigger = false)
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) {
$this->import_key = trim($this->import_key);
}
Expand Down Expand Up @@ -522,9 +519,6 @@ public function createStd(User $user, $notrigger = false, $mode = '')
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) {
$this->import_key = trim($this->import_key);
}
Expand Down Expand Up @@ -1139,9 +1133,6 @@ public function update(User $user, $notrigger = false, $mode = '')
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) {
$this->import_key = trim($this->import_key);
}
Expand Down
5 changes: 4 additions & 1 deletion htdocs/admin/multicurrency.php
Expand Up @@ -91,7 +91,10 @@
{
if ($currency->fetch($fk_multicurrency) > 0)
{
$currency->updateRate($rate);
$result=$currency->updateRate($rate);
if ($result<0) {
setEventMessages(null, $currency->errors, 'errors');
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/class/commonobject.class.php
Expand Up @@ -6227,6 +6227,7 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix
$value='';
if (is_array($value_arr) && count($value_arr)>0)
{
$toprint=array();
foreach ($value_arr as $keyval=>$valueval) {
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>';
}
Expand Down
29 changes: 12 additions & 17 deletions htdocs/core/class/cstate.class.php
Expand Up @@ -247,25 +247,20 @@ public function update($user = null, $notrigger = 0)
// }
//}

// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return -1 * $error;
} else {
$this->db->commit();
return 1;
}
}


/**
* Delete object in database
*
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/db/mysqli.class.php
Expand Up @@ -684,6 +684,7 @@ public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_key
// ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "CREATE TABLE ".$table."(";
$i=0;
$sqlfields=array();
foreach($fields as $field_name => $field_desc)
{
$sqlfields[$i] = $field_name." ";
Expand Down
Expand Up @@ -582,7 +582,7 @@ public function write_file($object, $outputlangs, $srctemplatepath)
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks

// Open and load template
Expand Down
3 changes: 2 additions & 1 deletion htdocs/expedition/class/expedition.class.php
Expand Up @@ -1145,9 +1145,10 @@ public function update($user = null, $notrigger = 0)
* Delete shipment.
* Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element)
*
* @param int $notrigger Disable triggers
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
*/
public function delete()
public function delete($notrigger = 0)
{
global $conf, $langs, $user;

Expand Down
13 changes: 6 additions & 7 deletions htdocs/loan/class/loanschedule.class.php
Expand Up @@ -48,13 +48,13 @@ class LoanSchedule extends CommonObject
/**
* @var string Create date
*/
public $datec='';
public $tms='';
public $datec;
public $tms;

/**
* @var string Payment date
*/
public $datep='';
public $datep;

public $amounts=array(); // Array of amounts
public $amount_capital; // Total amount of payment
Expand Down Expand Up @@ -275,17 +275,13 @@ public function update($user = 0, $notrigger = 0)
$error=0;

// Clean parameters
if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan);
if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital);
if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance);
if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest);
if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
if (isset($this->note_private)) $this->note_private=trim($this->note_private);
if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);

// Check parameters
// Put here code to add control on parameters values
Expand Down Expand Up @@ -564,6 +560,9 @@ private function lastPayment($loanid)
*/
public function paimenttorecord($loanid, $datemax)
{

$result=array();

$sql = "SELECT p.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p ";
$sql.= " WHERE p.fk_loan = " . $loanid;
Expand Down
1 change: 1 addition & 0 deletions htdocs/multicurrency/class/multicurrency.class.php
Expand Up @@ -417,6 +417,7 @@ public function addRate($rate)
else
{
$this->rate = null;
$this->errors=$currencyRate->errors;
return -1;
}
}
Expand Down
9 changes: 5 additions & 4 deletions htdocs/projet/class/project.class.php
Expand Up @@ -1660,7 +1660,7 @@ public function remove_element($tableName, $elementSelectId)
// phpcs:enable
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;

if ($TableName=="actioncomm")
if ($tableName=="actioncomm")
{
$sql.= " SET fk_project=NULL";
$sql.= " WHERE id=".$elementSelectId;
Expand Down Expand Up @@ -1738,7 +1738,7 @@ public function loadTimeSpent($datestart, $taskid = 0, $userid = 0)
$sql.= " AND pt.fk_projet = ".$this->id;
$sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
$sql.= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
if ($task_id) $sql.= " AND ptt.fk_task=".$taskid;
if ($taskid) $sql.= " AND ptt.fk_task=".$taskid;
if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid;

//print $sql;
Expand Down Expand Up @@ -1794,7 +1794,8 @@ public function load_board($user)
// For external user, no check is done on company because readability is managed by public status of project and assignement.
//$socid=$user->societe_id;

if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1, $socid);
$projectsListId = null;
if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1);

$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
Expand All @@ -1804,7 +1805,7 @@ public function load_board($user)
//if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
$sql.= " WHERE p.fk_statut = 1";
$sql.= " AND p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
if (! empty($projectsListId)) $sql.= " AND p.rowid IN (".$projectsListId.")";
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
// For external user, no check is done on company permission because readability is managed by public status of project and assignement.
Expand Down

0 comments on commit 0edd94c

Please sign in to comment.