diff --git a/.gitignore b/.gitignore index 111c201670d..33cde11b9c4 100755 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ default.properties dolibarr_install.log doxygen_warnings.log /.project +.DS_Store diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index f874f6ed074..735ba92a0bd 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -151,7 +151,7 @@ $db->commit(); $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" -$sql.= " AND entity in (".(!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?"1,":"").$conf->entity.")"; +$sql.= " AND entity in (".(!empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled $sql.= " ORDER BY r.module, r.id"; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 61366fe7219..ff1cce52ee7 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -279,4 +279,17 @@ $dolibarr_main_prod='0'; #$dolibarr_font_DOL_DEFAULT_TTF="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"; #$dolibarr_font_DOL_DEFAULT_TTF_BOLD="/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf"; +############################## +# Extrernal module # +############################## + +# multicompany_transverse_mode +# Pyramidal (0): The rights and groups are managed in each entity, +# users belong to the entity for their rights. +# Transversal (1): The groups can belong only to the master entity +# and that the user belongs to a particular entity +# Default value: 0 (pyramidal) +# Examples: +# $multicompany_transverse_mode='1'; + ?> diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index ca3f04b4602..639bd5ca5ca 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -50,6 +50,12 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) $fk_element = GETPOST('fk_element'); $type = GETPOST('type'); + if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if ($element == 'fichinter') $element = 'ficheinter'; if ($user->rights->$element->lire || $user->rights->$element->read) @@ -72,7 +78,7 @@ if((isset($_GET['field']) && ! empty($_GET['field'])) } else { - echo $langs->trans('NotEnoughPermissions'); + echo $langs->transnoentities('NotEnoughPermissions'); } } diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 097266bcc88..3f4c3d07560 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -56,6 +56,12 @@ if((isset($_POST['field']) && ! empty($_POST['field'])) $return=array(); $error=0; + if (preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + if ($element == 'fichinter') $element = 'ficheinter'; if ($user->rights->$element->creer || $user->rights->$element->write) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 241a7f5e8cd..24cca609cec 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -53,6 +53,8 @@ class Conf var $top_menu; var $smart_menu; + //! To store properties of multi-company + var $multicompany; //! Used to store instance for multi-company (default 1) var $entity=1; @@ -89,9 +91,10 @@ class Conf /** - * Load setup values into conf object (read llx_const) - * @param $db Handler d'acces base - * @return int < 0 if KO, >= 0 if OK + * Load setup values into conf object (read llx_const) + * + * @param DoliDB $db Handler d'acces base + * @return int < 0 if KO, >= 0 if OK */ function setValues($db) { @@ -112,7 +115,14 @@ class Conf $sql = "SELECT ".$db->decrypt('name')." as name,"; $sql.= " ".$db->decrypt('value')." as value, entity"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; - $sql.= " WHERE entity IN (0,".$this->entity.")"; + if (! empty($this->multicompany->transverse_mode)) + { + $sql.= " WHERE entity IN (0,1,".$this->entity.")"; + } + else + { + $sql.= " WHERE entity IN (0,".$this->entity.")"; + } $sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. $result = $db->query($sql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a6bb6220963..4a2002bc090 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -973,7 +973,7 @@ class Form } $out.= $userstatic->getFullName($langs); - if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { if ($obj->admin && ! $obj->entity) $out.=" (".$langs->trans("AllEntities").")"; else $out.=" (".$obj->label.")"; @@ -3734,7 +3734,7 @@ class Form $out.= '>'; $out.= $obj->nom; - if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) + if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { $out.= " (".$obj->label.")"; } diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js index 5ff7ca6cd25..c3ee9146565 100644 --- a/htdocs/core/js/editinplace.js +++ b/htdocs/core/js/editinplace.js @@ -7,9 +7,9 @@ $(document).ready(function() { - var element = $('#element').html(); - var table_element = $('#table_element').html(); - var fk_element = $('#fk_element').html(); + var element = $('#jeditable_element').html(); + var table_element = $('#jeditable_table_element').html(); + var fk_element = $('#jeditable_fk_element').html(); $('.edit_textarea').editable(urlSaveInPlace, { type : 'textarea', @@ -131,7 +131,7 @@ $(document).ready(function() { id : 'field', onblur : 'ignore', tooltip : tooltipInPlace, - placeholder : placeholderInPlace, + placeholder : ' ', cancel : cancelInPlace, submit : submitInPlace, indicator : indicatorInPlace, diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1ac34878050..ec10c68f2e4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -771,54 +771,55 @@ function dol_delete_preview($object) } /** -* Create a meta file with document file into same directory. -* This should allow rgrep search -* -* @param Object $object Object -* @return void -*/ + * Create a meta file with document file into same directory. + * This should allow rgrep search + * + * @param Object $object Object + * @return void + */ function dol_meta_create($object) { - global $langs,$conf; - - $object->fetch_thirdparty(); - - if ($conf->facture->dir_output) - { - $facref = dol_sanitizeFileName($object->ref); - $dir = $conf->facture->dir_output . "/" . $facref ; - $file = $dir . "/" . $facref . ".meta"; - - if (! is_dir($dir)) - { - create_exdir($dir); - } - - if (is_dir($dir)) - { - $nblignes = count($object->lines); - $client = $object->client->nom . " " . $object->client->address . " " . $object->client->cp . " " . $object->client->ville; - $meta = "REFERENCE=\"" . $object->ref . "\" + global $langs,$conf; + + $object->fetch_thirdparty(); + + if ($conf->facture->dir_output) + { + $facref = dol_sanitizeFileName($object->ref); + $dir = $conf->facture->dir_output . "/" . $facref; + $file = $dir . "/" . $facref . ".meta"; + + if (! is_dir($dir)) + { + create_exdir($dir); + } + + if (is_dir($dir)) + { + $nblignes = count($object->lines); + $client = $object->client->nom . " " . $object->client->address . " " . $object->client->cp . " " . $object->client->ville; + $meta = "REFERENCE=\"" . $object->ref . "\" DATE=\"" . dol_print_date($object->date,'') . "\" NB_ITEMS=\"" . $nblignes . "\" CLIENT=\"" . $client . "\" TOTAL_HT=\"" . $object->total_ht . "\" TOTAL_TTC=\"" . $object->total_ttc . "\"\n"; - - for ($i = 0 ; $i < $nblignes ; $i++) - { - //Pour les articles - $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\" + + for ($i = 0 ; $i < $nblignes ; $i++) + { + //Pour les articles + $meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\" ITEM_" . $i . "_UNIT_PRICE=\"" . $object->lines[$i]->price . "\" - ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\" - ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\" - "; - } - } - $fp = fopen($file,"w"); - fputs($fp,$meta); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) + ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\" + ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\" + "; + } + } + + $fp = fopen($file,"w"); + fputs($fp,$meta); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f36f9e6ad2f..11e5ce3d68c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -599,9 +599,9 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p // Parameters for edit in place if (! empty($GLOBALS['object'])) { - $out.=''."\n"; - $out.=''."\n"; - $out.=''."\n"; + $out.=''."\n"; + $out.=''."\n"; + $out.=''."\n"; } return $out; @@ -4445,4 +4445,4 @@ function printCommonFooter($zone='private') } -?> \ No newline at end of file +?> diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b01d7dc61b9..fc5eb564f50 100755 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -86,6 +86,7 @@ if (empty($dolibarr_main_db_cryptkey)) $dolibarr_main_db_cryptkey=''; if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0; if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0; if (empty($force_charset_do_notuse)) $force_charset_do_notuse='UTF-8'; +if (empty($multicompany_transverse_mode)) $multicompany_transverse_mode=0; // Security: CSRF protection // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index d7b183c72ee..01b895d4c3c 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -71,17 +71,30 @@ DROP TABLE IF EXISTS llx_pos_tmp; ALTER TABLE llx_deplacement ADD COLUMN fk_user_modif integer AFTER fk_user_author; -CREATE TABLE IF NOT EXISTS `llx_localtax` ( - `rowid` int(11) NOT NULL AUTO_INCREMENT, - `tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `datep` date DEFAULT NULL, - `datev` date DEFAULT NULL, - `amount` double NOT NULL DEFAULT '0', - `label` varchar(255) DEFAULT NULL, - `entity` int(11) NOT NULL DEFAULT '1', - `note` text, - `fk_bank` int(11) DEFAULT NULL, - `fk_user_creat` int(11) DEFAULT NULL, - `fk_user_modif` int(11) DEFAULT NULL, - PRIMARY KEY (`rowid`) +CREATE TABLE IF NOT EXISTS llx_localtax +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT '1', + tms timestamp, + datep date DEFAULT NULL, + datev date DEFAULT NULL, + amount double NOT NULL DEFAULT '0', + label varchar(255) DEFAULT NULL, + note text, + fk_bank integer DEFAULT NULL, + fk_user_creat integer DEFAULT NULL, + fk_user_modif integer DEFAULT NULL + ) ENGINE=InnoDB; + +ALTER TABLE llx_propal MODIFY ref_int varchar(255); +ALTER TABLE llx_propal MODIFY ref_ext varchar(255); +ALTER TABLE llx_propal MODIFY ref_client varchar(255); + +ALTER TABLE llx_commande MODIFY ref_int varchar(255); +ALTER TABLE llx_commande MODIFY ref_ext varchar(255); +ALTER TABLE llx_commande MODIFY ref_client varchar(255); + +ALTER TABLE llx_facture MODIFY ref_int varchar(255); +ALTER TABLE llx_facture MODIFY ref_ext varchar(255); +ALTER TABLE llx_facture MODIFY ref_client varchar(255); diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index b99f5ce054a..0c972d3bc8d 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -21,24 +21,24 @@ create table llx_commande ( rowid integer AUTO_INCREMENT PRIMARY KEY, - ref varchar(30) NOT NULL, -- order reference number - entity integer DEFAULT 1 NOT NULL, -- multi company id + ref varchar(30) NOT NULL, -- order reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id - ref_ext varchar(50), -- reference into an external system (not used by dolibarr) - ref_int varchar(50), -- reference into an internal system (used by dolibarr) - ref_client varchar(50), -- reference for customer + ref_ext varchar(255), -- reference into an external system (not used by dolibarr) + ref_int varchar(255), -- reference into an internal system (used by dolibarr) + ref_client varchar(255), -- reference for customer fk_soc integer NOT NULL, - fk_projet integer DEFAULT 0, -- projet auquel est rattache la commande + fk_projet integer DEFAULT 0, -- projet auquel est rattache la commande tms timestamp, - date_creation datetime, -- date de creation - date_valid datetime, -- date de validation - date_cloture datetime, -- date de cloture - date_commande date, -- date de la commande - fk_user_author integer, -- createur de la commande - fk_user_valid integer, -- valideur de la commande - fk_user_cloture integer, -- auteur cloture + date_creation datetime, -- date de creation + date_valid datetime, -- date de validation + date_cloture datetime, -- date de cloture + date_commande date, -- date de la commande + fk_user_author integer, -- createur de la commande + fk_user_valid integer, -- valideur de la commande + fk_user_cloture integer, -- auteur cloture source smallint, fk_statut smallint default 0, amount_ht real default 0, @@ -46,8 +46,8 @@ create table llx_commande remise_absolue real default 0, remise real default 0, tva double(24,8) default 0, - localtax1 double(24,8) default 0, -- total localtax1 - localtax2 double(24,8) default 0, -- total localtax2 + localtax1 double(24,8) default 0, -- total localtax1 + localtax2 double(24,8) default 0, -- total localtax2 total_ht double(24,8) default 0, total_ttc double(24,8) default 0, note text, @@ -55,11 +55,11 @@ create table llx_commande model_pdf varchar(255), facture tinyint default 0, - fk_cond_reglement integer, -- condition de reglement - fk_mode_reglement integer, -- mode de reglement + fk_cond_reglement integer, -- condition de reglement + fk_mode_reglement integer, -- mode de reglement date_livraison date default NULL, fk_availability integer NULL, - fk_demand_reason integer, -- should be named fk_input_reason - fk_adresse_livraison integer, -- delivery address (deprecated) + fk_demand_reason integer, -- should be named fk_input_reason + fk_adresse_livraison integer, -- delivery address (deprecated) import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql index a0d7b35d506..be0ac897b42 100644 --- a/htdocs/install/mysql/tables/llx_facture.sql +++ b/htdocs/install/mysql/tables/llx_facture.sql @@ -24,28 +24,28 @@ create table llx_facture ( rowid integer AUTO_INCREMENT PRIMARY KEY, - facnumber varchar(30) NOT NULL, -- invoice reference number - entity integer DEFAULT 1 NOT NULL, -- multi company id + facnumber varchar(30) NOT NULL, -- invoice reference number + entity integer DEFAULT 1 NOT NULL, -- multi company id - ref_ext varchar(50), -- reference into an external system (not used by dolibarr) - ref_int varchar(50), -- reference into an internal system (used by dolibarr) - ref_client varchar(50), -- reference for customer + ref_ext varchar(255), -- reference into an external system (not used by dolibarr) + ref_int varchar(255), -- reference into an internal system (used by dolibarr) + ref_client varchar(255), -- reference for customer - type smallint DEFAULT 0 NOT NULL, -- type of invoice + type smallint DEFAULT 0 NOT NULL, -- type of invoice increment varchar(10), fk_soc integer NOT NULL, - datec datetime, -- date de creation de la facture - datef date, -- date de la facture - date_valid date, -- date de validation - tms timestamp, -- date creation/modification + datec datetime, -- date de creation de la facture + datef date, -- date de la facture + date_valid date, -- date de validation + tms timestamp, -- date creation/modification paye smallint DEFAULT 0 NOT NULL, amount double(24,8) DEFAULT 0 NOT NULL, - remise_percent real DEFAULT 0, -- remise relative - remise_absolue real DEFAULT 0, -- remise absolue - remise real DEFAULT 0, -- remise totale calculee + remise_percent real DEFAULT 0, -- remise relative + remise_absolue real DEFAULT 0, -- remise absolue + remise real DEFAULT 0, -- remise totale calculee - close_code varchar(16), -- Code motif cloture sans paiement complet - close_note varchar(128), -- Commentaire cloture sans paiement complet + close_code varchar(16), -- Code motif cloture sans paiement complet + close_note varchar(128), -- Commentaire cloture sans paiement complet tva double(24,8) DEFAULT 0, -- montant tva apres remise totale localtax1 double(24,8) DEFAULT 0, -- amount localtax1 @@ -55,15 +55,15 @@ create table llx_facture fk_statut smallint DEFAULT 0 NOT NULL, - fk_user_author integer, -- createur de la facture - fk_user_valid integer, -- valideur de la facture + fk_user_author integer, -- createur de la facture + fk_user_valid integer, -- valideur de la facture - fk_facture_source integer, -- facture origine si facture avoir - fk_projet integer, -- projet auquel est associee la facture + fk_facture_source integer, -- facture origine si facture avoir + fk_projet integer, -- projet auquel est associee la facture - fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...) - fk_mode_reglement integer, -- mode de reglement (Virement, Prelevement) - date_lim_reglement date, -- date limite de reglement + fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...) + fk_mode_reglement integer, -- mode de reglement (Virement, Prelevement) + date_lim_reglement date, -- date limite de reglement note text, note_public text, diff --git a/htdocs/install/mysql/tables/llx_localtax.sql b/htdocs/install/mysql/tables/llx_localtax.sql index 460c3c29c63..58142a3f168 100644 --- a/htdocs/install/mysql/tables/llx_localtax.sql +++ b/htdocs/install/mysql/tables/llx_localtax.sql @@ -1,7 +1,6 @@ -- =================================================================== --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2005-2009 Regis Houssin --- Copyright (C) 2011 Juanjo Menent +-- Copyright (C) 2011 Juanjo Menent +-- Copyright (C) 2011 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,22 +20,15 @@ create table llx_localtax ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, tms timestamp, - datep date, -- date of payment - datev date, -- date of value - amount real NOT NULL DEFAULT 0, - label varchar(255), - entity integer DEFAULT 1 NOT NULL, + datep date, -- date of payment + datev date, -- date of value + amount double, + label varchar(255), note text, fk_bank integer, fk_user_creat integer, - fk_user_modif integer + fk_user_modif integer + )ENGINE=innodb; - --- --- List of codes for the field entity --- --- 1 : first company vat --- 2 : second company vat --- 3 : etc... --- \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index d675f73bbca..a293e9b5c0e 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -23,14 +23,14 @@ create table llx_propal ( rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30) NOT NULL, -- proposal reference number - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id - ref_ext varchar(50), -- reference into an external system (not used by dolibarr) - ref_int varchar(50), -- reference into an internal system (used by dolibarr) - ref_client varchar(50), -- customer proposal number + ref_ext varchar(255), -- reference into an external system (not used by dolibarr) + ref_int varchar(255), -- reference into an internal system (used by dolibarr) + ref_client varchar(255), -- customer proposal number fk_soc integer, - fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale + fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale tms timestamp, datec datetime, -- date de creation diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index c56ded1c2aa..5ee36650668 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -43,31 +43,31 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/conf.class.php"); $conf = new Conf(); // Identifiant propres au serveur base de donnee -$conf->db->host = $dolibarr_main_db_host; -$conf->db->port = $dolibarr_main_db_port; -$conf->db->name = $dolibarr_main_db_name; -$conf->db->user = $dolibarr_main_db_user; -$conf->db->pass = $dolibarr_main_db_pass; -$conf->db->type = $dolibarr_main_db_type; -$conf->db->prefix = $dolibarr_main_db_prefix; -$conf->db->character_set=$dolibarr_main_db_character_set; -$conf->db->dolibarr_main_db_collation=$dolibarr_main_db_collation; -$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; -$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; -$conf->file->main_limit_users = $dolibarr_main_limit_users; -$conf->file->mailing_limit_sendbyweb = $dolibarr_mailing_limit_sendbyweb; +$conf->db->host = $dolibarr_main_db_host; +$conf->db->port = $dolibarr_main_db_port; +$conf->db->name = $dolibarr_main_db_name; +$conf->db->user = $dolibarr_main_db_user; +$conf->db->pass = $dolibarr_main_db_pass; +$conf->db->type = $dolibarr_main_db_type; +$conf->db->prefix = $dolibarr_main_db_prefix; +$conf->db->character_set = $dolibarr_main_db_character_set; +$conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; +$conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; +$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; +$conf->file->main_limit_users = $dolibarr_main_limit_users; +$conf->file->mailing_limit_sendbyweb = $dolibarr_mailing_limit_sendbyweb; if (defined('TEST_DB_FORCE_TYPE')) $conf->db->type=constant('TEST_DB_FORCE_TYPE'); // For test purpose // Identifiant autres -$conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication; +$conf->file->main_authentication = empty($dolibarr_main_authentication)?'':$dolibarr_main_authentication; // Force https -$conf->file->main_force_https = empty($dolibarr_main_force_https)?'':$dolibarr_main_force_https; +$conf->file->main_force_https = empty($dolibarr_main_force_https)?'':$dolibarr_main_force_https; // Define charset for HTML Output (can set hidden value force_charset in conf file) -$conf->file->character_set_client=strtoupper($force_charset_do_notuse); +$conf->file->character_set_client = strtoupper($force_charset_do_notuse); // Cookie cryptkey -$conf->file->cookie_cryptkey = empty($dolibarr_main_cookie_cryptkey)?'':$dolibarr_main_cookie_cryptkey; +$conf->file->cookie_cryptkey = empty($dolibarr_main_cookie_cryptkey)?'':$dolibarr_main_cookie_cryptkey; // Define array of document root directories -$conf->file->dol_document_root=array('main' => DOL_DOCUMENT_ROOT); +$conf->file->dol_document_root = array('main' => DOL_DOCUMENT_ROOT); if (! empty($dolibarr_main_document_root_alt)) { // dolibarr_main_document_root_alt contains several directories @@ -78,6 +78,9 @@ if (! empty($dolibarr_main_document_root_alt)) } } +// Multi-Company transverse mode +$conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; + // Chargement des includes principaux de librairies communes if (! defined('NOREQUIREUSER')) require_once(DOL_DOCUMENT_ROOT ."/user/class/user.class.php"); // Need 500ko memory if (! defined('NOREQUIRETRAN')) require_once(DOL_DOCUMENT_ROOT ."/core/class/translate.class.php"); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 50b0376a6aa..3ab7eeed1fc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -502,7 +502,7 @@ class User extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = ur.fk_id"; - $sql.= " AND r.entity in (0,".(!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?"1,":"").$conf->entity.")"; + $sql.= " AND r.entity in (0,".(!empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; $sql.= " AND ur.fk_user= ".$this->id; $sql.= " AND r.perms IS NOT NULL"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 7d57125eb3b..bd96e434818 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -64,7 +64,7 @@ if ($id) } //Multicompany in mode transversal -if(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +if(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) { accessforbidden(); } @@ -205,7 +205,7 @@ if ($action == 'add' && $canadduser) // If multicompany is off, admin users must all be on entity 0. if($conf->multicompany->enabled) { - if($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ! empty($_POST["superadmin"])) + if($conf->multicompany->transverse_mode || ! empty($_POST["superadmin"])) { $edituser->entity=0; } @@ -261,8 +261,8 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield) $edituser = new User($db); $edituser->fetch($id); - if ($action == 'addgroup') $edituser->SetInGroup($group,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$editgroup->entity)); - if ($action == 'removegroup') $edituser->RemoveFromGroup($group,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$editgroup->entity)); + if ($action == 'addgroup') $edituser->SetInGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity)); + if ($action == 'removegroup') $edituser->RemoveFromGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity)); if ($result > 0) { @@ -319,7 +319,7 @@ if ($action == 'update' && ! $_POST["cancel"]) $edituser->phenix_pass = $_POST["phenix_pass"]; if($conf->multicompany->enabled) { - if($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ! empty($_POST["superadmin"])) + if($conf->multicompany->transverse_mode || ! empty($_POST["superadmin"])) { $edituser->entity=0; } @@ -704,7 +704,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print $form->selectyesno('admin',$_POST["admin"],1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) { if ($conf->use_javascript_ajax) { @@ -744,7 +744,7 @@ if (($action == 'create') || ($action == 'adduserldap')) //Multicompany if (! empty($conf->multicompany->enabled)) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); print "".''.$langs->trans("Entity").''; @@ -1076,7 +1076,7 @@ else print ''."\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''.$langs->trans("Entity").''; if ($fuser->admin && ! $fuser->entity) @@ -1237,7 +1237,7 @@ else print '
'; - if ($caneditfield && (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + if ($caneditfield && (empty($conf->multicompany->enabled) || (($fuser->entity == $conf->entity) || $fuser->entity == $user->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1249,7 +1249,7 @@ else } } elseif ($caneditpassword && ! $fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { print ''.$langs->trans("EditPassword").''; } @@ -1258,13 +1258,13 @@ else if ($conf->global->USER_PASSWORD_GENERATED != 'none') { if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("ReinitPassword").''; } if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { if ($fuser->email) print ''.$langs->trans("SendNewPassword").''; else print ''.$langs->trans("SendNewPassword").''; @@ -1273,19 +1273,19 @@ else // Activer if ($user->id <> $id && $candisableuser && $fuser->statut == 0 && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { print ''.$langs->trans("Reactivate").''; } // Desactiver if ($user->id <> $id && $candisableuser && $fuser->statut == 1 && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { print ''.$langs->trans("DisableUser").''; } // Delete if ($user->id <> $id && $candisableuser && - (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)) ) + (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { print ''.$langs->trans("DeleteUser").''; } @@ -1311,7 +1311,7 @@ else if (! empty($groupslist)) { - if( ! ($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if( ! ($conf->multicompany->enabled && $conf->multicompany->transverse_mode)) { foreach($groupslist as $groupforuser) { @@ -1334,7 +1334,7 @@ else // Multicompany if (! empty($conf->multicompany->enabled)) { - if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + if ($conf->entity == 1 && $conf->multicompany->transverse_mode) { $mc = new ActionsMulticompany($db); print ''.$langs->trans("Entity").''; @@ -1362,7 +1362,7 @@ else print ''; print ''; print ''; - if(! empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''; } @@ -1387,7 +1387,7 @@ else print img_object($langs->trans("ShowGroup"),"group").' '.$group->nom; } print ''; - if(! empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); $mc->getInfo($group->usergroup_entity); @@ -1544,7 +1544,7 @@ else { print $form->selectyesno('admin',$fuser->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) { if ($conf->use_javascript_ajax) { @@ -1602,7 +1602,7 @@ else //Multicompany if (! empty($conf->multicompany->enabled)) { - if(empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if(empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); print "".''; diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 16ee9d18bc8..dbf4e55d1f9 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -51,7 +51,7 @@ $userid=GETPOST("user","int"); // Security check $result = restrictedArea($user, 'user', $_GET["id"], 'usergroup', 'user'); -if(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +if(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) { accessforbidden(); } @@ -95,7 +95,7 @@ if ($action == 'add') if (! $message) { $object->nom = trim($_POST["nom"]); - if($conf->multicompany->enabled && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) $object->entity = 0; else $object->entity = $_POST["entity"]; @@ -141,8 +141,8 @@ if ($action == 'adduser' || $action =='removeuser') $edituser = new User($db); $edituser->fetch($userid); - if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$object->entity)); - if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->global->MULTICOMPANY_TRANSVERSE_MODE?GETPOST("entity"):$object->entity)); + if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,($conf->multicompany->transverse_mode?GETPOST("entity"):$object->entity)); + if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,($conf->multicompany->transverse_mode?GETPOST("entity"):$object->entity)); if ($result > 0) { @@ -176,7 +176,7 @@ if ($action == 'update') $object->oldcopy=dol_clone($object); $object->nom = trim($_POST["group"]); - if($conf->multicompany->enabled && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if($conf->multicompany->enabled && !empty($conf->multicompany->transverse_mode)) $object->entity = 0; else $object->entity = $_POST["entity"]; @@ -231,7 +231,7 @@ if ($action == 'create') // Multicompany if (! empty($conf->multicompany->enabled)) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); print "".''; @@ -317,7 +317,7 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); $mc->getInfo($object->entity); @@ -366,7 +366,7 @@ else if (! empty($object->members)) { - if( !($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if( !($conf->multicompany->enabled && $conf->multicompany->transverse_mode)) { foreach($object->members as $useringroup) { @@ -388,7 +388,7 @@ else // Multicompany if (! empty($conf->multicompany->enabled)) { - if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + if ($conf->entity == 1 && $conf->multicompany->transverse_mode) { $mc = new ActionsMulticompany($db); print ''; @@ -486,7 +486,7 @@ else // Multicompany if (! empty($conf->multicompany->enabled)) { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc = new ActionsMulticompany($db); print "".''; diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index d6beab319eb..1ea8f476949 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -58,7 +58,7 @@ print_fiche_titre($langs->trans("ListOfGroups")); $sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(ugu.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; -if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) +if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; } @@ -85,7 +85,7 @@ if ($resql) print ''; print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); //multicompany - if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) + if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder); } @@ -106,7 +106,7 @@ if ($resql) } print ""; //multicompany - if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) + if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) { dol_include_once("/multicompany/class/actions_multicompany.class.php"); $mc = new ActionsMulticompany($db); diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 52a328fb42c..20fcbf02931 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -169,7 +169,7 @@ if ($id) $sql.= " WHERE ugr.fk_id = r.id"; if(! empty($conf->multicompany->enabled)) { - if(empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if(empty($conf->multicompany->transverse_mode)) { $sql.= " AND r.entity = ".$conf->entity; } @@ -250,7 +250,7 @@ if ($id) //$sql.= " AND r.entity = ".(empty($conf->multicompany->enabled) ? $conf->entity : $fgroup->entity); if(! empty($conf->multicompany->enabled)) { - if(empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if(empty($conf->multicompany->transverse_mode)) { $sql.= " AND r.entity = ".$conf->entity; } diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 2af26b6fc8d..4db28e191a3 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -99,7 +99,7 @@ $sql = "SELECT u.rowid, u.name, u.firstname, u.admin, u.login, u.fk_societe, u.d $sql.= " s.nom, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid"; -if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) +if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) { $sql.= " WHERE u.entity IS NOT NULL"; } @@ -196,7 +196,7 @@ if ($canreadperms) $sql = "SELECT g.rowid, g.nom, g.note, g.entity, g.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) + if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index eb1b336c994..304d8508abb 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -69,7 +69,7 @@ $sql.= " u.ldap_sid, u.statut, u.entity,"; $sql.= " s.nom, s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_societe = s.rowid"; -if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) +if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) { $sql.= " WHERE u.entity IS NOT NULL"; }
'.$langs->trans("Groups").''.$langs->trans("Entity").'
'.$langs->trans("Entity").'
'.$langs->trans("Entity").'
'.$langs->trans("Entity").'
'.$langs->trans("Entity").'