From 9a92545d8d78ac5d82e25d4fcc17358c0d868373 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 30 Mar 2020 14:27:32 +0200 Subject: [PATCH 1/9] FIX missing default accountancy product buy code --- htdocs/product/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 27bf63f08fd..25700920d58 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1211,7 +1211,13 @@ else // Accountancy_code_buy print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; - print $formaccounting->select_account(GETPOST('accountancy_code_buy', 'alpha'), 'accountancy_code_buy', 1, null, 1, 1, ''); + if($type == 0) + { + $accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha')?(GETPOST('accountancy_code_buy', 'alpha')):$conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT); + } else { + $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); + } + print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, ''); print ''; } else // For external software From 04564e83ea8f01eccd12bf148155302cdbc6c5fe Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 31 Mar 2020 10:31:18 +0200 Subject: [PATCH 2/9] FIX : picture migration script from doli 9.0 --- scripts/user/migrate_picture_path.php | 129 ++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 scripts/user/migrate_picture_path.php diff --git a/scripts/user/migrate_picture_path.php b/scripts/user/migrate_picture_path.php new file mode 100755 index 00000000000..f478c42b865 --- /dev/null +++ b/scripts/user/migrate_picture_path.php @@ -0,0 +1,129 @@ +#!/usr/bin/env php + + * Copyright (C) 2015 Jean Heimburger + * + * 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 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file scripts/product/migrate_picture_path.php + * \ingroup scripts + * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ + */ +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path = __DIR__ . '/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n"; + exit(- 1); +} + +@set_time_limit(0); // No timeout for this script +define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". + +// Include and load Dolibarr environment variables +require_once $path . "../../htdocs/master.inc.php"; +require_once DOL_DOCUMENT_ROOT . "/user/class/user.class.php"; +require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; +// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). +// $user is created but empty. + +// $langs->setDefaultLang('en_US'); // To change default language of $langs +$langs->load("main"); // To load language file for default language + +// Global variables +$version = DOL_VERSION; +$error = 0; +$forcecommit = 0; + +print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n"; +dol_syslog($script_file . " launched with arg " . join(',', $argv)); + +if (! isset($argv[1]) || $argv[1] != 'user') { + print "Usage: $script_file user\n"; + exit(- 1); +} + +print '--- start' . "\n"; + +// Case to migrate products path +if ($argv[1] == 'user') { + $u = new User($db); + + $sql = "SELECT rowid as uid from " . MAIN_DB_PREFIX . "user"; // Get list of all products + $resql = $db->query($sql); + if ($resql) { + while ($obj = $db->fetch_object($resql)) { + $u->fetch($obj->uid); + print " migrating user id=" . $u->id . " ref=" . $u->ref . "\n"; + migrate_user_filespath($u); + } + } else { + print "\n sql error " . $sql; + exit(); + } +} + +$db->close(); // Close $db database opened handler + +exit($error); + +/** + * Migrate file from old path to new one for user $u + * + * @param User $u Object user + * @return void + */ +function migrate_user_filespath($u) +{ + global $conf; + + // Les fichiers joints des users sont toujours sur l'entité 1 + $dir = $conf->user->dir_output; + $origin = $dir . '/' . get_exdir($u->id, 2, 0, 0, $u, 'user'); + $destin = $dir . '/' . $u->id; + + $error = 0; + + $origin_osencoded = dol_osencode($origin); + $destin_osencoded = dol_osencode($destin); + dol_mkdir($destin); + + if (dol_is_dir($origin)) { + + $handle = opendir($origin_osencoded); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if ($file != '.' && $file != '..' && is_dir($origin_osencoded . '/' . $file)) { + $thumbs = opendir($origin_osencoded . '/' . $file); + if (is_resource($thumbs)) { + dol_mkdir($destin . '/' . $file); + while (($thumb = readdir($thumbs)) !== false) { + dol_move($origin . '/' . $file . '/' . $thumb, $destin . '/' . $file . '/' . $thumb); + } + // dol_delete_dir($origin.'/'.$file); + } + } else { + if (dol_is_file($origin . '/' . $file)) { + dol_move($origin . '/' . $file, $destin . '/' . $file); + } + } + } + } + } +} From 7cee643c05b3bcf4f6932b2fe7142fdfe4d7cc51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Apr 2020 18:51:25 +0200 Subject: [PATCH 3/9] Prepare 10.0.8 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 1f8d9bf3b8f..cf32d969ef9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION', '10.0.7'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION', '10.0.8'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO', chr(128)); From bc0d98b91c8c2f35d1903d1cff828f635bb3a369 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 3 Apr 2020 14:24:59 +0200 Subject: [PATCH 4/9] FIX 11.0 Ticket Module - Visibility 4, don't display extrafields at the creation --- htdocs/core/class/commonobject.class.php | 14 +++++++++----- htdocs/core/class/html.formticket.class.php | 4 ++-- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/ticket/card.php | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f5553032a09..d30eccb5136 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6634,7 +6634,8 @@ abstract class CommonObject $perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); } - if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation elseif ($mode == 'view' && empty($visibility)) continue; if (empty($perms)) continue; @@ -6661,9 +6662,11 @@ abstract class CommonObject case "view": $value = $this->array_options["options_".$key.$keysuffix]; break; - case "edit": - $getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values. - // GETPOST("options_" . $key) can be 'abc' or array(0=>'abc') + case "create": + case "edit": + + $getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values. + // GETPOST("options_" . $key) can be 'abc' or array(0=>'abc') if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) { if (is_array($getposttemp)) { @@ -6768,7 +6771,8 @@ abstract class CommonObject case "view": $out .= $extrafields->showOutputField($key, $value); break; - case "edit": + case "create": + case "edit": $out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element); break; } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index ecf137adb04..a48cf36c117 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -127,7 +127,7 @@ class FormTicket * @param int $withdolfichehead With dol_fiche_head * @return void */ - public function showForm($withdolfichehead = 0) + public function showForm($withdolfichehead = 0, $mode = 'edit') { global $conf, $langs, $user, $hookmanager; @@ -414,7 +414,7 @@ class FormTicket $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - print $ticketstat->showOptionals($extrafields, 'edit'); + print $ticketstat->showOptionals($extrafields, 'create'); } print ''; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 1ef3ef07255..e6cbad245d9 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -73,7 +73,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] //print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'
'."\n"; if (empty($enabled)) continue; // 0 = Never visible field - if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation if (empty($perms)) continue; // 0 = Not visible // Load language if required diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 8ca8bd22bfe..d59581fa914 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -637,7 +637,7 @@ if ($action == 'create' || $action == 'presend') $defaultref = ''; } - $formticket->showForm(1); + $formticket->showForm(1, 'create'); } if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' From c7cdb64087de7ad740814c9f250cc45a9587998a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 4 Apr 2020 11:07:48 +0200 Subject: [PATCH 5/9] FIX child categories only with good entity rights fix v9 to develop display only categories with good entity rights ( intradolibarr or via REST API) --- htdocs/categories/class/categorie.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index ad7128c31ef..2c2bea3ce0f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -917,7 +917,8 @@ class Categorie extends CommonObject { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE fk_parent = ".$this->id; + $sql .= " WHERE fk_parent = ".$this->id; + $sql .= " AND entity IN (".getEntity('category').")"; $res = $this->db->query($sql); if ($res) From ed0f6b56b98bc150b6d5a01f7b795447b57eff7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Apr 2020 00:29:34 +0200 Subject: [PATCH 6/9] FIX: The "test smtp connectivity" failed on page to setup mass emailing --- htdocs/admin/mails.php | 3 ++- htdocs/admin/mails_emailing.php | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 5275b77fa14..00d954883f9 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -99,6 +99,7 @@ $triggersendname = ''; // Disable triggers $paramname = 'id'; $mode = 'emailfortest'; $trackid = (($action == 'testhtml') ? "testhtml" : "test"); +$sendcontext=''; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action = 'test'; @@ -791,7 +792,7 @@ else print load_fiche_titre($langs->trans("DoTestServerAvailability")); include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mail = new CMailFile('', '', '', ''); + $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); $result = $mail->check_server_port($server, $port); if ($result) print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; else diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 60de9f34443..94b9bb4b83f 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -535,8 +535,9 @@ else print load_fiche_titre($langs->trans("DoTestServerAvailability")); include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mail = new CMailFile('', '', '', ''); - $result=$mail->check_server_port($server, $port); + $mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext); + + $result = $mail->check_server_port($server, $port); if ($result) print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; else { From a41f54c82fd95beedc7683b5f0dfc40ab4675b5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Apr 2020 02:39:40 +0200 Subject: [PATCH 7/9] Fix css --- htdocs/core/class/html.formfile.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 347b22400bd..ec9dff5f1a3 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1508,10 +1508,10 @@ class FormFile if (!empty($addfilterfields)) { print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; // Action column print ''; $searchpicto = $form->showFilterButtons(); From 2f1b25c67afac0e68167e4572f0a89f4cdfc6b92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Apr 2020 02:43:30 +0200 Subject: [PATCH 8/9] Fix property not defined --- .../template/core/modules/mymodule/mod_myobject_advanced.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index 33edc24e983..8ae1284c918 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -98,9 +98,9 @@ class mod_myobject_advanced extends ModeleNumRefMyObject */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $db, $langs, $mysoc; - $object = new MyObject($this->db); + $object = new MyObject($db); $object->initAsSpecimen(); /*$old_code_client=$mysoc->code_client; From 165df931f1ae4f6b1a7126944cf8aebe4e1db2c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 5 Apr 2020 03:14:12 +0200 Subject: [PATCH 9/9] Complete fix #13491 --- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/tpl/extrafields_add.tpl.php | 2 +- htdocs/user/card.php | 81 ++---------------------- 3 files changed, 6 insertions(+), 80 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 3781d66b0db..57d9db22861 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6592,7 +6592,7 @@ abstract class CommonObject * This function is responsible to output the and according to correct number of columns received into $params['colspan'] * * @param Extrafields $extrafields Extrafield Object - * @param string $mode Show output (view) or input (edit) for extrafield + * @param string $mode Show output ('view') or input ('create' or 'edit') for extrafield * @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan) * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) @@ -6666,7 +6666,6 @@ abstract class CommonObject break; case "create": case "edit": - $getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values. // GETPOST("options_" . $key) can be 'abc' or array(0=>'abc') if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php index 2ef606afa0b..38f1cb2b8de 100644 --- a/htdocs/core/tpl/extrafields_add.tpl.php +++ b/htdocs/core/tpl/extrafields_add.tpl.php @@ -45,7 +45,7 @@ if (empty($reshook)) { $params = array(); if (isset($tpl_context)) $params['tpl_context'] = $tpl_context; $params['cols']=$parameters['colspanvalue']; - print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params + print $object->showOptionals($extrafields, 'create', $params); } ?> diff --git a/htdocs/user/card.php b/htdocs/user/card.php index d12f6064131..152103cc5db 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1243,13 +1243,8 @@ if ($action == 'create' || $action == 'adduserldap') } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } + $parameters = array('colspan' => ' colspan="3"'); + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; // Note print ''; @@ -2515,74 +2510,6 @@ else } } - // // Skype - // if (! empty($conf->socialnetworks->enabled)) - // { - // print ''.$langs->trans("Skype").''; - // print ''; - // if ($caneditfield && empty($object->ldap_sid)) - // { - // print ''; - // } - // else - // { - // print ''; - // print $object->skype; - // } - // print ''; - // } - - // // Twitter - // if (! empty($conf->socialnetworks->enabled)) - // { - // print ''.$langs->trans("Twitter").''; - // print ''; - // if ($caneditfield && empty($object->ldap_sid)) - // { - // print ''; - // } - // else - // { - // print ''; - // print $object->twitter; - // } - // print ''; - // } - - // // Facebook - // if (! empty($conf->socialnetworks->enabled)) - // { - // print ''.$langs->trans("Facebook").''; - // print ''; - // if ($caneditfield && empty($object->ldap_sid)) - // { - // print ''; - // } - // else - // { - // print ''; - // print $object->facebook; - // } - // print ''; - // } - - // // LinkedIn - // if (! empty($conf->socialnetworks->enabled)) - // { - // print ''.$langs->trans("LinkedIn").''; - // print ''; - // if ($caneditfield && empty($object->ldap_sid)) - // { - // print ''; - // } - // else - // { - // print ''; - // print $object->linkedin; - // } - // print ''; - // } - // OpenID url if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER)) { @@ -2738,12 +2665,12 @@ else // Other attributes $parameters = array('colspan' => ' colspan="2"'); + //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { - if ($caneditfield) - { + if ($caneditfield) { print $object->showOptionals($extrafields, 'edit'); } else { print $object->showOptionals($extrafields, 'view');