From 104439f79dcd875849a6699358a8d8f61f1c31a4 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 11 Aug 2023 10:38:11 +0200 Subject: [PATCH 01/21] FIX: warning when Workboard Responses display non numeric strings --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 06a829ea4b5..8dbe7681920 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -437,7 +437,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop foreach ($valid_dashboardlines as $board) { - if ($board->nbtodolate > 0) { + if ($board->nbtodolate > 0 && is_numeric($board->nbtodo) && is_numeric($board->nbtodolate)) { $totaltodo += $board->nbtodo; $totallate += $board->nbtodolate; } From 4a453d0805c4ba959ab5b0bfeb67f58ef4a8b342 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 16 Aug 2023 10:40:03 +0200 Subject: [PATCH 02/21] fix: use of getDolGlobal in module builder template --- .../template/class/myobject.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index f309ef346c5..57358e2d110 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -740,12 +740,12 @@ class MyObject extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->mymodule_advance->validate)))) + if (! ((getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write)) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate)))) { $this->error='Permission denied'; return -1; - }*/ + } return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN'); } @@ -1034,15 +1034,15 @@ class MyObject extends CommonObject global $langs, $conf; $langs->load("mymodule@mymodule"); - if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) { + if (empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) { $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard'; } - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) { + if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) { $mybool = false; - $file = $conf->global->MYMODULE_MYOBJECT_ADDON.".php"; - $classname = $conf->global->MYMODULE_MYOBJECT_ADDON; + $file = getDolGlobalString('MYMODULE_MYOBJECT_ADDON').".php"; + $classname = getDolGlobalString('MYMODULE_MYOBJECT_ADDON'); // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); From 83ff60a131d68de5e007170d72dff1b2997f045e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 16 Aug 2023 10:44:01 +0200 Subject: [PATCH 03/21] fix: use of getDolGlobal in module builder template --- htdocs/modulebuilder/template/class/myobject.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 57358e2d110..eca483f0c8b 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -740,12 +740,13 @@ class MyObject extends CommonObject return 0; } - if (! ((getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write)) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate)))) + /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write')) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate')))) { $this->error='Permission denied'; return -1; - } + }*/ + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN'); } From e387e009bf77625a2103c4ff03dc6161a95d7536 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 16 Aug 2023 11:59:14 +0200 Subject: [PATCH 04/21] fix: use of getDolGlobal in module builder template --- htdocs/modulebuilder/template/admin/setup.php | 12 +-- .../template/class/myobject.class.php | 24 ++--- .../template/core/boxes/mymodulewidget1.php | 4 +- .../core/modules/modMyModule.class.php | 4 +- .../doc/doc_generic_myobject_odt.modules.php | 22 ++--- .../doc/pdf_standard_myobject.modules.php | 95 +++++++++---------- .../template/lib/mymodule_myobject.lib.php | 2 +- .../modulebuilder/template/mymoduleindex.php | 4 +- .../template/myobject_agenda.php | 4 +- .../modulebuilder/template/myobject_card.php | 4 +- .../modulebuilder/template/myobject_list.php | 4 +- 11 files changed, 89 insertions(+), 90 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index dea2a1a596e..10a02f6507c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -244,7 +244,7 @@ if ($action == 'updateMask') { $tmpobjectkey = GETPOST('object'); if (!empty($tmpobjectkey)) { $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; - if ($conf->global->$constforval == "$value") { + if (getDolGlobalString($constforval) == "$value") { dolibarr_del_const($db, $constforval, $conf->entity); } } @@ -257,7 +257,7 @@ if ($action == 'updateMask') { if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view - $conf->global->$constforval = $value; + $conf->global->{$constforval} = $value; } // We disable/enable the document template (into llx_document_model table) @@ -357,10 +357,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { continue; } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) { continue; } @@ -494,10 +494,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { $modulequalified = 0; } - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) { $modulequalified = 0; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index eca483f0c8b..5122bf3e59e 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -84,7 +84,7 @@ class MyObject extends CommonObject * Note: Filter must be a Dolibarr filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)" * 'label' the translation key. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled("multicurrency")' ...) + * 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt('MY_SETUP_PARAM')' or 'isModEnabled("multicurrency")' ...) * 'position' is the sort order of field. * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) @@ -251,7 +251,7 @@ class MyObject extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { + if (empty(getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID')) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { $this->fields['rowid']['visible'] = 0; } if (!isModEnabled('multicompany') && isset($this->fields['entity'])) { @@ -574,8 +574,8 @@ class MyObject extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->myobject->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->myobject->myobject_advance->validate)))) + /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write')) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->myobject_advance->validate)))) { $this->error='NotEnoughPermissions'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); @@ -692,8 +692,8 @@ class MyObject extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->mymodule_advance->validate)))) + /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write')) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate')))) { $this->error='Permission denied'; return -1; @@ -716,8 +716,8 @@ class MyObject extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->mymodule->mymodule_advance->validate)))) + /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write')) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate')))) { $this->error='Permission denied'; return -1; @@ -793,7 +793,7 @@ class MyObject extends CommonObject $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { $label = $langs->trans("ShowMyObject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -833,7 +833,7 @@ class MyObject extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + if (empty(getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'))) { $result .= '
No photo
'; } else { $result .= '
No photo
'; @@ -1105,8 +1105,8 @@ class MyObject extends CommonObject if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty($conf->global->MYOBJECT_ADDON_PDF)) { - $modele = $conf->global->MYOBJECT_ADDON_PDF; + } elseif (!empty(getDolGlobalString('MYOBJECT_ADDON_PDF'))) { + $modele = getDolGlobalString('MYOBJECT_ADDON_PDF'); } } diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 7ea4b553e71..4c34d790df4 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -101,8 +101,8 @@ class mymodulewidget1 extends ModeleBoxes $this->param = $param; - //$this->enabled = $conf->global->FEATURES_LEVEL > 0; // Condition when module is enabled or not - //$this->hidden = ! ($user->rights->mymodule->myobject->read); // Condition when module is visible by user (test on permission) + //$this->enabled = getDolGlobalInt(FEATURES_LEVEL) > 0; // Condition when module is enabled or not + //$this->hidden = ! ($user->hasRight('mymodule,'myobject','read'); // Condition when module is visible by user (test on permission) } /** diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 99cd900b512..311bc6c14b5 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -403,8 +403,8 @@ class modMyModule extends DolibarrModules $this->import_convertvalue_array[$r] = array( 't.ref' => array( 'rule'=>'getrefifauto', - 'class'=>(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON), - 'path'=>"/core/modules/commande/".(empty($conf->global->MYMODULE_MYOBJECT_ADDON) ? 'mod_myobject_standard' : $conf->global->MYMODULE_MYOBJECT_ADDON).'.php' + 'class'=>(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')), + 'path'=>"/core/modules/commande/".(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')).'.php' 'classobject'=>'MyObject', 'pathobject'=>'/mymodule/class/myobject.class.php', ), diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index b7dfc374a52..17936af12de 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -129,7 +129,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // List of directories area $texte .= ''; $texttitle = $langs->trans("ListOfDirectories"); - $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH))); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH')))); $listoffiles = array(); foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); @@ -155,7 +155,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); $texte .= '
'; $texte .= ''; $texte .= '
'; $texte .= ''; @@ -163,7 +163,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Scan directories $nbofiles = count($listoffiles); - if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH)) { + if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'))) { $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; $texte .= count($listoffiles); @@ -287,8 +287,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; + if (!empty(getDolGlobalString('MAIN_DOC_USE_TIMING'))) { + $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; } @@ -321,7 +321,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $contactobject = null; if (!empty($usecontact)) { // We can use the company of contact instead of thirdparty company - if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) { + if ($object->contact->socid != $object->thirdparty->id && ) { $object->contact->fetch_thirdparty(); $socobject = $object->contact->thirdparty; $contactobject = $object->contact; @@ -350,8 +350,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; $paramfreetext = 'MYMODULE_MYOBJECT_FREE_TEXT'; - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); + if (!empty(getDolGlobalString($paramfreetext))) { + $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); } // Open and load template @@ -477,7 +477,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file - if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + if (!empty(getDolGlobalString($MAIN_ODT_AS_PDF))) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { @@ -498,8 +498,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); + if (!empty(getDolGlobalString('MAIN_UMASK'))) { + @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); } $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 05486989e1d..6a28e07a336 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -172,32 +172,32 @@ class pdf_standard_myobject extends ModelePDFMyObject $outputlangs = $langs; } // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (!empty($conf->global->MAIN_USE_FPDF)) { + if (getDolGlobalInt('MAIN_USE_FPDF')) { $outputlangs->charset_output = 'ISO-8859-1'; } // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); - $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE); + $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies")); } $nblines = (is_array($object->lines) ? count($object->lines) : 0); $hidetop = 0; - if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) { - $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE; + if (!empty(getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'))) { + $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'); } // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); $this->atleastonephoto = false; /* - if (!empty($conf->global->MAIN_GENERATE_MYOBJECT_WITH_PICTURE)) + if (!empty(getDolGlobalString('MAIN_GENERATE_MYOBJECT_WITH_PICTURE'))) { $objphoto = new Product($this->db); @@ -288,8 +288,8 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetAutoPageBreak(1, 0); $heightforinfotot = 50; // Height reserved to output the info and total part and payment part - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + $heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + (empty(getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -298,8 +298,8 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { - $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + if (!empty(getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'))) { + $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -320,7 +320,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT; // If user has no certificate, we try to take the company one if (!$cert) { - $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT; + $cert = empty(getDolGlobalString('CERTIFICATE_CRT')) ? '' : getDolGlobalString('CERTIFICATE_CRT'); } // If a certificate is found if ($cert) { @@ -348,10 +348,10 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 0); $tab_top = 90 + $top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); $tab_height = 130 - $top_shift; $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $tab_height_newpage -= $top_shift; } @@ -395,7 +395,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } // $this->_pagefoot($pdf,$object,$outputlangs,1); @@ -453,7 +453,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } $height_note = $posyafter - $tab_top_newpage; @@ -475,7 +475,7 @@ class pdf_standard_myobject extends ModelePDFMyObject if (!empty($tplidx)) { $pdf->useTemplate($tplidx); } - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -532,7 +532,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $curY = $tab_top_newpage; // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; @@ -573,7 +573,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } else { // We found a page break // Allows data in the first page if description is long enough to break in multiples pages - if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) { + if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) { $showpricebeforepagebreak = 1; } else { $showpricebeforepagebreak = 0; @@ -693,7 +693,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $nexY = max($nexY, $posYAfterImage); // Add line - if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { + if (getDolGlobalInt('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); @@ -713,7 +713,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pagenb++; $pdf->setPage($pagenb); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } if (!empty($tplidx)) { @@ -734,7 +734,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->useTemplate($tplidx); } $pagenb++; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { + if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } } @@ -757,7 +757,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Display payment area /* - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty(getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS'))) { $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } @@ -783,8 +783,8 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); + if (!empty(getDolGlobalString('MAIN_UMASK'))) { + @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); } $this->result = array('fullpath'=>$file); @@ -848,16 +848,15 @@ class pdf_standard_myobject extends ModelePDFMyObject if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); } $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { - $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + if (!empty(getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))) { + $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -913,13 +912,13 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { + if (empty(getDolGlobalString('PDF_DISABLE_MYCOMPANY_LOGO'))) { if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; @@ -943,7 +942,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("PdfTitle"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { $title .= ' - '; $title .= $outputlangsbis->transnoentities("PdfTitle"); } @@ -971,7 +970,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); } - if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT_TITLE')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $posy += 3; @@ -981,7 +980,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } } - if (!empty($conf->global->PDF_SHOW_PROJECT)) { + if (getDolGlobalInt('PDF_SHOW_PROJECT')) { $object->fetch_projet(); if (!empty($object->project->ref)) { $outputlangs->load("projects"); @@ -997,7 +996,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("Date"); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) { + if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("Date"); } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); @@ -1010,7 +1009,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Get contact - if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { + if (getDolGlobalInt('DOC_SHOW_FIRST_SALES_REP')) { $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $usertmp = new User($this->db); @@ -1037,15 +1036,15 @@ class pdf_standard_myobject extends ModelePDFMyObject $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->marge_gauche; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->page_largeur - $this->marge_droite - 80; } - $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82; // Show sender frame @@ -1078,7 +1077,7 @@ class pdf_standard_myobject extends ModelePDFMyObject } // Recipient name - if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) { + if ($object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; @@ -1091,14 +1090,14 @@ class pdf_standard_myobject extends ModelePDFMyObject $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object); // Show recipient - $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + $widthrecbox = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100; if ($this->page_largeur < 210) { $widthrecbox = 84; // To work with US executive format } - $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posy = getDolGlobalInt('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posy += $top_shift; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; - if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { + if (getDolGlobalInt('MAIN_INVERT_SENDER_RECIPIENT')) { $posx = $this->marge_gauche; } @@ -1139,7 +1138,7 @@ class pdf_standard_myobject extends ModelePDFMyObject protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 0 : getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS'); return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } @@ -1209,7 +1208,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $rank = $rank + 10; $this->cols['photo'] = array( 'rank' => $rank, - 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm 'status' => false, 'title' => array( 'textkey' => 'Photo', @@ -1221,7 +1220,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto)) { + if (getDolGlobalInt('MAIN_GENERATE_DOCUEMENTS_WITH_PICTURE') && !empty($this->atleastonephoto)) { $this->cols['photo']['status'] = true; } @@ -1237,7 +1236,7 @@ class pdf_standard_myobject extends ModelePDFMyObject 'border-left' => true, // add left line separator ); - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { + if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) { $this->cols['vat']['status'] = true; } @@ -1288,7 +1287,7 @@ class pdf_standard_myobject extends ModelePDFMyObject ), 'border-left' => true, // add left line separator ); - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->cols['unit']['status'] = true; } diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php index d75f69a47f5..9f4bc9654fa 100644 --- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php +++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php @@ -65,7 +65,7 @@ function myobjectPrepareHead($object) $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) { - $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ''.$nbNote.'' : ''); + $head[$h][1] .= (!getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.$nbNote.'' : ''); } $head[$h][2] = 'note'; $h++; diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 3b7b1b13009..3c7cc5f9ec5 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -186,8 +186,8 @@ END MODULEBUILDER DRAFT MYOBJECT */ print '
'; -$NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; +$NBMAX = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); +$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT // Last modified myobject diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 6abb64d71c9..968076385c9 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -94,7 +94,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty(getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'))); } $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); @@ -186,7 +186,7 @@ $form = new Form($db); if ($object->id > 0) { $title = $langs->trans("Agenda"); - //if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; + $help_url = 'EN:Module_Agenda_En'; llxHeader('', $title, $help_url); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index dc8dafd433e..dea30f5c110 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -390,10 +390,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { + if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { $morehtmlref .= ' (
'.$langs->trans("OtherOrders").')'; } // Project diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 2c38e685b83..9865abb6533 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -369,7 +369,7 @@ $sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPri // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { +if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); @@ -404,7 +404,7 @@ $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { +if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); From cb8a6796df6450b0895676fa4d37d96ec8ee1655 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 16 Aug 2023 14:32:31 +0200 Subject: [PATCH 05/21] FIX: Quick search Intervention redirect to wrong page --- htdocs/fichinter/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index ebff3305365..83c6d15431d 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -364,7 +364,7 @@ $num = $db->num_rows($resql); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id); + header("Location: ".dol_buildpath('/fichinter/card.php', 1).'?id='.$id); exit; } From b37ca6772915754eef2f38392da1f58d1fd987f8 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sat, 19 Aug 2023 21:49:56 +0200 Subject: [PATCH 06/21] Update myobject.class.php fix https://github.com/Dolibarr/dolibarr/pull/25633#discussion_r1299167338 --- htdocs/modulebuilder/template/class/myobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 5122bf3e59e..b9fcc4da829 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -833,7 +833,7 @@ class MyObject extends CommonObject $pospoint = strpos($filearray[0]['name'], '.'); $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); - if (empty(getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'))) { + if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) { $result .= '
No photo
'; } else { $result .= '
No photo
'; From f255fac00013c2512d2886102f5748c60922ca4d Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 23 Aug 2023 20:06:42 +0200 Subject: [PATCH 07/21] Update doc_generic_myobject_odt.modules.php --- .../modules/mymodule/doc/doc_generic_myobject_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 17936af12de..fc826e6caad 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -321,7 +321,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $contactobject = null; if (!empty($usecontact)) { // We can use the company of contact instead of thirdparty company - if ($object->contact->socid != $object->thirdparty->id && ) { + if ($object->contact->socid != $object->thirdparty->id) { $object->contact->fetch_thirdparty(); $socobject = $object->contact->thirdparty; $contactobject = $object->contact; From 1cbe8c9327bbb26f01b1fafae13a054a465a302a Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 23 Aug 2023 20:08:58 +0200 Subject: [PATCH 08/21] Update doc_generic_myobject_odt.modules.php --- .../modules/mymodule/doc/doc_generic_myobject_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index fc826e6caad..dc0c0945278 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -321,7 +321,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $contactobject = null; if (!empty($usecontact)) { // We can use the company of contact instead of thirdparty company - if ($object->contact->socid != $object->thirdparty->id) { + if ($object->contact->socid != $object->thirdparty->id && getDolGlobalInt("MAIN_USE_COMPANY_NAME_OF_CONTACT")) { $object->contact->fetch_thirdparty(); $socobject = $object->contact->thirdparty; $contactobject = $object->contact; From 5deaaa08a21bac262f97d6662228cd2d4422b2ad Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 25 Aug 2023 09:10:47 +0200 Subject: [PATCH 09/21] fix review --- .../modules/mymodule/doc/pdf_standard_myobject.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 6a28e07a336..9b0cd33c283 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -179,7 +179,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); - if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { global $outputlangsbis; $outputlangsbis = new Translate('', $conf); $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); @@ -189,7 +189,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $nblines = (is_array($object->lines) ? count($object->lines) : 0); $hidetop = 0; - if (!empty(getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'))) { + if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) { $hidetop = getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE'); } From e56fed15c53f664d8f879a2af54ebfd6288a552f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Aug 2023 14:12:06 +0200 Subject: [PATCH 10/21] fix travais --- htdocs/modulebuilder/template/class/myobject.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index b9fcc4da829..b70a1d1a7b1 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -251,7 +251,7 @@ class MyObject extends CommonObject $this->db = $db; - if (empty(getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID')) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { + if (!getDolGlobalInt('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) { $this->fields['rowid']['visible'] = 0; } if (!isModEnabled('multicompany') && isset($this->fields['entity'])) { @@ -1035,11 +1035,11 @@ class MyObject extends CommonObject global $langs, $conf; $langs->load("mymodule@mymodule"); - if (empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) { + if (getDolGlobalString('MYMODULE_MYOBJECT_ADDON')=='') { $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard'; } - if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON'))) { + if (getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) { $mybool = false; $file = getDolGlobalString('MYMODULE_MYOBJECT_ADDON').".php"; @@ -1105,7 +1105,7 @@ class MyObject extends CommonObject if (!empty($this->model_pdf)) { $modele = $this->model_pdf; - } elseif (!empty(getDolGlobalString('MYOBJECT_ADDON_PDF'))) { + } elseif (getDolGlobalString('MYOBJECT_ADDON_PDF')) { $modele = getDolGlobalString('MYOBJECT_ADDON_PDF'); } } From 3db024e6b593ee60e496ff0023e8dd0f9ca563a3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Aug 2023 14:33:02 +0200 Subject: [PATCH 11/21] fix travis --- .../core/modules/modMyModule.class.php | 4 ++-- .../doc/doc_generic_myobject_odt.modules.php | 10 ++++----- .../doc/pdf_standard_myobject.modules.php | 22 +++++++++---------- .../template/myobject_agenda.php | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 311bc6c14b5..b5dfb86dba7 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -403,8 +403,8 @@ class modMyModule extends DolibarrModules $this->import_convertvalue_array[$r] = array( 't.ref' => array( 'rule'=>'getrefifauto', - 'class'=>(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')), - 'path'=>"/core/modules/commande/".(empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')) ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')).'.php' + 'class'=>(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')=='') ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')), + 'path'=>"/core/modules/commande/".(getDolGlobalString('MYMODULE_MYOBJECT_ADDON')=='') ? 'mod_myobject_standard' : getDolGlobalString('MYMODULE_MYOBJECT_ADDON')).'.php' 'classobject'=>'MyObject', 'pathobject'=>'/mymodule/class/myobject.class.php', ), diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index dc0c0945278..829cba459e1 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -163,7 +163,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Scan directories $nbofiles = count($listoffiles); - if (!empty(getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH'))) { + if (getDolGlobalString('MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH')) { $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; $texte .= count($listoffiles); @@ -287,7 +287,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); - if (!empty(getDolGlobalString('MAIN_DOC_USE_TIMING'))) { + if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); if ($format == '1') { $format = '%Y%m%d%H%M%S'; @@ -350,7 +350,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; $paramfreetext = 'MYMODULE_MYOBJECT_FREE_TEXT'; - if (!empty(getDolGlobalString($paramfreetext))) { + if (getDolGlobalString($paramfreetext)) { $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); } @@ -477,7 +477,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file - if (!empty(getDolGlobalString($MAIN_ODT_AS_PDF))) { + if (getDolGlobalString('MAIN_ODT_AS_PDF')) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { @@ -498,7 +498,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty(getDolGlobalString('MAIN_UMASK'))) { + if (getDolGlobalString('MAIN_UMASK')) { @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 9b0cd33c283..38be530e909 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -197,7 +197,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $realpatharray = array(); $this->atleastonephoto = false; /* - if (!empty(getDolGlobalString('MAIN_GENERATE_MYOBJECT_WITH_PICTURE'))) + if (getDolGlobalString('MAIN_GENERATE_MYOBJECT_WITH_PICTURE')) { $objphoto = new Product($this->db); @@ -289,7 +289,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $heightforinfotot = 50; // Height reserved to output the info and total part and payment part $heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + (empty(getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) ? 12 : 22); // Height reserved to output the footer (value include bottom margin) + $heightforfooter = $this->marge_basse + ((getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')=='') ? 12 : 22); // Height reserved to output the footer (value include bottom margin) if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -298,7 +298,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (!empty(getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'))) { + if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -320,7 +320,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT; // If user has no certificate, we try to take the company one if (!$cert) { - $cert = empty(getDolGlobalString('CERTIFICATE_CRT')) ? '' : getDolGlobalString('CERTIFICATE_CRT'); + $cert = getDolGlobalString('CERTIFICATE_CRT'); } // If a certificate is found if ($cert) { @@ -757,7 +757,7 @@ class pdf_standard_myobject extends ModelePDFMyObject // Display payment area /* - if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty(getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS'))) + if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && (getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')=='')) { $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs); } @@ -783,7 +783,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->errors = $hookmanager->errors; } - if (!empty(getDolGlobalString('MAIN_UMASK'))) { + if (getDolGlobalString('MAIN_UMASK')) { @chmod($file, octdec(getDolGlobalString('MAIN_UMASK'))); } @@ -848,14 +848,14 @@ class pdf_standard_myobject extends ModelePDFMyObject if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency)); } $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - if (!empty(getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))) { + if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) { $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR'))); } } @@ -912,7 +912,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty(getDolGlobalString('PDF_DISABLE_MYCOMPANY_LOGO'))) { + if (getDolGlobalString('PDF_DISABLE_MYCOMPANY_LOGO')) { if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!empty($conf->mycompany->multidir_output[$object->entity])) { @@ -942,7 +942,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("PdfTitle"); - if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '; $title .= $outputlangsbis->transnoentities("PdfTitle"); } @@ -996,7 +996,7 @@ class pdf_standard_myobject extends ModelePDFMyObject $pdf->SetTextColor(0, 0, 60); $title = $outputlangs->transnoentities("Date"); - if (!empty(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) && is_object($outputlangsbis)) { + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { $title .= ' - '.$outputlangsbis->transnoentities("Date"); } $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R'); diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 968076385c9..2a313d17da8 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -94,7 +94,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty(getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')) ? '' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'))); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'))); } $search_rowid = GETPOST('search_rowid'); $search_agenda_label = GETPOST('search_agenda_label'); From c2e292d1d43c3f1c9f653d6085ce316b3d76b191 Mon Sep 17 00:00:00 2001 From: avolani <31508728+avolani@users.noreply.github.com> Date: Wed, 30 Aug 2023 08:34:09 +0200 Subject: [PATCH 12/21] Return right content type Revert content type to html (no json here, ajax calls fails) --- htdocs/projet/ajax/projects.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 03d118dc9b9..b0001a2a4b2 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -62,7 +62,7 @@ dol_syslog("Call ajax projet/ajax/projects.php"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -top_httphead('application/json'); +top_httphead(); if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { return; From 1dc0f0a6e0426c56006598c73abca51b8e736c3e Mon Sep 17 00:00:00 2001 From: Florian Mortgat <50440633+atm-florianm@users.noreply.github.com> Date: Wed, 30 Aug 2023 10:47:59 +0200 Subject: [PATCH 13/21] Update htdocs/index.php Suggestion from PR --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index 8dbe7681920..bb7eeac9a85 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -437,7 +437,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop foreach ($valid_dashboardlines as $board) { - if ($board->nbtodolate > 0 && is_numeric($board->nbtodo) && is_numeric($board->nbtodolate)) { + if (is_numeric($board->nbtodo) && is_numeric($board->nbtodolate) && $board->nbtodolate > 0) { $totaltodo += $board->nbtodo; $totallate += $board->nbtodolate; } From 07d821b52caf729cca3c4c2d09fc851b61664c4f Mon Sep 17 00:00:00 2001 From: Andrea Volani Date: Mon, 4 Sep 2023 09:11:57 +0200 Subject: [PATCH 14/21] Return correct content type based on the call used. --- htdocs/projet/ajax/projects.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 03d118dc9b9..97d2b9daef9 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -62,7 +62,6 @@ dol_syslog("Call ajax projet/ajax/projects.php"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -top_httphead('application/json'); if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { return; @@ -70,21 +69,35 @@ if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { // Mode to get list of projects if (empty($mode) || $mode != 'gettasks') { + + top_httphead('application/json'); + // When used from jQuery, the search term is added as GET param "term". $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : ''); $formproject = new FormProjets($db); $arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); + + $db->close(); + + print json_encode($arrayresult); + + return; } // Mode to get list of tasks +// THIS MODE RETURNS HTML NOT JSON - THE CALL SHOULD BE UPDATE IN THE FUTURE if ($mode == 'gettasks') { + + top_httphead(); + $formproject = new FormProjets($db); $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), ''); + + $db->close(); + return; } -$db->close(); -print json_encode($arrayresult); From 4de001b43c2bfdf7110477c50516c1249ea5ae64 Mon Sep 17 00:00:00 2001 From: Andrea Volani Date: Mon, 4 Sep 2023 09:40:53 +0200 Subject: [PATCH 15/21] No need to enforce check on param 'htmlname' --- htdocs/projet/ajax/projects.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 97d2b9daef9..42bacc4a453 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -53,7 +53,6 @@ $discard_closed = GETPOST('discardclosed', 'int'); // Security check restrictedArea($user, 'projet', 0, 'projet&project'); - /* * View */ @@ -62,11 +61,6 @@ dol_syslog("Call ajax projet/ajax/projects.php"); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; - -if (empty($htmlname) && !GETPOST('mode', 'aZ09')) { - return; -} - // Mode to get list of projects if (empty($mode) || $mode != 'gettasks') { @@ -76,7 +70,7 @@ if (empty($mode) || $mode != 'gettasks') { $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : ''); $formproject = new FormProjets($db); - $arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); + $arrayresult = $formproject->select_projects_list($socid, '', '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey); $db->close(); From 3a84d84e655c0e38bb7bdb540288a4cccf36fbdb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2023 19:47:38 +0200 Subject: [PATCH 16/21] Fix phpcs --- htdocs/projet/ajax/projects.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/projet/ajax/projects.php b/htdocs/projet/ajax/projects.php index 42bacc4a453..fbb02a60a48 100644 --- a/htdocs/projet/ajax/projects.php +++ b/htdocs/projet/ajax/projects.php @@ -63,7 +63,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; // Mode to get list of projects if (empty($mode) || $mode != 'gettasks') { - top_httphead('application/json'); // When used from jQuery, the search term is added as GET param "term". @@ -82,7 +81,6 @@ if (empty($mode) || $mode != 'gettasks') { // Mode to get list of tasks // THIS MODE RETURNS HTML NOT JSON - THE CALL SHOULD BE UPDATE IN THE FUTURE if ($mode == 'gettasks') { - top_httphead(); $formproject = new FormProjets($db); @@ -92,6 +90,3 @@ if ($mode == 'gettasks') { return; } - - - From c437aecb1fc7bb66492ccdefb1feb875c67a51cc Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 5 Sep 2023 10:06:30 +0200 Subject: [PATCH 17/21] FIX multicompany compatibility --- htdocs/master.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 50a03e6fdb3..70c35008c8d 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -191,9 +191,9 @@ if (session_id() && !empty($_SESSION["dol_entity"])) { } elseif (!empty($_ENV["dol_entity"])) { // Entity inside a CLI script $conf->entity = $_ENV["dol_entity"]; -} elseif (GETPOSTISSET("loginfunction") && GETPOST("entity", 'int')) { +} elseif (GETPOSTISSET("loginfunction") && (GETPOST("entity", 'int') || GETPOST("switchentity", 'int'))) { // Just after a login page - $conf->entity = GETPOST("entity", 'int'); + $conf->entity = (GETPOSTISSET("entity") ? GETPOST("entity", 'int') : GETPOST("switchentity", 'int')); } elseif (defined('DOLENTITY') && is_numeric(constant('DOLENTITY'))) { // For public page with MultiCompany module $conf->entity = constant('DOLENTITY'); From c557baffc79298b07cfaba53f7b912ec1a7c8041 Mon Sep 17 00:00:00 2001 From: ATM-Sami Date: Tue, 5 Sep 2023 10:31:51 +0200 Subject: [PATCH 18/21] delete useless condition in massaction_pre --- htdocs/core/tpl/massactions_pre.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 54557539b26..c5c561c5ec5 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -31,7 +31,6 @@ // $sendto // $withmaindocfilemail - if ($massaction == 'predeletedraft') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDraftDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); } @@ -94,7 +93,7 @@ if ($massaction == 'preaffecttag' && isModEnabled('category')) { } } -if ($massaction == 'preupdateprice' && isModEnabled('category')) { +if ($massaction == 'preupdateprice') { $formquestion = array(); $valuefield = '
'; From e922d07a97ddae6a42fe62d4619ee3f0f04479d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Sep 2023 16:19:21 +0200 Subject: [PATCH 19/21] fix tooltip ajax load langs --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e54ef4ff62b..60dc22c5bb2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5058,7 +5058,7 @@ class Product extends CommonObject { global $conf, $langs; - $langs->load('products', 'other'); + $langs->loadLangs(array('products', 'other')); $datas = array(); $nofetch = !empty($params['nofetch']); From 0c17b266d7272c6295e8b4d1ae6cd1cb9bcaae0c Mon Sep 17 00:00:00 2001 From: atm-adrien Date: Tue, 5 Sep 2023 16:51:54 +0200 Subject: [PATCH 20/21] FIX : Can't access to rec supplier invoice card --- htdocs/fourn/facture/card-rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index e22dc721aba..ac74be12309 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -72,7 +72,7 @@ $month_date_when = GETPOST('month_date_when'); if ($user->socid) { $socid = $user->socid; } -$objecttype = 'facturefournisseur_rec'; +$objecttype = 'facture_fourn_rec'; if ($action == "create" || $action == "add") { $objecttype = ''; } From e2de78d9b477f9ec851ace7d31813b82cad76caa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Sep 2023 19:13:51 +0200 Subject: [PATCH 21/21] Fix permission on recurring invoice --- htdocs/core/lib/security.lib.php | 4 ++++ htdocs/fourn/facture/card-rec.php | 3 ++- htdocs/fourn/facture/list-rec.php | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0d4ae46a5dd..7092da65884 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -372,6 +372,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($features == 'facturerec') { $features = 'facture'; } + if ($features == 'supplier_invoicerec') { + $features = 'fournisseur'; + $feature2 = 'facture'; + } if ($features == 'mo') { $features = 'mrp'; } diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index ac74be12309..525b5e9123a 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -126,7 +126,8 @@ $now = dol_now(); $error = 0; -$result = restrictedArea($user, 'facture', $object->id, $objecttype); +$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype); + /* * Actions diff --git a/htdocs/fourn/facture/list-rec.php b/htdocs/fourn/facture/list-rec.php index e77000b45d3..b23d411977a 100644 --- a/htdocs/fourn/facture/list-rec.php +++ b/htdocs/fourn/facture/list-rec.php @@ -66,7 +66,6 @@ $objecttype = 'facture_fourn_rec'; if ($action == "create" || $action == "add") { $objecttype = ''; } -$result = restrictedArea($user, 'facture', $id, $objecttype); $search_ref = GETPOST('search_ref'); $search_societe = GETPOST('search_societe'); @@ -169,7 +168,7 @@ if ($socid > 0) { } $objecttype = 'facture_fourn_rec'; -$result = restrictedArea($user, 'facture', $object->id, $objecttype); +$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype); /*