From 37e16b5ff27b6359851deb0cccd9ffba477ef918 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 11:55:59 +0200 Subject: [PATCH 1/3] Trans --- htdocs/langs/en_US/ticket.lang | 1 + htdocs/langs/fr_FR/ticket.lang | 1 + htdocs/ticket/index.php | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 9f441d1c66f..6d50a1bf149 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -220,6 +220,7 @@ TicketChangeStatus=Change status TicketConfirmChangeStatus=Confirm the status change : %s ? TicketLogStatusChanged=Status changed : %s to %s TicketNotNotifyTiersAtCreate=Not notify company at create +Unread=Unread # # Logs diff --git a/htdocs/langs/fr_FR/ticket.lang b/htdocs/langs/fr_FR/ticket.lang index 0c38f72dd78..a2b29b577fb 100644 --- a/htdocs/langs/fr_FR/ticket.lang +++ b/htdocs/langs/fr_FR/ticket.lang @@ -219,6 +219,7 @@ TicketChangeStatus=Changer l'état TicketConfirmChangeStatus=Confirmez le changement d'état: %s? TicketLogStatusChanged=Statut changé: %s à %s TicketNotNotifyTiersAtCreate=Ne pas notifier l'entreprise à la création +Unread=Non lu # # Logs diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 92fe366c65c..e87e0166bc0 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -302,7 +302,7 @@ if ($result) { print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -322,16 +322,17 @@ if ($result) { $tickesupstatic->subject = $objp->subject; print ''; - // Creation date - print '"; // Ref print '\n"; + // Creation date + print '"; + // Subject print '
' . $transRecordedType . '' . $langs->trans('Ref') . '' . $langs->trans('Date') . '' . $langs->trans('Subject') . '' . $langs->trans('Type') . '' . $langs->trans('Category') . '
'; - print dol_print_date($db->jdate($objp->datec), 'dayhour'); - print "'; print $tickesupstatic->getNomUrl(1); print "'; + print dol_print_date($db->jdate($objp->datec), 'dayhour'); + print "'; print '' . dol_trunc($objp->subject, 30) . ''; From 8df834bd2a26f67d706fb16ecbadf2d6122d1ff5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 12:13:34 +0200 Subject: [PATCH 2/3] Debug module ticket --- htdocs/ticket/card.php | 2 +- htdocs/ticket/class/actions_ticket.class.php | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/contact.php | 2 +- htdocs/ticket/history.php | 2 +- htdocs/ticket/index.php | 2 +- htdocs/ticket/list.php | 43 +++++++++++--------- htdocs/ticket/new.php | 2 +- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 2 +- 9 files changed, 32 insertions(+), 27 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index cf49bda3562..b736b49646f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -5,7 +5,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 72e010eb1f4..6dc946ebad3 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -4,7 +4,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index de7f39049f8..3dc0ab39756 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -188,7 +188,7 @@ class Ticket extends CommonObject 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,), - 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index e96fb015c04..22199bed745 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -5,7 +5,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/history.php b/htdocs/ticket/history.php index c982acf3a3a..c840f3aa1a8 100644 --- a/htdocs/ticket/history.php +++ b/htdocs/ticket/history.php @@ -3,7 +3,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index e87e0166bc0..9acfd66c3bb 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -3,7 +3,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index cc3291a5e00..c99ac7e7e3a 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -5,7 +5,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -20,6 +20,7 @@ /** * \file htdocs/ticket/list.php * \ingroup ticket + * \brief List page for tickets */ require '../main.inc.php'; @@ -90,7 +91,6 @@ foreach($object->fields as $key => $val) if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } - // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach($object->fields as $key => $val) @@ -106,7 +106,7 @@ foreach($object->fields as $key => $val) if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -177,16 +177,21 @@ if (empty($reshook)) * View */ -$help_url = 'FR:DocumentationModuleTicket'; -llxHeader('', $langs->trans('TicketList'), $help_url); - -$form = new Form($db); +$form=new Form($db); $formTicket = new FormTicket($db); +$now=dol_now(); + $user_assign = new User($db); $user_create = new User($db); $socstatic = new Societe($db); +$help_url = 'FR:DocumentationModuleTicket'; +$title = $langs->trans('TicketList'); + +llxHeader('', $title, $help_url); + + // Build and execute select // -------------------------------------------------------------------- @@ -204,8 +209,8 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('ticket').")"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { @@ -245,6 +250,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); */ $sql.=$db->order($sortfield,$sortorder); @@ -253,18 +259,17 @@ $sql.=$db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } -// if total resultset is smaller the limit, no need to do paging. +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $resql = $result; $num = $nbtotalofrecords; } else @@ -434,7 +439,6 @@ if ($user->rights->ticket->delete) $arrayofmassactions['predelete']=$langs->tran if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - print '
'; if ($optioncss != '') print ''; print ''; @@ -456,7 +460,7 @@ if ($user->rights->ticket->write) $newcardbutton.= ''; } -print_barre_liste($langs->trans('TicketList'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_ticket', 0, $newcardbutton, '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_ticket', 0, $newcardbutton, '', $limit); if ($mode == 'my_assign') { print '
' . $langs->trans('TicketAssignedToMeInfos') . '

'; @@ -513,7 +517,6 @@ print ''; - foreach($object->fields as $key => $val) { $align=''; @@ -581,13 +584,15 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -if (! empty($extrafields->attributes[$object->table_element]['computed'])) { +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } + // Loop on record // -------------------------------------------------------------------- $i=0; @@ -696,7 +701,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/ticket/new.php b/htdocs/ticket/new.php index c92a8538bdf..8f33d87c804 100644 --- a/htdocs/ticket/new.php +++ b/htdocs/ticket/new.php @@ -4,7 +4,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index ec3703990bf..dd9f340429e 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -4,7 +4,7 @@ * * 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 - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, From 45a45b0dec7c28f610de72b997c8c4ad60c3495d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Jul 2018 13:02:01 +0200 Subject: [PATCH 3/3] NEW Can enable a module, even external module, from command line Conflicts: htdocs/install/upgrade2.php --- htdocs/core/class/extrafields.class.php | 12 +-- htdocs/core/db/mysqli.class.php | 26 ++++-- htdocs/install/upgrade.php | 13 +-- htdocs/install/upgrade2.php | 112 +++++++++++++++++------- 4 files changed, 112 insertions(+), 51 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 2216c0fd7aa..e8ba9a538ec 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -241,10 +241,10 @@ class ExtraFields if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255'; } $field_desc = array( - 'type'=>$typedb, - 'value'=>$lengthdb, - 'null'=>($required?'NOT NULL':'NULL'), - 'default' => $default_value + 'type'=>$typedb, + 'value'=>$lengthdb, + 'null'=>($required?'NOT NULL':'NULL'), + 'default' => $default_value ); $result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc); @@ -360,8 +360,8 @@ class ExtraFields $sql.= " ".$list.","; $sql.= " ".($default?"'".$this->db->escape($default)."'":"null").","; $sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").","; - $sql .= " " . $user->id . ","; - $sql .= " " . $user->id . ","; + $sql .= " " . (is_object($user) ? $user->id : 0). ","; + $sql .= " " . (is_object($user) ? $user->id : 0). ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1"); $sql.=')'; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 15d95e39194..23c19542ae6 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -765,28 +765,36 @@ class DoliDBMysqli extends DoliDB // ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); $sql= "ALTER TABLE ".$table." ADD ".$field_name." "; $sql.= $field_desc['type']; - if(preg_match("/^[^\s]/i",$field_desc['value'])) + if (preg_match("/^[^\s]/i",$field_desc['value'])) + { if (! in_array($field_desc['type'],array('date','datetime'))) { $sql.= "(".$field_desc['value'].")"; } - if(preg_match("/^[^\s]/i",$field_desc['attribute'])) - $sql.= " ".$field_desc['attribute']; - if(preg_match("/^[^\s]/i",$field_desc['null'])) - $sql.= " ".$field_desc['null']; - if(preg_match("/^[^\s]/i",$field_desc['default'])) + } + if (isset($field_desc['attribute']) && preg_match("/^[^\s]/i",$field_desc['attribute'])) + { + $sql.= " ".$field_desc['attribute']; + } + if (isset($field_desc['null']) && preg_match("/^[^\s]/i",$field_desc['null'])) + { + $sql.= " ".$field_desc['null']; + } + if (isset($field_desc['default']) && preg_match("/^[^\s]/i",$field_desc['default'])) { if(preg_match("/null/i",$field_desc['default'])) $sql.= " default ".$field_desc['default']; else $sql.= " default '".$field_desc['default']."'"; } - if(preg_match("/^[^\s]/i",$field_desc['extra'])) - $sql.= " ".$field_desc['extra']; + if (isset($field_desc['extra']) && preg_match("/^[^\s]/i",$field_desc['extra'])) + { + $sql.= " ".$field_desc['extra']; + } $sql.= " ".$field_position; dol_syslog(get_class($this)."::DDLAddField ".$sql,LOG_DEBUG); - if($this->query($sql)) { + if ($this->query($sql)) { return 1; } return -1; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 5132168c076..8570b4aa670 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2015-2016 Raphaël Doursenaud * @@ -21,10 +21,13 @@ * * cd htdocs/install * php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion] - * php upgrade2.php 3.4.0 3.5.0 + * php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE] * - * Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line a script from a module. - * Option 'ignoredbversion' allows to run migration even if database is a bugged database version. + * And for final step: + * php step5.php 3.4.0 3.5.0 + * + * Option 'dirmodule' allows to provide a path for an external module, so we migrate from command line using a script from a module. + * Option 'ignoredbversion' allows to run migration even if database version does not match start version of migration * Return code is 0 if OK, >0 if error */ @@ -84,7 +87,7 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial if (! $versionfrom && ! $versionto) { print 'Error: Parameter versionfrom or versionto missing.'."\n"; - print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 560bf3d2593..c52fb45a106 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2012 Laurent Destailleur + * Copyright (C) 2005-2018 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2010 Juanjo Menent * Copyright (C) 2015-2016 Raphaël Doursenaud @@ -18,13 +18,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Upgrade scripts can be ran from command line with syntax: + * Upgrade2 scripts can be ran from command line with syntax: * * cd htdocs/install - * php upgrade.php 3.4.0 3.5.0 - * php upgrade2.php 3.4.0 3.5.0 [MODULE_NAME1_TO_ENABLE,MODULE_NAME2_TO_ENABLE] + * php upgrade.php 3.4.0 3.5.0 [dirmodule|ignoredbversion] + * php upgrade2.php 3.4.0 3.5.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE] + * + * And for final step: + * php step5.php 3.4.0 3.5.0 * * Return code is 0 if OK, >0 if error + * + * Note: To just enable a module from command line, use this syntax: + * php upgrade2.php 0.0.0 0.0.0 [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE] */ /** @@ -77,7 +83,7 @@ if ($dolibarr_main_db_type == 'pgsql') $choix=2; if ($dolibarr_main_db_type == 'mssql') $choix=3; -dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page"); +dolibarr_install_syslog("--- upgrade2: entering upgrade2.php page ".$versionfrom." ".$versionto." ".$enablemodules); if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initialized", LOG_ERR); @@ -89,14 +95,14 @@ if (! is_object($conf)) dolibarr_install_syslog("upgrade2: conf file not initial if ((! $versionfrom || preg_match('/version/', $versionfrom)) && (! $versionto || preg_match('/version/', $versionto))) { print 'Error: Parameter versionfrom or versionto missing or having a bad format.'."\n"; - print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install) instead of page install/upgrade.php'."\n"; + print 'Upgrade must be ran from command line with parameters or called from page install/index.php (like a first install)'."\n"; // Test if batch mode $sapi_type = php_sapi_name(); $script_file = basename(__FILE__); $path=dirname(__FILE__).'/'; if (substr($sapi_type, 0, 3) == 'cli') { - print 'Syntax from command line: '.$script_file." x.y.z a.b.c\n"; + print 'Syntax from command line: '.$script_file." x.y.z a.b.c [MAIN_MODULE_NAME1_TO_ENABLE,MAIN_MODULE_NAME2_TO_ENABLE...]\n"; } exit; } @@ -507,12 +513,12 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 dolCopyDir($srcroot, $destroot, 0, 0); - // Actions for all versions (no database change, delete files and directories) + // Actions for all versions (no database change but delete some files and directories) migrate_delete_old_files($db, $langs, $conf); migrate_delete_old_dir($db, $langs, $conf); - // Actions for all versions (no database change, create directories) + // Actions for all versions (no database change but create some directories) dol_mkdir(DOL_DATA_ROOT.'/bank'); - // Actions for all versions (no database change, rename directories) + // Actions for all versions (no database change but rename some directories) migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits'); print '

'.$langs->trans("MigrationFinished").'
'; @@ -4502,11 +4508,11 @@ function migrate_delete_old_dir($db,$langs,$conf) * @param int $force 1=Reload module even if not already loaded * @return void */ -function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) +function migrate_reload_modules($db, $langs, $conf, $listofmodule=array(), $force=0) { if (count($listofmodule) == 0) return; - dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); + dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force.", listofmodule=".join(',', array_keys($listofmodule))); foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate' { @@ -4524,7 +4530,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_API') + elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; @@ -4534,7 +4540,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_BARCODE') + elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; @@ -4544,7 +4550,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_CRON') + elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; @@ -4554,7 +4560,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SOCIETE') + elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; @@ -4564,7 +4570,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 + elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; @@ -4574,7 +4580,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 + elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; @@ -4584,7 +4590,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; @@ -4594,7 +4600,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; @@ -4604,7 +4610,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; @@ -4614,7 +4620,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 + elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; @@ -4624,7 +4630,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; @@ -4634,7 +4640,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; @@ -4644,7 +4650,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 + elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; @@ -4654,7 +4660,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; @@ -4664,7 +4670,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 + elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; @@ -4674,7 +4680,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; @@ -4684,7 +4690,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SALARIES') // Permission has changed into 6.0 + elseif ($moduletoreload == 'MAIN_MODULE_SALARIES') // Permission has changed into 6.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Salaries module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSalaries.class.php'; @@ -4694,7 +4700,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; @@ -4704,7 +4710,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_WEBSITE') // Module added in 7.0 + elseif ($moduletoreload == 'MAIN_MODULE_WEBSITE') // Module added in 7.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Website module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modWebsite.class.php'; @@ -4714,6 +4720,50 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } + else + { + $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); + if (! empty($reg[1])) + { + if (strtoupper($moduletoreload) == $moduletoreload) // If key is un uppercase + { + $moduletoreloadshort = ucfirst(strtolower($reg[1])); + } + else // If key is a mix of up and low case + { + $moduletoreloadshort = $reg[1]; + } + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort." with mode ".$reloadmode); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; + if ($res) { + $classname = 'mod'.$moduletoreloadshort; + $mod=new $classname($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + else + { + dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + + $res=@dol_include_once(strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + if ($res) { + $classname = 'mod'.$moduletoreloadshort; + $mod=new $classname($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + else + { + dolibarr_install_syslog('Failed to include '.strtolower($moduletoreloadshort).'/core/modules/mod'.$moduletoreloadshort.'.class.php'); + } + } + } + else + { + dolibarr_install_syslog("Error, can't find module with name ".$moduletoreload, LOG_WARNING); + print "Error, can't find module with name ".$moduletoreload; + } + } if (! empty($mod) && is_object($mod)) {