diff --git a/ChangeLog.md b/ChangeLog.md index 9d78128..5fda608 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 @@ -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 @@ -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 diff --git a/admin/abricot_setup.php b/admin/abricot_setup.php index 1e86fa7..6c27a13 100644 --- a/admin/abricot_setup.php +++ b/admin/abricot_setup.php @@ -185,6 +185,7 @@ print ''; print '
'; print ''; +print ''; print $form->selectarray('ABRICOT_MAILS_FORMAT',array('iso-8859-1'=>'iso-8859-1', 'UTF-8'=>'UTF-8'),$conf->global->ABRICOT_MAILS_FORMAT); print ''; print '
'; diff --git a/backport/v12/core/lib/fonctions.lib.php b/backport/v12/core/lib/fonctions.lib.php index 1fab78f..fe1a5e1 100644 --- a/backport/v12/core/lib/fonctions.lib.php +++ b/backport/v12/core/lib/fonctions.lib.php @@ -1,4 +1,9 @@ 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.2'; $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 @@ -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 @@ -168,7 +168,7 @@ 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; } diff --git a/downlist.php b/downlist.php index c076e75..1aa417b 100644 --- a/downlist.php +++ b/downlist.php @@ -1,4 +1,9 @@ '.$textforempty.''."\n"; // id is -2 because -1 is already "do not contact" + $field.=''."\n"; // id is -2 because -1 is already "do not contact" } $field.=$this->_combo_option($pListe, $pDefault); @@ -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{ diff --git a/includes/class/class.list.tbs.php b/includes/class/class.list.tbs.php index 367f2e7..8e8cfef 100755 --- a/includes/class/class.list.tbs.php +++ b/includes/class/class.list.tbs.php @@ -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; diff --git a/includes/class/class.objet_std.php b/includes/class/class.objet_std.php index a0a7678..31a9fbf 100755 --- a/includes/class/class.objet_std.php +++ b/includes/class/class.objet_std.php @@ -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'); @@ -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; } } @@ -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)){ @@ -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{ diff --git a/includes/class/class.reponse.mail.php b/includes/class/class.reponse.mail.php index 34a5d26..1b2187b 100755 --- a/includes/class/class.reponse.mail.php +++ b/includes/class/class.reponse.mail.php @@ -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; diff --git a/includes/class/class.seedobject.php b/includes/class/class.seedobject.php index 1490d25..5cf0cb0 100644 --- a/includes/class/class.seedobject.php +++ b/includes/class/class.seedobject.php @@ -37,7 +37,7 @@ class SeedObjectDolibarr extends CommonObject */ protected function isDate($info) { - if (is_callable('parent::isDate')) return parent::isDate($info); + if (is_callable(parent::class.'::isDate')) return parent::isDate($info); if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; @@ -51,7 +51,7 @@ protected function isDate($info) */ protected function isArray($info) { - if (is_callable('parent::isArray')) return parent::isArray($info); + if (is_callable(parent::class.'::isArray')) return parent::isArray($info); if(is_array($info)) { @@ -69,7 +69,7 @@ protected function isArray($info) */ protected function isNull($info) { - if (is_callable('parent::isNull')) return parent::isNull($info); + if (is_callable(parent::class.'::isNull')) return parent::isNull($info); if(is_array($info)) { @@ -87,7 +87,7 @@ protected function isNull($info) */ protected function isInt($info) { - if (is_callable('parent::isInt')) return parent::isInt($info); + if (is_callable(parent::class.'::isInt')) return parent::isInt($info); if(is_array($info)) { @@ -105,7 +105,7 @@ protected function isInt($info) */ protected function isFloat($info) { - if (is_callable('parent::isFloat')) return parent::isFloat($info); + if (is_callable(parent::class.'::isFloat')) return parent::isFloat($info); if(is_array($info)) { @@ -123,7 +123,7 @@ protected function isFloat($info) */ protected function isText($info) { - if (is_callable('parent::isText')) return parent::isText($info); + if (is_callable(parent::class.'::isText')) return parent::isText($info); if(is_array($info)) { @@ -141,7 +141,7 @@ protected function isText($info) */ protected function isIndex($info) { - if (is_callable('parent::isIndex')) return parent::isIndex($info); + if (is_callable(parent::class.'::isIndex')) return parent::isIndex($info); if(is_array($info)) { @@ -282,7 +282,7 @@ class SeedObjectDolibarr extends CommonObject */ public function isDate($info) { - if (is_callable('parent::isDate')) return parent::isDate($info); + if (is_callable(parent::class.'::isDate')) return parent::isDate($info); if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true; else return false; @@ -296,7 +296,7 @@ public function isDate($info) */ public function isArray($info) { - if (is_callable('parent::isArray')) return parent::isArray($info); + if (is_callable(parent::class.'::isArray')) return parent::isArray($info); if(is_array($info)) { @@ -314,7 +314,7 @@ public function isArray($info) */ public function isNull($info) { - if (is_callable('parent::isNull')) return parent::isNull($info); + if (is_callable(parent::class.'::isNull')) return parent::isNull($info); if(is_array($info)) { @@ -332,7 +332,7 @@ public function isNull($info) */ public function isInt($info) { - if (is_callable('parent::isInt')) return parent::isInt($info); + if (is_callable(parent::class.'::isInt')) return parent::isInt($info); if(is_array($info)) { @@ -350,7 +350,7 @@ public function isInt($info) */ public function isFloat($info) { - if (is_callable('parent::isFloat')) return parent::isFloat($info); + if (is_callable(parent::class.'::isFloat')) return parent::isFloat($info); if(is_array($info)) { @@ -368,7 +368,7 @@ public function isFloat($info) */ public function isText($info) { - if (is_callable('parent::isText')) return parent::isText($info); + if (is_callable(parent::class.'::isText')) return parent::isText($info); if(is_array($info)) { @@ -386,7 +386,7 @@ public function isText($info) */ public function isIndex($info) { - if (is_callable('parent::isIndex')) return parent::isIndex($info); + if (is_callable(parent::class.'::isIndex')) return parent::isIndex($info); if(is_array($info)) { @@ -550,9 +550,9 @@ protected function init() $this->date_creation = 0; $this->tms = 0; - if(!isset($this->fields['rowid'])) $this->fields['rowid']=array('type'=>'integer','index'=>true); - if(!isset($this->fields['date_creation'])) $this->fields['date_creation']=array('type'=>'date'); - if(!isset($this->fields['tms'])) $this->fields['tms']=array('type'=>'date'); + if(!isset($this->fields['rowid'])) $this->fields['rowid']=array('type'=>'integer','index'=>true, 'enabled'=>1, 'visible'=>0); + if(!isset($this->fields['date_creation'])) $this->fields['date_creation']=array('type'=>'date', 'enabled'=>1, 'visible'=>0); + if(!isset($this->fields['tms'])) $this->fields['tms']=array('type'=>'date', 'enabled'=>1, 'visible'=>0); if (!empty($this->fields)) { @@ -1050,7 +1050,7 @@ public function setValues(&$Tab) foreach ($Tab as $key => $value) { - if($this->fields[$key]['type'] == 'datetime'){ + if($this->checkFieldType($key, 'datetime')){ if(!empty($value)) $value .= ' '. $Tab[$key.'hour'] .':'.$Tab[$key.'min'].':'.$Tab[$key.'sec']; $this->setDate($key, $value); } @@ -1088,7 +1088,7 @@ public function setValues(&$Tab) public function createCommon(User $user, $notrigger = false) { // method_exists() with key word 'parent' doesn't work - if (is_callable('parent::createCommon')) return parent::createCommon($user, $notrigger); + if (is_callable(parent::class.'::createCommon')) return parent::createCommon($user, $notrigger); $error = 0; @@ -1142,63 +1142,6 @@ public function createCommon(User $user, $notrigger = false) } } - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @param string $morewhere Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetchCommon($id, $ref = null, $morewhere='') - { - // method_exists() with key word 'parent' doesn't work - if (is_callable('parent::fetchCommon')) return parent::fetchCommon($id, $ref, $morewhere); - - - if (empty($id) && empty($ref)) return false; - - $sql = 'SELECT '.$this->get_field_list().', date_creation, tms'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - - if(!empty($id)) $sql.= ' WHERE rowid = '.$id; - else $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']); - if ($morewhere) $sql.=$morewhere; - - $res = $this->db->query($sql); - if ($res) - { - $num = $this->db->num_rows($res); - - if(empty($num)) - { - return 0; - } - - if ($obj = $this->db->fetch_object($res)) - { - $this->id = $id; - $this->set_vars_by_db($obj); - - $this->date_creation = $this->db->idate($obj->date_creation); - $this->tms = $this->db->idate($obj->tms); - - return $this->id; - } - else - { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; - } - } - else - { - $this->error = $this->db->lasterror(); - $this->errors[] = $this->error; - return -1; - } - } /** * Update object into database @@ -1210,7 +1153,7 @@ public function fetchCommon($id, $ref = null, $morewhere='') public function updateCommon(User $user, $notrigger = false) { // method_exists() with key word 'parent' doesn't work - if (is_callable('parent::updateCommon')) return parent::updateCommon($user, $notrigger); + if (is_callable(parent::class.'::updateCommon')) return parent::updateCommon($user, $notrigger); $error = 0; @@ -1275,7 +1218,7 @@ public function updateCommon(User $user, $notrigger = false) public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0) { // method_exists() with key word 'parent' doesn't work - if (is_callable('parent::deleteCommon')) return parent::deleteCommon($user, $notrigger, $forcechilddeletion); + if (is_callable(parent::class.'::deleteCommon')) return parent::deleteCommon($user, $notrigger, $forcechilddeletion); $error=0; @@ -1315,7 +1258,11 @@ public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion function addFieldsInDb() { - $resql = $this->db->query('SHOW FIELDS FROM ' . MAIN_DB_PREFIX . $this->table_element); + if ($this->db->type == 'pgsql') { + $resql = $this->db->query("SELECT column_name FROM information_schema.columns WHERE table_schema != 'pg_catalog' AND table_schema != 'information_schema' AND table_name = '". MAIN_DB_PREFIX . $this->table_element . "';"); + } else { + $resql = $this->db->query('SHOW FIELDS FROM ' . MAIN_DB_PREFIX . $this->table_element); + } if($resql===false ) { var_dump($this->db);exit; @@ -1325,7 +1272,11 @@ function addFieldsInDb() $Tab = array(); while ($obj = $this->db->fetch_object($resql)) { - $Tab[] = $obj->Field; + if ($this->db->type == 'pgsql') { + $Tab[] = $obj->column_name; + } else { + $Tab[] = $obj->Field; + } } $TChamps = array_merge(array('date_creation' => array('type' => 'date'), 'tms' => array('type' => 'date'),'rowid'=>array('type'=>'integer','index'=>true)), $this->fields); @@ -1336,7 +1287,7 @@ function addFieldsInDb() { if ($this->isInt($info)) { - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.$this->table_element.' ADD '.$champs.' int(11) '.(! empty($info['notnull']) ? ' NOT NULL' : '').' DEFAULT \''.(! empty($info['default']) && is_int($info['default']) ? $info['default'] : '0')."'"; + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.$this->table_element.' ADD '.$champs.' integer '.(! empty($info['notnull']) ? ' NOT NULL' : '').' DEFAULT \''.(! empty($info['default']) && is_int($info['default']) ? $info['default'] : '0')."'"; if(array_key_exists('foreignkey', $info) && ! empty($info['foreignkey'])) { $fk = explode('.', $info['foreignkey']); // fk[0] => tablename, fk[1] => field $sql.= ', ADD CONSTRAINT FOREIGN KEY ('.$champs.') REFERENCES '.$fk[0].'('.$fk[1].')'; @@ -1374,7 +1325,12 @@ function init_db_by_vars() if(empty($this->table_element))exit('NoDataTableDefined'); - $resql = $this->db->query("SHOW TABLES FROM `" . $dolibarr_main_db_name . "` LIKE '" . MAIN_DB_PREFIX . $this->table_element . "'"); + if ($this->db->type == 'pgsql') { + $resql = $this->db->query("SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' AND tablename ILIKE '" . MAIN_DB_PREFIX . $this->table_element . "';"); + } else { + $resql = $this->db->query("SHOW TABLES FROM `" . $dolibarr_main_db_name . "` LIKE '" . MAIN_DB_PREFIX . $this->table_element . "'"); + } + if($resql === false) { var_dump($this->db);exit; @@ -1391,38 +1347,47 @@ function init_db_by_vars() rowid integer AUTO_INCREMENT PRIMARY KEY ,date_creation datetime DEFAULT NULL ,tms timestamp - ,KEY date_creation (date_creation) - ,KEY tms (tms) ) ENGINE=InnoDB DEFAULT CHARSET=" . $charset; - if (!empty($conf->db->dolibarr_main_db_collation)) $sql .= ' COLLATE='.$conf->db->dolibarr_main_db_collation; - + if (empty($conf->db->dolibarr_main_db_collation)) { + $sql .= ';'; + } else { + $sql .= ' COLLATE='.$conf->db->dolibarr_main_db_collation.';'; + } - $res = $this->db->query($sql); + $res = $this->db->query($sql); + if($res===false) { + var_dump($this->db);exit; + } + $sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . $this->table_element . ' ADD INDEX idx_'.$this->table_element .'_date_creation (date_creation);'; + $res = $this->db->query($sql); + if($res===false) { + var_dump($this->db);exit; + } + $sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . $this->table_element . ' ADD INDEX idx_'.$this->table_element .'_tms (tms);'; + $res = $this->db->query($sql); if($res===false) { var_dump($this->db);exit; - - } - - } else { - // Conversion de l'ancienne table sans auto_increment - $resql = $this->db->query('DESC '.MAIN_DB_PREFIX . $this->table_element); - if ($resql) - { - while ($desc = $this->db->fetch_object($resql)) + if ($this->db->type != 'pgsql') { + // Conversion de l'ancienne table sans auto_increment + $resql = $this->db->query('DESC '.MAIN_DB_PREFIX . $this->table_element); + if ($resql) { - if ($desc->Field == 'rowid') + while ($desc = $this->db->fetch_object($resql)) { - if (strpos($desc->Extra, 'auto_increment') === false) + if ($desc->Field == 'rowid') { - $this->db->query('ALTER TABLE '.MAIN_DB_PREFIX . $this->table_element.' MODIFY COLUMN rowid INT auto_increment'); - } + if (strpos($desc->Extra, 'auto_increment') === false) + { + $this->db->query('ALTER TABLE '.MAIN_DB_PREFIX . $this->table_element.' MODIFY COLUMN rowid INT auto_increment'); + } - break; + break; + } } } } @@ -1432,7 +1397,13 @@ function init_db_by_vars() if(!empty($this->isextrafieldmanaged)) { - $resql = $this->db->query("SHOW TABLES FROM " . $dolibarr_main_db_name . " LIKE '" . MAIN_DB_PREFIX . $this->table_element . "_extrafields'"); + + if($this->db->type == 'pgsql'){ + $resql = $this->db->query("SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema' AND tablename ILIKE '" . MAIN_DB_PREFIX . $this->table_element . "_extrafields';"); + } else { + $resql = $this->db->query("SHOW TABLES FROM " . $dolibarr_main_db_name . " LIKE '" . MAIN_DB_PREFIX . $this->table_element . "_extrafields'"); + } + if($resql === false) { var_dump($this->db);exit; } @@ -1449,12 +1420,26 @@ function init_db_by_vars() ,tms timestamp ,fk_object integer ,import_key varchar(14) - ,KEY tms (tms) - , UNIQUE fk_object (fk_object) ) ENGINE=InnoDB DEFAULT CHARSET=" . $charset; - if (!empty($conf->db->dolibarr_main_db_collation)) $sql .= ' COLLATE='.$conf->db->dolibarr_main_db_collation; + if (empty($conf->db->dolibarr_main_db_collation)) { + $sql .= ';'; + } else { + $sql .= ' COLLATE='.$conf->db->dolibarr_main_db_collation.';'; + } + + $res = $this->db->query($sql); + if($res===false) { + var_dump($this->db);exit; + } + + $sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . $this->table_element . ' ADD UNIQUE INDEX udx_'.$this->table_element .'_fk_object (fk_object);'; + $res = $this->db->query($sql); + if($res===false) { + var_dump($this->db);exit; + } + $sql = 'ALTER TABLE ' . MAIN_DB_PREFIX . $this->table_element . ' ADD INDEX idx_'.$this->table_element .'_tms (tms);'; $res = $this->db->query($sql); if($res===false) { var_dump($this->db);exit; diff --git a/includes/class/class.tools.php b/includes/class/class.tools.php index ca09673..757b59d 100755 --- a/includes/class/class.tools.php +++ b/includes/class/class.tools.php @@ -239,10 +239,19 @@ function sortByPosition($a, $b) { */ static function getConstant(){ - /* table des bglobales */ - $temp = $GLOBALS; + /** + * PHP 8.1 + * Fatal error: Cannot acquire reference to $GLOBALS in ... + * Referencing $GLOBALS is no longer allowed + * Prior to PHP 8.1, it was possible to create a reference to $GLOBALS array, and modify that reference. All changes would then be reflected in the global variables as well. + */ + $Tout = array(); - foreach($temp as $key => $val){ + foreach($GLOBALS as $key => $val){ + if ($key == 'GLOBALS') { + continue; + } + if(substr($key,0,4)=="GBL_"){ $Tout[] = $key; } diff --git a/includes/lib/admin.lib.php b/includes/lib/admin.lib.php index 3e49a09..f94e95f 100644 --- a/includes/lib/admin.lib.php +++ b/includes/lib/admin.lib.php @@ -109,11 +109,11 @@ function TModuleVersionCompare($versionSource,$versionTarget, $skipDolVersion = * Display title * @param string $title */ -function setup_print_title($title="", $width = 300) +function setup_print_title($title="Parameter", $width = 300) { global $langs; print ''; - print ''.$langs->trans("Parameter").''; + print ''.$langs->trans($title) . ''; print ' '; print ''.$langs->trans('Value').''; print ''; @@ -199,7 +199,7 @@ function setup_print_input_form_part($confkey, $title = false, $desc ='', $metas if($type!='textarea'){ $defaultMetas['type'] = 'text'; - $defaultMetas['value'] = $conf->global->{$confkey}; + $defaultMetas['value'] = isset($conf->global->{$confkey}) ? $conf->global->{$confkey} : ''; } diff --git a/script/change-datetime-default-to-null.php b/script/change-datetime-default-to-null.php index 03540e4..096d915 100644 --- a/script/change-datetime-default-to-null.php +++ b/script/change-datetime-default-to-null.php @@ -1,4 +1,9 @@ expensereport->enabled)) { +if(!isModEnabled('expensereport')) { _logMsg('1. Activation du module note de frais', 'title'); echo ' > Activation du module à faire via l\'interface administrateur
'; echo ' > Désactivation des types de frais à faire dans le dictionnaire
'; diff --git a/script/migration_ticketmsg_to_actioncomm.php b/script/migration_ticketmsg_to_actioncomm.php index bf653c9..7c9aece 100644 --- a/script/migration_ticketmsg_to_actioncomm.php +++ b/script/migration_ticketmsg_to_actioncomm.php @@ -1,4 +1,9 @@ tab_translate[$key]."
"; //if ($key == 'Order') print "Domain=$domain, found a string for key=$key=$tab[0] with value $tab[1]. Currently in cache ".$this->tab_translate[$key]."
"; if (empty($tab_translate[$key])) { // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) @@ -278,8 +282,12 @@ function _helpUsage($path,$script_file) { global $conf; - print "Usage: ".$script_file." cronSecuritykey moduleFolderName langKeyTarget langKeyFrom(optional default fr_FR) \n"; + print "DEPRECATED : Use Module Dev Community tool instead\n"; + print "https://github.com/Dolibarr/dolibarr-dev-community-tools\n\n"; + + print "Usage: ".$script_file." cronSecuritykey moduleFolderName langKeyTarget langKeyFrom(optional default fr_FR)\n"; print "Exemple: ./".$script_file." khce86zgj84fzefef8f48 moduleFolderName en_EN fr_FR\n"; + print "\n"; } diff --git a/script/set-atm-default-config.php b/script/set-atm-default-config.php new file mode 100644 index 0000000..257b385 --- /dev/null +++ b/script/set-atm-default-config.php @@ -0,0 +1,29 @@ + '1', + 'MAIN_INFO_SOCIETE_LOGO_NO_BACKGROUND' => '1', +]; + +foreach ($TCONST_TO_SET_GLOBALLY as $constName => $constValue) { + $sql = sprintf($BOOL_CONST_SQL_TEMPLATE, $constName, $constValue); + ast_sqlQuerylog($db, $sql); +} + +echo ast_log('FIN'); diff --git a/tpl/extrafields_setup.tpl.php b/tpl/extrafields_setup.tpl.php index 11535c1..4882702 100644 --- a/tpl/extrafields_setup.tpl.php +++ b/tpl/extrafields_setup.tpl.php @@ -1,4 +1,9 @@