Qual: Fix phan notices (multicurrency,opcache,opensurvey)

This commit is contained in:
MDW 2025-02-08 12:25:38 +01:00
parent fd7fee2e8f
commit 687421d8f0
No known key found for this signature in database
11 changed files with 77 additions and 59 deletions

View File

@ -9,12 +9,12 @@
*/ */
return [ return [
// # Issue statistics: // # Issue statistics:
// PhanTypeMismatchArgument : 2340+ occurrences // PhanTypeMismatchArgument : 2330+ occurrences
// PhanUndeclaredProperty : 530+ occurrences // PhanUndeclaredProperty : 530+ occurrences
// PhanTypeMismatchArgumentNullable : 430+ occurrences // PhanTypeMismatchArgumentNullable : 430+ occurrences
// PhanUndeclaredGlobalVariable : 190+ occurrences // PhanUndeclaredGlobalVariable : 190+ occurrences
// PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences
// PhanPossiblyUndeclaredGlobalVariable : 160+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 150+ occurrences
// PhanTypeMismatchProperty : 130+ occurrences // PhanTypeMismatchProperty : 130+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 120+ occurrences // PhanTypeMismatchArgumentProbablyReal : 120+ occurrences
// PhanPluginUnknownArrayMethodParamType : 110+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences
@ -23,9 +23,9 @@ return [
// PhanTypeInvalidDimOffset : 25+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences
// PhanPluginUndeclaredVariableIsset : 20+ occurrences // PhanPluginUndeclaredVariableIsset : 20+ occurrences
// PhanTypeMismatchDimFetch : 20+ occurrences // PhanTypeMismatchDimFetch : 20+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences // PhanUndeclaredConstant : 15+ occurrences
// PhanTypeComparisonFromArray : 10+ occurrences // PhanTypeComparisonFromArray : 10+ occurrences
// PhanTypeMismatchArgumentNullableInternal : 10+ occurrences
// PhanUndeclaredMethod : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences
// PhanPluginSuspiciousParamPosition : 7 occurrences // PhanPluginSuspiciousParamPosition : 7 occurrences
// PhanPluginUnknownObjectMethodCall : 7 occurrences // PhanPluginUnknownObjectMethodCall : 7 occurrences
@ -588,14 +588,7 @@ return [
'htdocs/multicurrency/class/api_multicurrencies.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/multicurrency/class/api_multicurrencies.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'],
'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument'], 'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument'],
'htdocs/multicurrency/multicurrency_rate.php' => ['PhanTypeMismatchArgument'], 'htdocs/multicurrency/multicurrency_rate.php' => ['PhanTypeMismatchArgument'],
'htdocs/opcachepreload.php' => ['PhanEmptyForeach'], 'htdocs/opensurvey/results.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/opensurvey/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'],
'htdocs/opensurvey/class/opensurveysondage.class.php' => ['PhanTypeMismatchProperty'],
'htdocs/opensurvey/exportcsv.php' => ['PhanTypeMismatchArgument'],
'htdocs/opensurvey/list.php' => ['PhanPluginUndeclaredVariableIsset'],
'htdocs/opensurvey/results.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal', 'PhanUndeclaredGlobalVariable'],
'htdocs/opensurvey/wizard/choix_date.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument'],
'htdocs/opensurvey/wizard/create_survey.php' => ['PhanPossiblyUndeclaredGlobalVariable'],
'htdocs/partnership/class/api_partnerships.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/partnership/class/api_partnerships.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'],
'htdocs/partnership/class/partnership.class.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/class/partnership.class.php' => ['PhanUndeclaredProperty'],
'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'],

View File

@ -5,7 +5,7 @@
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr> * Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -522,12 +522,12 @@ class MultiCurrency extends CommonObject
* *
* @param DoliDB $dbs Object db * @param DoliDB $dbs Object db
* @param string $code Code value search * @param string $code Code value search
* @param int|string $date_document Date from document (propal, order, invoice, ...) * @param int $date_document Date from document (propal, order, invoice, ...)
* *
* @return array{0:int,1:float} [0] => id currency * @return array{0:int,1:float} [0] => id currency
* [1] => rate * [1] => rate
*/ */
public static function getIdAndTxFromCode($dbs, $code, $date_document = '') public static function getIdAndTxFromCode($dbs, $code, $date_document = 0)
{ {
$sql1 = "SELECT m.rowid, mc.rate FROM ".MAIN_DB_PREFIX."multicurrency m"; $sql1 = "SELECT m.rowid, mc.rate FROM ".MAIN_DB_PREFIX."multicurrency m";
@ -699,11 +699,19 @@ class MultiCurrency extends CommonObject
} }
return 1; return 1;
} else { } else {
dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING); if (isset($response->error->info)) {
if ($mode == "cron") { $error_info_syslog = $response->error->info; // @phan-suppress-current-line PhanTypeExpectedObjectPropAccess
$this->output = $langs->trans('multicurrency_syncronize_error', $response->error->info); $error_info = $error_info_syslog;
} else { } else {
setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors'); $error_info_syslog = json_encode($response);
$error_info = "No error information found (see syslog)";
}
dol_syslog("Failed to call endpoint ".$error_info_syslog, LOG_WARNING);
if ($mode == "cron") {
$this->output = $langs->trans('multicurrency_syncronize_error', $error_info);
} else {
setEventMessages($langs->trans('multicurrency_syncronize_error', $error_info), null, 'errors');
} }
return -1; return -1;
} }

View File

@ -12,7 +12,7 @@
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com> * Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -112,10 +112,10 @@ $fieldstosearchall = array(
// Definition of fields for lists // Definition of fields for lists
$arrayfields = array( $arrayfields = array(
'cr.date_sync' => array('label' => 'Date', 'checked' => 1), 'cr.date_sync' => array('label' => 'Date', 'checked' => '1'),
'cr.rate' => array('label' => 'Rate', 'checked' => 1), 'cr.rate' => array('label' => 'Rate', 'checked' => '1'),
'cr.rate_indirect' => array('label' => 'RateIndirect', 'checked' => 0, 'enabled' => (!getDolGlobalString('MULTICURRENCY_USE_RATE_INDIRECT') ? 0 : 1)), 'cr.rate_indirect' => array('label' => 'RateIndirect', 'checked' => '0', 'enabled' => (!getDolGlobalString('MULTICURRENCY_USE_RATE_INDIRECT') ? '0' : '1')),
'm.code' => array('label' => 'Code', 'checked' => 1), 'm.code' => array('label' => 'Code', 'checked' => '1'),
); );

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -27,6 +28,6 @@
$files = array(); /* An array of files you want to preload */ $files = array(); /* An array of files you want to preload */
foreach ($files as $file) { foreach ($files as $file) { // @phan-suppress-current-line PhanEmptyForeach
opcache_compile_file($file); opcache_compile_file($file);
} }

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -61,7 +61,7 @@ if (GETPOST('id')) {
// Initialize objects // Initialize objects
$object = new Opensurveysondage($db); $object = new Opensurveysondage($db);
$result = $object->fetch(0, $numsondage); $result = $object->fetch('', $numsondage);
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
exit; exit;
@ -70,7 +70,7 @@ if ($result <= 0) {
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('surveycard', 'globalcard')); $hookmanager->initHooks(array('surveycard', 'globalcard'));
$expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); $expiredate = dol_mktime(0, 0, 0, GETPOSTINT('expiremonth'), GETPOSTINT('expireday'), GETPOSTINT('expireyear'));
$permissiontoread = $user->hasRight('opensurvey', 'read'); $permissiontoread = $user->hasRight('opensurvey', 'read');
$permissiontoadd = $user->hasRight('opensurvey', 'write'); $permissiontoadd = $user->hasRight('opensurvey', 'write');
@ -201,6 +201,7 @@ if (empty($reshook)) {
*/ */
$form = new Form($db); $form = new Form($db);
$userstatic = null;
if ($object->fk_user_creat) { if ($object->fk_user_creat) {
$userstatic = new User($db); $userstatic = new User($db);
@ -271,7 +272,7 @@ if ($action == 'edit') {
print yn($object->mailsonde); print yn($object->mailsonde);
//If option is active and linked user does not have an email, we show a warning //If option is active and linked user does not have an email, we show a warning
if ($object->fk_user_creat && $object->mailsonde) { if ($object->fk_user_creat && $object->mailsonde && $userstatic !== null) {
if (!$userstatic->email) { if (!$userstatic->email) {
print ' '.img_warning($langs->trans('NoEMail')); print ' '.img_warning($langs->trans('NoEMail'));
} }
@ -330,7 +331,7 @@ print '</td></tr>';
// Author // Author
print '<tr><td>'; print '<tr><td>';
print $langs->trans("Author").'</td><td>'; print $langs->trans("Author").'</td><td>';
if ($object->fk_user_creat > 0) { if ($object->fk_user_creat > 0 && $userstatic !== null) {
print $userstatic->getLoginUrl(-1); print $userstatic->getLoginUrl(-1);
} else { } else {
if ($action == 'edit') { if ($action == 'edit') {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2020-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -60,6 +60,13 @@ class Opensurveysondage extends CommonObject
public $date_m; public $date_m;
/**
* Lines of the survey - Note: the type differs from CommonObjectLine[] !
*
* @var array<array{id_users:int,nom:string,responses:string}>
*/
public $lines;
/** /**
* 'type' field format: * 'type' field format:
* 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]', * 'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',
@ -374,9 +381,9 @@ class Opensurveysondage extends CommonObject
/** /**
* Update object into database * Update object into database
* *
* @param User $user User that modifies * @param User $user User that modifies
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK
*/ */
public function update(User $user, $notrigger = 0) public function update(User $user, $notrigger = 0)
{ {
@ -438,9 +445,9 @@ class Opensurveysondage extends CommonObject
/** /**
* Delete object in database * Delete object in database
* *
* @param User $user User that deletes * @param User $user User that deletes
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
* @param string $numsondage Num sondage admin to delete * @param string $numsondage Num sondage admin to delete
* @return int Return integer <0 if KO, >0 if OK * @return int Return integer <0 if KO, >0 if OK
*/ */
public function delete(User $user, $notrigger = 0, $numsondage = '') public function delete(User $user, $notrigger = 0, $numsondage = '')
@ -534,7 +541,7 @@ class Opensurveysondage extends CommonObject
* @param int<0,2> $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) * @param int<0,2> $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
* @param int<0,1> $notooltip 1=Disable tooltip * @param int<0,1> $notooltip 1=Disable tooltip
* @param string $morecss Add more css on link * @param string $morecss Add more css on link
* @param int<-1,1> $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int<-1,1> $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values when clicking
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
@ -719,8 +726,8 @@ class Opensurveysondage extends CommonObject
/** /**
* Deletes a comment of the poll * Deletes a comment of the poll
* *
* @param int $id_comment Id of the comment * @param int $id_comment Id of the comment
* @return boolean False in case of the query fails, true if it was successful * @return bool False in case of the query fails, true if it was successful
*/ */
public function deleteComment($id_comment) public function deleteComment($id_comment)
{ {
@ -758,7 +765,7 @@ class Opensurveysondage extends CommonObject
/** /**
* Return status label of Order * Return status label of Order
* *
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label if status * @return string Label if status
*/ */
public function getLibStatut($mode) public function getLibStatut($mode)
@ -770,8 +777,8 @@ class Opensurveysondage extends CommonObject
/** /**
* Return label of status * Return label of status
* *
* @param int $status Id status * @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @param int<0,6> $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status * @return string Label of status
*/ */
public function LibStatut($status, $mode) public function LibStatut($status, $mode)
@ -809,7 +816,7 @@ class Opensurveysondage extends CommonObject
/** /**
* Return number of votes done for this survey. * Return number of votes done for this survey.
* *
* @return int Number of votes * @return int<0,max> Number of votes
*/ */
public function countVotes() public function countVotes()
{ {
@ -842,7 +849,7 @@ class Opensurveysondage extends CommonObject
* @param string $filter Filter as an Universal Search string. * @param string $filter Filter as an Universal Search string.
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')' * Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
* @param string $filtermode No more used * @param string $filtermode No more used
* @return array|int int <0 if KO, array of pages if OK * @return array<string,self>|int<-1,-1> int <0 if KO, array of pages if OK
*/ */
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
{ {

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -46,7 +47,7 @@ if (GETPOST('id')) {
// Initialize Objects // Initialize Objects
$object = new Opensurveysondage($db); $object = new Opensurveysondage($db);
$result = $object->fetch(0, $numsondage); $result = $object->fetch('', $numsondage);
if ($result <= 0) { if ($result <= 0) {
dol_print_error(null, 'Failed to get survey id '.$numsondage); dol_print_error(null, 'Failed to get survey id '.$numsondage);
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2013-2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -305,11 +306,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) { if ($search_all) {
// Ensure $fieldstosearchall is set and array $fieldstosearchall = array();
if (!isset($fieldstosearchall) || !is_array($fieldstosearchall)) { // @phan-suppress-next-line PhanEmptyForeach
$fieldstosearchall = array(); foreach ($fieldstosearchall as $key => $val) { // @phpstan-ignore-line
}
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
} }
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).implode(', ', $fieldstosearchall).'</div>';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -51,7 +51,7 @@ $action = GETPOST('action', 'aZ09');
$numsondage = GETPOST("id", 'alphanohtml'); $numsondage = GETPOST("id", 'alphanohtml');
$object = new Opensurveysondage($db); $object = new Opensurveysondage($db);
$result = $object->fetch(0, $numsondage); $result = $object->fetch('', $numsondage);
if ($result <= 0) { if ($result <= 0) {
dol_print_error(null, 'Failed to get survey id '.$numsondage); dol_print_error(null, 'Failed to get survey id '.$numsondage);
} }
@ -115,6 +115,7 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) { // bo
$testmodifier = false; $testmodifier = false;
$testligneamodifier = false; $testligneamodifier = false;
$ligneamodifier = -1; $ligneamodifier = -1;
$modifier = '';
for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nblines; $i++) {
if (GETPOSTISSET('modifierligne'.$i)) { if (GETPOSTISSET('modifierligne'.$i)) {
$ligneamodifier = $i; $ligneamodifier = $i;
@ -226,6 +227,7 @@ if (GETPOSTISSET("ajoutercolonne") && $object->format == "D") {
//on rajoute la valeur dans les valeurs //on rajoute la valeur dans les valeurs
$datesbase = explode(",", $object->sujet); $datesbase = explode(",", $object->sujet);
$taillebase = count($datesbase); $taillebase = count($datesbase);
$cleinsertion = -1;
//recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau //recherche de l'endroit de l'insertion de la nouvelle date dans les dates deja entrées dans le tableau
if ($nouvelledate < $datesbase[0]) { if ($nouvelledate < $datesbase[0]) {
@ -424,13 +426,14 @@ for ($i = 0; $i < $nbcolonnes; $i++) {
*/ */
$form = new Form($db); $form = new Form($db);
$userstatic = null;
if ($object->fk_user_creat) { if ($object->fk_user_creat) {
$userstatic = new User($db); $userstatic = new User($db);
$userstatic->fetch($object->fk_user_creat); $userstatic->fetch($object->fk_user_creat);
} }
$result = $object->fetch(0, $numsondage); $result = $object->fetch('', $numsondage);
if ($result <= 0) { if ($result <= 0) {
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
exit; exit;
@ -538,7 +541,7 @@ print '</td></tr>';
// Author // Author
print '<tr><td>'; print '<tr><td>';
print $langs->trans("Author").'</td><td>'; print $langs->trans("Author").'</td><td>';
if ($object->fk_user_creat) { if ($object->fk_user_creat && $userstatic !== null) {
print $userstatic->getLoginUrl(-1); print $userstatic->getLoginUrl(-1);
} else { } else {
print dol_htmlentities($object->nom_admin); print dol_htmlentities($object->nom_admin);
@ -1064,6 +1067,7 @@ if (empty($testligneamodifier)) {
// Select value of best choice (for checkbox columns only) // Select value of best choice (for checkbox columns only)
$nbofcheckbox = 0; $nbofcheckbox = 0;
$meilleurecolonne = null;
for ($i = 0; $i < $nbcolonnes + 1; $i++) { for ($i = 0; $i < $nbcolonnes + 1; $i++) {
if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) {
$nbofcheckbox++; $nbofcheckbox++;

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -49,7 +49,7 @@ $_SESSION["formatsondage"] = "D";
$erreur = false; $erreur = false;
$erreurNb = 0; $erreurNb = 0;
$choixdate = ''; $choixdate = '';
$errheure = array();
/* /*
* Actions * Actions
@ -60,7 +60,6 @@ if (GETPOST('confirmation')) {
// We save hours entered // We save hours entered
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) { if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) {
$nbofchoice = count($_SESSION["totalchoixjour"]); $nbofchoice = count($_SESSION["totalchoixjour"]);
$errheure = array();
if ($nbofchoice * $_SESSION["nbrecaseshoraires"] > 200) { if ($nbofchoice * $_SESSION["nbrecaseshoraires"] > 200) {
setEventMessages($langs->trans("ErrorFieldTooLong"), null, 'errors'); setEventMessages($langs->trans("ErrorFieldTooLong"), null, 'errors');
@ -148,6 +147,7 @@ if (GETPOST('confirmation')) {
$erreur = true; $erreur = true;
} }
// Suppress notice regarding $_SESSION @phan-suppress-next-line PhanTypeMismatchArgument
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty((string) $j, $_SESSION['horaires'.$i]) === false) { if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty((string) $j, $_SESSION['horaires'.$i]) === false) {
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) { if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) {
$_SESSION["horaires$i"][$j] = ''; $_SESSION["horaires$i"][$j] = '';
@ -523,6 +523,7 @@ for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
if ($i < $premierjourmois) { if ($i < $premierjourmois) {
print '<td class="avant"></td>'."\n"; print '<td class="avant"></td>'."\n";
} else { } else {
$dejafait = null;
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) { if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
$nbofchoice = count($_SESSION["totalchoixjour"]); $nbofchoice = count($_SESSION["totalchoixjour"]);
for ($j = 0; $j < $nbofchoice; $j++) { for ($j = 0; $j < $nbofchoice; $j++) {
@ -589,7 +590,7 @@ if (issetAndNoEmpty('totalchoixjour', $_SESSION) || $erreur) {
//affichage des cases d'horaires //affichage des cases d'horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) { for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
if (isset($errheure[$i][$j]) && $errheure[$i][$j]) { if (isset($errheure[$i][$j]) /* && $errheure[$i][$j] */) {
// When an error is found, the checkbox background is red // When an error is found, the checkbox background is red
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n"; print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
} else { } else {

View File

@ -3,7 +3,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr> * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com> * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -64,6 +64,7 @@ foreach ($session_var as $var) {
// On initialise également les autres variables // On initialise également les autres variables
$cocheplus = ''; $cocheplus = '';
$cochemail = ''; $cochemail = '';
$champdatefin = 0;
// Jump to correct page // Jump to correct page
if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) { if (!empty($creation_sondage_date) || !empty($creation_sondage_autre)) {
@ -181,6 +182,7 @@ if ($_SESSION["mailsonde"]) {
print '<input type="checkbox" id="mailsonde" name="mailsonde" '.$cochemail.'> <label for="mailsonde">'.$langs->trans("ToReceiveEMailForEachVote").'</label><br>'."\n"; print '<input type="checkbox" id="mailsonde" name="mailsonde" '.$cochemail.'> <label for="mailsonde">'.$langs->trans("ToReceiveEMailForEachVote").'</label><br>'."\n";
$allow_comments = '';
if ($_SESSION['allow_comments']) { if ($_SESSION['allow_comments']) {
$allow_comments = 'checked'; $allow_comments = 'checked';
} }
@ -189,6 +191,7 @@ if (GETPOSTISSET('allow_comments')) {
} }
print '<input type="checkbox" id="allow_comments" name="allow_comments" '.$allow_comments.'"> <label for="allow_comments">'.$langs->trans('CanComment').'</label><br>'."\n"; print '<input type="checkbox" id="allow_comments" name="allow_comments" '.$allow_comments.'"> <label for="allow_comments">'.$langs->trans('CanComment').'</label><br>'."\n";
$allow_spy = '';
if ($_SESSION['allow_spy']) { if ($_SESSION['allow_spy']) {
$allow_spy = 'checked'; $allow_spy = 'checked';
} }