From 5f5c7a91260328daccb010d3d32716178594bb90 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 11:42:24 +0100 Subject: [PATCH 01/14] NEW Show user id of web process in system info - web server --- htdocs/admin/system/web.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/web.php b/htdocs/admin/system/web.php index 7a5816ad3e8..ca911af97b8 100644 --- a/htdocs/admin/system/web.php +++ b/htdocs/admin/system/web.php @@ -53,11 +53,19 @@ print ''.$langs->trans("IP")."".$_SERVER["SERVE print ''.$langs->trans("Port")."" . $_SERVER["SERVER_PORT"] . "\n"; print ''.$langs->trans("DocumentRootServer")."".$_SERVER["DOCUMENT_ROOT"]."\n"; print ''.$langs->trans("DataRootServer")."" . DOL_DATA_ROOT . "\n"; +// Web user group by default $labeluser=dol_getwebuser('user'); $labelgroup=dol_getwebuser('group'); if ($labeluser && $labelgroup) { - print ''.$langs->trans("WebUserGroup")."".$labeluser.'/'.$labelgroup."\n"; + print ''.$langs->trans("WebUserGroup")." (env vars)".$labeluser.'/'.$labelgroup."\n"; +} +// Web user group real (detected by 'id' external command) +$arrayout=array(); $varout=0; +exec('id', $arrayout, $varout); +if (empty($varout)) // Test command is ok. Work only on Linux OS. +{ + print ''.$langs->trans("WebUserGroup")." (real, 'id' command)".join(',', $arrayout)."\n"; } print ''; print ''; From 4381c35835384e25150aab186625fbb5de2e2af9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 11:42:40 +0100 Subject: [PATCH 02/14] Standardize code --- htdocs/societe/class/societe.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 305b6677482..042e748ad36 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -428,7 +428,7 @@ class Societe extends CommonObject * @param User $user Object of user that ask creation * @return int >= 0 if OK, < 0 if KO */ - function create($user) + function create(User $user) { global $langs,$conf,$mysoc; @@ -725,7 +725,7 @@ class Societe extends CommonObject /** * Update parameters of third party * - * @param int $id id societe + * @param int $id Id of company (deprecated, use 0 here and call update on an object loaded by a fetch) * @param User $user Utilisateur qui demande la mise a jour * @param int $call_trigger 0=non, 1=oui * @param int $allowmodcodeclient Inclut modif code client et code compta @@ -739,6 +739,8 @@ class Societe extends CommonObject global $langs,$conf,$hookmanager; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (empty($id)) $id = $this->id; + $error=0; dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); @@ -766,7 +768,7 @@ class Societe extends CommonObject $this->skype = trim($this->skype); $this->url = $this->url?clean_url($this->url,0):''; $this->note_private = trim($this->note_private); - $this->note_public = trim($this->note_public); + $this->note_public = trim($this->note_public); $this->idprof1 = trim($this->idprof1); $this->idprof2 = trim($this->idprof2); $this->idprof3 = trim($this->idprof3); @@ -882,7 +884,7 @@ class Societe extends CommonObject $sql .= ",url = ".(! empty($this->url)?"'".$this->db->escape($this->url)."'":"null"); $sql .= ",note_private = ".(! empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); + $sql .= ",note_public = ".(! empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql .= ",siren = '". $this->db->escape($this->idprof1) ."'"; $sql .= ",siret = '". $this->db->escape($this->idprof2) ."'"; From ce3e586bd0aeb3a4edd3c10871fd41a596d02ca1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 11:44:31 +0100 Subject: [PATCH 03/14] Fix doxygen --- htdocs/core/lib/pdf.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 2f5a8961cd2..73df708ca27 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -595,12 +595,12 @@ function pdf_pagehead(&$pdf,$outputlangs,$page_height) * @param Translate $outputlangs Output language * @param array $exclude Array of family keys we want to exclude. For example array('mycompany', 'object', 'date', 'user', ...) * @param Object $object Object - * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are truncated and html sanitized (to use for help tooltip) + * @param int $onlykey 1=Do not calculate some heavy values of keys (performance enhancement when we need only the keys), 2=Values are truncated and html sanitized (to use for help tooltip) * @return array Array of substitutions */ -function pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykeys=0) +function pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0) { - $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykeys, $exclude, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, $onlykey, $exclude, $object); $substitutionarray['__FROM_NAME__']='__FROM_NAME__'; $substitutionarray['__FROM_EMAIL__']='__FROM_EMAIL__'; return $substitutionarray; From fa1fbe7db7c96f3baaea47efa74bf47e75c5e561 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 13:25:49 +0100 Subject: [PATCH 04/14] Work on websiteaccounts --- dev/setup/apache/virtualhost | 62 +++++++++++++++++++ htdocs/core/lib/company.lib.php | 4 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 19 +++--- htdocs/install/mysql/tables/llx_user.sql | 1 + .../mysql/tables/llx_websiteaccount.key.sql | 2 +- .../mysql/tables/llx_websiteaccount.sql | 6 +- htdocs/website/class/websiteaccount.class.php | 3 +- 7 files changed, 84 insertions(+), 13 deletions(-) create mode 100644 dev/setup/apache/virtualhost diff --git a/dev/setup/apache/virtualhost b/dev/setup/apache/virtualhost new file mode 100644 index 00000000000..c3a2dff3e43 --- /dev/null +++ b/dev/setup/apache/virtualhost @@ -0,0 +1,62 @@ + +#php_admin_value sendmail_path "/usr/sbin/sendmail -t -i" +#php_admin_value mail.force_extra_parameters "-f postmaster@mydomain.com" +php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f postmaster@mydomain.com" +php_admin_value open_basedir /tmp/:/home/../htdocs + +ServerName myvirtualalias +ServerAlias myvirtualalias + +UseCanonicalName On + +AddDefaultCharset UTF-8 + +DocumentRoot "/home/.../htdocs" + + + AllowOverride None + Options -Indexes -MultiViews +FollowSymLinks -ExecCGI + Require all granted + + + + Deny from all + RemoveHandler .phtml .php .php3 .php4 .php5 .php6 .phps .cgi .exe .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .htm .html .wml + AddType application/x-httpd-php-source .phtml .php .php3 .php4 .php5 .php6 .phps .cgi .exe .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .htm .html .wml + + + +ErrorLog /var/log/apache2/myvirtualalias_error_log +TransferLog /var/log/apache2/myvirtualalias_access_log + +# Compress returned resources of type php pages, text file export, css and javascript +AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript + +AddType text/javascript .jgz +AddEncoding gzip .jgz +ExpiresActive On +ExpiresByType image/x-icon A2592000 +ExpiresByType image/gif A2592000 +ExpiresByType image/png A2592000 +ExpiresByType image/jpeg A2592000 +ExpiresByType text/css A2592000 +ExpiresByType text/javascript A2592000 +ExpiresByType application/x-javascript A2592000 +ExpiresByType application/javascript A2592000 + +SSLEngine On + +# A self-signed (snakeoil) certificate can be created by installing +# the ssl-cert package. See +# /usr/share/doc/apache2.2-common/README.Debian.gz for more info. +# If both key and certificate are stored in the same file, only the +# SSLCertificateFile directive is needed. +SSLCertificateFile /etc/letsencrypt/live/www.mydomain.com/cert.pem +SSLCertificateKeyFile /etc/letsencrypt/live/www.mydomain.com/privkey.pem +SSLCertificateChainFile /etc/letsencrypt/live/www.mydomain.com/chain.pem + +#RewriteEngine on +#RewriteCond %{SERVER_PORT} ^80$ +#RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [L,R] + + diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 216c321499b..e2106051ce9 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -389,7 +389,7 @@ function societe_admin_prepare_head() * Return country label, code or id from an id, code or label * * @param int $searchkey Id or code of country to search - * @param int $withcode '0'=Return label, + * @param string $withcode '0'=Return label, * '1'=Return code + label, * '2'=Return code from id, * '3'=Return id from code, @@ -400,7 +400,7 @@ function societe_admin_prepare_head() * @param int $searchlabel Label of country to search (warning: searching on label is not reliable) * @return mixed String with country code or translated country name or Array('id','code','label') */ -function getCountry($searchkey,$withcode='',$dbtouse=0,$outputlangs='',$entconv=1,$searchlabel='') +function getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='') { global $db,$langs; 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 c3899e7c142..75edcab3c9b 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 @@ -176,17 +176,18 @@ ALTER TABLE llx_menu MODIFY fk_leftmenu varchar(100); CREATE TABLE llx_websiteaccount( 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, + fk_website integer NOT NULL, 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), + 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 ) ENGINE=innodb; @@ -197,6 +198,10 @@ ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_k ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_status (status); ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc); +ALTER TABLE llx_websiteaccount ADD UNIQUE INDEX uk_websiteaccount_login_website_soc(login, fk_website, fk_soc); + +ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); + create table llx_websiteaccount_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -206,7 +211,7 @@ create table llx_websiteaccount_extrafields ) ENGINE=innodb; - +alter table llx_user add column pass_encoding varchar(24) NULL; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 71ea5a559f5..27732169bd1 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -34,6 +34,7 @@ create table llx_user fk_user_creat integer, fk_user_modif integer, login varchar(50) NOT NULL, + pass_encoding varchar(24); pass varchar(128), pass_crypted varchar(128), pass_temp varchar(128), -- temporary password when asked for forget password diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.key.sql b/htdocs/install/mysql/tables/llx_websiteaccount.key.sql index 463218b04cd..7b455be2df4 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount.key.sql +++ b/htdocs/install/mysql/tables/llx_websiteaccount.key.sql @@ -24,5 +24,5 @@ ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc); ALTER TABLE llx_websiteaccount ADD UNIQUE INDEX uk_websiteaccount_login_website_soc(login, fk_website, fk_soc); ---ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_field_id FOREIGN KEY (fk_field) REFERENCES llx_myotherobject(rowid); +ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.sql b/htdocs/install/mysql/tables/llx_websiteaccount.sql index 838fc170595..f48d3f31845 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount.sql +++ b/htdocs/install/mysql/tables/llx_websiteaccount.sql @@ -18,11 +18,13 @@ CREATE TABLE llx_websiteaccount( -- 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, - date_last_login datetime, + 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, diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index f420c8abcf8..5e3a80fff81 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -84,7 +84,7 @@ class WebsiteAccount extends CommonObject 'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,), 'date_previous_login' => array('type'=>'datetime', 'label'=>'PreviousConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>51, 'notnull'=>0,), //'note_public' => array('type'=>'text', 'label'=>'NotePublic', 'visible'=>-1, 'enabled'=>1, 'position'=>45, 'notnull'=>-1,), - //'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,), + 'note_private' => array('type'=>'text', 'label'=>'NotePrivate', 'visible'=>-1, 'enabled'=>1, 'position'=>46, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), @@ -97,6 +97,7 @@ class WebsiteAccount extends CommonObject public $pass_crypted; public $date_last_login; public $date_previous_login; + public $note_private; public $date_creation; public $tms; public $fk_user_creat; From 55386a3ae22dcd279d27df58e19c38987e141948 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 13:52:03 +0100 Subject: [PATCH 05/14] Work on website module --- ..._modBlockedlog_ActionsBlockedLog.class.php | 4 +-- .../install/mysql/migration/6.0.0-7.0.0.sql | 35 ++++++++++++++----- ...nt.key.sql => llx_website_account.key.sql} | 14 ++++---- ...iteaccount.sql => llx_website_account.sql} | 2 +- .../llx_website_account_extrafields.key.sql | 20 +++++++++++ .../llx_website_account_extrafields.sql | 23 ++++++++++++ .../tables/llx_website_extrafields.key.sql | 20 +++++++++++ ...fields.sql => llx_website_extrafields.sql} | 4 +-- htdocs/website/class/websiteaccount.class.php | 8 +++-- 9 files changed, 105 insertions(+), 25 deletions(-) rename htdocs/install/mysql/tables/{llx_websiteaccount.key.sql => llx_website_account.key.sql} (54%) rename htdocs/install/mysql/tables/{llx_websiteaccount.sql => llx_website_account.sql} (97%) create mode 100644 htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_website_account_extrafields.sql create mode 100644 htdocs/install/mysql/tables/llx_website_extrafields.key.sql rename htdocs/install/mysql/tables/{llx_websiteaccount_extrafields.sql => llx_website_extrafields.sql} (89%) diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 520e02f1810..348aeb4dcc8 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -48,13 +48,11 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers { if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - - // Test if event/record is qualified $listofqualifiedelement = array('payment', 'facture'); if (! in_array($object->element, $listofqualifiedelement)) return 1; + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // Event/record is qualified if ($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' 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 75edcab3c9b..84c248c3642 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 @@ -173,7 +173,18 @@ ALTER TABLE llx_menu MODIFY fk_mainmenu varchar(100); ALTER TABLE llx_menu MODIFY fk_leftmenu varchar(100); -CREATE TABLE llx_websiteaccount( +CREATE TABLE llx_website_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_website_extrafields ADD INDEX idx_website_extrafields (fk_object); + + +CREATE TABLE llx_website_account( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, login varchar(64) NOT NULL, pass_encoding varchar(24) NOT NULL, @@ -181,6 +192,7 @@ CREATE TABLE llx_websiteaccount( 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, @@ -192,17 +204,17 @@ CREATE TABLE llx_websiteaccount( ) ENGINE=innodb; -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_import_key (import_key); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_status (status); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc); +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_websiteaccount ADD UNIQUE INDEX uk_websiteaccount_login_website_soc(login, fk_website, fk_soc); +ALTER TABLE llx_website_account ADD UNIQUE INDEX uk_website_account_login_website_soc(login, fk_website, fk_soc); -ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +ALTER TABLE llx_website_account ADD CONSTRAINT llx_website_account_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); -create table llx_websiteaccount_extrafields +CREATE TABLE llx_website_account_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, @@ -210,6 +222,11 @@ create table llx_websiteaccount_extrafields import_key varchar(14) -- import key ) ENGINE=innodb; +ALTER TABLE llx_website_account_extrafields ADD INDEX idx_website_account_extrafields (fk_object); + + + + alter table llx_user add column pass_encoding varchar(24) NULL; diff --git a/htdocs/install/mysql/tables/llx_websiteaccount.key.sql b/htdocs/install/mysql/tables/llx_website_account.key.sql similarity index 54% rename from htdocs/install/mysql/tables/llx_websiteaccount.key.sql rename to htdocs/install/mysql/tables/llx_website_account.key.sql index 7b455be2df4..1302ec50d2c 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount.key.sql +++ b/htdocs/install/mysql/tables/llx_website_account.key.sql @@ -15,14 +15,14 @@ -- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_rowid (rowid); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_login (login); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_status (status); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_website (fk_website); -ALTER TABLE llx_websiteaccount ADD INDEX idx_websiteaccount_fk_soc (fk_soc); +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_status (status); +ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_website (fk_website); +ALTER TABLE llx_website_account ADD INDEX idx_website_account_fk_soc (fk_soc); -- END MODULEBUILDER INDEXES -ALTER TABLE llx_websiteaccount ADD UNIQUE INDEX uk_websiteaccount_login_website_soc(login, fk_website, fk_soc); +ALTER TABLE llx_website_account ADD UNIQUE INDEX uk_website_account_login_website_soc(login, fk_website, fk_soc); -ALTER TABLE llx_websiteaccount ADD CONSTRAINT llx_websiteaccount_fk_website FOREIGN KEY (fk_website) REFERENCES llx_website(rowid); +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_websiteaccount.sql b/htdocs/install/mysql/tables/llx_website_account.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_websiteaccount.sql rename to htdocs/install/mysql/tables/llx_website_account.sql index f48d3f31845..373ba53f484 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount.sql +++ b/htdocs/install/mysql/tables/llx_website_account.sql @@ -14,7 +14,7 @@ -- along with this program. If not, see http://www.gnu.org/licenses/. -CREATE TABLE llx_websiteaccount( +CREATE TABLE llx_website_account( -- BEGIN MODULEBUILDER FIELDS rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, login varchar(64) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql b/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql new file mode 100644 index 00000000000..9970f8bc680 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_website_account_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2017 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_website_account_extrafields ADD INDEX idx_website_account_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_website_account_extrafields.sql b/htdocs/install/mysql/tables/llx_website_account_extrafields.sql new file mode 100644 index 00000000000..7bec7e958d9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_website_account_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) 2017 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_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/install/mysql/tables/llx_website_extrafields.key.sql b/htdocs/install/mysql/tables/llx_website_extrafields.key.sql new file mode 100644 index 00000000000..1963744b701 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_website_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2017 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_website_extrafields ADD INDEX idx_website_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql b/htdocs/install/mysql/tables/llx_website_extrafields.sql similarity index 89% rename from htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql rename to htdocs/install/mysql/tables/llx_website_extrafields.sql index fd4d4e3653f..7ca3b94c713 100644 --- a/htdocs/install/mysql/tables/llx_websiteaccount_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_website_extrafields.sql @@ -1,4 +1,4 @@ --- Copyright (C) 2016 Laurent Destailleur +-- Copyright (C) 2017 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 @@ -13,7 +13,7 @@ -- 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_websiteaccount_extrafields +CREATE TABLE llx_website_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index 5e3a80fff81..c5cd4ffe788 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -42,7 +42,7 @@ class WebsiteAccount extends CommonObject /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'websiteaccount'; + public $table_element = 'website_account'; /** * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ @@ -77,8 +77,9 @@ class WebsiteAccount extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), - 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), - 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>30, 'notnull'=>-1,), + 'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>-1, 'enabled'=>1, 'position'=>30), + 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1), + 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1), 'fk_website' => array('type'=>'integer:Website:website/class/website.class.php', 'label'=>'WebSite', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>1, 'index'=>1), 'date_last_login' => array('type'=>'datetime', 'label'=>'LastConnexion', 'visible'=>2, 'enabled'=>1, 'position'=>50, 'notnull'=>0,), @@ -94,6 +95,7 @@ class WebsiteAccount extends CommonObject ); public $rowid; public $login; + public $pass_encoding; public $pass_crypted; public $date_last_login; public $date_previous_login; From 458be3c814120ef60106f77391d8db83bb0f70ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 14:38:00 +0100 Subject: [PATCH 06/14] Clean translation files --- htdocs/collab/index.php | 2 +- htdocs/langs/en_US/main.lang | 3 +-- htdocs/langs/en_US/other.lang | 2 ++ htdocs/website/index.php | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php index c356db8625b..2c056cd0e07 100644 --- a/htdocs/collab/index.php +++ b/htdocs/collab/index.php @@ -177,7 +177,7 @@ if (count($object->records) > 0) // ***** Part for web sites print '
'; - print $langs->trans("Website").': '; + print $langs->trans("WebSite").': '; print '
'; // List of websites diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 979a601fa91..67705d2686d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -813,7 +813,7 @@ ModuleBuilder=Module Builder SetMultiCurrencyCode=Set currency BulkActions=Bulk actions ClickToShowHelp=Click to show tooltip help -Website=Web site +WebSite=Web site WebSites=Web sites ExpenseReport=Expense report ExpenseReports=Expense reports @@ -823,7 +823,6 @@ AutomaticallyCalculated=Automatically calculated TitleSetToDraft=Go back to draft ConfirmSetToDraft=Are you sure you want to go back to Draft status ? ImportId=Import id -Websites=Web sites Events=Events EMailTemplates=Emails templates FileNotShared=File not shared to exernal public diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index e8ef03d86fb..0d9d1cfbd85 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -214,6 +214,7 @@ StartUpload=Start upload CancelUpload=Cancel upload FileIsTooBig=Files is too big PleaseBePatient=Please be patient... +ResetPassword=Reset password RequestToResetPasswordReceived=A request to change your Dolibarr password has been received NewKeyIs=This is your new keys to login NewKeyWillBe=Your new key to login to software will be @@ -223,6 +224,7 @@ ForgetIfNothing=If you didn't request this change, just forget this email. Your IfAmountHigherThan=If amount higher than %s SourcesRepository=Repository for sources Chart=Chart +PassEncoding=Password encoding ##### Export ##### ExportsArea=Exports area diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2ecd13dbb71..1065a811047 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1152,7 +1152,7 @@ if (count($object->records) > 0) print ''; print '
'; - print $langs->trans("Website").': '; + print $langs->trans("WebSite").': '; print '
'; // List of website @@ -1306,10 +1306,10 @@ if (count($object->records) > 0) if ($action == 'createfromclone') { // Create an array for form $formquestion = array( - array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("Website") ,'value'=> 'copy_of_'.$object->ref), + array('type' => 'text', 'name' => 'siteref', 'label'=> $langs->trans("WebSite") ,'value'=> 'copy_of_'.$object->ref), //array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("SiteIsANewTranslation"), 'value' => 0), //array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, '', 0, 0, 'minwidth200')), - //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("Website"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) + //array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)) ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id='.$object->id, $langs->trans('CloneSite'), '', 'confirm_createfromclone', $formquestion, 0, 1, 200); @@ -1326,7 +1326,7 @@ if (count($object->records) > 0) array('type' => 'text', 'name' => 'pageurl', 'label'=> $langs->trans("WEBSITE_PAGENAME") ,'value'=> 'copy_of_'.$objectpage->pageurl), array('type' => 'checkbox', 'name' => 'is_a_translation', 'label' => $langs->trans("PageIsANewTranslation"), 'value' => 0), array('type' => 'other','name' => 'newlang','label' => $langs->trans("Language"), 'value' => $formadmin->select_language(GETPOST('newlang', 'az09')?GETPOST('newlang', 'az09'):$langs->defaultlang, 'newlang', 0, null, 1, 0, 0, 'minwidth200')), - array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("Website"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), + array('type' => 'other','name' => 'newwebsite','label' => $langs->trans("WebSite"), 'value' => $formwebsite->selectWebsite($object->id, 'newwebsite', 0)), ); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?website='.$object->ref.'&pageid=' . $pageid, $langs->trans('ClonePage'), '', 'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550); From a346a1a5e949dde46efa03536e32efc665473f28 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 15:56:16 +0100 Subject: [PATCH 07/14] Work on website module --- htdocs/core/class/commonobject.class.php | 42 ++++++++++++------- htdocs/core/class/extrafields.class.php | 4 +- htdocs/core/lib/company.lib.php | 4 +- htdocs/core/tpl/commonfields_view.tpl.php | 6 ++- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 4 ++ htdocs/install/mysql/tables/llx_website.sql | 2 +- htdocs/langs/en_US/main.lang | 1 + .../modulebuilder/template/myobject_list.php | 14 +++---- htdocs/societe/website.php | 17 ++++---- htdocs/website/class/website.class.php | 6 ++- htdocs/website/class/websiteaccount.class.php | 19 ++++----- htdocs/website/class/websitepage.class.php | 2 +- htdocs/website/lib/websiteaccount.lib.php | 4 +- 14 files changed, 72 insertions(+), 55 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d52a2edf73c..fcf6c913e27 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5263,7 +5263,7 @@ abstract class CommonObject * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields * - * @param array $val Array of properties for field to show + * @param array $val Array of properties of field to show * @param string $key Key of attribute * @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value) * @param string $moreparam To add more parametes on html input tag @@ -5283,7 +5283,6 @@ abstract class CommonObject } $objectid = $this->id; - $label=$val['label']; $type =$val['type']; $size =$val['css']; @@ -5307,8 +5306,8 @@ abstract class CommonObject } $langfile=$val['langfile']; $list=$val['list']; - $hidden=(abs($val['visible'])!=1 ? 1 : 0); $help=$val['help']; + $hidden=(($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) if ($hidden) return ''; @@ -5320,21 +5319,37 @@ abstract class CommonObject $value = dol_eval($computed, 1, 0); } - $showsize=0; - if ($type == 'date') + if (empty($showsize)) + { + if ($type == 'date') + { + $showsize=10; + } + elseif ($type == 'datetime') + { + $showsize=19; + } + elseif ($type == 'int' || $type == 'integer') + { + $showsize=10; + } + else + { + $showsize=round($size); + if ($showsize > 48) $showsize=48; + } + } + + if ($key == 'ref') $value=$this->getNomUrl(1, '', 0, '', 1); + elseif ($key == 'status') $value=$this->getLibStatut(3); + elseif ($type == 'date') { - $showsize=10; $value=dol_print_date($value,'day'); } elseif ($type == 'datetime') { - $showsize=19; $value=dol_print_date($value,'dayhour'); } - elseif ($type == 'int') - { - $showsize=10; - } elseif ($type == 'double') { if (!empty($value)) { @@ -5569,11 +5584,6 @@ abstract class CommonObject { $value=preg_replace('/./i','*',$value); } - else - { - $showsize=round($size); - if ($showsize > 48) $showsize=48; - } //print $type.'-'.$size; $out=$value; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ae1cd2848be..ca7bed7ff4e 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1315,7 +1315,7 @@ class ExtraFields * * @param string $key Key of attribute * @param string $value Value to show - * @param string $moreparam To add more parametes on html input tag (only checkbox use html input for output rendering) + * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) * @return string Formated value */ function showOutputField($key,$value,$moreparam='') @@ -1334,7 +1334,7 @@ class ExtraFields $perms=$this->attribute_perms[$key]; $langfile=$this->attribute_langfile[$key]; $list=$this->attribute_list[$key]; - $hidden=(abs($list)!=1 ? 1 : 0); + $hidden=(($list != 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e2106051ce9..ac98fa599a9 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -209,10 +209,10 @@ function societe_prepare_head(Societe $object) if (! empty($conf->website->enabled) && (!empty($user->rights->societe->lire) )) { $head[$h][0] = DOL_URL_ROOT.'/societe/website.php?id='.$object->id; - $head[$h][1] = $langs->trans("WebSites"); + $head[$h][1] = $langs->trans("WebSiteAccounts"); $nbNote = 0; $sql = "SELECT COUNT(n.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."websiteaccount as n"; + $sql.= " FROM ".MAIN_DB_PREFIX."website_account as n"; $sql.= " WHERE fk_soc = ".$object->id; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/tpl/commonfields_view.tpl.php b/htdocs/core/tpl/commonfields_view.tpl.php index 4c0f23a5af2..ded3247f1dd 100644 --- a/htdocs/core/tpl/commonfields_view.tpl.php +++ b/htdocs/core/tpl/commonfields_view.tpl.php @@ -26,9 +26,11 @@ foreach($object->fields as $key => $val) { - if (abs($val['visible']) != 1) continue; // Discard such field from form + // Discard if extrafield is a hidden field on form + if (abs($val['visible']) != 1) continue; + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field - if ($key == 'status') continue; // Status is alreadt in dol_banner + if ($key == 'status') continue; // Status is already in dol_banner $value=$object->$key; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 15bfd51f83b..b57025e3dd6 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -42,7 +42,7 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { - // Discard if extrafield is a hidden field + // Discard if extrafield is a hidden field on form if (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 1) continue; // Load language if required 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 84c248c3642..385d3830171 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 @@ -63,6 +63,10 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +UPDATE llx_website SET entity = 1 WHERE entity IS NULL; +-- VMYSQL4.3 ALTER TABLE llx_website MODIFY COLUMN entity integer NOT NULL DEFAULT 1; +-- VPGSQL8.2 ALTER TABLE llx_website ALTER COLUMN entity SET NOT NULL; + ALTER TABLE llx_user ADD COLUMN birth date; -- VMYSQL4.1 ALTER TABLE llx_holiday_users DROP PRIMARY KEY; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index 14afe19d0aa..6946b981c86 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -20,7 +20,7 @@ CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, - entity integer DEFAULT 1, + entity integer NOT NULL DEFAULT 1, ref varchar(128) NOT NULL, description varchar(255), status integer DEFAULT 1, diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 67705d2686d..7f89918e90a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -815,6 +815,7 @@ BulkActions=Bulk actions ClickToShowHelp=Click to show tooltip help WebSite=Web site WebSites=Web sites +WebSiteAccounts=Web site accounts ExpenseReport=Expense report ExpenseReports=Expense reports HR=HR diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ab6a36b4d40..5716f88b4b1 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -488,12 +488,10 @@ while ($i < min($num, $limit)) if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); - elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'ref') print $object->getNomUrl(1, '', 0, '', 1); - elseif ($key == 'status') print $object->getLibStatut(3); - else print $obj->$key; + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) @@ -510,12 +508,12 @@ while ($i < min($num, $limit)) { if (! empty($arrayfields["ef.".$key]['checked'])) { - print 'getAlignFlag($key); + print ''; $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print $extrafields->showOutputField($key, $obj->$tmpkey, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 2b6349e36ae..c268f56922c 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -255,7 +255,7 @@ $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."websiteaccount as t"; +$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').")"; else $sql.=" WHERE 1 = 1"; @@ -488,12 +488,11 @@ while ($i < min($num, $limit)) if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if (in_array($val['type'], array('date'))) print dol_print_date($db->jdate($obj->$key), 'day', 'tzuser'); - elseif (in_array($val['type'], array('datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); - elseif ($key == 'ref' || $key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); - elseif ($key == 'status') print $objectwebsiteaccount->getLibStatut(3); - else print $obj->$key; + print ''; + if ($key == 'login') print $objectwebsiteaccount->getNomUrl(1, '', 0, '', 1); + else print $objectwebsiteaccount->showOutputField($val, $key, $obj->$key, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) @@ -510,12 +509,12 @@ while ($i < min($num, $limit)) { if (! empty($arrayfields["ef.".$key]['checked'])) { - print 'getAlignFlag($key); + print ''; $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print $extrafields->showOutputField($key, $obj->$tmpkey, ''); print ''; if (! $i) $totalarray['nbfield']++; if (! empty($val['isameasure'])) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index e99fc3fe31e..c63aee5b9b2 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -44,7 +44,11 @@ class Website extends CommonObject */ public $table_element = 'website'; /** - * @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png + * @var array Does websiteaccount support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 1; + /** + * @var string String with name of icon for website. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'globe'; diff --git a/htdocs/website/class/websiteaccount.class.php b/htdocs/website/class/websiteaccount.class.php index c5cd4ffe788..275b2491e49 100644 --- a/htdocs/website/class/websiteaccount.class.php +++ b/htdocs/website/class/websiteaccount.class.php @@ -77,7 +77,7 @@ class WebsiteAccount extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'login' => array('type'=>'varchar(64)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Login',), - 'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>-1, 'enabled'=>1, 'position'=>30), + 'pass_encoding' => array('type'=>'varchar(24)', 'label'=>'PassEncoding', 'visible'=>-2, 'enabled'=>1, 'position'=>30), 'pass_crypted' => array('type'=>'varchar(128)', 'label'=>'Password', 'visible'=>1, 'enabled'=>1, 'position'=>31, 'notnull'=>1), 'pass_temp' => array('type'=>'varchar(128)', 'label'=>'Temp', 'visible'=>0, 'enabled'=>0, 'position'=>32, 'notnull'=>-1,), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1, 'index'=>1), @@ -117,11 +117,11 @@ class WebsiteAccount extends CommonObject /** * @var int Name of subtable line */ - //public $table_element_line = 'websiteaccountdet'; + //public $table_element_line = 'website_accountdet'; /** * @var int Field with ID of parent key if this field has a parent */ - //public $fk_element = 'fk_websiteaccount'; + //public $fk_element = 'fk_website_account'; /** * @var int Name of subtable class that manage subtable lines */ @@ -129,7 +129,7 @@ class WebsiteAccount extends CommonObject /** * @var array Array of child tables (child tables to delete before deleting a record) */ - //protected $childtables=array('websiteaccountdet'); + //protected $childtables=array('website_accountdet'); /** * @var WebsiteAccountLine[] Array of subtable lines */ @@ -319,12 +319,11 @@ class WebsiteAccount extends CommonObject $linkstart.=$linkclose.'>'; $linkend=''; - if ($withpicto) - { - $result.=($linkstart.img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; - } - $result.= $linkstart . $this->ref . $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + return $result; } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 34a6f047874..15ffc7bed69 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -44,7 +44,7 @@ class WebsitePage extends CommonObject */ public $table_element = 'website_page'; /** - * @var string String with name of icon for websiteaccount. Must be the part after the 'object_' into object_myobject.png + * @var string String with name of icon for websitepage. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'label'; diff --git a/htdocs/website/lib/websiteaccount.lib.php b/htdocs/website/lib/websiteaccount.lib.php index b294b25f3b2..95ae071d971 100644 --- a/htdocs/website/lib/websiteaccount.lib.php +++ b/htdocs/website/lib/websiteaccount.lib.php @@ -41,7 +41,7 @@ function websiteaccountPrepareHead($object) $head[$h][2] = 'card'; $h++; - if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) + /*if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { $nbNote = 0; if(!empty($object->fields['note_private'])) $nbNote++; @@ -51,7 +51,7 @@ function websiteaccountPrepareHead($object) if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; $h++; - } + }*/ /* require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; From c479efa480998b6a53822dabe4ab9801756d1f10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 16:29:23 +0100 Subject: [PATCH 08/14] Fix encoding with select2 --- htdocs/comm/mailing/cibles.php | 2 ++ htdocs/core/tpl/card_presend.tpl.php | 5 +++-- htdocs/societe/class/societe.class.php | 13 +++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 5a5ef5fa90c..cdfd3e526cd 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -224,6 +224,8 @@ if ($object->fetch($id) >= 0) dol_fiche_end(); + print '
'; + $allowaddtarget=($object->statut == 0); diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 01b53487821..c5e8e68901b 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -116,12 +116,13 @@ if ($action == 'presend') } $formmail->withfrom = 1; + // Fill list of recipient with email inside <>. $liste = array(); if ($object->element == 'expensereport') { $fuser = new User($db); $fuser->fetch($object->fk_user_author); - $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; + $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; } elseif ($object->element == 'societe') { @@ -131,7 +132,7 @@ if ($action == 'presend') } elseif ($object->element == 'user' || $object->element == 'member') { - $liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">"; + $liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">"; } else { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 042e748ad36..aa33fcf575b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2087,7 +2087,7 @@ class Societe extends CommonObject if ($this->email && $addthirdparty) { if (empty($this->name)) $this->name=$this->nom; - $contact_emails['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; + $contact_emails['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->email.">"; } //var_dump($contact_emails) return $contact_emails; @@ -2108,7 +2108,7 @@ class Societe extends CommonObject { if (empty($this->name)) $this->name=$this->nom; // TODO: Tester si tel non deja present dans tableau contact - $contact_phone['thirdparty']=$langs->trans("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; + $contact_phone['thirdparty']=$langs->transnoentitiesnoconv("ThirdParty").': '.dol_trunc($this->name,16)." <".$this->phone.">"; } return $contact_phone; } @@ -2118,7 +2118,7 @@ class Societe extends CommonObject * * @param string $mode 'email' or 'mobile' * @param int $hidedisabled 1=Hide contact if disabled - * @return array Array of contacts emails or mobile array(id=>'Name ') + * @return array Array of contacts emails or mobile. Example: array(id=>'Name ') */ function contact_property_array($mode='email', $hidedisabled=0) { @@ -2140,7 +2140,8 @@ class Societe extends CommonObject $sepa="("; $sepb=")"; if ($mode == 'email') { - $sepa="<"; $sepb=">"; + //$sepa="<"; $sepb=">"; + $sepa="<"; $sepb=">"; } $i = 0; while ($i < $nump) @@ -2155,8 +2156,8 @@ class Societe extends CommonObject { if (empty($property)) { - if ($mode == 'email') $property=$langs->trans("NoEMail"); - else if ($mode == 'mobile') $property=$langs->trans("NoMobilePhone"); + if ($mode == 'email') $property=$langs->transnoentitiesnoconv("NoEMail"); + else if ($mode == 'mobile') $property=$langs->transnoentitiesnoconv("NoMobilePhone"); } if (!empty($obj->poste)) From 4ac8cb9168593a52bf2d8183f11aa8df365ae2d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 16:31:33 +0100 Subject: [PATCH 09/14] Fix sql syntax --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 385d3830171..75ae31b9279 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 @@ -521,7 +521,7 @@ ALTER TABLE llx_actioncomm_reminder ADD UNIQUE INDEX uk_actioncomm_reminder_uniq -- May have error due to duplicate keys ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity); --- SPEC : use database type "double" to store monetary values +-- SPEC : use database type 'double' to store monetary values ALTER TABLE llx_blockedlog MODIFY COLUMN amounts double(24,8); ALTER TABLE llx_chargessociales MODIFY COLUMN amount double(24,8); ALTER TABLE llx_commande MODIFY COLUMN amount_ht double(24,8); From cd70e1506b346a7aaace90a9520bad3ed9ce122b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 17:20:08 +0100 Subject: [PATCH 10/14] Work on common core code --- htdocs/core/actions_addupdatedelete.inc.php | 1 + htdocs/core/class/commonobject.class.php | 10 ++++++---- htdocs/core/class/html.form.class.php | 6 +++--- htdocs/core/tpl/commonfields_add.tpl.php | 4 +++- htdocs/core/tpl/commonfields_edit.tpl.php | 4 +++- htdocs/langs/en_US/website.lang | 3 ++- htdocs/website/websiteaccount_card.php | 7 +++++-- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index c7e57641c29..b2ec79af5a7 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -87,6 +87,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) { foreach ($object->fields as $key => $val) { + if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields $value = GETPOST($key,'alpha'); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fcf6c913e27..47b27641436 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1396,7 +1396,7 @@ abstract class CommonObject } /** - * Load properties id_previous and id_next + * Load properties id_previous and id_next by comparing $fieldid with $this->ref * * @param string $filter Optional filter. Example: " AND (t.field1 = 'aa' OR t.field2 = 'bb')" * @param string $fieldid Name of field to use for the select MAX and MIN @@ -1433,7 +1433,7 @@ abstract class CommonObject if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; - //print $filter.' '.$sql."
"; + //print 'filter = '.$filter.' -> '.$sql."
"; $result = $this->db->query($sql); if (! $result) { @@ -6044,7 +6044,7 @@ abstract class CommonObject } /** - * Function to load data into current object this + * Function to load data from a SQL pointer into properties of current object $this * * @param stdClass $obj Contain data of object from database */ @@ -6082,8 +6082,10 @@ abstract class CommonObject { $this->{$field} = $obj->{$field}; } - } + + // If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions. + if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id; } /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 33a591b0fb3..7df1fd1f4a2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6158,13 +6158,13 @@ class Form /** * Return a HTML area with the reference of object and a navigation bar for a business object - * Note: To add a particular filter on select, you can have $object->next_prev_filter set to add SQL criterias. + * Note: To complete search with a particular filter on select, you can set $object->next_prev_filter set to define SQL criterias. * * @param object $object Object to show. * @param string $paramid Name of parameter to use to name the id into the URL next/previous link. * @param string $morehtml More html content to output just before the nav bar. * @param int $shownav Show Condition (navigation is shown if value is 1). - * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field). Use 'none' to disable next/prev. + * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field compared to $object->ref). Use 'none' to disable next/prev. * @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref. * @param string $morehtmlref More html to show after ref. * @param string $moreparam More param to add in nav link url. Must start with '&...'. @@ -6194,7 +6194,7 @@ class Form if ($shownav) { //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; - $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); + $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''), $fieldid, $nodbprefix); $navurl = $_SERVER["PHP_SELF"]; // Special case for project/task page diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php index 203ba67f3db..f6aebd6357c 100644 --- a/htdocs/core/tpl/commonfields_add.tpl.php +++ b/htdocs/core/tpl/commonfields_add.tpl.php @@ -26,7 +26,9 @@ foreach($object->fields as $key => $val) { - if (abs($val['visible']) != 1) continue; // Discard such field from form + // Discard if extrafield is a hidden field on form + if (abs($val['visible']) != 1) continue; + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field print ''; diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index a70b92e6f46..248cd4b4086 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -26,7 +26,9 @@ foreach($object->fields as $key => $val) { - if (abs($val['visible']) != 1) continue; // Discard such field from form + // Discard if extrafield is a hidden field on form + if (abs($val['visible']) != 1) continue; + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field print 'id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + if ($object->fk_soc >0 && empty($socid)) $socid = $object->fk_soc; + $res = $object->fetch_optionals($object->id, $extralabels); $head = websiteaccountPrepareHead($object); @@ -259,7 +261,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ $linkback=''; - if ($socid) $linkback = '' . $langs->trans("BackToList") . ''; + if ($socid) $linkback = '' . $langs->trans("BackToListOfThirdParty") . ''; if ($fk_website) $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; @@ -306,8 +308,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea */ $morehtmlref.='
'; + if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref); print '
'; From 048766bd24a4cedbf4578116b98435ebf6affa40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 17:24:14 +0100 Subject: [PATCH 11/14] Fix sql error --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 8fd8de639c3..a66a4635281 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1541,7 +1541,7 @@ class ActionComm extends CommonObject // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->jdate($now - (3600 * 24 * 32))."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; $this->db->query($sql); return 0; From a72703d3165529bbe232f580b0bdd54fbc3b51c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 17:29:25 +0100 Subject: [PATCH 12/14] Fix deprecated code --- htdocs/categories/class/categorie.class.php | 6 ++---- htdocs/categories/viewcat.php | 4 ++-- htdocs/societe/class/societe.class.php | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 7a7a6f06a1f..2e69626c1aa 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -766,12 +766,10 @@ class Categorie extends CommonObject // For backward compatibility if ($type == 'societe') { $type = 'customer'; - dol_syslog( get_class( $this ) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead", - LOG_WARNING ); + dol_syslog( get_class( $this ) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING); } elseif ($type == 'fournisseur') { $type = 'supplier'; - dol_syslog( get_class( $this ) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", - LOG_WARNING ); + dol_syslog( get_class( $this ) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); } $this->db->begin(); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index a3ca8053281..daa5ade05b5 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -88,13 +88,13 @@ if ($id > 0 && $removeelem > 0) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); - $elementtype = 'fournisseur'; + $elementtype = 'supplier'; } else if ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) { $tmpobject = new Societe($db); $result = $tmpobject->fetch($removeelem); - $elementtype = 'societe'; + $elementtype = 'customer'; } else if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index aa33fcf575b..5b203c71693 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1463,11 +1463,11 @@ class Societe extends CommonObject // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) if ($this->client || $this->prospect) { - $toute_categs['societe'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER); + $toute_categs['customer'] = $static_cat->containing($this->id,Categorie::TYPE_CUSTOMER); } if ($this->fournisseur) { - $toute_categs['fournisseur'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER); + $toute_categs['supplier'] = $static_cat->containing($this->id,Categorie::TYPE_SUPPLIER); } // Remove each "Categorie" From f32f3ff17fa5999d13cd944fe0826aafba06ea8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 17:56:53 +0100 Subject: [PATCH 13/14] Better default function to generate passwords --- htdocs/core/lib/security2.lib.php | 45 +++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 4d79b87122e..c526d57bee0 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -439,7 +439,7 @@ function encodedecode_dbpassconf($level=0) /** * Return a generated password using default module * - * @param boolean $generic true=Create generic password (use md5, sha1 depending on setup), false=Use the configured password generation module + * @param boolean $generic true=Create generic password (32 chars/numbers), false=Use the configured password generation module * @return string New value for password */ function getRandomPassword($generic=false) @@ -447,7 +447,48 @@ function getRandomPassword($generic=false) global $db,$conf,$langs,$user; $generated_password=''; - if ($generic) $generated_password=dol_hash(mt_rand()); + if ($generic) + { + $length = 32; + $lowercase = "qwertyuiopasdfghjklzxcvbnm"; + $uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP"; + $numbers = "1234567890"; + $randomCode = ""; + if (function_exists('random_int')) // Cryptographic random + { + $max = strlen($lowercase) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $lowercase{random_int(0, $max)}; + } + $max = strlen($uppercase) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $uppercase{random_int(0, $max)}; + } + $max = strlen($numbers) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $numbers{random_int(0, $max)}; + } + + $generated_password=str_shuffle($randomCode); + } + else // Old platform, non cryptographic random + { + $max = strlen($lowercase) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $lowercase{mt_rand(0, $max)}; + } + $max = strlen($uppercase) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $uppercase{mt_rand(0, $max)}; + } + $max = strlen($numbers) - 1; + for ($x = 0; $x < abs($length/3); $x++) { + $randomCode .= $numbers{mt_rand(0, $max)}; + } + + $generated_password=str_shuffle($randomCode); + } + } else if (! empty($conf->global->USER_PASSWORD_GENERATED)) { $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); From e78406e1204f876363c080055b5cb6a845904b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Nov 2017 20:04:18 +0100 Subject: [PATCH 14/14] Debug cronjob --- htdocs/core/lib/security.lib.php | 14 +++++++------- htdocs/cron/class/cronjob.class.php | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 308327ba331..fed22dafdfb 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -74,24 +74,24 @@ function dol_decode($chain) * If constant MAIN_SECURITY_SALT is defined, we use it as a salt. * * @param string $chain String to hash - * @param int $type Type of hash (0:auto, 1:sha1, 2:sha1+md5, 3:md5, 4:md5 for OpenLdap). Use 3 here, if hash is not needed for security purpose, for security need, prefer 0. + * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string */ -function dol_hash($chain,$type=0) +function dol_hash($chain, $type='0') { global $conf; // Salt value if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; - if ($type == 1) return sha1($chain); - else if ($type == 2) return sha1(md5($chain)); - else if ($type == 3) return md5($chain); - else if ($type == 4) return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base) + if ($type == '1' || $type == 'sha1') return sha1($chain); + else if ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); + else if ($type == '3' || $type == 'md5') return md5($chain); + else if ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5,$chain)); // For OpenLdap with md5 (based on an unencrypted password in base) else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); else if (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); - // No particular enconding defined, use default + // No particular encoding defined, use default return md5($chain); } diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 24cac301379..3ebf3f22d02 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1121,7 +1121,7 @@ class Cronjob extends CommonObject $error++; } } - if ($execmethod == 2) // This method may create + if ($execmethod == 2) // With this method, there is no way to get the return code, only output { $ok=0; $handle = fopen($outputfile, 'w+b'); @@ -1154,7 +1154,7 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::executeCLI output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); - return $reval; + return $retval; }