Fix warnings

This commit is contained in:
Laurent Destailleur 2022-12-31 12:39:42 +01:00
parent 377ba47763
commit 15c05d9b7d
9 changed files with 57 additions and 54 deletions

View File

@ -429,7 +429,7 @@ class ActionComm extends CommonObject
$now = dol_now(); $now = dol_now();
// Check parameters // Check parameters
if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 if (!isset($this->userownerid) || (string) $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) or > 0
dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING);
$this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined';
return -1; return -1;

View File

@ -1141,24 +1141,24 @@ class ExtraFields
$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>'; $out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
$out .= '<option value="0">&nbsp;</option>'; $out .= '<option value="0">&nbsp;</option>';
foreach ($param['options'] as $key => $val) { foreach ($param['options'] as $key2 => $val2) {
if ((string) $key == '') { if ((string) $key2 == '') {
continue; continue;
} }
$valarray = explode('|', $val); $valarray = explode('|', $val2);
$val = $valarray[0]; $val2 = $valarray[0];
$parent = ''; $parent = '';
if (!empty($valarray[1])) { if (!empty($valarray[1])) {
$parent = $valarray[1]; $parent = $valarray[1];
} }
$out .= '<option value="'.$key.'"'; $out .= '<option value="'.$key2.'"';
$out .= (((string) $value == (string) $key) ? ' selected' : ''); $out .= (((string) $value == (string) $key2) ? ' selected' : '');
$out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); $out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
$out .= '>'; $out .= '>';
if ($langfile && $val) { if ($langfile && $val2) {
$out .= $langs->trans($val); $out .= $langs->trans($val2);
} else { } else {
$out .= $val; $out .= $val2;
} }
$out .= '</option>'; $out .= '</option>';
} }

View File

@ -135,13 +135,13 @@ if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 ||
$textforlistofdirs = '<!-- Directory scanned -->'."\n"; $textforlistofdirs = '<!-- Directory scanned -->'."\n";
$listofmodules = array(); $listofmodules = array();
$i = 0; $i = 0;
foreach ($dirsrootforscan as $dirread) { foreach ($dirsrootforscan as $tmpdirread) {
$moduletype = 'external'; $moduletype = 'external';
if ($dirread == DOL_DOCUMENT_ROOT) { if ($tmpdirread == DOL_DOCUMENT_ROOT) {
$moduletype = 'internal'; $moduletype = 'internal';
} }
$dirsincustom = dol_dir_list($dirread, 'directories'); $dirsincustom = dol_dir_list($tmpdirread, 'directories');
if (is_array($dirsincustom) && count($dirsincustom) > 0) { if (is_array($dirsincustom) && count($dirsincustom) > 0) {
foreach ($dirsincustom as $dircustomcursor) { foreach ($dirsincustom as $dircustomcursor) {
$fullname = $dircustomcursor['fullname']; $fullname = $dircustomcursor['fullname'];
@ -170,7 +170,7 @@ foreach ($dirsrootforscan as $dirread) {
'modulenamewithcase'=>$modulenamewithcase, 'modulenamewithcase'=>$modulenamewithcase,
'moduledescriptorrelpath'=> $moduledescriptorrelpath, 'moduledescriptorrelpath'=> $moduledescriptorrelpath,
'moduledescriptorfullpath'=>$moduledescriptorfullpath, 'moduledescriptorfullpath'=>$moduledescriptorfullpath,
'moduledescriptorrootpath'=>$dirread, 'moduledescriptorrootpath'=>$tmpdirread,
'moduletype'=>$moduletype 'moduletype'=>$moduletype
); );
} }
@ -200,8 +200,8 @@ foreach ($dirsrootforscan as $dirread) {
} else { } else {
$textforlistofdirs .= ', '; $textforlistofdirs .= ', ';
} }
$textforlistofdirs .= '<strong class="wordbreakimp">'.$dirread.'</strong>'; $textforlistofdirs .= '<strong class="wordbreakimp">'.$tmpdirread.'</strong>';
if ($dirread == DOL_DOCUMENT_ROOT) { if ($tmpdirread == DOL_DOCUMENT_ROOT) {
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) { if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL")); $textforlistofdirs .= $form->textwithpicto('', $langs->trans("ConstantIsOn", "MAIN_FEATURES_LEVEL"));
} }

View File

@ -148,17 +148,17 @@ if (empty($reshook)) {
$objectbomchildline = new BOMLine($db); $objectbomchildline = new BOMLine($db);
foreach ($TBomLineId as $id_bom_line) { foreach ($TBomLineId as $id_bom_line) {
$object = new Mo($db); $object = new Mo($db); // modified by the actions_addupdatedelete.inc.php
$objectbomchildline->fetch($id_bom_line); $objectbomchildline->fetch($id_bom_line);
$TMoLines = $moline->fetchAll('DESC', 'rowid', '1', '', array('origin_id' => $id_bom_line)); $TMoLines = $moline->fetchAll('DESC', 'rowid', '1', '', array('origin_id' => $id_bom_line));
foreach ($TMoLines as $moline) { foreach ($TMoLines as $tmpmoline) {
$_POST['fk_bom'] = $objectbomchildline->fk_bom_child; $_POST['fk_bom'] = $objectbomchildline->fk_bom_child;
$_POST['fk_parent_line'] = $moline->id; $_POST['fk_parent_line'] = $tmpmoline->id;
$_POST['qty'] = $moline->qty; $_POST['qty'] = $tmpmoline->qty;
$_POST['fk_product'] = $moline->fk_product; $_POST['fk_product'] = $tmpmoline->fk_product;
} }
include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';

View File

@ -266,15 +266,15 @@ if ($mode == 'config' && $user->admin) {
$dirmodels = array('/core/modules/printing/'); $dirmodels = array('/core/modules/printing/');
} }
foreach ($result as $driver) { foreach ($result as $tmpdriver) {
foreach ($dirmodels as $dir) { foreach ($dirmodels as $dir) {
if (file_exists(dol_buildpath($dir, 0).$driver.'.modules.php')) { if (file_exists(dol_buildpath($dir, 0).$tmpdriver.'.modules.php')) {
$classfile = dol_buildpath($dir, 0).$driver.'.modules.php'; $classfile = dol_buildpath($dir, 0).$tmpdriver.'.modules.php';
break; break;
} }
} }
require_once $classfile; require_once $classfile;
$classname = 'printing_'.$driver; $classname = 'printing_'.$tmpdriver;
$printer = new $classname($db); $printer = new $classname($db);
$langs->load($printer::LANGFILE); $langs->load($printer::LANGFILE);
//print '<pre>'.print_r($printer, true).'</pre>'; //print '<pre>'.print_r($printer, true).'</pre>';

View File

@ -106,8 +106,8 @@ if ($action == 'other' && GETPOST('value_PRODUIT_MULTIPRICES_LIMIT') > 0) {
} }
if ($action == 'other') { if ($action == 'other') {
$princingrules = GETPOST('princingrule', 'alpha'); $princingrules = GETPOST('princingrule', 'alpha');
foreach ($select_pricing_rules as $rule => $label) { // Loop on each possible mode foreach ($select_pricing_rules as $tmprule => $tmplabel) { // Loop on each possible mode
if ($rule == $princingrules) { // We are on selected rule, we enable it if ($tmprule == $princingrules) { // We are on selected rule, we enable it
if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually if ($princingrules == 'PRODUCT_PRICE_UNIQ') { // For this case, we disable entries manually
$res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_MULTIPRICES', 0, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'PRODUIT_CUSTOMER_PRICES_BY_QTY', 0, 'chaine', 0, '', $conf->entity);
@ -119,10 +119,9 @@ if ($action == 'other') {
$res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, $rulesselected, 1, 'chaine', 0, '', $conf->entity);
} }
} }
} else // We clear this mode } else { // We clear this mode
{ if (strpos($tmprule, '&') === false) {
if (strpos($rule, '&') === false) { $res = dolibarr_set_const($db, $tmprule, 0, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, $rule, 0, 'chaine', 0, '', $conf->entity);
} }
} }
} }

View File

@ -102,6 +102,8 @@ if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) {
$object = new Task($db); $object = new Task($db);
$error = 0;
/* /*
* Actions * Actions
@ -201,10 +203,10 @@ if ($action == 'addtime' && $user->rights->projet->lire) {
if (empty($timetoadd)) { if (empty($timetoadd)) {
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
} else { } else {
foreach ($timetoadd as $taskid => $value) { // Loop on each task foreach ($timetoadd as $tmptaskid => $tmpvalue) { // Loop on each task
$updateoftaskdone = 0; $updateoftaskdone = 0;
foreach ($value as $key => $val) { // Loop on each day foreach ($tmpvalue as $key => $val) { // Loop on each day
$amountoadd = $timetoadd[$taskid][$key]; $amountoadd = $timetoadd[$tmptaskid][$key];
if (!empty($amountoadd)) { if (!empty($amountoadd)) {
$tmpduration = explode(':', $amountoadd); $tmpduration = explode(':', $amountoadd);
$newduration = 0; $newduration = 0;
@ -219,8 +221,8 @@ if ($action == 'addtime' && $user->rights->projet->lire) {
} }
if ($newduration > 0) { if ($newduration > 0) {
$object->fetch($taskid); $object->fetch($tmptaskid);
$object->progress = GETPOST($taskid.'progress', 'int'); $object->progress = GETPOST($tmptaskid.'progress', 'int');
$object->timespent_duration = $newduration; $object->timespent_duration = $newduration;
$object->timespent_fk_user = $usertoprocess->id; $object->timespent_fk_user = $usertoprocess->id;
$object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd'); $object->timespent_date = dol_time_plus_duree($firstdaytoshow, $key, 'd');
@ -239,11 +241,11 @@ if ($action == 'addtime' && $user->rights->projet->lire) {
} }
if (!$updateoftaskdone) { // Check to update progress if no update were done on task. if (!$updateoftaskdone) { // Check to update progress if no update were done on task.
$object->fetch($taskid); $object->fetch($tmptaskid);
//var_dump($object->progress); //var_dump($object->progress);
//var_dump(GETPOST($taskid . 'progress', 'int')); exit; //var_dump(GETPOST($tmptaskid . 'progress', 'int')); exit;
if ($object->progress != GETPOST($taskid.'progress', 'int')) { if ($object->progress != GETPOST($tmptaskid.'progress', 'int')) {
$object->progress = GETPOST($taskid.'progress', 'int'); $object->progress = GETPOST($tmptaskid.'progress', 'int');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');

View File

@ -152,6 +152,7 @@ $search_array_options = array();
$search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_'); $search_array_options_project = $extrafields->getOptionalsFromPost('projet', '', 'search_');
$search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_'); $search_array_options_task = $extrafields->getOptionalsFromPost('projet_task', '', 'search_task_');
$error = 0;
/* /*
@ -263,10 +264,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac
if (empty($timetoadd)) { if (empty($timetoadd)) {
setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors'); setEventMessages($langs->trans("ErrorTimeSpentIsEmpty"), null, 'errors');
} else { } else {
foreach ($timetoadd as $taskid => $value) { // Loop on each task foreach ($timetoadd as $tmptaskid => $tmpvalue) { // Loop on each task
$updateoftaskdone = 0; $updateoftaskdone = 0;
foreach ($value as $key => $val) { // Loop on each day foreach ($tmpvalue as $key => $val) { // Loop on each day
$amountoadd = $timetoadd[$taskid][$key]; $amountoadd = $timetoadd[$tmptaskid][$key];
if (!empty($amountoadd)) { if (!empty($amountoadd)) {
$tmpduration = explode(':', $amountoadd); $tmpduration = explode(':', $amountoadd);
$newduration = 0; $newduration = 0;
@ -281,10 +282,10 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac
} }
if ($newduration > 0) { if ($newduration > 0) {
$object->fetch($taskid); $object->fetch($tmptaskid);
if (GETPOSTISSET($taskid.'progress')) { if (GETPOSTISSET($tmptaskid.'progress')) {
$object->progress = GETPOST($taskid.'progress', 'int'); $object->progress = GETPOST($tmptaskid.'progress', 'int');
} else { } else {
unset($object->progress); unset($object->progress);
} }
@ -308,11 +309,11 @@ if ($action == 'addtime' && $user->rights->projet->lire && GETPOST('formfilterac
} }
if (!$updateoftaskdone) { // Check to update progress if no update were done on task. if (!$updateoftaskdone) { // Check to update progress if no update were done on task.
$object->fetch($taskid); $object->fetch($tmptaskid);
//var_dump($object->progress); //var_dump($object->progress);
//var_dump(GETPOST($taskid . 'progress', 'int')); exit; //var_dump(GETPOST($tmptaskid . 'progress', 'int')); exit;
if ($object->progress != GETPOST($taskid.'progress', 'int')) { if ($object->progress != GETPOST($tmptaskid.'progress', 'int')) {
$object->progress = GETPOST($taskid.'progress', 'int'); $object->progress = GETPOST($tmptaskid.'progress', 'int');
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) { if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');

View File

@ -64,3 +64,4 @@ exclude:
- name: PhpArrayWriteIsNotUsedInspection - name: PhpArrayWriteIsNotUsedInspection
- name: PhpUndefinedNamespaceInspection - name: PhpUndefinedNamespaceInspection
- name: PhpArraySearchInBooleanContextInspection - name: PhpArraySearchInBooleanContextInspection
- name: PhpPropertyOnlyWrittenInspection