diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php
index 15939c806c25e..e5d93114c7cf9 100644
--- a/htdocs/admin/usergroup.php
+++ b/htdocs/admin/usergroup.php
@@ -28,12 +28,9 @@
* \ingroup core
* \brief Page to setup usergroup module
*/
+namespace Dolibarr\User;
-// Load Dolibarr environment
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+use Dolibarr\{ExtraFields};
/**
* @var Conf $conf
diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php
index 6ec1d99c03216..09f62f5c8cd73 100644
--- a/htdocs/core/boxes/box_lastlogin.php
+++ b/htdocs/core/boxes/box_lastlogin.php
@@ -23,9 +23,9 @@
* \ingroup core
* \brief Module to show box of last user logins
*/
+namespace Dolibarr;
-include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
-
+use Dolibarr\ModeleBoxes;
/**
* Class to manage the box of last login
*/
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 5ebf55004ada8..ebd4cd8443511 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -25,7 +25,7 @@
* \ingroup core
* \brief File containing the parent class of boxes
*/
-
+namespace Dolibarr;
/**
* Class ModeleBoxes
diff --git a/htdocs/core/class/Autoloader.php b/htdocs/core/class/Autoloader.php
new file mode 100644
index 0000000000000..9d3470b7da6db
--- /dev/null
+++ b/htdocs/core/class/Autoloader.php
@@ -0,0 +1,52 @@
+use_javascript_ajax) {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$comboenhancement = ajax_combobox('select_categ_'.$htmlname);
$moreforfilter .= $comboenhancement;
}
@@ -1225,7 +1226,6 @@ public static function getBoxesArea($user, $areacode)
{
global $conf, $langs, $db;
- include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
// From include
'
@phan-var-force ModeleBoxes[] $boxactivated
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 2534c04a58c0e..4a63511f0cc1f 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -26,8 +26,7 @@
* \brief Class file for html component project
*/
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-
+namespace Dolibarr\HTML;
/**
* Class to manage building of HTML components
*/
diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php
index 3142b991aaeac..4cc4ba3e01134 100644
--- a/htdocs/core/class/html.formpropal.class.php
+++ b/htdocs/core/class/html.formpropal.class.php
@@ -22,7 +22,7 @@
* \brief File of class with all html predefined components
*/
-
+namespace Dolibarr\HTML;
/**
* Class to manage generation of HTML components for proposal management
*/
diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index b3addf7f7db2b..b7075b16372c9 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+namespace Dolibarr\HTML;
/**
* This class help you create setup render
*/
diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php
index cf82ca3c81c5f..33233080ed6df 100644
--- a/htdocs/core/class/html.formsms.class.php
+++ b/htdocs/core/class/html.formsms.class.php
@@ -23,9 +23,8 @@
* \ingroup core
* \brief Fichier de la class permettant la generation du formulaire html d'envoi de mail unitaire
*/
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-
+namespace Dolibarr\HTML;
/**
* Class permettant la generation du formulaire d'envoi de Sms
* Usage: $formsms = new FormSms($db)
diff --git a/htdocs/core/class/html.formsocialcontrib.class.php b/htdocs/core/class/html.formsocialcontrib.class.php
index 06d0f4ae8d3a7..fb48ec30a5fe9 100644
--- a/htdocs/core/class/html.formsocialcontrib.class.php
+++ b/htdocs/core/class/html.formsocialcontrib.class.php
@@ -22,7 +22,7 @@
* \brief File of class with all html predefined components
*/
-
+namespace Dolibarr\HTML;
/**
* Class to manage generation of HTML components for social contributions management
*/
diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index 5ba1465f7b44f..2cf02a7ef4d1e 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -28,14 +28,8 @@
* \brief File of class to generate the form for creating a new ticket.
*/
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
-
-if (!class_exists('FormCompany')) {
- include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
-}
+namespace Dolibarr\HTML;
/**
* Class to generate the form for creating a new ticket.
* Usage: $formticket = new FormTicket($db)
diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php
index afea3d81e3c09..b3e684ee59cb4 100644
--- a/htdocs/core/class/html.formwebsite.class.php
+++ b/htdocs/core/class/html.formwebsite.class.php
@@ -22,7 +22,7 @@
* \brief File of class to manage component html for module website
*/
-
+namespace Dolibarr\HTML;
/**
* Class to manage component html for module website
*/
diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php
index 68340e873d28d..49243b7d79ccc 100644
--- a/htdocs/core/class/infobox.class.php
+++ b/htdocs/core/class/infobox.class.php
@@ -24,6 +24,7 @@
* \brief File of class to manage widget boxes
*/
+namespace Dolibarr;
/**
* Class to manage boxes on pages. This is an utility class (all is static)
*/
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 8f1d46ed5ca3e..834380d7b758e 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -24,7 +24,7 @@
* \ingroup core
* \brief File for Translate class
*/
-
+namespace Dolibarr;
/**
* Class to manage translations
diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php
index 046f850472223..d515ee259a27d 100644
--- a/htdocs/core/db/Database.interface.php
+++ b/htdocs/core/db/Database.interface.php
@@ -21,7 +21,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
+namespace Dolibarr\DB;
/**
* Class to manage Dolibarr database access for an SQL database
*/
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 63847079776e5..e59e567eb6ab9 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -23,9 +23,7 @@
* \file htdocs/core/db/DoliDB.class.php
* \brief Class file to manage Dolibarr database access
*/
-
-require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php';
-
+namespace Dolibarr\DB;
/**
* Class to manage Dolibarr database access
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index 160805761bc39..9142dfec03ca1 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -269,7 +269,7 @@ public function connect($host, $login, $passwd, $name, $port = 0)
if (strpos($host, 'ssl://') === 0) {
$tmp = new mysqliDoli($host, $login, $passwd, $name, $port);
} else {
- $tmp = new mysqli($host, $login, $passwd, $name, $port);
+ $tmp = new \mysqli($host, $login, $passwd, $name, $port);
}
} catch (Exception $e) {
dol_syslog(get_class($this)."::connect failed", LOG_DEBUG);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index d1ea43af5d121..03bf6fb09e46f 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -425,7 +425,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
{
require_once DOL_DOCUMENT_ROOT."/core/db/".$type.'.class.php';
- $class = 'DoliDB'.ucfirst($type);
+ $class = 'Dolibarr\\DB\\DoliDB'.ucfirst($type);
$db = new $class($type, $host, $user, $pass, $name, $port);
return $db;
}
@@ -452,7 +452,6 @@ function getEntity($element, $shared = 1, $currentobject = null)
global $conf, $mc, $hookmanager, $object, $action, $db;
if (!is_object($hookmanager)) {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
}
@@ -2898,7 +2897,6 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab
$out .= '">'."\n";
}
if (!empty($dragdropfile)) {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$out .= dragAndDropFileUpload("dragDropAreaTabBar");
}
$parameters = array('tabname' => $active, 'out' => $out);
@@ -3122,7 +3120,6 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
// Conversion du PDF en image png si fichier png non existent
if (!file_exists($fileimage) || (filemtime($fileimage) < filemtime($filepdf))) {
if (!getDolGlobalString('MAIN_DISABLE_PDF_THUMBS')) { // If you experience trouble with pdf thumb generation and imagick, you can disable here.
- include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$ret = dol_convert_file($filepdf, 'png', $fileimage, '0'); // Convert first page of PDF into a file _preview.png
if ($ret < 0) {
$error++;
@@ -3870,7 +3867,6 @@ function dol_now($mode = 'auto')
if ($mode == 'gmt') {
$ret = time(); // Time for now at greenwich.
} elseif ($mode == 'tzserver') { // Time for now with PHP server timezone added
- require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
$ret = (int) (dol_now('gmt') + ($tzsecond * 3600));
//} elseif ($mode == 'tzref') {// Time for now with parent company timezone is added
@@ -4080,7 +4076,6 @@ function getArrayOfSocialNetworks()
$socialnetworks = array();
// Enable caching of array
- require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'socialnetworks_' . $conf->entity;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
@@ -4703,7 +4698,6 @@ function dolGetCountryCodeFromIp($ip)
$datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE');
//$ip='24.24.24.24';
//$datafile='/usr/share/GeoIP/GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages)
- include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php';
$geoip = new DolGeoIP('country', $datafile);
//print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n";
$countrycode = $geoip->getCountryCodeFromIP($ip);
@@ -4730,7 +4724,6 @@ function dol_user_country()
$datafile = getDolGlobalString('GEOIPMAXMIND_COUNTRY_DATAFILE');
//$ip='24.24.24.24';
//$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';
- include_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php';
$geoip = new DolGeoIP('country', $datafile);
$countrycode = $geoip->getCountryCodeFromIP($ip);
$ret = $countrycode;
@@ -5995,8 +5988,6 @@ function img_credit_card($brand, $morecss = null)
*/
function img_mime($file, $titlealt = '', $morecss = '')
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
$mimetype = dol_mimetype($file, '', 1);
$mimeimg = dol_mimetype($file, '', 2);
$mimefa = dol_mimetype($file, '', 4);
@@ -6128,7 +6119,6 @@ function dol_print_error($db = null, $error = '', $errors = null)
// If error occurs before the $lang object was loaded
if (!$langs) {
- require_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
$langs = new Translate('', $conf);
$langs->load("main");
}
@@ -7139,8 +7129,6 @@ function price2num($amount, $rounding = '', $option = 0)
*/
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no', $use_short_label = 0)
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
-
if (($forceunitoutput == 'no' && $dimension < 1 / 10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
$dimension *= 1000000;
$unit -= 6;
@@ -7524,8 +7512,6 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
{
global $db, $mysoc;
- require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-
$ret = 0;
$found = 0;
@@ -7619,10 +7605,6 @@ function get_product_localtax_for_country($idprod, $local, $thirdpartytouse)
{
global $db, $mysoc;
- if (!class_exists('Product')) {
- require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
- }
-
$ret = 0;
$found = 0;
@@ -7692,8 +7674,6 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
{
global $conf, $db;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-
// Note: possible values for tva_assuj are 0/1 or franchise/reel
$seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj == 'franchise')) ? 0 : 1;
@@ -7711,7 +7691,6 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
if ($seller_in_cee && $buyer_in_cee) {
$isacompany = $thirdparty_buyer->isACompany();
if ($isacompany && getDolGlobalString('MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!isValidVATID($thirdparty_buyer)) {
$isacompany = 0;
}
@@ -7780,7 +7759,6 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer,
if (($seller_in_cee && $buyer_in_cee)) {
$isacompany = $thirdparty_buyer->isACompany();
if ($isacompany && getDolGlobalString('MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL')) {
- require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!isValidVATID($thirdparty_buyer)) {
$isacompany = 0;
}
@@ -7827,16 +7805,10 @@ function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer,
global $db;
if ($idprodfournprice > 0) {
- if (!class_exists('ProductFournisseur')) {
- require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
- }
$prodprice = new ProductFournisseur($db);
$prodprice->fetch_product_fournisseur_price($idprodfournprice);
return $prodprice->fourn_tva_npr;
} elseif ($idprod > 0) {
- if (!class_exists('Product')) {
- require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
- }
$prod = new Product($db);
$prod->fetch($idprod);
return $prod->tva_npr;
@@ -9489,7 +9461,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
$paymenturl = '';
} else {
// Set the online payment url link into __ONLINE_PAYMENT_URL__ key
- require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$outputlangs->loadLangs(array('paypal', 'other'));
$amounttouse = 0;
@@ -9523,7 +9494,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
// Show structured communication
if (getDolGlobalString('INVOICE_PAYMENT_ENABLE_STRUCTURED_COMMUNICATION') && $object->element == 'facture') {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions_be.lib.php';
$substitutionarray['__PAYMENT_STRUCTURED_COMMUNICATION__'] = dolBECalculateStructuredCommunication($object->ref, $object->type);
}
@@ -9561,7 +9531,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'propal') {
'@phan-var-force Propal $object';
$substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'commande') {
@@ -9575,13 +9544,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'contrat') {
'@phan-var-force Contrat $object';
$substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'fichinter') {
'@phan-var-force Fichinter $object';
$substitutionarray['__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT."/fichinter/card.php?id=".$object->id;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'supplier_proposal') {
@@ -9609,7 +9576,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if ((empty($exclude) || !in_array('objectamount', $exclude)) && (empty($include) || in_array('objectamount', $include))) {
'@phan-var-force Facture|FactureRec $object';
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
$substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', false, $outputlangs) : null) : '';
$substitutionarray['__DATE_DUE_YMD__'] = is_object($object) ? (isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', false, $outputlangs) : null) : '';
@@ -9683,8 +9649,6 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if ((empty($exclude) || !in_array('date', $exclude)) && (empty($include) || in_array('date', $include))) {
- include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
$now = dol_now();
$tmp = dol_getdate($now, true);
@@ -9940,8 +9904,6 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
{
global $conf, $user;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
// Note: substitution key for each extrafields, using key __EXTRA_XXX__ is already available into the getCommonSubstitutionArray used to build the substitution array.
// Check if there is external substitution to do, requested by plugins
@@ -13738,7 +13700,6 @@ function getElementProperties($elementType)
// Add hook
if (!is_object($hookmanager)) {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
}
$hookmanager->initHooks(array('elementproperties'));
@@ -14559,8 +14520,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null,
global $param, $massactionbutton;
- require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
-
// Check parameters
if (!is_object($filterobj) && !is_object($objcon)) {
dol_print_error(null, 'BadParameter');
@@ -14876,11 +14835,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null,
if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) {
$delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
- require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-
$formactions = new FormActions($db);
$actionstatic = new ActionComm($db);
@@ -14977,7 +14931,6 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = null,
$out .= getTitleFieldOfList($tmp);
}
- require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
$caction = new CActionComm($db);
$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1);
@@ -15360,7 +15313,6 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show
global $action, $object;
if (!is_object($langs)) {
- include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
$langs = new Translate('', $conf);
$langs->setDefaultLang();
}
@@ -15386,7 +15338,6 @@ function recordNotFound($message = '', $printheader = 1, $printfooter = 1, $show
if (empty($showonlymessage)) {
if (empty($hookmanager)) {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('main'));
diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php
index ef2f44d06304c..7c936eec79aae 100644
--- a/htdocs/core/tpl/login.tpl.php
+++ b/htdocs/core/tpl/login.tpl.php
@@ -23,6 +23,8 @@
// Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...);
// $titletruedolibarrversion must be defined
+require_once __DIR__ . "/../lib/functions.lib.php";
+
if (!defined('NOBROWSERNOTIF')) {
define('NOBROWSERNOTIF', 1);
}
diff --git a/htdocs/index.php b/htdocs/index.php
index b8e6d089292b9..6fe739cf4555b 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -30,8 +30,12 @@
define('CSRFCHECK_WITH_TOKEN', 1); // We force need to use a token to login when making a POST
+require_once __DIR__.'/core/class/Autoloader.php';
require 'main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+
+use Dolibarr\HTML\FormOther;
+use Dolibarr\InfoBox;
+use Dolibarr\HTML\Form;
/**
* @var Conf $conf
@@ -71,7 +75,6 @@
exit;
}
if (GETPOST('addbox')) { // Add box (when submit is done from a form when ajax disabled)
- require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone = GETPOSTINT('areacode');
$userid = GETPOSTINT('userid');
$boxorder = GETPOST('boxorder', 'aZ09');
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 5c06842b25d61..be517ce9e3d62 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -38,6 +38,8 @@
* \ingroup core
* \brief File that defines environment for Dolibarr GUI pages only (file not required by scripts)
*/
+require_once __DIR__ . "/core/class/Autoloader.php";
+require_once __DIR__ . "/core/lib/functions.lib.php";
//@ini_set('memory_limit', '128M'); // This may be useless if memory is hard limited by your PHP
diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php
index d7e9a5b0505f2..8b5e1398b1633 100644
--- a/htdocs/master.inc.php
+++ b/htdocs/master.inc.php
@@ -32,12 +32,10 @@
* \brief File that defines environment for all Dolibarr process (pages or scripts)
* This script reads the conf file, init $lang, $db and and empty $user
*/
+namespace Dolibarr;
// Include the conf.php and functions.lib.php and security.lib.php. This defined the constants like DOL_DOCUMENT_ROOT, DOL_DATA_ROOT, DOL_URL_ROOT...
// This file may have been already required by main.inc.php. But may not by scripts. So, here the require_once must be kept.
-require_once 'filefunc.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
/**
* @var Translate $langs
*
diff --git a/htdocs/multicurrency/class/currencyrate.class.php b/htdocs/multicurrency/class/currencyrate.class.php
index dbeed1d2749ba..30c50ad091a1d 100644
--- a/htdocs/multicurrency/class/currencyrate.class.php
+++ b/htdocs/multicurrency/class/currencyrate.class.php
@@ -27,8 +27,7 @@
* \ingroup multicurrency
* \brief This file is a CRUD class file (Create/Read/Update/Delete) for currencyrate
*/
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
+namespace Dolibarr;
/**
* Class CurrencyRate
diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php
index 2523134ed3653..a8a55c3a0f2cf 100644
--- a/htdocs/multicurrency/class/multicurrency.class.php
+++ b/htdocs/multicurrency/class/multicurrency.class.php
@@ -26,9 +26,7 @@
* \ingroup multicurrency
* \brief This file is a CRUD class file (Create/Read/Update/Delete) for multicurrency
*/
-
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/currencyrate.class.php';
+namespace Dolibarr\MultiCurrency;
/**
* Class Currency
diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php
index d3aeeb8d17dc9..92dc98af8f3a6 100644
--- a/htdocs/product/class/html.formproduct.class.php
+++ b/htdocs/product/class/html.formproduct.class.php
@@ -23,8 +23,7 @@
* \brief File for class with methods for building product related HTML components
*/
-require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
-
+namespace Dolibarr\HTML;
/**
* Class with static methods for building HTML components related to products
* Only components common to products and services must be here.
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 5ff1c35496aa0..f94698bcad129 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -42,13 +42,10 @@
* \ingroup societe
* \brief File for third party class
*/
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonincoterm.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonsocialnetworks.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
+namespace Dolibarr\ThirdParty;
+use Dolibarr\{CommonObject, CommonPeople, CommonIncoterm, CommonSocialNetworks, Conf};
+use Dolibarr\MultiCurrency\MultiCurrency;
/**
* Class to manage third parties objects (customers, suppliers, prospects...)
diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php
index 11332a7febd55..168dc4d0e6468 100644
--- a/htdocs/societe/index.php
+++ b/htdocs/societe/index.php
@@ -27,12 +27,12 @@
* \ingroup societe
* \brief Home page for third parties area
*/
+namespace Dolibarr;
+use Dolibarr\HTML\FormOther;
+use Dolibarr\HookManager;
// Load Dolibarr environment
require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
/**
* @var Conf $conf
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index ba728ebc94ca2..7c8e2573adb34 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -36,12 +36,10 @@
* \brief File of class to manage users
* \ingroup core
*/
+namespace Dolibarr\User;
-require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/commonpeople.class.php';
-
+use Dolibarr\{CommonObject, CommonPeople, DefaultValues};
+use stdClass;
/**
* Class to manage Dolibarr users
@@ -820,7 +818,6 @@ public function loadDefaultValues()
if (getDolGlobalString('MAIN_ENABLE_DEFAULT_VALUES')) {
// Load user->default_values for user. TODO Save this in memcached ?
- require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php';
$defaultValues = new DefaultValues($this->db);
$result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,'.$this->id.') AND (entity:in:'.(isset($this->entity) ? $this->entity : $conf->entity).','.$conf->entity.')'); // User 0 (all) + me (if defined)