From 6338328c900df5e46d05e732d5a703c463f94b52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Mar 2018 11:09:53 +0100 Subject: [PATCH] Fix scrutinizer errors --- .../boxes/box_graph_invoices_permonth.php | 2 + .../core/class/commondocgenerator.class.php | 2 +- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/class/extrafields.class.php | 1 + htdocs/core/class/html.formactions.class.php | 1 + htdocs/core/class/html.formwebsite.class.php | 7 ++- htdocs/core/lib/admin.lib.php | 5 ++- htdocs/core/lib/website.lib.php | 1 + htdocs/societe/class/societe.class.php | 45 +++++++++---------- htdocs/website/class/website.class.php | 2 +- 10 files changed, 36 insertions(+), 33 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 4c95d446f8a..d665d70da56 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -91,6 +91,8 @@ class box_graph_invoices_permonth extends ModeleBoxes if ($user->rights->facture->lire) { + $mesg = ''; + $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f5a16aa540b..a4ea3a70447 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -319,7 +319,7 @@ abstract class CommonDocGenerator foreach($conf->global as $key => $val) { - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $key)) $newval = '*****forbidden*****'; else $newval = $val; $array_other['__['.$key.']__'] = $newval; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c7335298bdd..fe4eaffc177 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4691,7 +4691,8 @@ abstract class CommonObject if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) { // If there is an encryption choice, we use it to crypt data before insert - $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + $tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']) + $algo=reset($tmparrays); if ($algo != '') { //global $action; // $action may be 'create', 'update', 'update_extras'... diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4477a4812da..861848e6924 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -235,6 +235,7 @@ class ExtraFields $lengthdb='11'; } elseif ($type=='html') { $typedb='text'; + $lengthdb=$length; } elseif($type=='password') { $typedb='varchar'; $lengthdb='128'; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2d66661c839..f254fe44b9d 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -194,6 +194,7 @@ class FormActions $projectid = $object->fk_project; if ($typeelement == 'project') $projectid = $object->id; + $buttontoaddnewevent=''; if (! empty($conf->agenda->enabled)) { $buttontoaddnewevent = ''; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index e7cd6d447a0..86e0f48c65f 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -164,7 +164,7 @@ class FormWebsite * * @param string $htmlname Name of select zone * @param string $selected Selected value - * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param int $useempty 1=Add an empty value in list * @param string $moreattrib More attributes on HTML select tag * @return void */ @@ -177,9 +177,9 @@ class FormWebsite $arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage'); $out = ''; - $out .= '"; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index fcc3098c730..0f219a032cc 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1288,9 +1288,10 @@ function complete_elementList_with_modules(&$elementList) $modules[$i] = $objMod; $filename[$i]= $modName; - $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module + $orders[$i] = $objMod->family."_".$j; // Sort on family then module number + $dirmod[$i] = $dir; //print "x".$modName." ".$orders[$i]."\n
"; - $dirmod[$i] = $dirroot; + if (! empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 82e9a98d43f..50716c27aca 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -177,6 +177,7 @@ function redirectToContainer($containerref, $containeraliasalt='',$containerid=0 global $db, $website; $newurl = ''; + $result=0; // We make redirect using the alternative alias, we must find the real $containerref if ($containeraliasalt) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 48c35c7143e..db614ed833e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1169,7 +1169,7 @@ class Societe extends CommonObject $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($ref_alias)."'"; if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; @@ -2833,10 +2833,10 @@ class Societe extends CommonObject //Check NIF if (preg_match('/(^[0-9]{8}[A-Z]{1}$)/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 0, 8) % 23, 1)) + return 1; + else + return -1; //algorithm checking type code CIF $sum = $num[2] + $num[4] + $num[6]; @@ -2846,31 +2846,31 @@ class Societe extends CommonObject //Chek special NIF if (preg_match('/^[KLM]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) - return 1; - else - return -1; + if ($num[8] == chr(64 + $n) || $num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr($string, 1, 8) % 23, 1)) + return 1; + else + return -1; //Check CIF if (preg_match('/^[ABCDEFGHJNPQRSUVW]{1}/', $string)) - if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) - return 2; - else - return -2; + if ($num[8] == chr(64 + $n) || $num[8] == substr($n, strlen($n) - 1, 1)) + return 2; + else + return -2; //Check NIE T if (preg_match('/^[T]{1}/', $string)) - if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) - return 3; - else - return -3; + if ($num[8] == preg_match('/^[T]{1}[A-Z0-9]{8}$/', $string)) + return 3; + else + return -3; //Check NIE XYZ if (preg_match('/^[XYZ]{1}/', $string)) - if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) - return 3; - else - return -3; + if ($num[8] == substr('TRWAGMYFPDXBNJZSQVHLCKE', substr(str_replace(array('X','Y','Z'), array('0','1','2'), $string), 0, 8) % 23, 1)) + return 3; + else + return -3; //Can not be verified return -4; @@ -2894,9 +2894,6 @@ class Societe extends CommonObject else { return -1; } - - //Wrong format - return 0; } return $ok; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 3574c95e470..5a46425cb66 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -616,7 +616,7 @@ class Website extends CommonObject // Generate the index.php page to be the home page //------------------------------------------------- - $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl); + $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl); } }