FIX error reported by scrutinizer

This commit is contained in:
Laurent Destailleur 2016-05-08 11:33:46 +02:00
parent eaa548124b
commit c8d98dbfdc
4 changed files with 129 additions and 134 deletions

View File

@ -76,8 +76,6 @@ if ($action == 'add') {
$res = $object->create($user); $res = $object->create($user);
if ($res == 0) {
} else {
if ($res == - 3) { if ($res == - 3) {
$error = 1; $error = 1;
$action = "create"; $action = "create";
@ -87,8 +85,8 @@ if ($action == 'add') {
$action = "create"; $action = "create";
} }
} }
} header("Location: account.php");
Header("Location: account.php"); exit;
} else if ($action == 'edit') { } else if ($action == 'edit') {
if (! GETPOST('cancel', 'alpha')) { if (! GETPOST('cancel', 'alpha')) {
$result = $object->fetch($id); $result = $object->fetch($id);
@ -134,7 +132,8 @@ if ($action == 'add') {
$result = $object->delete($user); $result = $object->delete($user);
if ($result > 0) { if ($result > 0) {
Header("Location: account.php"); header("Location: account.php");
exit;
} }
} }

View File

@ -39,8 +39,6 @@ class FormAdvTargetEmailing extends Form
global $langs; global $langs;
$this->db = $db; $this->db = $db;
return 1;
} }
/** /**
@ -90,6 +88,7 @@ class FormAdvTargetEmailing extends Form
global $conf, $langs; global $conf, $langs;
$langs->load("dict"); $langs->load("dict");
$maxlength = 0;
$out = ''; $out = '';
$countryArray = array(); $countryArray = array();
@ -151,7 +150,7 @@ class FormAdvTargetEmailing extends Form
$options_array = array (); $options_array = array ();
$sql_usr = '';
$sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login"; $sql_usr .= "SELECT DISTINCT u2.rowid, u2.lastname as name, u2.firstname, u2.login";
$sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; $sql_usr .= " FROM " . MAIN_DB_PREFIX . "user as u2, " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
$sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")"; $sql_usr .= " WHERE u2.entity IN (0," . $conf->entity . ")";
@ -247,11 +246,13 @@ class FormAdvTargetEmailing extends Form
$sql .= ' WHERE ' . $InfoFieldList [3]; $sql .= ' WHERE ' . $InfoFieldList [3];
} }
} }
if (! empty ( $InfoFieldList [1] ) && $key == 'ts_payeur') { if (! empty($InfoFieldList[1])) {
$sql .= " ORDER BY nom"; $sql .= " ORDER BY nom";
} }
// $sql.= ' WHERE entity = '.$conf->entity; // $sql.= ' WHERE entity = '.$conf->entity;
$options_array = array();
dol_syslog(get_class($this) . "::".__METHOD__,LOG_DEBUG); dol_syslog(get_class($this) . "::".__METHOD__,LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
@ -277,7 +278,7 @@ class FormAdvTargetEmailing extends Form
* Return combo list with people title * Return combo list with people title
* *
* @param string $htmlname Name of HTML select combo field * @param string $htmlname Name of HTML select combo field
* @param array $selected_array array * @param array $selected_array Array
* @return string HTML combo * @return string HTML combo
*/ */
function multiselectCivility($htmlname='civilite_id',$selected_array = array()) function multiselectCivility($htmlname='civilite_id',$selected_array = array())
@ -365,14 +366,12 @@ class FormAdvTargetEmailing extends Form
if (count($options_array) > 0) { if (count($options_array) > 0) {
foreach ($options_array as $keyoption => $valoption) { foreach ($options_array as $keyoption => $valoption) {
// If key is in intersect table then it have to e selected // If key is in intersect table then it have to e selected
$selected = '';
if (count ( $intersect_array ) > 0) { if (count ( $intersect_array ) > 0) {
if (array_key_exists ( $keyoption, $intersect_array )) { if (array_key_exists ( $keyoption, $intersect_array )) {
$selected = ' selected="selected"'; $selected = ' selected="selected"';
} else {
$selected = '';
} }
} }
$return .= '<option' . $selected . ' value="' . $keyoption . '">' . $valoption . '</option>'; $return .= '<option' . $selected . ' value="' . $keyoption . '">' . $valoption . '</option>';
} }
} }

View File

@ -52,7 +52,7 @@ class mailing_advthirdparties extends MailingTargets
* *
* @param int $mailing_id Id of mailing. No need to use it. * @param int $mailing_id Id of mailing. No need to use it.
* @param array $socid Array of id soc to add * @param array $socid Array of id soc to add
* @param int $type_of_target define in advtargetemailing.class.php * @param int $type_of_target Defined in advtargetemailing.class.php
* @param array $contactid Array of contact id to add * @param array $contactid Array of contact id to add
* @return int <0 if error, number of emails added if ok * @return int <0 if error, number of emails added if ok
*/ */
@ -73,10 +73,7 @@ class mailing_advthirdparties extends MailingTargets
$sql.= " WHERE s.entity IN (".getEntity('societe', 1).")"; $sql.= " WHERE s.entity IN (".getEntity('societe', 1).")";
$sql.= " AND s.rowid IN (".implode(',',$socid).")"; $sql.= " AND s.rowid IN (".implode(',',$socid).")";
$sql.= " ORDER BY email"; $sql.= " ORDER BY email";
}
dol_syslog(get_class($this)."::add_to_target societe sql=".$sql, LOG_DEBUG);
// Stock recipients emails into targets table // Stock recipients emails into targets table
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
@ -116,6 +113,7 @@ class mailing_advthirdparties extends MailingTargets
return -1; return -1;
} }
} }
}
if (($type_of_target==1) || ($type_of_target==2)) { if (($type_of_target==1) || ($type_of_target==2)) {
// Select the third parties from category // Select the third parties from category
@ -131,10 +129,7 @@ class mailing_advthirdparties extends MailingTargets
$sql.= " AND socp.fk_soc IN (".implode(',',$socid).")"; $sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
} }
$sql.= " ORDER BY email"; $sql.= " ORDER BY email";
}
dol_syslog(get_class($this)."::add_to_target contact sql=".$sql);
// Stock recipients emails into targets table // Stock recipients emails into targets table
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
@ -174,6 +169,7 @@ class mailing_advthirdparties extends MailingTargets
return -1; return -1;
} }
} }
}
dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles,true), LOG_DEBUG); dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles,true), LOG_DEBUG);

View File

@ -3041,6 +3041,7 @@ class Product extends CommonObject
function get_sousproduits_arbo() function get_sousproduits_arbo()
{ {
//$parent = $this->getParent(); //$parent = $this->getParent();
$parent=array();
$parent[$this->label]=array(0 => $this->id); $parent[$this->label]=array(0 => $this->id);
foreach($parent as $key => $value) // key=label, value[0]=id foreach($parent as $key => $value) // key=label, value[0]=id