Qual: Fix 'SqlInjection' notices (#39222)

# Qual: Fix 'SqlInjection' notices

Batch of 25 files with changes to fix 'SqlInjection' Notices
This commit is contained in:
MDW 2026-07-20 02:51:25 +02:00 committed by GitHub
parent 7cc8ae1efb
commit 1df0531b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 166 additions and 164 deletions

View file

@ -3,7 +3,7 @@
* Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -102,7 +102,7 @@ $form = new Form($db);
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('formfilteraction')) {
$sql = "SELECT date_start, date_end";
$sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear ";
if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) {
$sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT');
} else {
@ -375,7 +375,7 @@ if ($action != 'export') {
$newcardbutton .= dolGetButtonTitle($langs->trans('ExportToPdf'), '', 'fa fa-file-pdf paddingleft', $_SERVER['PHP_SELF'] . '&token=' . newToken(), 'exportpdfbutton', $permissiontoexport, array('morecss' => 'marginleftonly'));
$newcardbutton .= dolGetButtonTitleSeparator();
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'.(!empty($type)?'&type=sub':'').'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'.(!empty($type) ? '&type=sub' : '').'&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
}
if ($contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
@ -515,7 +515,7 @@ if ($action != 'export') {
if (getDolGlobalString('ACCOUNTANCY_SHOW_OPENING_BALANCE')) {
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features
$sql .= " WHERE t.entity = " . ((int) $conf->entity); // Never do sharing into accounting features
$sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'";
$sql .= " GROUP BY t.numero_compte";

View file

@ -3,7 +3,7 @@
* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -100,9 +100,9 @@ if ($action == 'up') {
// Menu before
$sql = "SELECT m.rowid, m.position";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql .= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".GETPOSTINT("menuId")."))";
$sql .= " WHERE (m.position < ".((int) $current['order'])." OR (m.position = ".((int) $current['order'])." AND rowid < ".GETPOSTINT("menuId")."))";
$sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'";
$sql .= " AND m.entity = ".$conf->entity;
$sql .= " AND m.entity = ".((int) $conf->entity);
$sql .= " AND m.type = '".$db->escape($current['type'])."'";
$sql .= " AND m.fk_menu = '".$db->escape((string) $current['fk_menu'])."'";
$sql .= " ORDER BY m.position, m.rowid";
@ -151,9 +151,9 @@ if ($action == 'up') {
// Menu after
$sql = "SELECT m.rowid, m.position";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql .= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".GETPOSTINT("menuId")."))";
$sql .= " WHERE (m.position > ".((int) $current['order'])." OR (m.position = ".((int) $current['order'])." AND rowid > ".GETPOSTINT("menuId")."))";
$sql .= " AND m.menu_handler='".$db->escape($menu_handler_to_search)."'";
$sql .= " AND m.entity = ".$conf->entity;
$sql .= " AND m.entity = ".((int) $conf->entity);
$sql .= " AND m.type = '".$db->escape($current['type'])."'";
$sql .= " AND m.fk_menu = '".$db->escape((string) $current['fk_menu'])."'";
$sql .= " ORDER BY m.position, m.rowid";
@ -291,7 +291,7 @@ $data[] = array('rowid' => 0, 'fk_menu' => -1, 'title' => 'racine', 'mainmenu' =
$sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module";
$sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
$sql .= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
//$sql.= " AND fk_menu >= 0";
$sql .= " ORDER BY m.position, m.rowid"; // Order is position then rowid (because we need a sort criteria when position is same)

View file

@ -270,12 +270,12 @@ if ($action == 'add' && $permissiontoadd) { // Add recipients
}
if ($result > 0) {
$query_temlate_id = '';
$get_param_template_id = '';
if (!empty($template_id)) {
$query_temlate_id = '&template_id='.$template_id;
$get_param_template_id = '&template_id='.$template_id;
}
setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id.$query_temlate_id);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id.$get_param_template_id);
exit();
}
if ($result == 0) {

View file

@ -261,7 +261,7 @@ class PaymentVarious extends CommonObject
$sql .= " accountancy_code='".$this->db->escape($this->accountancy_code)."',";
$sql .= " subledger_account='".$this->db->escape($this->subledger_account)."',";
$sql .= " fk_projet='".$this->db->escape((string) $this->fk_project)."',";
$sql .= " fk_bank=".($this->fk_bank > 0 ? $this->fk_bank : "null").",";
$sql .= " fk_bank=".($this->fk_bank > 0 ? ((int) $this->fk_bank) : "null").",";
$sql .= " fk_user_author=".(int) $this->fk_user_author.",";
$sql .= " fk_user_modif=".(int) $this->fk_user_modif;
$sql .= " WHERE rowid=".((int) $this->id);

View file

@ -230,9 +230,9 @@ if (isModEnabled('accounting')) {
$sql = "SELECT b.rowid ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
$sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
$sql .= " WHERE b.entity = ".((int) $conf->entity); // In module double party accounting, we never share entities
$sql .= " AND b.numero_compte = aa.account_number";
$sql .= " AND aa.entity = ".$conf->entity;
$sql .= " AND aa.entity = ".((int) $conf->entity);
$sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
$sql .= $db->plimit(1);
@ -278,10 +278,10 @@ if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT date_format(b.doc_date, '%Y-%m') as dm, sum(b.debit - b.credit) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
$sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
$sql .= " WHERE b.entity = ".((int) $conf->entity); // In module double party accounting, we never share entities
$sql .= " AND b.doc_type = 'supplier_invoice'";
$sql .= " AND b.numero_compte = aa.account_number";
$sql .= " AND aa.entity = ".$conf->entity;
$sql .= " AND aa.entity = ".((int) $conf->entity);
$sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
$sql .= " AND aa.pcg_type = 'EXPENSE'"; // TODO Be able to use a custom group
}

View file

@ -285,9 +285,9 @@ if (isModEnabled('accounting')) {
$sql = "SELECT b.rowid ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
$sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
$sql .= " WHERE b.entity = ".((int) $conf->entity); // In module double party accounting, we never share entities
$sql .= " AND b.numero_compte = aa.account_number";
$sql .= " AND aa.entity = ".$conf->entity;
$sql .= " AND aa.entity = ".((int) $conf->entity);
$sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
$sql .= $db->plimit(1);

View file

@ -221,7 +221,7 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo
// Recupere liste des boites d'un user si ce dernier a sa propre liste
$sql = "SELECT b.rowid as id, b.box_id, b.position, b.box_order, b.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."boxes as b";
$sql .= " WHERE b.entity = ".$conf->entity;
$sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND b.rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::fetch rowid=".((int) $rowid));

View file

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -123,7 +123,7 @@ class Link extends CommonObject
$this->db->begin();
$sql = "INSERT INTO ".$this->db->prefix()."links (entity, datea, url, label, objecttype, objectid, share,share_pass)";
$sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datea)."'";
$sql .= " VALUES (".((int) $conf->entity).", '".$this->db->idate($this->datea)."'";
$sql .= ", '".$this->db->escape($this->url)."'";
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->escape($this->objecttype)."'";
@ -345,7 +345,7 @@ class Link extends CommonObject
$rowid = $this->id;
}
$sqlwhere=[];
$sqlwhere = [];
$sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid, share, share_pass FROM ".$this->db->prefix()."links";
if (!empty((int) $rowid)) {
@ -356,10 +356,10 @@ class Link extends CommonObject
}
if ($conf->entity != 0) {
$sqlwhere[] = " entity = ".$conf->entity;
$sqlwhere[] = " entity = ".((int) $conf->entity);
}
if (count($sqlwhere)>0) {
$sql .=' WHERE '.implode(' AND ', $sqlwhere);
if (count($sqlwhere) > 0) {
$sql .= ' WHERE '.implode(' AND ', $sqlwhere);
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);

View file

@ -1289,17 +1289,17 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so
$sql .= " AND wp.type_container IN (".$db->sanitize($typestring, 1).")";
}
$sql .= " AND (";
$searchalgo = '';
$sqlsearchalgo = '';
if (preg_match('/meta/', $algo)) {
// TODO Use a better way to scan keywords
$searchalgo .= "wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
$searchalgo .= " OR wp.pageurl LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.aliasalt LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
$searchalgo .= " OR wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring))."%'";
$sqlsearchalgo .= "wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
$sqlsearchalgo .= " OR wp.pageurl LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.aliasalt LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
$sqlsearchalgo .= " OR wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring))."%'";
}
if (preg_match('/content/', $algo)) {
$searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
$sqlsearchalgo .= ($sqlsearchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'";
}
$sql .= $searchalgo;
$sql .= $sqlsearchalgo;
if (is_array($otherfilters) && !empty($otherfilters['category'])) {
$sql .= ' AND cwp.fk_website_page = wp.rowid AND cwp.fk_categorie = '.((int) $otherfilters['category']);
}

View file

@ -3,7 +3,7 @@
* Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -134,10 +134,10 @@ class mod_facture_mars extends ModeleNumRefFactures
$max = '';
$posindice = strlen($this->prefixinvoice) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -157,10 +157,10 @@ class mod_facture_mars extends ModeleNumRefFactures
$fayymm = '';
$posindice = strlen($this->prefixcreditnote) + 6;
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL
$sql = "SELECT MAX(SUBSTRING(ref FROM ".((int) $posindice).")) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -201,7 +201,7 @@ class mod_facture_mars extends ModeleNumRefFactures
// First we get the max value
$posindice = strlen($prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-%'";
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
@ -221,15 +221,15 @@ class mod_facture_mars extends ModeleNumRefFactures
if ($mode == 'last') {
if ($max >= (pow(10, 4) - 1)) {
$num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
$sql_num = ((int) $max); // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04d", $max);
$sql_num = sprintf("%04d", ((int) $max));
}
$ref = '';
$sql = "SELECT ref as ref";
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$num."'";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$sql_num."'";
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$sql .= " ORDER BY ref DESC";

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -137,10 +137,10 @@ class mod_facture_terre extends ModeleNumRefFactures
$max = '';
$posindice = strlen($this->prefixinvoice) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -160,10 +160,10 @@ class mod_facture_terre extends ModeleNumRefFactures
$fayymm = '';
$posindice = strlen($this->prefixcreditnote) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -182,10 +182,10 @@ class mod_facture_terre extends ModeleNumRefFactures
$fayymm = '';
$posindice = strlen($this->prefixdeposit) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -229,7 +229,7 @@ class mod_facture_terre extends ModeleNumRefFactures
// First we get the max value
$posindice = strlen($prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-%'";
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
@ -248,15 +248,15 @@ class mod_facture_terre extends ModeleNumRefFactures
if ($mode == 'last') {
if ($max >= (pow(10, 4) - 1)) {
$num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
$sql_num = (int) $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04d", $max);
$sql_num = sprintf("%04d", (int) $max);
}
$ref = '';
$sql = "SELECT ref as ref";
$sql .= " FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$num."'";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$sql_num."'";
$sql .= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$sql .= " ORDER BY ref DESC";

View file

@ -8,6 +8,7 @@
* Copyright (C) 2014-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 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
@ -191,13 +192,13 @@ class modAdherent extends DolibarrModules
// Boxes
//-------
$this->boxes = array(
0 => array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'),
2 => array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'),
3 => array('file'=>'box_members_last_modified.php', 'enabledbydefaulton'=>'membersindex'),
4 => array('file'=>'box_members_last_subscriptions.php', 'enabledbydefaulton'=>'membersindex'),
5 => array('file'=>'box_members_subscriptions_by_year.php', 'enabledbydefaulton'=>'membersindex'),
6 => array('file'=>'box_members_by_type.php', 'enabledbydefaulton'=>'membersindex'),
7 => array('file'=>'box_members_by_tags.php', 'enabledbydefaulton'=>'membersindex'),
0 => array('file' => 'box_members.php', 'enabledbydefaulton' => 'Home'),
2 => array('file' => 'box_birthdays_members.php', 'enabledbydefaulton' => 'Home'),
3 => array('file' => 'box_members_last_modified.php', 'enabledbydefaulton' => 'membersindex'),
4 => array('file' => 'box_members_last_subscriptions.php', 'enabledbydefaulton' => 'membersindex'),
5 => array('file' => 'box_members_subscriptions_by_year.php', 'enabledbydefaulton' => 'membersindex'),
6 => array('file' => 'box_members_by_type.php', 'enabledbydefaulton' => 'membersindex'),
7 => array('file' => 'box_members_by_tags.php', 'enabledbydefaulton' => 'membersindex'),
);
// Permissions
@ -286,27 +287,27 @@ class modAdherent extends DolibarrModules
$this->export_label[$r] = 'MembersAndSubscriptions';
$this->export_permission[$r] = array(array("adherent", "export"));
$this->export_fields_array[$r] = array(
'a.rowid'=>'MemberId', 'a.ref'=>'MemberRef', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'MemberNature',
'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.code_departement'=>'StateCode', 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country",
'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status",
'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation',
'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel',
'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount'
'a.rowid' => 'MemberId', 'a.ref' => 'MemberRef', 'a.civility' => "UserTitle", 'a.lastname' => "Lastname", 'a.firstname' => "Firstname", 'a.login' => "Login", 'a.gender' => "Gender", 'a.morphy' => 'MemberNature',
'a.societe' => 'Company', 'a.address' => "Address", 'a.zip' => "Zip", 'a.town' => "Town", 'd.code_departement' => 'StateCode', 'd.nom' => "State", 'co.code' => "CountryCode", 'co.label' => "Country",
'a.phone' => "PhonePro", 'a.phone_perso' => "PhonePerso", 'a.phone_mobile' => "PhoneMobile", 'a.email' => "Email", 'a.birth' => "Birthday", 'a.statut' => "Status",
'a.photo' => "Photo", 'a.note_public' => "NotePublic", 'a.note_private' => "NotePrivate", 'a.datec' => 'DateCreation', 'a.datevalid' => 'DateValidation',
'a.tms' => 'DateLastModification', 'a.datefin' => 'DateEndSubscription', 'ta.rowid' => 'MemberTypeId', 'ta.libelle' => 'MemberTypeLabel',
'c.rowid' => 'SubscriptionId', 'c.dateadh' => 'DateSubscription', 'c.datef' => 'DateEndSubscription', 'c.subscription' => 'Amount'
);
$this->export_TypeFields_array[$r] = array(
'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text",
'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text",
'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date',
'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle::member_type', 'ta.libelle'=>'Text',
'c.rowid'=>'Numeric', 'c.dateadh'=>'Date', 'c.datef'=>'Date', 'c.subscription'=>'Numeric'
'a.civility' => "Text", 'a.lastname' => "Text", 'a.firstname' => "Text", 'a.login' => "Text", 'a.gender' => 'Text', 'a.morphy' => 'Text', 'a.societe' => 'Text', 'a.address' => "Text",
'a.zip' => "Text", 'a.town' => "Text", 'd.nom' => "Text", 'co.code' => 'Text', 'co.label' => "Text", 'a.phone' => "Text", 'a.phone_perso' => "Text", 'a.phone_mobile' => "Text",
'a.email' => "Text", 'a.birth' => "Date", 'a.statut' => "Status", 'a.note_public' => "Text", 'a.note_private' => "Text", 'a.datec' => 'Date', 'a.datevalid' => 'Date',
'a.tms' => 'Date', 'a.datefin' => 'Date', 'ta.rowid' => 'List:adherent_type:libelle::member_type', 'ta.libelle' => 'Text',
'c.rowid' => 'Numeric', 'c.dateadh' => 'Date', 'c.datef' => 'Date', 'c.subscription' => 'Numeric'
);
$this->export_entities_array[$r] = array(
'a.rowid'=>'member', 'a.ref'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member',
'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member",
'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member",
'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member',
'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type',
'c.rowid'=>'subscription', 'c.dateadh'=>'subscription', 'c.datef'=>'subscription', 'c.subscription'=>'subscription'
'a.rowid' => 'member', 'a.ref' => 'member', 'a.civility' => "member", 'a.lastname' => "member", 'a.firstname' => "member", 'a.login' => "member", 'a.gender' => 'member', 'a.morphy' => 'member',
'a.societe' => 'member', 'a.address' => "member", 'a.zip' => "member", 'a.town' => "member", 'd.nom' => "member", 'co.code' => "member", 'co.label' => "member",
'a.phone' => "member", 'a.phone_perso' => "member", 'a.phone_mobile' => "member", 'a.email' => "member", 'a.birth' => "member", 'a.statut' => "member",
'a.photo' => "member", 'a.note_public' => "member", 'a.note_private' => "member", 'a.datec' => 'member', 'a.datevalid' => 'member', 'a.tms' => 'member',
'a.datefin' => 'member', 'ta.rowid' => 'member_type', 'ta.libelle' => 'member_type',
'c.rowid' => 'subscription', 'c.dateadh' => 'subscription', 'c.datef' => 'subscription', 'c.subscription' => 'subscription'
);
// Add extra fields
$keyforselect = 'adherent';
@ -321,7 +322,7 @@ class modAdherent extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';
$this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';
$this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$this->export_dependencies_array[$r] = array('subscription' => 'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
// Imports
//--------
@ -335,21 +336,21 @@ class modAdherent extends DolibarrModules
$this->import_label[$r] = "Members"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
$this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id
$this->import_tables_array[$r] = array('a' => MAIN_DB_PREFIX.'adherent', 'extra' => MAIN_DB_PREFIX.'adherent_extrafields');
$this->import_tables_creator_array[$r] = array('a' => 'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r] = array(
'a.ref' => 'MemberRef*',
'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password",
"a.fk_adherent_type"=>"MemberTypeId*", 'a.morphy'=>'MemberNature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town",
'a.state_id'=>'StateId|StateCode', 'a.country'=>"CountryId|CountryCode", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile",
'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate",
'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription'
'a.civility' => "UserTitle", 'a.lastname' => "Lastname*", 'a.firstname' => "Firstname", 'a.gender' => "Gender", 'a.login' => "Login*", "a.pass" => "Password",
"a.fk_adherent_type" => "MemberTypeId*", 'a.morphy' => 'MemberNature*', 'a.societe' => 'Company', 'a.address' => "Address", 'a.zip' => "Zip", 'a.town' => "Town",
'a.state_id' => 'StateId|StateCode', 'a.country' => "CountryId|CountryCode", 'a.phone' => "PhonePro", 'a.phone_perso' => "PhonePerso", 'a.phone_mobile' => "PhoneMobile",
'a.email' => "Email", 'a.birth' => "Birthday", 'a.statut' => "Status*", 'a.photo' => "Photo", 'a.note_public' => "NotePublic", 'a.note_private' => "NotePrivate",
'a.datec' => 'DateCreation', 'a.datefin' => 'DateEndSubscription'
);
if (isModEnabled("societe")) {
$this->import_fields_array[$r]['a.fk_soc'] = "ThirdParty";
}
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";
$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".((int) $conf->entity).")";
$resql = $this->db->query($sql);
if ($resql) { // This can fail when class is used on old database (during migration for example)
while ($obj = $this->db->fetch_object($resql)) {
@ -360,10 +361,10 @@ class modAdherent extends DolibarrModules
}
// End add extra fields
$this->import_convertvalue_array[$r] = array(
'a.ref'=>array(
'rule'=>'getrefifauto',
'a.ref' => array(
'rule' => 'getrefifauto',
'class' => getDolGlobalString('MEMBER_ADDON', 'mod_member_simple'),
'path'=>"/core/modules/member/".getDolGlobalString('MEMBER_ADDON', 'mod_member_simple').'.php'
'path' => "/core/modules/member/".getDolGlobalString('MEMBER_ADDON', 'mod_member_simple').'.php'
),
'a.state_id' => array(
'rule' => 'fetchidfromcodeid',
@ -381,23 +382,23 @@ class modAdherent extends DolibarrModules
)
);
if (isModEnabled("societe")) {
$this->import_convertvalue_array[$r]['a.fk_soc'] = array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty');
$this->import_convertvalue_array[$r]['a.fk_soc'] = array('rule' => 'fetchidfromref', 'classfile' => '/societe/class/societe.class.php', 'class' => 'Societe', 'method' => 'fetch', 'element' => 'ThirdParty');
}
$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_fieldshidden_array[$r] = array('extra.fk_object' => 'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r] = array(
'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)',
'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
'a.civility' => 'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type' => 'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy' => '(phy|mor)',
'a.statut' => '^[0|1]', 'a.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
$this->import_examplevalues_array[$r] = array(
'a.ref'=>"auto or MEM2010-1234",
'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.gender'=>'man or woman', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1',
'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1',
'a.email'=>'jsmith@example.com', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member",
'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')
'a.ref' => "auto or MEM2010-1234",
'a.civility' => "MR", 'a.lastname' => 'Smith', 'a.firstname' => 'John', 'a.gender' => 'man or woman', 'a.login' => 'jsmith', 'a.pass' => 'passofjsmith', 'a.fk_adherent_type' => '1',
'a.morphy' => '"mor" or "phy"', 'a.societe' => 'JS company', 'a.address' => '21 jump street', 'a.zip' => '55000', 'a.town' => 'New York', 'a.country' => '1',
'a.email' => 'jsmith@example.com', 'a.birth' => '1972-10-10', 'a.statut' => "0 or 1", 'a.note_public' => "This is a public comment on member",
'a.note_private' => "This is private comment on member", 'a.datec' => dol_print_date($now, '%Y-%m__%d'), 'a.datefin' => dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')
);
if (isModEnabled("societe")) {
$this->import_examplevalues_array[$r]['a.fk_soc'] = "rowid or name";
}
$this->import_updatekeys_array[$r] = array('a.ref'=>'MemberRef', 'a.login'=>'Login');
$this->import_updatekeys_array[$r] = array('a.ref' => 'MemberRef', 'a.login' => 'Login');
// Import subscriptions
$r++;
@ -405,42 +406,42 @@ class modAdherent extends DolibarrModules
$this->import_label[$r] = "Subscriptions"; // Translation key
$this->import_icon[$r] = $this->picto;
$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
$this->import_tables_array[$r] = array('c'=>MAIN_DB_PREFIX.'subscription');
$this->import_tables_array[$r] = array('c' => MAIN_DB_PREFIX.'subscription');
$this->import_fields_array[$r] = array(
'c.fk_adherent' => 'MemberRef*',
'c.note'=>'Note', 'c.dateadh'=>'DateSubscription', 'c.datef'=>'DateEndSubscription', 'c.subscription'=>'Amount', 'c.fk_type' => 'MemberType', 'c.fk_bank' => 'Bank'
'c.note' => 'Note', 'c.dateadh' => 'DateSubscription', 'c.datef' => 'DateEndSubscription', 'c.subscription' => 'Amount', 'c.fk_type' => 'MemberType', 'c.fk_bank' => 'Bank'
);
$this->import_convertvalue_array[$r] = array(
'c.fk_adherent' => array(
'rule'=>'fetchidfromref',
'classfile'=>'/adherents/class/adherent.class.php',
'class'=>'Adherent',
'method'=>'fetch',
'element'=>'member'
'rule' => 'fetchidfromref',
'classfile' => '/adherents/class/adherent.class.php',
'class' => 'Adherent',
'method' => 'fetch',
'element' => 'member'
)
);
$this->import_examplevalues_array[$r] = array(
'c.fk_adherent' => 'member ref',
'c.note'=>'Subscription #33', 'c.dateadh'=>'2025-09-01', 'c.datef'=>'2026-08-31', 'c.subscription'=>'50'
'c.note' => 'Subscription #33', 'c.dateadh' => '2025-09-01', 'c.datef' => '2026-08-31', 'c.subscription' => '50'
);
// Cronjobs
$arraydate = dol_getdate(dol_now());
$datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
0=>array(
'label'=>'SendReminderForExpiredSubscriptionTitle',
'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',
'objectname'=>'Adherent',
'method'=>'sendReminderForExpiredSubscription',
'parameters'=>'10;0',
'comment'=>'SendReminderForExpiredSubscription',
'frequency'=>1,
'unitfrequency'=> 3600 * 24,
'priority'=>50,
'status'=>1,
'test'=>'isModEnabled("member")',
'datestart'=>$datestart
0 => array(
'label' => 'SendReminderForExpiredSubscriptionTitle',
'jobtype' => 'method', 'class' => 'adherents/class/adherent.class.php',
'objectname' => 'Adherent',
'method' => 'sendReminderForExpiredSubscription',
'parameters' => '10;0',
'comment' => 'SendReminderForExpiredSubscription',
'frequency' => 1,
'unitfrequency' => 3600 * 24,
'priority' => 50,
'status' => 1,
'test' => 'isModEnabled("member")',
'datestart' => $datestart
),
);
}

View file

@ -442,7 +442,7 @@ class modSupplierOrder extends DolibarrModules
// Add extra fields
$import_extrafield_sample = array();
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, " . $conf->entity . ")";
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseur' AND entity IN (0, " . ((int) $conf->entity) . ")";
$resql = $this->db->query($sql);
if ($resql) {
@ -524,7 +524,7 @@ class modSupplierOrder extends DolibarrModules
}
// Add extra fields
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, " . $conf->entity . ")";
$sql = "SELECT name, label, fieldrequired FROM " . MAIN_DB_PREFIX . "extrafields WHERE type <> 'separate' AND elementtype = 'commande_fournisseurdet' AND entity IN (0, " . ((int) $conf->entity) . ")";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {

View file

@ -3,7 +3,7 @@
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -118,7 +118,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
// First, we get the max value (response immediate car champ indexe)
$posindice = strlen($prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(".$db->sanitize($field)." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(".$db->sanitize($field)." FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."societe";
$sql .= " WHERE ".$db->sanitize($field)." LIKE '".$db->escape($prefix)."____-%'";
$sql .= " AND entity IN (".getEntity('societe').")";
@ -218,7 +218,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
}
$sql .= " AND entity IN (".getEntity('societe').")";
if ($soc->id > 0) {
$sql .= " AND rowid <> ".$soc->id;
$sql .= " AND rowid <> ".((int) $soc->id);
}
dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG);

View file

@ -4,7 +4,7 @@
* Copyright (C) 2013-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 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
@ -116,10 +116,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
$max = '';
$posindice = strlen($this->prefixinvoice) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
@ -138,10 +138,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
$siyymm = '';
$posindice = strlen($this->prefixcreditnote) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -160,10 +160,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
$siyymm = '';
$posindice = strlen($this->prefixdeposit) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
@ -202,10 +202,10 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
// First, we get the max value
$posindice = strlen($prefix) + 6;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".((int) $posindice).") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -222,16 +222,16 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
if ($mode == 'last') {
if ($max >= (pow(10, 4) - 1)) {
$num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
$sql_num = (int) $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
} else {
$num = sprintf("%04d", $max);
$sql_num = sprintf("%04d", (int) $max);
}
$ref = '';
$sql = "SELECT ref as ref";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$num."'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " WHERE ref LIKE '".$db->escape($prefix)."____-".$sql_num."'";
$sql .= " AND entity = ".((int) $conf->entity);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql = $db->query($sql);

View file

@ -599,7 +599,7 @@ class EcmDirectory extends CommonObject
$sql = "SELECT fk_parent as id_parent, rowid as id_son";
$sql .= " FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql .= " WHERE fk_parent != 0";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -688,7 +688,7 @@ class EcmDirectory extends CommonObject
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ecm_directories as ca";
$sql .= " ON c.rowid = ca.fk_parent";
$sql .= " WHERE c.fk_user_c = u.rowid";
$sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND c.entity = ".((int) $conf->entity);
$sql .= " ORDER BY c.label, c.rowid";
dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG);
@ -800,7 +800,7 @@ class EcmDirectory extends CommonObject
if (empty($all)) { // By default
$sql .= " WHERE rowid = ".((int) $this->id);
} else {
$sql .= " WHERE entity = ".$conf->entity;
$sql .= " WHERE entity = ".((int) $conf->entity);
}
dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG);

View file

@ -138,7 +138,7 @@ class ExpenseReportStats extends Stats
{
$sql = "SELECT MONTH(".$this->db->ifsql("e.".$this->db->sanitize($this->datetouse)." IS NULL", "e.date_create", "e.".$this->db->sanitize($this->datetouse)).") as dm, count(*)";
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
$sql .= " WHERE YEAR(e.".$this->datetouse.") = ".((int) $year);
$sql .= " WHERE YEAR(e.".$this->db->sanitize($this->datetouse).") = ".((int) $year);
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');

View file

@ -334,7 +334,7 @@ class Export
{
// phpcs:enable
// Build the sql request
$sql = $this->array_export_sql_start[$indice];
$sql = $this->array_export_sql_start[$indice]; // @phan-suppress-current-line SqlInjection
$i = 0;
//print_r($array_selected);
@ -343,7 +343,7 @@ class Export
continue; // Field not selected
}
if (preg_match('/^none\./', $key)) {
continue; // A field that must not appears into SQL
continue; // A field that must not appear into SQL
}
if ($i > 0) {
$sql .= ', ';
@ -357,9 +357,9 @@ class Export
$newfield = $key;
}
$sql .= $newfield;
$sql .= $newfield; // @phan-suppress-current-line SqlInjection
}
$sql .= $this->array_export_sql_end[$indice];
$sql .= $this->array_export_sql_end[$indice]; // @phan-suppress-current-line SqlInjection
// Add the WHERE part. Filtering into sql if a filtering array is provided
if (is_array($array_filterValue) && !empty($array_filterValue)) {
@ -370,21 +370,21 @@ class Export
continue;
}
if ($value != '') {
$sqlWhere .= " AND ".$this->buildFilterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
$sqlWhere .= " AND ".$this->buildFilterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); // @phan-suppress-current-line SqlInjection
}
}
$sql .= $sqlWhere;
}
// Add the sort order
$sql .= $this->array_export_sql_order[$indice];
$sql .= $this->array_export_sql_order[$indice]; // @phan-suppress-current-line SqlInjection
// Add the HAVING part.
if (is_array($array_filterValue) && !empty($array_filterValue)) {
// Loop on each condition to add
foreach ($array_filterValue as $key => $value) {
if (preg_match('/GROUP_CONCAT/i', $key) and $value != '') {
$sql .= " HAVING ".$this->buildFilterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]);
$sql .= " HAVING ".$this->buildFilterQuery($this->array_export_TypeFields[$indice][$key], $key, $array_filterValue[$key]); // @phan-suppress-current-line SqlInjection
}
}
}
@ -576,7 +576,7 @@ class Export
}
$sql = "SELECT ".$this->db->sanitize($keyList)." as rowid, ".$this->db->sanitize($InfoFieldList[2])." as label".(empty($InfoFieldList[3]) ? "" : ", ".$this->db->sanitize($InfoFieldList[3])." as code");
if ($InfoFieldList[1] == 'c_stcomm') {
$sql = "SELECT id as id, ".$this->db->sanitize($keyList)." as rowid, ".$InfoFieldList[2]." as label".(empty($InfoFieldList[3]) ? "" : ", ".$this->db->sanitize($InfoFieldList[3]).' as code');
$sql = "SELECT id as id, ".$this->db->sanitize($keyList)." as rowid, ".$this->db->sanitize($InfoFieldList[2])." as label".(empty($InfoFieldList[3]) ? "" : ", ".$this->db->sanitize($InfoFieldList[3]).' as code');
}
if ($InfoFieldList[1] == 'c_country') {
$sql = "SELECT ".$this->db->sanitize($keyList)." as rowid, ".$this->db->sanitize($InfoFieldList[2])." as label, code as code";
@ -727,7 +727,7 @@ class Export
$this->error = "ErrorBadParameter can't find dataset ".$datatoexport." into preload arrays this->array_export_code";
return -1;
}
$sql = $this->build_sql($indice, $array_selected, $array_filterValue);
$sql = $this->build_sql($indice, $array_selected, $array_filterValue); // @phan-suppress-current-line SqlInjection
}
// Run the SQL

View file

@ -579,14 +579,14 @@ class Position extends CommonObject
if (preg_match('/^[\(]?PROV/i', $this->ref)) {
// Now we rename also files into index
$sql = 'UPDATE ' . MAIN_DB_PREFIX . "ecm_files set filename = CONCAT('" . $this->db->escape($this->newref) . "', SUBSTR(filename, " . (strlen($this->ref) + 1) . ")), filepath = 'position/" . $this->db->escape($this->newref) . "'";
$sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'position/" . $this->db->escape($this->ref) . "' and entity = " . $conf->entity;
$sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'position/" . $this->db->escape($this->ref) . "' and entity = " . ((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'position/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'position/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$sql .= " WHERE filepath = 'position/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;

View file

@ -567,7 +567,7 @@ class SkillRank extends CommonObject
$this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'skillrank/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'skillrank/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$sql .= " WHERE filepath = 'skillrank/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;

View file

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2012-2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2026 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
@ -264,7 +265,7 @@ if ($socid > 0) {
$sql .= " AND f.fk_statut > 0";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND d.fk_facture = f.rowid";
$sql .= " AND f.fk_soc = $socid";
$sql .= " AND f.fk_soc = ".((int) $socid);
$sql .= " AND d.buy_price_ht IS NOT NULL";
// We should not use this here. Option ForceBuyingPriceIfNull should have effect only when inserting data. Once data is recorded, it must be used as it is for report.
// We keep it with value ForceBuyingPriceIfNull = 2 for retroactive effect but results are unpredictable.

View file

@ -593,7 +593,7 @@ class StockTransferLine extends CommonObjectLine
$this->error = $this->db->lasterror();
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'stocktransferline/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filepath = 'stocktransferline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$sql .= " WHERE filepath = 'stocktransferline/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;

View file

@ -253,7 +253,7 @@ if (empty($reshook)) {
$countUnarchived++;
}
if ($countUnarchived>0) {
if ($countUnarchived > 0) {
setEventMessage($langs->trans($countUnarchived > 1 ? 'QuickMemoUnArchiveCount' : 'QuickMemoUnArchived', $countUnarchived));
}
} else {
@ -313,7 +313,7 @@ if (!empty($object->ismultientitymanaged) && (int) $object->ismultientitymanaged
$sql .= " WHERE t.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
} elseif (preg_match('/^\w+@\w+$/', (string) $object->ismultientitymanaged)) {
$tmparray = explode('@', (string) $object->ismultientitymanaged);
$sql .= " LEFT JOIN ".$object->db->prefix().$tmparray[1]." as pt ON t.".$db->sanitize($tmparray[0])." = pt.rowid";
$sql .= " LEFT JOIN ".$object->db->prefix().$db->sanitize($tmparray[1])." as pt ON t.".$db->sanitize($tmparray[0])." = pt.rowid";
$sql .= " WHERE pt.entity IN (".getEntity($object->element, (GETPOSTINT('search_current_entity') ? 0 : 1)).")";
} else {
$sql .= " WHERE 1 = 1";
@ -532,7 +532,7 @@ $param .= $hookmanager->resPrint;
// List of mass actions available
$arrayofmassactions = array(
'unarchive'=> $langs->trans("UnarchiveMemo"),
'unarchive' => $langs->trans("UnarchiveMemo"),
//'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),

View file

@ -4,7 +4,7 @@
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2022-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
*
@ -529,7 +529,7 @@ $def = array();
$sql = "SELECT nom";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = 'company'";
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $db->query($sql);
if ($resql) {
$i = 0;

View file

@ -364,7 +364,7 @@ class dolReceiptPrinter extends Printer
$sql = "SELECT rowid, name, template";
$sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
$sql .= " WHERE entity = ".$conf->entity;
$sql .= " WHERE entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
@ -523,7 +523,7 @@ class dolReceiptPrinter extends Printer
$error = 0;
$sql = "INSERT INTO ".$this->db->prefix()."printer_receipt_template";
$sql .= " (name, template, entity) VALUES ('".$this->db->escape($name)."'";
$sql .= ", '".$this->db->escape($template)."', ".$conf->entity.")";
$sql .= ", '".$this->db->escape($template)."', ".((int) $conf->entity).")";
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@ -544,7 +544,7 @@ class dolReceiptPrinter extends Printer
$error = 0;
$sql = 'DELETE FROM '.$this->db->prefix().'printer_receipt_template';
$sql .= " WHERE rowid = ".((int) $templateid);
$sql .= " AND entity = ".$conf->entity;
$sql .= " AND entity = ".((int) $conf->entity);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;