Merge pull request #33249 from mdeweerd/phan/website

Qual: Fix phan notices (website)
This commit is contained in:
Laurent Destailleur
2025-03-01 00:41:03 +01:00
committed by GitHub
19 changed files with 82 additions and 77 deletions

View File

@@ -365,13 +365,11 @@ return [
'htdocs/core/lib/images.lib.php' => ['PhanTypeMismatchArgumentNullable'],
'htdocs/core/lib/invoice.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/loan.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/modulebuilder.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/pdf.lib.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/lib/product.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/project.lib.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/core/lib/security.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/sendings.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/website.lib.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/lib/xcal.lib.php' => ['PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'],
'htdocs/core/login/functions_dolibarr.php' => ['PhanTypeMismatchArgument'],
'htdocs/core/login/functions_ldap.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
@@ -653,9 +651,6 @@ return [
'htdocs/webservices/server_supplier_invoice.php' => ['PhanUndeclaredProperty'],
'htdocs/webservices/server_thirdparty.php' => ['PhanUndeclaredProperty'],
'htdocs/webservices/server_user.php' => ['PhanUndeclaredProperty'],
'htdocs/website/class/website.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullableInternal'],
'htdocs/website/index.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
'htdocs/website/samples/wrapper.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
'htdocs/website/websiteaccount_card.php' => ['PhanUndeclaredProperty'],
'htdocs/workstation/class/workstation.class.php' => ['PhanUndeclaredProperty'],
'htdocs/workstation/workstation_card.php' => ['PhanUndeclaredProperty'],

View File

@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2024 Alexandre Spangaro <aspangaro@easya.solutions>
* 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
* it under the terms of the GNU General Public License as published by
@@ -67,7 +67,7 @@ $actl[1] = img_picto($langs->trans("Activated"), 'switch_on', 'class="size15x"')
$listoffset = GETPOST('listoffset', 'alpha');
$listlimit = GETPOSTINT('listlimit') > 0 ? GETPOSTINT('listlimit') : 1000;
$sortfield = GETPOST("sortfield", 'aZ09comma');
$sortfield = (string) GETPOST("sortfield", 'aZ09comma');
$sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {

View File

@@ -5,6 +5,7 @@
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* 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
* it under the terms of the GNU General Public License as published by
@@ -273,7 +274,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("MembersShowMembershipTypesTable");
print '</td><td>';
print $form->selectyesno("MEMBER_SHOW_TABLE", !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
print $form->selectyesno("MEMBER_SHOW_TABLE", (int) !$skiptable, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
print "</td></tr>\n";
// Show "vote allowed" setting for membership types
@@ -281,7 +282,7 @@ if (getDolGlobalString('MEMBER_ENABLE_PUBLIC')) {
print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("MembersShowVotesAllowed");
print '</td><td>';
print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
print $form->selectyesno("MEMBER_SHOW_VOTE_ALLOWED", (int) !$hidevoteallowed, 1, false, 0, 1); // Reverse the logic "hide -> show" for retrocompatibility
print "</td></tr>\n";
// Jump to an online payment page

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -258,7 +258,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
// Modifie valeur des champs
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
$sql .= $tabrowid[$id]."=";
$sql .= "'".$db->escape($rowid)."', ";
$sql .= "'".$db->escape((string) $rowid)."', ";
}
$i = 0;
foreach ($listfieldmodify as $field) {

View File

@@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* it under the terms of the GNU General Public License as published by
@@ -72,7 +73,7 @@ top_httphead();
if (!empty($action) && $action === 'updatedElementContent' && $usercanmodify && !empty($content) && !empty($element_id) && !empty($website_ref) && !empty($page_id)) {
// Page object
$objectpage = new WebsitePage($db);
$res = $objectpage->fetch($page_id);
$res = $objectpage->fetch((int) $page_id);
if (!$res) {
print "Cannot find page with ID = " . $page_id . ".";
exit;

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* it under the terms of the GNU General Public License as published by
@@ -258,7 +258,7 @@ class FormWebsite
* @param int<0,1> $showempty Show empty record
* @param string $action Action on page that use this select list
* @param string $morecss More CSS
* @param null|string[] $excludeids Exclude some ID in list
* @param ?array<int|string> $excludeids Exclude some ID in list
* @return string HTML select component with list of block containers
*/
public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200', $excludeids = null)

View File

@@ -5,7 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024-2025 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -338,7 +338,7 @@ interface Database
* Create a table into database
*
* @param string $table Name of table
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param array<string,array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Name of the field that will be the primary key
* @param string $type Type of the table
* @param ?array<string,mixed> $unique_keys Associative array Name of fields that will be unique key => value

View File

@@ -825,7 +825,7 @@ class DoliDBMysqli extends DoliDB
* Create a table into database
*
* @param string $table Name of table
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur

View File

@@ -1058,7 +1058,7 @@ class DoliDBPgsql extends DoliDB
* Create a table into database
*
* @param string $table Nom de la table
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur

View File

@@ -5,7 +5,7 @@
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2024-2025 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -966,7 +966,7 @@ class DoliDBSqlite3 extends DoliDB
* Create a table into database
*
* @param string $table Nom de la table
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,value?:string,attribute?:string,null?:string,extra?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param array<string,array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int|string,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>,value?:string,attribute?:string,null?:string,extra?:string}> $fields Tableau associatif [nom champ][tableau des descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur

View File

@@ -4,7 +4,7 @@
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
* 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -1380,7 +1380,7 @@ function unActivateModule($value, $requiredby = 1)
* @param string[] $tabrowid Tabrowid
* @param bool[] $tabcond Tabcond
* @param array<array<string,string>> $tabhelp Tabhelp
* @param array<string,array<string,array<string,string>>> $tabcomplete Tab complete (will replace all other in future). Key is table name.
* @param array<string|int,array<int|string,string|array<string,string>>> $tabcomplete Tab complete (will replace all other in future). Key is table name.
* @return int 1
*/
function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tabsql, &$tabsqlsort, &$tabfield, &$tabfieldvalue, &$tabfieldinsert, &$tabrowid, &$tabcond, &$tabhelp, &$tabcomplete)

View File

@@ -6,7 +6,7 @@
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* 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>
*
* 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
@@ -685,7 +685,7 @@ function dol_fileperm($pathoffile)
* Make replacement of strings into a file.
*
* @param string $srcfile Source file (can't be a directory)
* @param array<string,string> $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...)
* @param array<string,string|int> $arrayreplacement Array with strings to replace. Example: array('valuebefore'=>'valueafter', ...)
* @param string $destfile Destination file (can't be a directory). If empty, will be same than source file.
* @param string $newmask Mask for new file. '0' by default means getDolGlobalString('MAIN_UMASK'). Example: '0666'.
* @param int $indexdatabase 1=index new file into database.

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2009-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -143,10 +143,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$texttoinsert .= " 'notnull' => ".(empty($val['notnull']) ? 0 : (int) $val['notnull']).",";
$texttoinsert .= ' "visible" => "'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",';
if (!empty($val['noteditable'])) {
$texttoinsert .= ' "noteditable" => "'.dol_escape_php($val['noteditable']).'",';
$texttoinsert .= ' "noteditable" => "'.dol_escape_php((string) $val['noteditable']).'",';
}
if (!empty($val['alwayseditable'])) {
$texttoinsert .= ' "alwayseditable" => "'.dol_escape_php($val['alwayseditable']).'",';
$texttoinsert .= ' "alwayseditable" => "'.dol_escape_php((string) $val['alwayseditable']).'",';
}
if (array_key_exists('default', $val) && (!empty($val['default']) || $val['default'] === '0')) {
$texttoinsert .= ' "default" => "'.dol_escape_php($val['default']).'",';
@@ -555,7 +555,7 @@ function deletePerms($file)
* @param int|string $a value 1
* @param int|string $b value 2
* @return int<-1,1> <=0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
*/
*/
function compareFirstValue($a, $b)
{
return strcmp($a[0], $b[0]);

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* it under the terms of the GNU General Public License as published by
@@ -530,7 +530,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$tmpwebsitepage = new WebsitePage($db);
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$result = $tmpwebsitepage->fetch(0, $website->id, '', $containeraliasalt);
$result = $tmpwebsitepage->fetch(0, (string) $website->id, '', $containeraliasalt);
if ($result > 0) {
$containerref = $tmpwebsitepage->pageurl;
} else {
@@ -554,7 +554,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$tmpwebsitepage = new WebsitePage($db);
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$result = $tmpwebsitepage->fetch(0, $website->id, $containerref);
$result = $tmpwebsitepage->fetch(0, (string) $website->id, $containerref);
unset($tmpwebsitepage);
}
if ($result > 0) {
@@ -622,7 +622,7 @@ function includeContainer($containerref, $once = 0, $cachedelay = 0, $cachekey =
$fullpathcache = '';
// If we ask to use the cache delay
if ($cachedelay > 0 && !getDolGlobalString("WEBSITE_DISABLE_CACHE_OF_CONTAINERS")) {
$fullpathcache = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/temp/'.$websitekey.'-'.$websitepage->id.'-'.$containerref.($cachekey ? '-'.$cachekey: '').'.cache';
$fullpathcache = DOL_DATA_ROOT.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/temp/'.$websitekey.'-'.$websitepage->id.'-'.$containerref.($cachekey ? '-'.$cachekey : '').'.cache';
}
if (empty($includehtmlcontentopened)) {
@@ -638,7 +638,7 @@ function includeContainer($containerref, $once = 0, $cachedelay = 0, $cachekey =
// We don't print info messages for pages of type library or service
if (!empty($websitepage->type_container) && !in_array($websitepage->type_container, array('library', 'service'))) {
print "\n".'<!-- include '.$websitekey.'/'.$containerref.($cachekey ? ' '.$cachekey: '').(is_object($websitepage) ? ' parent id='.$websitepage->id : '').' level='.$includehtmlcontentopened.' -->'."\n";
print "\n".'<!-- include '.$websitekey.'/'.$containerref.($cachekey ? ' '.$cachekey : '').(is_object($websitepage) ? ' parent id='.$websitepage->id : '').' level='.$includehtmlcontentopened.' -->'."\n";
}
$tmpoutput = '';

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024-2025 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>
*
* This program is free software; you can redistribute it and/or modify
@@ -496,7 +496,7 @@ class TraceableDB extends DoliDB
* Create a table into database
*
* @param string $table Name of table
* @param array<string,array{type:string,label:string,enabled:int<0,2>|string,position:int,notnull?:int,visible:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param array<string,array{type:string,label?:string,enabled?:int<0,2>|string,position?:int,notnull?:int,visible?:int<-2,5>|string,alwayseditable?:int<0,1>,noteditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int<0,1>,isameasure?:int<0,1>,css?:string,csslist?:string,help?:string,showoncombobox?:int<0,2>,disabled?:int<0,1>,arrayofkeyval?:array<int,string>,autofocusoncreate?:int<0,1>,comment?:string,copytoclipboard?:int<1,2>,validate?:int<0,1>}> $fields Associative table [field name][table of descriptions]
* @param string $primary_key Nom du champ qui sera la clef primaire
* @param string $type Type de la table
* @param ?array<string,mixed> $unique_keys Tableau associatifs Nom de champs qui seront clef unique => valeur

View File

@@ -66,7 +66,7 @@ $cancel = GETPOST('cancel', 'alpha');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'aZ09');
$module = GETPOST('module', 'alpha');
$module = (string) GETPOST('module', 'alpha');
$tab = (string) GETPOST('tab', 'aZ09');
$tabobj = GETPOST('tabobj', 'alpha');
$tabdic = GETPOST('tabdic', 'alpha');
@@ -90,12 +90,12 @@ $find = GETPOST('find', 'alpha');
$modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha'));
$objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha'));
$dicname = dol_sanitizeFileName(GETPOST('dicname', 'alpha'));
$editorname = GETPOST('editorname', 'alpha');
$editorurl = GETPOST('editorurl', 'alpha');
$version = GETPOST('version', 'alpha');
$family = GETPOST('family', 'alpha');
$picto = GETPOST('idpicto', 'alpha');
$idmodule = GETPOST('idmodule', 'alpha');
$editorname = (string) GETPOST('editorname', 'alpha');
$editorurl = (string) GETPOST('editorurl', 'alpha');
$version = (string) GETPOST('version', 'alpha');
$family = (string) GETPOST('family', 'alpha');
$picto = (string) GETPOST('idpicto', 'alpha');
$idmodule = (string) GETPOST('idmodule', 'alpha');
$format = ''; // Prevent undefined in css tab
// Security check
@@ -418,7 +418,7 @@ if ($dirins && $action == 'initmodule' && $modulename && $user->hasRight("module
}
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); // @phpstan-ignore-line
//var_dump($result);
if ($result < 0) {
setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors');
@@ -1655,7 +1655,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname && $user->hasRi
$arrayreplacement['---Replace with your own copyright and developer email---'] = dol_print_date($now, '%Y').' ' . getDolGlobalString('MODULEBUILDER_SPECIFIC_AUTHOR');
}
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); // @phpstan-ignore-line
//var_dump($result);
if ($result < 0) {
setEventMessages($langs->trans("ErrorFailToMakeReplacementInto", $phpfileval['fullname']), null, 'errors');
@@ -3297,7 +3297,7 @@ $h++;
$linktoenabledisable = '';
if (is_array($listofmodules) && count($listofmodules) > 0) {
if (/* is_array($listofmodules) && */ count($listofmodules) > 0) {
// Define $linktoenabledisable
$modulelowercase = strtolower($module);

View File

@@ -4,7 +4,7 @@
* Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 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
* it under the terms of the GNU General Public License as published by
@@ -823,7 +823,7 @@ class Website extends CommonObject
dol_delete_file($filetplold);
// Create new file
$objectpagenew = $objectpageold->createFromClone($user, $pageid, $objectpageold->pageurl, '', 0, $object->id, 1);
$objectpagenew = $objectpageold->createFromClone($user, $pageid, $objectpageold->pageurl, '', 0, $object->id, '1');
//print $pageid.' = '.$objectpageold->pageurl.' -> '.$objectpagenew->id.' = '.$objectpagenew->pageurl.'<br>';
if (is_object($objectpagenew) && $objectpagenew->pageurl) {
@@ -1170,7 +1170,7 @@ class Website extends CommonObject
$line .= "'".$this->db->escape($objectpageold->lang)."', ";
$line .= "'".$this->db->escape($objectpageold->image)."', ";
$line .= "'".$this->db->escape($objectpageold->keywords)."', ";
$line .= "'".$this->db->escape($objectpageold->status)."', ";
$line .= "'".$this->db->escape((string) $objectpageold->status)."', ";
$line .= "'".$this->db->idate($objectpageold->date_creation)."', ";
$line .= "'".$this->db->idate($objectpageold->date_modification)."', ";
$line .= ($objectpageold->import_key ? "'".$this->db->escape((string) $objectpageold->import_key)."'" : "null").", ";
@@ -1219,7 +1219,7 @@ class Website extends CommonObject
//var_dump($this->fk_default_home.' - '.$objectpageold->id.' - '.$objectpageold->newid);exit;
if ($this->fk_default_home > 0 && ($objectpageold->id == $this->fk_default_home) && ($objectpageold->newid > 0)) { // This is the page that is set as the home page
// Warning: We must keep llx_ here. It is a generic SQL.
$line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape($objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;";
$line = "UPDATE llx_website SET fk_default_home = ".($objectpageold->newid > 0 ? $this->db->escape((string) $objectpageold->newid)."__+MAX_llx_website_page__" : "null")." WHERE rowid = __WEBSITE_ID__;";
$line .= "\n";
fwrite($fp, $line);
}
@@ -1698,7 +1698,7 @@ class Website extends CommonObject
if ($languagecodeselected) {
// Convert $languagecodeselected into a long language code
if (strlen($languagecodeselected) == 2) {
$languagecodeselected = (empty($arrayofspecialmainlanguages[$languagecodeselected]) ? $languagecodeselected.'_'.strtoupper($languagecodeselected) : $arrayofspecialmainlanguages[$languagecodeselected]);
$languagecodeselected = (string) (empty($arrayofspecialmainlanguages[$languagecodeselected]) ? $languagecodeselected.'_'.strtoupper($languagecodeselected) : $arrayofspecialmainlanguages[$languagecodeselected]);
}
$countrycode = strtolower(substr($languagecodeselected, -2));

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2016-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@@ -158,7 +158,7 @@ if (GETPOST('refreshsite') || GETPOST('refreshsite_x') || GETPOST('refreshsite.x
// Load variable for pagination
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortfield = (string) GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
if (empty($page) || $page == -1) {
@@ -167,8 +167,6 @@ if (empty($page) || $page == -1) {
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
//if (! $sortfield) $sortfield='name';
//if (! $sortorder) $sortorder='ASC';
if (empty($action)) {
$action = 'preview';
@@ -208,12 +206,12 @@ if (($pageid > 0 || $pageref) && $action != 'addcontainer') {
if ($res >= 0 && $object->id > 0) {
if ($objectpage->fk_website != $object->id) { // We have a bad page that does not belong to web site
if ($object->fk_default_home > 0) {
$res = $objectpage->fetch($object->fk_default_home, $object->id, ''); // We search first page of web site
$res = $objectpage->fetch($object->fk_default_home, (string) $object->id, ''); // We search first page of web site
if ($res > 0) {
$pageid = $object->fk_default_home;
}
} else {
$res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site
$res = $objectpage->fetch(0, (string) $object->id, ''); // We search first page of web site
if ($res == 0) { // Page was not found, we reset it
$objectpage = new WebsitePage($db);
} else { // We found a page, we set pageid to it.
@@ -343,7 +341,9 @@ if (GETPOST('optionsitefiles')) {
$algo .= 'sitefiles';
}
if (empty($sortfield)) {
$searchkey = GETPOST('searchstring', 'restricthtmlallowunvalid'); // or 'none', must be same as $searchstring
if ($sortfield == '') {
if ($action == 'file_manager') { // Test on permission not required
$sortfield = 'name';
$sortorder = 'ASC';
@@ -352,13 +352,15 @@ if (empty($sortfield)) {
$sortorder = 'ASC';
}
}
'@phan-var-force string $sortfield';
$searchkey = GETPOST('searchstring', 'restricthtmlallowunvalid'); // or 'none', must be same then $searchstring
$langcode = '';
$containertype = '';
$otherfilters = array();
if ($action == 'replacesite' || $mode == 'replacesite') { // Test on permission not required
$containertype = GETPOST('optioncontainertype', 'aZ09') != '-1' ? GETPOST('optioncontainertype', 'aZ09') : '';
$langcode = GETPOST('optionlanguage', 'aZ09');
$otherfilters = array();
if (GETPOSTINT('optioncategory') > 0) {
$otherfilters['category'] = GETPOSTINT('optioncategory');
}
@@ -723,6 +725,7 @@ if ($action == 'addsite' && $usercanedit) {
setEventMessages($langs->transnoentities("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("Ref")), null, 'errors');
}
$tmpobject = null;
if (!$error) {
$arrayotherlang = explode(',', GETPOST('WEBSITE_OTHERLANG', 'alphanohtml'));
foreach ($arrayotherlang as $key => $val) {
@@ -750,7 +753,7 @@ if ($action == 'addsite' && $usercanedit) {
}
}
if (!$error) {
if (!$error && $tmpobject !== null) {
$db->commit();
setEventMessages($langs->trans("SiteAdded", $object->ref), null, 'mesgs');
$action = '';
@@ -800,6 +803,8 @@ if ($action == 'addcontainer' && $usercanedit) {
}
$pageurl = '';
$urltograbdirwithoutslash = '';
$urltograbdirrootwithoutslash = '';
if (!$error) {
// Clean url to grab, so url can be
// http://www.example.com/ or http://www.example.com/dir1/ or http://www.example.com/dir1/aaa
@@ -820,7 +825,7 @@ if ($action == 'addcontainer' && $usercanedit) {
// Check pageurl is not already used
if ($pageurl) {
$tmpwebsitepage = new WebsitePage($db);
$result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
$result = $tmpwebsitepage->fetch(0, (string) $object->id, $pageurl);
if ($result > 0) {
setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors');
$error++;
@@ -1140,7 +1145,7 @@ if ($action == 'addcontainer' && $usercanedit) {
$action = 'createcontainer';
break;
} else {
$result = $websitepagetemp->fetch(0, $object->id, $aliastotest);
$result = $websitepagetemp->fetch(0, (string) $object->id, $aliastotest);
if ($result < 0) {
$error++;
$langs->load("errors");
@@ -1448,7 +1453,7 @@ if (GETPOSTISSET('pageid') && $action == 'delete' && $permissiontodelete && !GET
$res = $object->fetch(0, $websitekey);
$website = $object;
$res = $objectpage->fetch($pageid, $object->id);
$res = $objectpage->fetch($pageid, (string) $object->id);
if ($res > 0) {
$res = $objectpage->delete($user);
@@ -2105,7 +2110,7 @@ if ($action == 'updatemeta' && $usercanedit) {
$action = 'editmeta';
}
$res = $objectpage->fetch($pageid, $object->id);
$res = $objectpage->fetch($pageid, (string) $object->id);
if ($res <= 0) {
$error++;
setEventMessages('Page not found '.$objectpage->error, $objectpage->errors, 'errors');
@@ -2114,7 +2119,7 @@ if ($action == 'updatemeta' && $usercanedit) {
// Check alias not exists
if (!$error && GETPOST('WEBSITE_PAGENAME', 'alpha')) {
$websitepagetemp = new WebsitePage($db);
$result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha'));
$result = $websitepagetemp->fetch(-1 * $objectpage->id, (string) $object->id, GETPOST('WEBSITE_PAGENAME', 'alpha'));
if ($result < 0) {
$error++;
$langs->load("errors");
@@ -2145,7 +2150,7 @@ if ($action == 'updatemeta' && $usercanedit) {
$action = 'editmeta';
break;
} else {
$result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
$result = $websitepagetemp->fetch(-1 * $objectpage->id, (string) $object->id, $aliastotest);
if ($result < 0) {
$error++;
$langs->load("errors");
@@ -2446,7 +2451,7 @@ if ((($action == 'updatesource' || $action == 'updatecontent' || $action == 'con
$res = $objectpage->fetch($object->fk_default_home);
}
if (!($res > 0)) {
$res = $objectpage->fetch(0, $object->id);
$res = $objectpage->fetch(0, (string) $object->id);
}
}
}
@@ -2927,7 +2932,7 @@ if ($action == 'generatesitemaps' && $usercanedit) {
// URL of sitemaps must end with trailing slash if page is ''
$loc = $domtree->createElement('loc', $domainname.'/'.$pageurl);
$lastmod = $domtree->createElement('lastmod', dol_print_date($db->jdate(dol_now()), 'dayrfc', 'gmt'));
$lastmod = $domtree->createElement('lastmod', dol_print_date(dol_now(), 'dayrfc', 'gmt'));
$url->appendChild($loc);
$url->appendChild($lastmod);
@@ -3152,8 +3157,8 @@ if ($action != 'preview' && $action != 'editcontent' && $action != 'editsource'
}
$disabled = '';
if (!GETPOST('hide_websitemenu')) {
$disabled = '';
if (!$user->hasRight('website', 'write')) {
$disabled = ' disabled="disabled"';
}
@@ -3651,7 +3656,7 @@ if (!GETPOST('hide_websitemenu')) {
}
$formquestion = array(
array('type' => 'hidden', 'name' => 'sourcepageurl', 'value' => $objectpage->pageurl),
array('type' => 'other', 'tdclass' => 'fieldrequired', 'name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)),
array('type' => 'other', 'tdclass' => 'fieldrequired', 'name' => 'newwebsite', 'label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite((string) $object->id, 'newwebsite', 0)),
array('type' => 'text', 'tdclass' => 'maxwidth200 fieldrequired', 'moreattr' => 'autofocus="autofocus"', 'name' => 'newtitle', 'label' => $langs->trans("WEBSITE_TITLE"), 'value' => $langs->trans("CopyOf").' '.$objectpage->title),
array('type' => 'text', 'tdclass' => 'maxwidth200', 'name' => 'newpageurl', 'label' => $langs->trans("WEBSITE_PAGENAME"), 'value' => '')
);
@@ -3842,7 +3847,7 @@ if (!GETPOST('hide_websitemenu')) {
} else {
print 'console.log("A change has been detected, but saving is not enabled by option WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT, so no ajax update is done");';
}
print '
print '
$(this).removeClass(\'modified\');
}
@@ -4738,7 +4743,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
$pagelang = $objectpage->lang;
$pageallowedinframes = $objectpage->allowed_in_frames;
$pagehtmlheader = $objectpage->htmlheader;
$pagedatecreation = $objectpage->date_creation;
$pagedatecreation = (string) $objectpage->date_creation;
$pagedatemodification = $objectpage->date_modification;
$pageauthorid = $objectpage->fk_user_creat;
$pageusermodifid = $objectpage->fk_user_modif;
@@ -4933,7 +4938,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
}
}
if (empty($object->lang) && empty($object->otherlang)) {
$onlykeys = null; // We keep full list of languages
$onlykeys = array(); // We keep full list of languages
}
print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang : '', 'WEBSITE_LANG', 0, array(), '1', 0, 0, 'minwidth200', 0, 0, 0, $onlykeys, 1);
$htmltext = $langs->trans("AvailableLanguagesAreDefinedIntoWebsiteProperties");
@@ -5009,12 +5014,14 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties
// Categories
if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
$disabled = '';
$langs->load('categories');
$cate_arbo = array();
$arrayselected = array();
if (!GETPOSTISSET('categories')) {
$c = new Categorie($db);
$cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
$arrayselected = array();
if (is_array($cats)) {
foreach ($cats as $cat) {
$arrayselected[] = $cat->id;

View File

@@ -1,5 +1,6 @@
<?php
/* 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
* it under the terms of the GNU General Public License as published by
@@ -151,11 +152,11 @@ if ($rss) {
$website = new Website($db);
$websitepage = new WebsitePage($db);
$website->fetch('', $websitekey);
$website->fetch(0, $websitekey);
$filters = array('type_container'=>'blogpost', 'status'=>1);
$filters = array('type_container' => 'blogpost', 'status' => '1');
if ($l) {
$filters['lang'] = $l;
$filters['lang'] = (string) $l;
}
$MAXNEWS = $limit;