From 38cd5180d9b7c9e1b3237452572cab236a722016 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 20:08:55 +0200 Subject: [PATCH 1/5] FIX for migration from old versions --- htdocs/core/modules/DolibarrModules.class.php | 33 ++++++++++++------- .../modules/modSupplierProposal.class.php | 2 +- htdocs/install/upgrade2.php | 26 +++++++++++++++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 527bf945547..562f9eed374 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1671,11 +1671,12 @@ class DolibarrModules // Can not be abstract, because we need to insta // Search if perm already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE id = ".$r_id." AND entity = ".$entity; + $resqlselect=$this->db->query($sql); if ($resqlselect) { - $obj = $this->db->fetch_object($resqlselect); - if ($obj->nb == 0) + $objcount = $this->db->fetch_object($resqlselect); + if ($objcount && $objcount->nb == 0) { if (dol_strlen($r_perms) ) { @@ -1739,23 +1740,33 @@ class DolibarrModules // Can not be abstract, because we need to insta { $obj2=$this->db->fetch_object($resqlseladmin); dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + $tmpuser=new User($this->db); - $tmpuser->fetch($obj2->rowid); - if (!empty($tmpuser->id)) { + $result = $tmpuser->fetch($obj2->rowid); + if ($result > 0) { $tmpuser->addrights($r_id, '', '', 0, 1); } + else + { + dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR); + } $i++; } - if (! empty($user->admin)) // Reload permission for current user if defined - { - // We reload permissions - $user->clearrights(); - $user->getrights(); - } } - else dol_print_error($this->db); + else + { + dol_print_error($this->db); + } } } + + if ($reinitadminperms && ! empty($user->admin)) // Reload permission for current user if defined + { + // We reload permissions + $user->clearrights(); + $user->getrights(); + } + } $this->db->free($resql); } diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 34584ea3ffa..b1881f11c71 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -246,7 +246,7 @@ class modSupplierProposal extends DolibarrModules public function remove($options = '') { $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" + "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries ); return $this->_remove($sql, $options); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b7d18e8163a..ce55b400593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -192,6 +192,32 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $versiontoarray=explode('.',$versionto); $versionranarray=explode('.',DOL_VERSION); + + // Force to execute this at begin to avoid the new core code into Dolibarr to be broken. + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN langs varchar(24)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fieldcomputed text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN fielddefault varchar(255)'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; + $db->query($sql, 1); + $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; + $db->query($sql, 1); + + $afterversionarray=explode('.','2.0.0'); $beforeversionarray=explode('.','2.7.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) From d4d9a8d75a7488f175bae846252774c45ee30bd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Jul 2018 20:13:30 +0200 Subject: [PATCH 2/5] Fix 8.0 not 9.0 --- htdocs/install/upgrade2.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index ce55b400593..d27fbb8e113 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -198,8 +198,6 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $db->query($sql, 1); $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemployment date'; $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN dateemploymentend date'; - $db->query($sql, 1); $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_range integer'; $db->query($sql, 1); $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN default_c_exp_tax_cat integer'; @@ -212,8 +210,6 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $db->query($sql, 1); $sql = 'ALTER TABLE '.MAIN_DB_PREFIX."extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'"; $db->query($sql, 1); - $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'extrafields ADD COLUMN help text'; - $db->query($sql, 1); $sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL'; $db->query($sql, 1); From 64e778a78f4563475a421357c97870c9e8e767d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jul 2018 10:21:42 +0200 Subject: [PATCH 3/5] Fix pgsql migration --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 6bc8594a826..fb890d14375 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -467,10 +467,13 @@ ALTER TABLE llx_extrafields ADD COLUMN enabled varchar(255) DEFAULT '1'; ALTER TABLE llx_extrafields ADD COLUMN tms timestamp; -- We fix value of 'list' from 0 to 1 for all extrafields created before this migration -UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; -UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list != 3; +--VMYSQL4.1 UPDATE llx_extrafields SET list = 1 WHERE list = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; +--VMYSQL4.1 UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list <> 3; +--VPGSQL8.2 UPDATE llx_extrafields SET list = 1 WHERE list::integer = 0 AND fk_user_author IS NULL and fk_user_modif IS NULL and datec IS NULL; +--VPGSQL8.2 UPDATE llx_extrafields SET list = 3 WHERE type = 'separate' AND list::integer <> 3; -ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; +--VMYSQL4.1 ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1; +--VPGSQL8.2 ALTER TABLE llx_extrafields MODIFY COLUMN list integer DEFAULT 1 USING list::integer; --VPGSQL8.2 ALTER TABLE llx_extrafields ALTER COLUMN list SET DEFAULT 1; ALTER TABLE llx_extrafields MODIFY COLUMN langs varchar(64); From 9842978b8560d52ed087cb0cb95da8223c9056d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Jul 2018 11:16:45 +0200 Subject: [PATCH 4/5] Fix trim config values --- htdocs/install/step1.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index bae967fec77..6f1143d6f10 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -893,45 +893,45 @@ function write_conf_file($conffile) fputs($fp,'// and explanations for all possibles parameters.'."\n"); fputs($fp,'//'."\n"); - fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",($main_url)).'\';'); + fputs($fp, '$dolibarr_main_url_root=\''.str_replace("'","\'",trim($main_url)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",($main_dir)).'\';'); + fputs($fp, '$dolibarr_main_document_root=\''.str_replace("'","\'",trim($main_dir)).'\';'); fputs($fp,"\n"); - fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",("/".$main_alt_dir_name)).'\';'); + fputs($fp, $main_use_alt_dir.'$dolibarr_main_url_root_alt=\''.str_replace("'","\'",trim("/".$main_alt_dir_name)).'\';'); fputs($fp,"\n"); - fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",($main_dir."/".$main_alt_dir_name)).'\';'); + fputs($fp, $main_use_alt_dir.'$dolibarr_main_document_root_alt=\''.str_replace("'","\'",trim($main_dir."/".$main_alt_dir_name)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'","\'",($main_data_dir)).'\';'); + fputs($fp, '$dolibarr_main_data_root=\''.str_replace("'","\'",trim($main_data_dir)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'","\'",($db_host)).'\';'); + fputs($fp, '$dolibarr_main_db_host=\''.str_replace("'","\'",trim($db_host)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'","\'",($db_port)).'\';'); + fputs($fp, '$dolibarr_main_db_port=\''.str_replace("'","\'",trim($db_port)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'","\'",($db_name)).'\';'); + fputs($fp, '$dolibarr_main_db_name=\''.str_replace("'","\'",trim($db_name)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'","\'",($main_db_prefix)).'\';'); + fputs($fp, '$dolibarr_main_db_prefix=\''.str_replace("'","\'",trim($main_db_prefix)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'","\'",($db_user)).'\';'); + fputs($fp, '$dolibarr_main_db_user=\''.str_replace("'","\'",trim($db_user)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'","\'",($db_pass)).'\';'); + fputs($fp, '$dolibarr_main_db_pass=\''.str_replace("'","\'",trim($db_pass)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'","\'",($db_type)).'\';'); + fputs($fp, '$dolibarr_main_db_type=\''.str_replace("'","\'",trim($db_type)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'","\'",($db_character_set)).'\';'); + fputs($fp, '$dolibarr_main_db_character_set=\''.str_replace("'","\'",trim($db_character_set)).'\';'); fputs($fp,"\n"); - fputs($fp, '$dolibarr_main_db_collation=\''.str_replace("'","\'",($db_collation)).'\';'); + fputs($fp, '$dolibarr_main_db_collation=\''.str_replace("'","\'",trim($db_collation)).'\';'); fputs($fp,"\n"); /* Authentication */ From 5883899bc73a0c2eeadc844398a6f366105fe433 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Jul 2018 02:31:49 +0200 Subject: [PATCH 5/5] Little debug of option WEBSITE_USE_WEBSITE_ACCOUNTS --- htdocs/core/lib/company.lib.php | 4 +-- .../install/mysql/migration/7.0.0-8.0.0.sql | 3 ++ .../mysql/tables/llx_societe_account.sql | 3 +- .../mysql/tables/llx_website_account.key.sql | 29 --------------- .../mysql/tables/llx_website_account.sql | 36 ------------------- htdocs/societe/class/societeaccount.class.php | 2 +- htdocs/societe/website.php | 18 +++++----- htdocs/website/class/website.class.php | 2 +- htdocs/website/lib/websiteaccount.lib.php | 8 ++--- htdocs/website/websiteaccount_card.php | 10 +++--- 10 files changed, 26 insertions(+), 89 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_website_account.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_website_account.sql diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 450c294f19e..2999833e81e 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -234,8 +234,8 @@ function societe_prepare_head(Societe $object) $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."website_account as n"; - $sql.= " WHERE fk_soc = ".$object->id; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_account as n"; + $sql.= " WHERE fk_soc = ".$object->id.' AND fk_website > 0'; $resql=$db->query($sql); if ($resql) { diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 7ca1d16d67e..21feb62b978 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -84,6 +84,9 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE -- For 8.0 +DROP TABLE llx_website_account; +DROP TABLE llx_website_account_extrafields; + ALTER TABLE llx_paiementfourn ADD COLUMN fk_user_modif integer AFTER fk_user_author; -- delete old permission no more used diff --git a/htdocs/install/mysql/tables/llx_societe_account.sql b/htdocs/install/mysql/tables/llx_societe_account.sql index 7a0f87cbe5d..4123a3b05e2 100644 --- a/htdocs/install/mysql/tables/llx_societe_account.sql +++ b/htdocs/install/mysql/tables/llx_societe_account.sql @@ -13,7 +13,8 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see http://www.gnu.org/licenses/. -- --- Table to store accounts of thirdparties on websites +-- Table to store accounts of thirdparties on external websites (like on stripe field site = 'stripe') +-- or on local website (fk_website). CREATE TABLE llx_societe_account( -- BEGIN MODULEBUILDER FIELDS diff --git a/htdocs/install/mysql/tables/llx_website_account.key.sql b/htdocs/install/mysql/tables/llx_website_account.key.sql deleted file mode 100644 index 2114d3c0f85..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account.key.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright (C) 2016 Laurent Destailleur --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see http://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_website_account ADD INDEX idx_website_account_rowid (rowid); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_login (login); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_import_key (import_key); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_status (status); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_soc (fk_soc); -ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_website (fk_website); --- END MODULEBUILDER INDEXES - -ALTER TABLE llx_website_account ADD UNIQUE INDEX uk_website_account_login_website_soc(login, fk_website, fk_soc); - -ALTER TABLE llx_website_account ADD CONSTRAINT llx_website_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); - diff --git a/htdocs/install/mysql/tables/llx_website_account.sql b/htdocs/install/mysql/tables/llx_website_account.sql deleted file mode 100644 index 373ba53f484..00000000000 --- a/htdocs/install/mysql/tables/llx_website_account.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Copyright (C) 2016 Laurent Destailleur --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see http://www.gnu.org/licenses/. - - -CREATE TABLE llx_website_account( - -- BEGIN MODULEBUILDER FIELDS - rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, - login varchar(64) NOT NULL, - pass_encoding varchar(24) NOT NULL, - pass_crypted varchar(128), - pass_temp varchar(128), -- temporary password when asked for forget password - fk_soc integer, - fk_website integer NOT NULL, - note_private text, - date_last_login datetime, - date_previous_login datetime, - date_creation datetime NOT NULL, - tms timestamp NOT NULL, - fk_user_creat integer NOT NULL, - fk_user_modif integer, - import_key varchar(14), - status integer - -- END MODULEBUILDER FIELDS -) ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 6b2199925be..7340a319534 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -334,7 +334,7 @@ class SocieteAccount extends CommonObject $label.= '' . $langs->trans('Login') . ': ' . $this->ref; //$label.= '' . $langs->trans('WebSite') . ': ' . $this->ref; - $url = dol_buildpath('/societe/societeaccount_card.php',1).'?id='.$this->id; + $url = dol_buildpath('/website/websiteaccount_card.php',1).'?id='.$this->id; if ($option != 'nolink') { diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 3ce1477a9c3..3563283ba05 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -31,7 +31,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -57,12 +57,12 @@ if (! $sortorder) $sortorder='ASC'; // Initialize technical objects $object=new Societe($db); -$objectwebsiteaccount=new WebsiteAccount($db); +$objectwebsiteaccount=new SocieteAccount($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('websitethirdpartylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); +$extralabels = $extrafields->fetch_name_optionals_label('thirdpartyaccount'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); unset($objectwebsiteaccount->fields['fk_soc']); // Remove this field, we are already on the thirdparty @@ -252,9 +252,9 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $objectwebsiteaccount); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."website_account as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."websiteaccount_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('websiteaccount').")"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe_account as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_account_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($objectwebsiteaccount->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('societeaccount').")"; else $sql.=" WHERE 1 = 1"; $sql.=" AND fk_soc = ".$object->id; foreach($search as $key => $val) @@ -335,9 +335,9 @@ print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit); $topicmail="Information"; -$modelmail="websiteaccount"; -$objecttmp=new WebsiteAccount($db); -$trackid='websiteaccount'.$object->id; +$modelmail="societeaccount"; +$objecttmp=new SocieteAccount($db); +$trackid='thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 5a46425cb66..c3d18b889e7 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -44,7 +44,7 @@ class Website extends CommonObject */ public $table_element = 'website'; /** - * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var array Does website support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 1; /** diff --git a/htdocs/website/lib/websiteaccount.lib.php b/htdocs/website/lib/websiteaccount.lib.php index 95ae071d971..0b63be45188 100644 --- a/htdocs/website/lib/websiteaccount.lib.php +++ b/htdocs/website/lib/websiteaccount.lib.php @@ -22,17 +22,15 @@ */ /** - * Prepare array of tabs for WebsiteAccount + * Prepare array of tabs for SocieteAccount * - * @param WebsiteAccount $object WebsiteAccount - * @return array Array of tabs + * @param SocieteAccount $object SocieteAccount + * @return array Array of tabs */ function websiteaccountPrepareHead($object) { global $db, $langs, $conf; - $langs->load("monmodule@monmodule"); - $h = 0; $head = array(); diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 850888320dd..9a1ad910672 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -16,9 +16,9 @@ */ /** - * \file htdocs/Website/websiteaccount_card.php + * \file htdocs/website/websiteaccount_card.php * \ingroup website - * \brief Page to create/edit/view websiteaccount + * \brief Page to create/edit/view thirdparty website account */ // Load Dolibarr environment @@ -38,7 +38,7 @@ if (! $res) die("Include of main fails"); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); -include_once(DOL_DOCUMENT_ROOT.'/website/class/websiteaccount.class.php'); +include_once(DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'); include_once(DOL_DOCUMENT_ROOT.'/website/lib/websiteaccount.lib.php'); // Load translation files required by the page @@ -53,12 +53,12 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new WebsiteAccount($db); +$object=new SocieteAccount($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->website->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('websiteaccountcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('websiteaccount'); +$extralabels = $extrafields->fetch_name_optionals_label('societeaccount'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Initialize array of search criterias