From 8c13c87429dc1d0df723fdd0ab57462d936845b8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 1 Dec 2018 16:55:42 +0100 Subject: [PATCH 1/9] Fix path for user photo --- htdocs/core/class/html.form.class.php | 8 ++++---- htdocs/user/card.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4d91e8a358a..ef95b3679ef 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6860,10 +6860,10 @@ class Form $dir=$conf->user->dir_output; if (! empty($object->photo)) { - if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini'); - else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small'); - else $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo; - $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo; + if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); + else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); + else $file=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fd6234268b2..b4aed9f7844 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -449,14 +449,14 @@ if (empty($reshook)) { if (!$error && !count($object->errors)) { if (GETPOST('deletephoto') && $object->photo) { - $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; - $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; + $fileimg = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/logos/'.$object->photo; + $dirthumbs = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/logos/thumbs'; dol_delete_file($fileimg); dol_delete_dir_recursive($dirthumbs); } if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); + $dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id; dol_mkdir($dir); From 72225f65247f3fbba5be98b3a3adcf9139d15d26 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 1 Dec 2018 23:57:15 +0100 Subject: [PATCH 2/9] Migration of user photo paths --- htdocs/install/upgrade2.php | 71 ++++++++++++++++++++++++++++++++- htdocs/langs/en_US/install.lang | 1 + 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 1011dcef9cb..08fa147fb0d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -446,7 +446,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $beforeversionarray=explode('.','9.0.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { - //migrate_rename_directories($db,$langs,$conf,'/contracts','/contract'); + migrate_user_photospath(); } } @@ -4826,7 +4826,76 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) } } +/** + * Migrate file from old path to new one for users + * + * @return void + */ +function migrate_user_photospath() +{ + global $conf, $db, $langs; + + print ''; + print ''.$langs->trans('MigrationUserPhotoPath')."
\n"; + + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $fuser = new User($db); + + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users + $resql = $db->query($sql); + if ($resql) + { + while ($obj = $db->fetch_object($resql)) + { + $fuser->fetch($obj->uid); + //echo '
'.$fuser->id.' -> '.$fuser->entity; + $entity = (!empty($fuser->entity)) ? $fuser->entity : 1; + $dir = $conf->user->multidir_output[$entity]; + $origin = $dir .'/'. get_exdir($fuser->id,2,0,0,$fuser,'user'); + $destin = $dir.'/'.$fuser->id; + + $error = 0; + + $origin_osencoded=dol_osencode($origin); + $destin_osencoded=dol_osencode($destin); + dol_mkdir($destin); + //echo '
'.$origin.' -> '.$destin; + if (dol_is_dir($origin)) + { + $handle=opendir($origin_osencoded); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if ($file != '.' && $file != '..' && is_dir($origin_osencoded.'/'.$file)) + { + $thumbs = opendir($origin_osencoded.'/'.$file); + if (is_resource($thumbs)) + { + dol_mkdir($destin.'/'.$file); + while (($thumb = readdir($thumbs)) !== false) + { + dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb); + } + // dol_delete_dir($origin.'/'.$file); + } + } + else + { + if (dol_is_file($origin.'/'.$file) ) + { + dol_move($origin.'/'.$file, $destin.'/'.$file); + } + } + } + } + } + } + } + + print ''; +} /* A faire egalement: Modif statut paye et fk_facture des factures payes completement diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index bcca348c861..c92d83988ff 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -200,6 +200,7 @@ MigrationRemiseEntity=Update entity field value of llx_societe_remise MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except MigrationUserRightsEntity=Update entity field value of llx_user_rights MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights +MigrationUserPhotoPath=Migration of photo paths for users MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm ShowNotAvailableOptions=Show unavailable options From ad05b531e7f9603b885630364c6049c84ee63e9d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Dec 2018 00:02:43 +0100 Subject: [PATCH 3/9] Fix display user photo with new path --- htdocs/core/class/html.form.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1394ad46f2b..8ba38b81edb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6861,10 +6861,10 @@ class Form $dir=$conf->user->dir_output; if (! empty($object->photo)) { - if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); - else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); - else $file=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; - $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + if ((string) $imagesize == 'mini') $file=get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); + else if ((string) $imagesize == 'small') $file=get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); + else $file=get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + $originalfile=get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; From d2d623b0b6f6688291714087987f9121a74ac128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 2 Dec 2018 09:26:24 +0100 Subject: [PATCH 4/9] GETPOSTISSET has only one param --- htdocs/admin/mails_templates.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 945656962ea..a9068544e35 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -11,6 +11,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud + * Copyright (C) 2018 Frédéric France * * 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 @@ -995,7 +996,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; if (! empty($conf->global->MAIN_MULTILANGS)) { - $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang; + $selectedlang = GETPOSTISSET('langcode')?GETPOST('langcode', 'aZ09'):$langs->defaultlang; if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } From ab02cb3cde4c718423765c4756d3051612ddccbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 2 Dec 2018 10:12:40 +0100 Subject: [PATCH 5/9] doc comment adherent class --- htdocs/adherents/class/adherent.class.php | 98 +++++++++++++++++------ 1 file changed, 74 insertions(+), 24 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 39d31986511..cee9ce36edd 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -59,6 +59,9 @@ class Adherent extends CommonObject public $mesgs; + /** + * @var string login of member + */ public $login; //! Clear password in memory @@ -68,29 +71,70 @@ class Adherent extends CommonObject //! Encrypted password in database (always defined) public $pass_indatabase_crypted; + /** + * @var string company name + * @deprecated + */ public $societe; /** - * @var Societe $company {@type Societe} + * @var string company name */ public $company; + /** + * @var int Thirdparty ID + */ + public $fk_soc; + /** * @var string Address */ public $address; - public $zip; + /** + * @var string zipcode + */ + public $zip; + + /** + * @var string town + */ public $town; - public $state_id; // Id of department - public $state_code; // Code of department - public $state; // Label of department + /** + * @var int Id of state + */ + public $state_id; + /** + * @var string Code of state + */ + public $state_code; + + /** + * @var string Label of state + */ + public $state; + + /** + * @var string email + */ public $email; - public $skype; - public $twitter; + /** + * @var string skype account + */ + public $skype; + + /** + * @var string twitter account + */ + public $twitter; + + /** + * @var string facebook account + */ public $facebook; /** @@ -120,8 +164,12 @@ class Adherent extends CommonObject public $morphy; public $public; - public $statut; // -1:brouillon, 0:resilie, >=1:valide,paye - public $photo; + + // -1:brouillon, 0:resilie, >=1:valide,paye + // def in common object + //public $statut; + + public $photo; public $datec; public $datem; @@ -129,21 +177,20 @@ class Adherent extends CommonObject public $birth; - public $note_public; - public $note_private; + /** + * @var int id type member + */ + public $typeid; - public $typeid; // Id type adherent - public $type; // Libelle type adherent + /** + * @var string label type member + */ + public $type; public $need_subscription; public $user_id; public $user_login; - /** - * @var int Thirdparty ID - */ - public $fk_soc; - public $datefin; // From member table // Fields loaded by fetch_subscriptions() @@ -155,7 +202,10 @@ class Adherent extends CommonObject public $last_subscription_amount; public $subscriptions=array(); - public $oldcopy; // To contains a clone of this when we need to save old properties of object + /** + * @var Adherent To contains a clone of this when we need to save old properties of object + */ + public $oldcopy; /** * @var int Entity @@ -593,11 +643,11 @@ class Adherent extends CommonObject $luser->societe_id=$this->societe; $luser->birth=$this->birth; - $luser->address=$this->address; - $luser->zip=$this->zip; - $luser->town=$this->town; - $luser->country_id=$this->country_id; - $luser->state_id=$this->state_id; + $luser->address=$this->address; + $luser->zip=$this->zip; + $luser->town=$this->town; + $luser->country_id=$this->country_id; + $luser->state_id=$this->state_id; $luser->email=$this->email; $luser->skype=$this->skype; From 3b31354dc23b36a22abc9cc386bf9301e557ec33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 2 Dec 2018 10:33:23 +0100 Subject: [PATCH 6/9] cats may be int or array --- htdocs/adherents/card.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 347c29fc30d..b77759b98a3 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1286,8 +1286,11 @@ else $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_MEMBER); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + $arrayselected = array(); + if (is_array($cats)) { + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } } print $form->multiselectarray('memcats', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print ""; From 044c54da94c929cc6fdfc51adcbe9e9226b75d46 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sun, 2 Dec 2018 10:45:37 +0100 Subject: [PATCH 7/9] Warning error if $conf->browser->layout is empty --- htdocs/core/lib/ajax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index afff8198e09..76de6ede2d7 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -377,7 +377,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ // select2 disabled for smartphones with standard browser. // TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array) - if ($conf->browser->layout == 'phone') return ''; + if (! empty($conf->browser->layout) and $conf->browser->layout == 'phone') return ''; if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return ''; From 30f192517754ab537a2913815bd9c8337e4f9554 Mon Sep 17 00:00:00 2001 From: IJ Date: Sun, 2 Dec 2018 12:29:52 +0000 Subject: [PATCH 8/9] FIX: Add Missing Translation Strings into ecm.lang - ECMDocsByHolidays - ECMDocsBySupplierProposals --- htdocs/langs/en_US/ecm.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 1c89de928ca..43ddd3bf36f 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -34,6 +34,8 @@ ECMDocsByProjects=Documents linked to projects ECMDocsByUsers=Documents linked to users ECMDocsByInterventions=Documents linked to interventions ECMDocsByExpenseReports=Documents linked to expense reports +ECMDocsByHolidays=Documents linked to holidays +ECMDocsBySupplierProposals=Documents linked to supplier proposals ECMNoDirectoryYet=No directory created ShowECMSection=Show directory DeleteSection=Remove directory From ea119a26c7e64ef6729db74af9ae1027b4604a8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Dec 2018 17:03:11 +0100 Subject: [PATCH 9/9] Update ajax.lib.php --- htdocs/core/lib/ajax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 76de6ede2d7..e3a0f44c9ac 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -377,7 +377,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $ // select2 disabled for smartphones with standard browser. // TODO With select2 v4, it seems ok, except that responsive style on table become crazy when scrolling at end of array) - if (! empty($conf->browser->layout) and $conf->browser->layout == 'phone') return ''; + if (! empty($conf->browser->layout) && $conf->browser->layout == 'phone') return ''; if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return ''; if (empty($conf->use_javascript_ajax)) return '';