Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from ATM 3.9.3 #7

Open
wants to merge 1 commit into
base: 2022.5.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@ ___

# NOT RELEASED

## RELEASE 3.9

- FIX: Replace `is_callable('parent::method')` with `is_callable(parent::class.'::method')` to avoid deprecation warning on php8.2 - *27/11/2024* - 3.9.2
- FIX: constructor TResponseMail, class properties was not defined with old PHP constructor - *30/07/2024* - 3.9.1
- FIX : Compat v20
Changed Dolibarr compatibility range to 16 min - 20 max - *04/08/2024* - 3.9.0

## RELEASE 3.6
- FIX : Warning php 8.2 warning undefined array key visible - *13/03/2024* - 3.8.3
- FIX : Warning php 8.2 warning undefined array key visible - *14/12/2023* - 3.8.2
- FIX : Warning php 8.2 - *11/12/2023* - 3.8.1
- NEW : Compatibilité Dolibarr 19 - *22/11/2023* - 3.8.0
Attention : perte compatibilité Dolibarr inférieur à 6
- NEW : TObjetStd add nullable property to integer fields - *21/11/2023* - 3.7.0
- NEW : script de pré-configuration (initialisation / remplacement de certaines const) lors des installs / montées de version - *19/10/2023* - 3.6.0
- FIX : traitement séparation des requêtes SQL, erreur sql lors de l'activation module productbycompany *7/12/2023* - 3.6.1

## RELEASE 3.5

- FIX : PHP8: date string versus timestamp mixup - *05/09/2023* - 3.5.10
- FIX : PHP8: warnings - *30/08/2023* - 3.5.9
- FIX : Prise en compte du paramètre titre dans la fonction setup_print_title - *29/08/2023* - 3.5.8
- FIX : setup_print_title function correction *03/08/2023* - 3.5.7
- FIX : Query escape column names and Mysql/Pgsql compatibility *24/03/2023* - 3.5.6
- FIX : Substitution script include ticket ref *3.5.5* - **27/02/2023**
- FIX : script de migration des ticketsup prend en compte la ref dans actioncomm + traitement erreur extrafields - *21/12/2022* - 3.5.4
- FIX : Retro compat *18/11/2022* - 3.5.3
Expand All @@ -18,6 +37,7 @@ ___


## RELEASE 3.4 - 11/03/2022

- FIX : Fatal inclusion lib fail - *09/08/2022* - 3.4.10
- FIX : V16 FAMILY - *02/06/2022* - 3.4.9
- FIX : V16 NewToken() - *02/06/2022* - 3.4.8
Expand All @@ -35,6 +55,7 @@ ___
- NEW : Script for set to 1 encrypting of the password in multicompany admin/security conf *14/01/2022* - 3.3

## RELEASE 3.2 - 29/06/2021

- FIX : fatal php8.1 remove &$GLOBAL to $GLOBAL - *31/05/2022)* - 3.2.9
- FIX : Script for MVD add missing substitutions *08/07/2021* - 3.2.8
- FIX : Script for MVD add missing substitutions *07/07/2021* - 3.2.7
Expand Down
1 change: 1 addition & 0 deletions admin/abricot_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
print '<td align="center" width="200">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="action" value="set_ABRICOT_MAILS_FORMAT">';
print '<input type="hidden" name="token" value="'. newToken() .'">';
print $form->selectarray('ABRICOT_MAILS_FORMAT',array('iso-8859-1'=>'iso-8859-1', 'UTF-8'=>'UTF-8'),$conf->global->ABRICOT_MAILS_FORMAT);
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
Expand Down
5 changes: 5 additions & 0 deletions backport/v12/core/lib/fonctions.lib.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* SPDX-License-Identifier: GPL-3.0-or-later
* This file is part of Dolibarr module Abricot
*/



if ((float) DOL_VERSION < 12) {
Expand Down
42 changes: 21 additions & 21 deletions core/modules/modAbricot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct($db)
// (where XXX is value of numeric property 'numero' of module)
$this->description = "Collection of specific ATM functions and classes";
// Possible values for version are: 'development', 'experimental' or version
$this->version = '3.5.5';
$this->version = '3.9.3';
$this->editor_name = 'ATM Consulting';
$this->editor_url = 'https://www.atm-consulting.fr';
// Key used in llx_const table to save module status enabled/disabled
Expand Down Expand Up @@ -115,9 +115,9 @@ public function __construct($db)
// List of modules id to disable if this one is disabled
$this->requiredby = array();
// Minimum version of PHP required by module
$this->phpmin = array(5, 3);
$this->phpmin = array(7, 0);
// Minimum version of Dolibarr required by module
$this->need_dolibarr_version = array(3, 2);
$this->need_dolibarr_version = array(16, 0);
$this->langfiles = 'abricot@abricot'; // langfiles@mymodule
// Constants
// List of particular constants to add when module is enabled
Expand All @@ -144,9 +144,9 @@ public function __construct($db)
// Example:
$this->tabs = array(
// // To add a new tab identified by code tabname1
// 'objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__',
// 'objecttype:+tabname1:Title1:langfile@mymodule:$user->hasRight('mymodule', 'read'):/mymodule/mynewtab1.php?id=__ID__',
// // To add another new tab identified by code tabname2
// 'objecttype:+tabname2:Title2:langfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__',
// 'objecttype:+tabname2:Title2:langfile@mymodule:$user->hasRight('othermodule', 'read'):/mymodule/mynewtab2.php?id=__ID__',
// // To remove an existing tab identified by code tabname
// 'objecttype:-tabname'
);
Expand All @@ -168,14 +168,14 @@ public function __construct($db)
// 'categories_x' to add a tab in category view
// (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
// Dictionnaries
if (! isset($conf->mymodule->enabled)) {
if (! isModEnabled('mymodule')) {
$conf->mymodule=new stdClass();
$conf->mymodule->enabled = 0;
}
$this->dictionnaries = array();
/* Example:
// This is to avoid warnings
if (! isset($conf->mymodule->enabled)) $conf->mymodule->enabled=0;
if (! isModEnabled('mymodule')) $conf->mymodule->enabled=0;
$this->dictionnaries=array(
'langs'=>'mymodule@mymodule',
// List of tables we want to see into dictonnary editor
Expand Down Expand Up @@ -207,9 +207,9 @@ public function __construct($db)
'tabrowid'=>array("rowid","rowid","rowid"),
// Condition to show each dictionnary
'tabcond'=>array(
$conf->mymodule->enabled,
$conf->mymodule->enabled,
$conf->mymodule->enabled
isModEnabled('mymodule'),
isModEnabled('mymodule'),
isModEnabled('mymodule')
)
);
*/
Expand Down Expand Up @@ -241,10 +241,10 @@ public function __construct($db)
//// Permission by default for new user (0/1)
//$this->rights[$r][3] = 1;
//// In php code, permission will be checked by test
//// if ($user->rights->permkey->level1->level2)
//// if ($user->hasRight('permkey', 'level1', 'level2'))
//$this->rights[$r][4] = 'level1';
//// In php code, permission will be checked by test
//// if ($user->rights->permkey->level1->level2)
//// if ($user->hasRight('permkey', 'level1', 'level2'))
//$this->rights[$r][5] = 'level2';
//$r++;
// Main menu entries
Expand All @@ -268,9 +268,9 @@ public function __construct($db)
// 'langs'=>'mylangfile',
// 'position'=>100,
// // Define condition to show or hide menu entry.
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
// 'enabled'=>'$conf->mymodule->enabled',
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
// // Use 'isModEnabled('mymodule')' if entry must be visible if module is enabled.
// 'enabled'=>'isModEnabled('mymodule')',
// // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2')'
// // if you want your menu with a permission rules
// 'perms'=>'1',
// 'target'=>'',
Expand All @@ -293,9 +293,9 @@ public function __construct($db)
// 'langs'=>'mylangfile',
// 'position'=>100,
// // Define condition to show or hide menu entry.
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
// 'enabled'=>'$conf->mymodule->enabled',
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
// // Use 'isModEnabled('mymodule')' if entry must be visible if module is enabled.
// 'enabled'=>'isModEnabled('mymodule')',
// // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2')'
// // if you want your menu with a permission rules
// 'perms'=>'1',
// 'target'=>'',
Expand All @@ -319,10 +319,10 @@ public function __construct($db)
// 'langs'=>'mylangfile',
// 'position'=>100,
// // Define condition to show or hide menu entry.
// // Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
// // Use 'isModEnabled('mymodule')' if entry must be visible if module is enabled.
// // Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
// 'enabled'=>'$conf->mymodule->enabled',
// // Use 'perms'=>'$user->rights->mymodule->level1->level2'
// 'enabled'=>'isModEnabled('mymodule')',
// // Use 'perms'=>'$user->hasRight('mymodule', 'level1', 'level2')'
// // if you want your menu with a permission rules
// 'perms'=>'1',
// 'target'=>'',
Expand Down
5 changes: 5 additions & 0 deletions downlist.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?php
/**
* SPDX-License-Identifier: GPL-3.0-or-later
* This file is part of Dolibarr module Abricot
*/


$s_name = $_POST['session_name'] or die('Pas de session trouvée');
session_name($s_name);
Expand Down
8 changes: 4 additions & 4 deletions includes/class/class.form.core.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlen
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;

$projectsListId = false;
if (empty($user->rights->projet->all->lire))
if (empty($user->hasRight('projet', 'all', 'lire')))
{
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
Expand Down Expand Up @@ -342,7 +342,7 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlen
{
$obj = $db->fetch_object($resql);
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire)
if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->hasRight('societe', 'lire'))
{
// Do nothing
}
Expand Down Expand Up @@ -1461,7 +1461,7 @@ function combo($pLib,$pName,$pListe,$pDefault,$pTaille=1,$onChange='',$plus='',$
$valueofempty=$showEmpty;
}

$field.='<option value="'.($show_empty < 0 ? $show_empty : -1).'"'.( $pDefault==$valueofempty ?' selected':'').'>'.$textforempty.'</option>'."\n"; // id is -2 because -1 is already "do not contact"
$field.='<option value="'.(isset($show_empty) && $show_empty < 0 ? $show_empty : -1).'"'.( $pDefault==$valueofempty ?' selected':'').'>'.$textforempty.'</option>'."\n"; // id is -2 because -1 is already "do not contact"
}

$field.=$this->_combo_option($pListe, $pDefault);
Expand Down Expand Up @@ -2017,7 +2017,7 @@ function button_js($array){
if($pVal=='')$pVal='Supprimer';
if($url!=''){
//la page se rafraichi sur elle meme, meme en popin car c'est l'action suivant qui fera le rafraichissement.
if((substr($url,0,4)=='http')||($url[0] == '?')){
if((substr($url,0,4)=='http')||(mb_substr($url, 0, 1) == '?')){
$url = "document.location.href='".$url."&mode=popin'";
}
else{
Expand Down
2 changes: 1 addition & 1 deletion includes/class/class.list.tbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private function getSearchKey($key, &$TParam) {
$TKey[] = $prefixe.'`'. $field .'`';
}
} else {
$TKey[] =$TPrefixe[0].'`'. strtr($key,';','*').'`';
$TKey[] = (isset($TPrefixe[0])?$TPrefixe[0]:'').'`'. strtr($key,';','*').'`';
}

return $TKey;
Expand Down
31 changes: 26 additions & 5 deletions includes/class/class.objet_std.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,15 @@ function addFieldsInDb(&$db) {

if(!in_array($champs, $Tab)) {
if($this->_is_int($info)) {
$db->Execute('ALTER TABLE `'.$this->get_table().'` ADD `'.$champs.'` int(11) NOT NULL DEFAULT \''.(!empty($info['default']) && is_int($info['default']) ? $info['default'] : '0').'\'');
$sqlAlterInt = 'ALTER TABLE `'.$this->get_table().'` ADD `'.$champs.'` integer';
if(! isset($info['nullable']) || $info['nullable'] === false) $sqlAlterInt .= ' NOT';
$sqlAlterInt .= ' NULL';

if(empty($info['default']) || ! is_int($info['default']) && strtoupper($info['default']) !== 'NULL') $sqlAlterInt .= ' DEFAULT 0';
else $sqlAlterInt .= ' DEFAULT '.$info['default'];

$db->Execute($sqlAlterInt);
// $db->Execute('ALTER TABLE `'.$this->get_table().'` ADD `'.$champs.'` integer NOT NULL DEFAULT \''.(!empty($info['default']) && is_int($info['default']) ? $info['default'] : '0').'\'');
}else if($this->_is_date($info)) {

$db->Execute('ALTER TABLE `'.$this->get_table().'` ADD `'.$champs.'` datetime NULL');
Expand Down Expand Up @@ -474,7 +482,11 @@ function _set_save_query(&$query){
else $query[$nom_champ] = NULL;
}
else{
$date = date('Y-m-d H:i:s',$this->{$nom_champ});
if (preg_match('/^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$/', $this->{$nom_champ})) {
$date = $this->{$nom_champ};
} else {
$date = date('Y-m-d H:i:s', $this->{$nom_champ});
}
$query[$nom_champ] = $date;
}
}
Expand All @@ -485,8 +497,16 @@ function _set_save_query(&$query){
$query[$nom_champ] = serialize($this->{$nom_champ});
}

else if($this->_is_int($info)){
$query[$nom_champ] = (int)Tools::string2num($this->{$nom_champ});
else if($this->_is_int($info)) {
$res = (int) Tools::string2num($this->{$nom_champ});

// Handle nullable properties
if(isset($info['default']) && $res === 0 && $res !== $info['default']) {
$res = $info['default'];
if(isset($info['nullable']) && strtoupper($info['default']) === 'NULL') $res = null;
}

$query[$nom_champ] = $res;
}

else if($this->_is_float($info)){
Expand Down Expand Up @@ -958,7 +978,8 @@ function get_tab($recursif = false, $object = null) {
else $Tab[$key] = $value;
}
else if(substr($key,0, strlen(OBJETSTD_DATEMASK) )===OBJETSTD_DATEMASK){
if($value===FALSE)$Tab[$key] = '0000-00-00 00:00:00';
if($value===FALSE) $Tab[$key] = '0000-00-00 00:00:00';
elseif (is_string($value) && preg_match('/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/', $value)) $Tab[$key] = $value;
else $Tab[$key] = date('Y-m-d H:i:s',$value);
}
else{
Expand Down
2 changes: 1 addition & 1 deletion includes/class/class.reponse.mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TReponseMail{
* Constructor
* @access protected
*/
function TReponseMail($emailfrom="",$emailto="",$titre="",$corps=""){
function __construct($emailfrom="",$emailto="",$titre="",$corps=""){
global $conf;

$this->emailfrom=$emailfrom;
Expand Down
Loading