From bcdf19f0ffa750a9bb2146626de871c25f31b7f6 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 27 Jan 2020 10:54:08 +0100 Subject: [PATCH 01/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/adherents/class/adherent.class.php | 32 +- htdocs/user/class/user.class.php | 338 +++++++++++----------- 2 files changed, 191 insertions(+), 179 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ff2e5082736..2c2602bca56 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -641,7 +641,7 @@ class Adherent extends CommonObject $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); + $result=$this->setPassword($user, $this->pass, $this->pass_indatabase_crypted, $isencrypted, $notrigger, $nosyncuserpass); if (! $nbrowsaffected) $nbrowsaffected++; } } @@ -966,7 +966,7 @@ class Adherent extends CommonObject * @param int $nosyncuser Do not synchronize linked user * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $password_indatabase_crypted = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -974,21 +974,23 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); - // If new password not provided, we generate one - if (! $password) + // If password_crypted not provided, try crypt password provided + if(!$password_indatabase_crypted) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); + // If new password not provided, we generate one + if (!$password) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $password=getRandomPassword(false); + } + + // Crypt password + $password_crypted = dol_hash($password); + + } else { + $password_crypted = $password_indatabase_crypted; } - // Crypt password - $password_crypted = dol_hash($password); - - $password_indatabase = ''; - if (! $isencrypted) - { - $password_indatabase = $password; - } $this->db->begin(); @@ -1030,7 +1032,7 @@ class Adherent extends CommonObject if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, 0, 0, 1); + $result=$luser->setPassword($user, $this->pass, $this->pass_indatabase_crypted, 0, 0, 1); if ($result < 0) { $this->error=$luser->error; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9bfe66d9dec..ff5639b91ad 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -75,34 +75,34 @@ class User extends CommonObject public $personal_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; - /** - * Twitter username - * @var string - * @deprecated - */ + /** + * Twitter username + * @var string + * @deprecated + */ public $twitter; - /** - * Facebook username - * @var string - * @deprecated - */ + /** + * Facebook username + * @var string + * @deprecated + */ public $facebook; - /** - * Linkedin username - * @var string - * @deprecated - */ + /** + * Linkedin username + * @var string + * @deprecated + */ public $linkedin; public $job; // job position @@ -121,7 +121,7 @@ class User extends CommonObject public $office_phone; public $office_fax; public $user_mobile; - public $personal_mobile; + public $personal_mobile; public $admin; public $login; public $api_key; @@ -139,18 +139,18 @@ class User extends CommonObject public $pass_indatabase_crypted; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + * Date modification record (tms) + * + * @var integer + */ + public $datem; //! If this is defined, it is an external user /** @@ -167,8 +167,8 @@ class User extends CommonObject public $contactid; /** - * @var int ID - */ + * @var int ID + */ public $fk_member; /** @@ -176,7 +176,7 @@ class User extends CommonObject */ public $fk_user; public $fk_user_expense_validator; - public $fk_user_holiday_validator; + public $fk_user_holiday_validator; public $clicktodial_url; public $clicktodial_login; @@ -222,10 +222,10 @@ class User extends CommonObject public $fk_warehouse; public $fields = array( - 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - ); + 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + ); const STATUS_DISABLED = 0; @@ -391,7 +391,7 @@ class User extends CommonObject $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; - $this->personal_mobile = $obj->personal_mobile; + $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; $this->personal_email = $obj->personal_email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -427,8 +427,8 @@ class User extends CommonObject $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->fk_user_expense_validator = $obj->fk_user_expense_validator; - $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; + $this->fk_user_expense_validator = $obj->fk_user_expense_validator; + $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; @@ -1032,7 +1032,7 @@ class User extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1122,24 +1122,24 @@ class User extends CommonObject // Remove extrafields if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } // Remove user if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { - $error++; - $this->error = $this->db->lasterror(); - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (!$this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) @@ -1180,7 +1180,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value @@ -1302,7 +1302,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1313,7 +1313,7 @@ class User extends CommonObject */ public function create_from_contact($contact, $login = '', $password = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; $error = 0; @@ -1381,7 +1381,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1391,7 +1391,7 @@ class User extends CommonObject */ public function create_from_member($member, $login = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; // Positionne parametres @@ -1402,6 +1402,7 @@ class User extends CommonObject $this->email = $member->email; $this->fk_member = $member->id; $this->pass = $member->pass; + $this->pass_indatabase_crypted = $member->pass_indatabase_crypted; $this->address = $member->address; $this->zip = $member->zip; $this->town = $member->town; @@ -1417,7 +1418,7 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - $newpass = $this->setPassword($user, $this->pass); + $newpass = $this->setPassword($user, $this->pass, $this->pass_indatabase_crypted); if (is_numeric($newpass) && $newpass < 0) $result = -2; if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty @@ -1456,7 +1457,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * @@ -1464,7 +1465,7 @@ class User extends CommonObject */ public function set_default_rights() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def"; @@ -1523,7 +1524,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); @@ -1541,9 +1542,9 @@ class User extends CommonObject $this->office_phone = trim($this->office_phone); $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); - $this->personal_mobile = trim($this->personal_mobile); + $this->personal_mobile = trim($this->personal_mobile); $this->email = trim($this->email); - $this->personal_email = trim($this->personal_email); + $this->personal_email = trim($this->personal_email); $this->job = trim($this->job); $this->signature = trim($this->signature); @@ -1594,10 +1595,10 @@ class User extends CommonObject $sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'"; $sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; - $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; + $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; $sql .= ", email = '".$this->db->escape($this->email)."'"; - $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", job = '".$this->db->escape($this->job)."'"; $sql .= ", signature = '".$this->db->escape($this->signature)."'"; $sql .= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1609,8 +1610,8 @@ class User extends CommonObject $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); $sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null"); $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".$this->db->escape($this->fk_user)."'" : "null"); - $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); - $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); + $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); + $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); if (isset($this->thm) || $this->thm != '') $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null"); if (isset($this->tjm) || $this->tjm != '') $sql .= ", tjm= ".($this->tjm != '' ? "'".$this->db->escape($this->tjm)."'" : "null"); if (isset($this->salary) || $this->salary != '') $sql .= ", salary= ".($this->salary != '' ? "'".$this->db->escape($this->salary)."'" : "null"); @@ -1810,7 +1811,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion @@ -1819,7 +1820,7 @@ class User extends CommonObject */ public function update_last_login_date() { - // phpcs:enable + // phpcs:enable $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; @@ -1854,7 +1855,7 @@ class User extends CommonObject * @param int $nosyncmember Do not synchronize linked member * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $password_indatabase_crypted = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1863,14 +1864,23 @@ class User extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG); - // If new password not provided, we generate one - if (!$password) + // If password_crypted not provided, try crypt password provided + if(!$password_indatabase_crypted) { - $password = getRandomPassword(false); + // If new password not provided, we generate one + if (!$password) + { + $password = getRandomPassword(false); + } + + // Crypt password + $password_crypted = dol_hash($password); + + } else { + $password_crypted = $password_indatabase_crypted; } - // Crypt password - $password_crypted = dol_hash($password); + // Mise a jour if (!$changelater) @@ -1913,7 +1923,7 @@ class User extends CommonObject if ($result >= 0) { - $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + $result = $adh->setPassword($user, $this->pass, $this->pass_indatabase_crypted, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent if ($result < 0) { $this->error = $adh->error; @@ -1977,7 +1987,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1988,7 +1998,7 @@ class User extends CommonObject */ public function send_password($user, $password = '', $changelater = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; global $dolibarr_main_url_root; @@ -2002,19 +2012,19 @@ class User extends CommonObject $outputlangs = new Translate("", $conf); if (isset($this->conf->MAIN_LANG_DEFAULT) - && $this->conf->MAIN_LANG_DEFAULT != 'auto') + && $this->conf->MAIN_LANG_DEFAULT != 'auto') { // If user has defined its own language (rare because in most cases, auto is used) $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT); } if ($user->conf->MAIN_LANG_DEFAULT) { - $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); - } + $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } else { // If user has not defined its own language, we used current language $outputlangs = $langs; } - // Load translation files required by the page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "errors", "users", "other")); $appli = constant('DOL_APPLICATION_TITLE'); @@ -2057,8 +2067,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } - $mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -2068,8 +2078,8 @@ class User extends CommonObject '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2094,7 +2104,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * @@ -2102,7 +2112,7 @@ class User extends CommonObject */ public function fetch_clicktodial() { - // phpcs:enable + // phpcs:enable $sql = "SELECT url, login, pass, poste "; $sql .= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql .= " WHERE u.fk_user = ".$this->id; @@ -2132,15 +2142,15 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return int <0 if KO, >0 if OK - */ - public function update_clicktodial() - { - // phpcs:enable + */ + public function update_clicktodial() + { + // phpcs:enable $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; @@ -2170,10 +2180,10 @@ class User extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2184,7 +2194,7 @@ class User extends CommonObject */ public function SetInGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2235,7 +2245,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2246,7 +2256,7 @@ class User extends CommonObject */ public function RemoveFromGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2333,7 +2343,7 @@ class User extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; + if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; @@ -2427,8 +2437,8 @@ class User extends CommonObject $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpictoimg) { - $paddafterimage = ''; - if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; + $paddafterimage = ''; + if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; // Only picto if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo @@ -2482,7 +2492,7 @@ class User extends CommonObject $linkend = ''; } - if ($option == 'nolink') + if ($option == 'nolink') { $linkstart = ''; $linkend = ''; @@ -2506,17 +2516,17 @@ class User extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of a status of user (active, inactive) - * - * @param int $status Id status + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status of user (active, inactive) + * + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -2549,7 +2559,7 @@ class User extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN; @@ -2567,7 +2577,7 @@ class User extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -2593,7 +2603,7 @@ class User extends CommonObject 'LDAP_FIELD_SKYPE' => 'skype', 'LDAP_FIELD_TWITTER' => 'twitter', 'LDAP_FIELD_FACEBOOK' => 'facebook', - 'LDAP_FIELD_LINKEDIN' => 'linkedin' + 'LDAP_FIELD_LINKEDIN' => 'linkedin' ); // Champs @@ -2677,22 +2687,22 @@ class User extends CommonObject if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; } - if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; - if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { - $usergroup = new UserGroup($this->db); - $groupslist = $usergroup->listGroupsForUser($this->id); - $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; - if (!empty($groupslist)) { - foreach ($groupslist as $groupforuser) { - $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list - break; - } - } - } - if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; + if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; + if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { + $usergroup = new UserGroup($this->db); + $groupslist = $usergroup->listGroupsForUser($this->id); + $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; + if (!empty($groupslist)) { + foreach ($groupslist as $groupforuser) { + $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list + break; + } + } + } + if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; - return $info; - } + return $info; + } /** @@ -2719,7 +2729,7 @@ class User extends CommonObject $this->note_public = 'This is a note public'; $this->note_private = 'This is a note private'; $this->email = 'email@specimen.com'; - $this->personal_email = 'personalemail@specimen.com'; + $this->personal_email = 'personalemail@specimen.com'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', @@ -2729,7 +2739,7 @@ class User extends CommonObject $this->office_phone = '0999999999'; $this->office_fax = '0999999998'; $this->user_mobile = '0999999997'; - $this->personal_mobile = '0999999996'; + $this->personal_mobile = '0999999996'; $this->admin = 0; $this->login = 'dolibspec'; $this->pass = 'dolibspec'; @@ -2854,7 +2864,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2863,7 +2873,7 @@ class User extends CommonObject */ public function update_ldap2dolibarr(&$ldapuser) { - // phpcs:enable + // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) global $user, $conf; @@ -2894,7 +2904,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * @@ -2903,7 +2913,7 @@ class User extends CommonObject */ public function get_children() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; @@ -2962,7 +2972,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the hierarchy/tree of users into an array. * Set and return this->users that is an array sorted according to tree with arrays of: @@ -2976,9 +2986,9 @@ class User extends CommonObject * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - public function get_full_tree($deleteafterid = 0, $filter = '') - { - // phpcs:enable + public function get_full_tree($deleteafterid = 0, $filter = '') + { + // phpcs:enable global $conf, $user; global $hookmanager; @@ -3078,8 +3088,8 @@ class User extends CommonObject * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children() */ - public function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids = array(); if (isset($this->cache_childids[$this->id])) @@ -3107,7 +3117,7 @@ class User extends CommonObject return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3116,9 +3126,9 @@ class User extends CommonObject * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - public function build_path_from_id_user($id_user, $protection = 0) - { - // phpcs:enable + public function build_path_from_id_user($id_user, $protection = 0) + { + // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); if (!empty($this->users[$id_user]['fullpath'])) @@ -3171,7 +3181,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load metrics this->nb for dashboard * @@ -3179,7 +3189,7 @@ class User extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable $this->nb = array(); @@ -3215,7 +3225,7 @@ class User extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3242,7 +3252,7 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3252,7 +3262,7 @@ class User extends CommonObject */ public function user_get_property($rowid, $mode) { - // phpcs:enable + // phpcs:enable $user_property = ''; if (empty($rowid)) return ''; @@ -3294,8 +3304,8 @@ class User extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND', $entityfilter = false) - { - global $conf, $user; + { + global $conf, $user; $sql = "SELECT t.rowid"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t '; @@ -3370,8 +3380,8 @@ class User extends CommonObject } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } From dc0237f0e13349f88a26045f8c5abee57e277467 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 27 Jan 2020 09:58:18 +0000 Subject: [PATCH 02/41] Fixing style errors. --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ff5639b91ad..8809873acc6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1875,7 +1875,6 @@ class User extends CommonObject // Crypt password $password_crypted = dol_hash($password); - } else { $password_crypted = $password_indatabase_crypted; } From b3e5fcff1099f0d905f66278f549109ce02fd32e Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 27 Jan 2020 11:01:13 +0100 Subject: [PATCH 03/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/langs/es_ES/zapier.lang | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 htdocs/langs/es_ES/zapier.lang diff --git a/htdocs/langs/es_ES/zapier.lang b/htdocs/langs/es_ES/zapier.lang new file mode 100644 index 00000000000..6b28c81832e --- /dev/null +++ b/htdocs/langs/es_ES/zapier.lang @@ -0,0 +1,28 @@ +# Copyright (C) 2019 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 +# 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 . + +# +# Generic +# + +# Module label 'ModuleZapierForDolibarrName' +ModuleZapierForDolibarrName = Zapier para Dolibarr +# Module description 'ModuleZapierForDolibarrDesc' +ModuleZapierForDolibarrDesc = Zapier para el módulo Dolibarr + +# +# Admin page +# +ZapierForDolibarrSetup = Configuración de Zapier para Dolibarr From b1724f7038d28418236e9906dcd6817410e36b9d Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Tue, 28 Jan 2020 09:25:49 +0100 Subject: [PATCH 04/41] FIX: #11975 When a product is split between multiple pages in a document, prices/quantity/etc appear on the last relevant page --- .../commande/doc/pdf_einstein.modules.php | 7 ++++++- .../commande/doc/pdf_eratosthene.modules.php | 16 ++++++++++++++-- .../modules/contract/doc/pdf_strato.modules.php | 8 +++++++- .../expedition/doc/pdf_espadon.modules.php | 16 ++++++++++++++-- .../expedition/doc/pdf_rouget.modules.php | 16 ++++++++++++++-- .../expensereport/doc/pdf_standard.modules.php | 8 +++++++- .../modules/facture/doc/pdf_crabe.modules.php | 16 ++++++++++++++-- .../modules/facture/doc/pdf_sponge.modules.php | 16 ++++++++++++++-- .../modules/livraison/doc/pdf_typhon.modules.php | 8 +++++++- .../modules/project/doc/pdf_baleine.modules.php | 8 +++++++- .../modules/project/doc/pdf_beluga.modules.php | 8 +++++++- .../project/doc/pdf_timespent.modules.php | 8 +++++++- .../modules/propale/doc/pdf_azur.modules.php | 16 ++++++++++++++-- .../modules/propale/doc/pdf_cyan.modules.php | 16 ++++++++++++++-- .../reception/doc/pdf_squille.modules.php | 16 ++++++++++++++-- .../modules/stock/doc/pdf_standard.modules.php | 8 +++++++- .../stock/doc/pdf_stdmovement.modules.php | 8 +++++++- .../supplier_invoice/pdf/pdf_canelle.modules.php | 8 +++++++- .../supplier_order/pdf/pdf_cornas.modules.php | 16 ++++++++++++++-- .../supplier_order/pdf/pdf_muscadet.modules.php | 16 ++++++++++++++-- .../doc/pdf_standard.modules.php | 8 +++++++- .../supplier_proposal/doc/pdf_aurore.modules.php | 16 ++++++++++++++-- 22 files changed, 230 insertions(+), 33 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 075ba0efb84..30fd293533b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -440,7 +440,12 @@ class pdf_einstein extends ModelePDFCommandes else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; } } else // No pagebreak diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 6342cd6ce74..b1dbca4dc56 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -572,7 +572,13 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -610,7 +616,13 @@ class pdf_eratosthene extends ModelePDFCommandes else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index badf7343295..c0cc4845aa5 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -391,7 +391,13 @@ class pdf_strato extends ModelePDFContract else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 0e74faaa56d..3b917275040 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -433,7 +433,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } @@ -475,7 +481,13 @@ class pdf_espadon extends ModelePdfExpedition else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 0e9db902662..705b3db4064 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -452,7 +452,13 @@ class pdf_rouget extends ModelePdfExpedition $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -494,7 +500,13 @@ class pdf_rouget extends ModelePdfExpedition else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index a2cefcf9ff0..2892b6196f3 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -385,7 +385,13 @@ class pdf_standard extends ModeleExpenseReport else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 64aa3c52e25..f623742bfe0 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -494,7 +494,13 @@ class pdf_crabe extends ModelePDFFactures $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -534,7 +540,13 @@ class pdf_crabe extends ModelePDFFactures else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3e00e2cab68..87a9face2bd 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -600,7 +600,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -639,7 +645,13 @@ class pdf_sponge extends ModelePDFFactures else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 00268810ce8..4d659ca193a 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -409,7 +409,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 910ef3ec1cf..79941dba8d6 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -362,7 +362,13 @@ class pdf_baleine extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index b26b46604ff..4072f22bf58 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -512,7 +512,13 @@ class pdf_beluga extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 27822545fa2..0c1eba3c9ac 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -293,7 +293,13 @@ class pdf_timespent extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9219de5863c..67496a7597c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -502,7 +502,13 @@ class pdf_azur extends ModelePDFPropales $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -543,7 +549,13 @@ class pdf_azur extends ModelePDFPropales else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1e67ac6485c..308a67bedcc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -582,7 +582,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } @@ -624,7 +630,13 @@ class pdf_cyan extends ModelePDFPropales else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 125c56960ca..93204a44a4b 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -374,7 +374,13 @@ class pdf_squille extends ModelePdfReception $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -417,7 +423,13 @@ class pdf_squille extends ModelePdfReception else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 97c0744c121..292e551a1eb 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -383,7 +383,13 @@ class pdf_standard extends ModelePDFStock else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 4f59c2510b4..19986161413 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -543,7 +543,13 @@ class pdf_stdmovement extends ModelePDFMovement else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 32926e098e3..e1d6133ab39 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -430,7 +430,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 8ff4c3ad429..25962f3b45d 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -523,7 +523,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -564,7 +570,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index a30232f0b41..60658bc8e59 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -445,7 +445,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -492,7 +498,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index e8b97224aad..0d3f3569c56 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -365,7 +365,13 @@ class pdf_standard extends ModelePDFSuppliersPayments else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ff8ab76c674..0bd15e86403 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -430,7 +430,13 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -480,7 +486,13 @@ class pdf_aurore extends ModelePDFSupplierProposal else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak From 37aca0704198bb07dfa6e157810ef125d0910056 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 28 Jan 2020 08:29:00 +0000 Subject: [PATCH 05/41] Fixing style errors. --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 2 -- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 1 - htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 2 -- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 -- htdocs/core/modules/expensereport/doc/pdf_standard.modules.php | 1 - htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 -- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 -- htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 1 - htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 -- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 -- htdocs/core/modules/reception/doc/pdf_squille.modules.php | 2 -- htdocs/core/modules/stock/doc/pdf_standard.modules.php | 1 - htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php | 1 - .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 1 - htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php | 2 -- htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php | 2 -- .../core/modules/supplier_payment/doc/pdf_standard.modules.php | 1 - .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 -- 18 files changed, 29 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index b1dbca4dc56..250f8095b05 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -578,7 +578,6 @@ class pdf_eratosthene extends ModelePDFCommandes $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -622,7 +621,6 @@ class pdf_eratosthene extends ModelePDFCommandes $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c0cc4845aa5..0058ad524f4 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -397,7 +397,6 @@ class pdf_strato extends ModelePDFContract $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 3b917275040..5706ce5d7fa 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -439,7 +439,6 @@ class pdf_espadon extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } @@ -487,7 +486,6 @@ class pdf_espadon extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 705b3db4064..a19d98748ee 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -458,7 +458,6 @@ class pdf_rouget extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -506,7 +505,6 @@ class pdf_rouget extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 2892b6196f3..c1654aa0aec 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -391,7 +391,6 @@ class pdf_standard extends ModeleExpenseReport $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index f623742bfe0..4d7ee892692 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -500,7 +500,6 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -546,7 +545,6 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 87a9face2bd..1a300bee0e0 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -606,7 +606,6 @@ class pdf_sponge extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -651,7 +650,6 @@ class pdf_sponge extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 4d659ca193a..88a51c7c94f 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -415,7 +415,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 67496a7597c..222858750a7 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -508,7 +508,6 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -555,7 +554,6 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 308a67bedcc..db9b5a3818d 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -588,7 +588,6 @@ class pdf_cyan extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } @@ -636,7 +635,6 @@ class pdf_cyan extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 93204a44a4b..f1c2eba89e4 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -380,7 +380,6 @@ class pdf_squille extends ModelePdfReception $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -429,7 +428,6 @@ class pdf_squille extends ModelePdfReception $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 292e551a1eb..b2898c2fbac 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -389,7 +389,6 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 19986161413..362f17c7e9c 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -549,7 +549,6 @@ class pdf_stdmovement extends ModelePDFMovement $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index e1d6133ab39..26329ac889f 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -436,7 +436,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 25962f3b45d..6d3fe584eb3 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -529,7 +529,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -576,7 +575,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 60658bc8e59..5bad5b6be24 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -451,7 +451,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -504,7 +503,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 0d3f3569c56..836d7c04072 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -371,7 +371,6 @@ class pdf_standard extends ModelePDFSuppliersPayments $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 0bd15e86403..6b57a81af5a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -436,7 +436,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -492,7 +491,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak From 91575e5b544ddcb363c9acd7973f8c4725301eb7 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Tue, 28 Jan 2020 10:52:33 +0100 Subject: [PATCH 06/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/adherents/class/adherent.class.php | 34 +-- htdocs/user/class/user.class.php | 343 +++++++++++----------- 2 files changed, 189 insertions(+), 188 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 2c2602bca56..1ec82f7da31 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -641,7 +641,7 @@ class Adherent extends CommonObject $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $this->pass_indatabase_crypted, $isencrypted, $notrigger, $nosyncuserpass); + $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); if (! $nbrowsaffected) $nbrowsaffected++; } } @@ -964,9 +964,10 @@ class Adherent extends CommonObject * @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut) * @param int $notrigger 1=Ne declenche pas les triggers * @param int $nosyncuser Do not synchronize linked user + * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $password_indatabase_crypted = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0, $alreadyencrypted = 0) { global $conf, $langs; @@ -974,23 +975,22 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); - // If password_crypted not provided, try crypt password provided - if(!$password_indatabase_crypted) + // If new password not provided, we generate one + if (! $password) { - // If new password not provided, we generate one - if (!$password) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); - } - - // Crypt password - $password_crypted = dol_hash($password); - - } else { - $password_crypted = $password_indatabase_crypted; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $password=getRandomPassword(false); } + // Crypt password + if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); + else $password_crypted = $password; + + $password_indatabase = ''; + if (! $isencrypted) + { + $password_indatabase = $password; + } $this->db->begin(); @@ -1032,7 +1032,7 @@ class Adherent extends CommonObject if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, $this->pass_indatabase_crypted, 0, 0, 1); + $result=$luser->setPassword($user, $this->pass, 0, 0, 1, 1); if ($result < 0) { $this->error=$luser->error; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8809873acc6..98bc2a7c7b0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -75,34 +75,34 @@ class User extends CommonObject public $personal_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; - /** - * Twitter username - * @var string - * @deprecated - */ + /** + * Twitter username + * @var string + * @deprecated + */ public $twitter; - /** - * Facebook username - * @var string - * @deprecated - */ + /** + * Facebook username + * @var string + * @deprecated + */ public $facebook; - /** - * Linkedin username - * @var string - * @deprecated - */ + /** + * Linkedin username + * @var string + * @deprecated + */ public $linkedin; public $job; // job position @@ -121,7 +121,7 @@ class User extends CommonObject public $office_phone; public $office_fax; public $user_mobile; - public $personal_mobile; + public $personal_mobile; public $admin; public $login; public $api_key; @@ -139,18 +139,18 @@ class User extends CommonObject public $pass_indatabase_crypted; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + * Date modification record (tms) + * + * @var integer + */ + public $datem; //! If this is defined, it is an external user /** @@ -167,8 +167,8 @@ class User extends CommonObject public $contactid; /** - * @var int ID - */ + * @var int ID + */ public $fk_member; /** @@ -176,7 +176,7 @@ class User extends CommonObject */ public $fk_user; public $fk_user_expense_validator; - public $fk_user_holiday_validator; + public $fk_user_holiday_validator; public $clicktodial_url; public $clicktodial_login; @@ -222,10 +222,10 @@ class User extends CommonObject public $fk_warehouse; public $fields = array( - 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - ); + 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + ); const STATUS_DISABLED = 0; @@ -391,7 +391,7 @@ class User extends CommonObject $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; - $this->personal_mobile = $obj->personal_mobile; + $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; $this->personal_email = $obj->personal_email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -427,8 +427,8 @@ class User extends CommonObject $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->fk_user_expense_validator = $obj->fk_user_expense_validator; - $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; + $this->fk_user_expense_validator = $obj->fk_user_expense_validator; + $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; @@ -1032,7 +1032,7 @@ class User extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1122,24 +1122,24 @@ class User extends CommonObject // Remove extrafields if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } // Remove user if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { - $error++; - $this->error = $this->db->lasterror(); - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (!$this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) @@ -1180,7 +1180,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value @@ -1302,7 +1302,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1313,7 +1313,7 @@ class User extends CommonObject */ public function create_from_contact($contact, $login = '', $password = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; $error = 0; @@ -1381,7 +1381,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1391,7 +1391,7 @@ class User extends CommonObject */ public function create_from_member($member, $login = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; // Positionne parametres @@ -1418,7 +1418,9 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - $newpass = $this->setPassword($user, $this->pass, $this->pass_indatabase_crypted); + if(!$this->pass && $this->pass_indatabase_crypted) $newpass = $this->setPassword($user, $this->pass_indatabase_crypted, 0, 0, 0, 1); + else $newpass = $this->setPassword($user, $this->pass); + if (is_numeric($newpass) && $newpass < 0) $result = -2; if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty @@ -1457,7 +1459,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * @@ -1465,7 +1467,7 @@ class User extends CommonObject */ public function set_default_rights() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def"; @@ -1524,7 +1526,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); @@ -1542,9 +1544,9 @@ class User extends CommonObject $this->office_phone = trim($this->office_phone); $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); - $this->personal_mobile = trim($this->personal_mobile); + $this->personal_mobile = trim($this->personal_mobile); $this->email = trim($this->email); - $this->personal_email = trim($this->personal_email); + $this->personal_email = trim($this->personal_email); $this->job = trim($this->job); $this->signature = trim($this->signature); @@ -1595,10 +1597,10 @@ class User extends CommonObject $sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'"; $sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; - $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; + $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; $sql .= ", email = '".$this->db->escape($this->email)."'"; - $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", job = '".$this->db->escape($this->job)."'"; $sql .= ", signature = '".$this->db->escape($this->signature)."'"; $sql .= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1610,8 +1612,8 @@ class User extends CommonObject $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); $sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null"); $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".$this->db->escape($this->fk_user)."'" : "null"); - $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); - $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); + $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); + $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); if (isset($this->thm) || $this->thm != '') $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null"); if (isset($this->tjm) || $this->tjm != '') $sql .= ", tjm= ".($this->tjm != '' ? "'".$this->db->escape($this->tjm)."'" : "null"); if (isset($this->salary) || $this->salary != '') $sql .= ", salary= ".($this->salary != '' ? "'".$this->db->escape($this->salary)."'" : "null"); @@ -1811,7 +1813,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion @@ -1820,7 +1822,7 @@ class User extends CommonObject */ public function update_last_login_date() { - // phpcs:enable + // phpcs:enable $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; @@ -1853,9 +1855,10 @@ class User extends CommonObject * @param int $changelater 1=Change password only after clicking on confirm email * @param int $notrigger 1=Does not launch triggers * @param int $nosyncmember Do not synchronize linked member + * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $password_indatabase_crypted = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $alreadyencrypted = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1864,21 +1867,15 @@ class User extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG); - // If password_crypted not provided, try crypt password provided - if(!$password_indatabase_crypted) + // If new password not provided, we generate one + if (!$password) { - // If new password not provided, we generate one - if (!$password) - { - $password = getRandomPassword(false); - } - - // Crypt password - $password_crypted = dol_hash($password); - } else { - $password_crypted = $password_indatabase_crypted; + $password = getRandomPassword(false); } + // Crypt password + if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); + else $password_crypted = $password; // Mise a jour @@ -1922,7 +1919,11 @@ class User extends CommonObject if ($result >= 0) { - $result = $adh->setPassword($user, $this->pass, $this->pass_indatabase_crypted, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + + if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted + + if ($result < 0) { $this->error = $adh->error; @@ -1986,7 +1987,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1997,7 +1998,7 @@ class User extends CommonObject */ public function send_password($user, $password = '', $changelater = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; global $dolibarr_main_url_root; @@ -2011,19 +2012,19 @@ class User extends CommonObject $outputlangs = new Translate("", $conf); if (isset($this->conf->MAIN_LANG_DEFAULT) - && $this->conf->MAIN_LANG_DEFAULT != 'auto') + && $this->conf->MAIN_LANG_DEFAULT != 'auto') { // If user has defined its own language (rare because in most cases, auto is used) $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT); } if ($user->conf->MAIN_LANG_DEFAULT) { - $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); - } + $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } else { // If user has not defined its own language, we used current language $outputlangs = $langs; } - // Load translation files required by the page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "errors", "users", "other")); $appli = constant('DOL_APPLICATION_TITLE'); @@ -2066,8 +2067,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } - $mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -2077,8 +2078,8 @@ class User extends CommonObject '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2103,7 +2104,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * @@ -2111,7 +2112,7 @@ class User extends CommonObject */ public function fetch_clicktodial() { - // phpcs:enable + // phpcs:enable $sql = "SELECT url, login, pass, poste "; $sql .= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql .= " WHERE u.fk_user = ".$this->id; @@ -2141,15 +2142,15 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return int <0 if KO, >0 if OK - */ - public function update_clicktodial() - { - // phpcs:enable + */ + public function update_clicktodial() + { + // phpcs:enable $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; @@ -2179,10 +2180,10 @@ class User extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2193,7 +2194,7 @@ class User extends CommonObject */ public function SetInGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2244,7 +2245,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2255,7 +2256,7 @@ class User extends CommonObject */ public function RemoveFromGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2342,7 +2343,7 @@ class User extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; + if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; @@ -2436,8 +2437,8 @@ class User extends CommonObject $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpictoimg) { - $paddafterimage = ''; - if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; + $paddafterimage = ''; + if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; // Only picto if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo @@ -2491,7 +2492,7 @@ class User extends CommonObject $linkend = ''; } - if ($option == 'nolink') + if ($option == 'nolink') { $linkstart = ''; $linkend = ''; @@ -2515,17 +2516,17 @@ class User extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of a status of user (active, inactive) - * - * @param int $status Id status + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status of user (active, inactive) + * + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -2558,7 +2559,7 @@ class User extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN; @@ -2576,7 +2577,7 @@ class User extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -2602,7 +2603,7 @@ class User extends CommonObject 'LDAP_FIELD_SKYPE' => 'skype', 'LDAP_FIELD_TWITTER' => 'twitter', 'LDAP_FIELD_FACEBOOK' => 'facebook', - 'LDAP_FIELD_LINKEDIN' => 'linkedin' + 'LDAP_FIELD_LINKEDIN' => 'linkedin' ); // Champs @@ -2686,22 +2687,22 @@ class User extends CommonObject if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; } - if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; - if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { - $usergroup = new UserGroup($this->db); - $groupslist = $usergroup->listGroupsForUser($this->id); - $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; - if (!empty($groupslist)) { - foreach ($groupslist as $groupforuser) { - $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list - break; - } - } - } - if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; + if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; + if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { + $usergroup = new UserGroup($this->db); + $groupslist = $usergroup->listGroupsForUser($this->id); + $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; + if (!empty($groupslist)) { + foreach ($groupslist as $groupforuser) { + $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list + break; + } + } + } + if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; - return $info; - } + return $info; + } /** @@ -2728,7 +2729,7 @@ class User extends CommonObject $this->note_public = 'This is a note public'; $this->note_private = 'This is a note private'; $this->email = 'email@specimen.com'; - $this->personal_email = 'personalemail@specimen.com'; + $this->personal_email = 'personalemail@specimen.com'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', @@ -2738,7 +2739,7 @@ class User extends CommonObject $this->office_phone = '0999999999'; $this->office_fax = '0999999998'; $this->user_mobile = '0999999997'; - $this->personal_mobile = '0999999996'; + $this->personal_mobile = '0999999996'; $this->admin = 0; $this->login = 'dolibspec'; $this->pass = 'dolibspec'; @@ -2863,7 +2864,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2872,7 +2873,7 @@ class User extends CommonObject */ public function update_ldap2dolibarr(&$ldapuser) { - // phpcs:enable + // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) global $user, $conf; @@ -2903,7 +2904,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * @@ -2912,7 +2913,7 @@ class User extends CommonObject */ public function get_children() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; @@ -2971,7 +2972,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the hierarchy/tree of users into an array. * Set and return this->users that is an array sorted according to tree with arrays of: @@ -2985,9 +2986,9 @@ class User extends CommonObject * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - public function get_full_tree($deleteafterid = 0, $filter = '') - { - // phpcs:enable + public function get_full_tree($deleteafterid = 0, $filter = '') + { + // phpcs:enable global $conf, $user; global $hookmanager; @@ -3087,8 +3088,8 @@ class User extends CommonObject * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children() */ - public function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids = array(); if (isset($this->cache_childids[$this->id])) @@ -3116,7 +3117,7 @@ class User extends CommonObject return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3125,9 +3126,9 @@ class User extends CommonObject * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - public function build_path_from_id_user($id_user, $protection = 0) - { - // phpcs:enable + public function build_path_from_id_user($id_user, $protection = 0) + { + // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); if (!empty($this->users[$id_user]['fullpath'])) @@ -3180,7 +3181,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load metrics this->nb for dashboard * @@ -3188,7 +3189,7 @@ class User extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable $this->nb = array(); @@ -3224,7 +3225,7 @@ class User extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3251,7 +3252,7 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3261,7 +3262,7 @@ class User extends CommonObject */ public function user_get_property($rowid, $mode) { - // phpcs:enable + // phpcs:enable $user_property = ''; if (empty($rowid)) return ''; @@ -3303,8 +3304,8 @@ class User extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND', $entityfilter = false) - { - global $conf, $user; + { + global $conf, $user; $sql = "SELECT t.rowid"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t '; @@ -3379,8 +3380,8 @@ class User extends CommonObject } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } From 77ced158fd3e6f3efe92a27b288678228834516e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 28 Jan 2020 10:00:14 +0000 Subject: [PATCH 07/41] Fixing style errors. --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 98bc2a7c7b0..af23dca5e96 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1919,7 +1919,6 @@ class User extends CommonObject if ($result >= 0) { - if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted From 540e82102b32da0f242ec27fac0c3a028f5d2243 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 27 Jan 2020 10:54:08 +0100 Subject: [PATCH 08/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/adherents/class/adherent.class.php | 32 +- htdocs/user/class/user.class.php | 338 +++++++++++----------- 2 files changed, 191 insertions(+), 179 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ec4042cdf88..4dbdb519831 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -641,7 +641,7 @@ class Adherent extends CommonObject $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); + $result=$this->setPassword($user, $this->pass, $this->pass_indatabase_crypted, $isencrypted, $notrigger, $nosyncuserpass); if (! $nbrowsaffected) $nbrowsaffected++; } } @@ -966,7 +966,7 @@ class Adherent extends CommonObject * @param int $nosyncuser Do not synchronize linked user * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $password_indatabase_crypted = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -974,21 +974,23 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); - // If new password not provided, we generate one - if (! $password) + // If password_crypted not provided, try crypt password provided + if(!$password_indatabase_crypted) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); + // If new password not provided, we generate one + if (!$password) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $password=getRandomPassword(false); + } + + // Crypt password + $password_crypted = dol_hash($password); + + } else { + $password_crypted = $password_indatabase_crypted; } - // Crypt password - $password_crypted = dol_hash($password); - - $password_indatabase = ''; - if (! $isencrypted) - { - $password_indatabase = $password; - } $this->db->begin(); @@ -1030,7 +1032,7 @@ class Adherent extends CommonObject if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, 0, 0, 1); + $result=$luser->setPassword($user, $this->pass, $this->pass_indatabase_crypted, 0, 0, 1); if ($result < 0) { $this->error=$luser->error; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 9bfe66d9dec..ff5639b91ad 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -75,34 +75,34 @@ class User extends CommonObject public $personal_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; - /** - * Twitter username - * @var string - * @deprecated - */ + /** + * Twitter username + * @var string + * @deprecated + */ public $twitter; - /** - * Facebook username - * @var string - * @deprecated - */ + /** + * Facebook username + * @var string + * @deprecated + */ public $facebook; - /** - * Linkedin username - * @var string - * @deprecated - */ + /** + * Linkedin username + * @var string + * @deprecated + */ public $linkedin; public $job; // job position @@ -121,7 +121,7 @@ class User extends CommonObject public $office_phone; public $office_fax; public $user_mobile; - public $personal_mobile; + public $personal_mobile; public $admin; public $login; public $api_key; @@ -139,18 +139,18 @@ class User extends CommonObject public $pass_indatabase_crypted; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + * Date modification record (tms) + * + * @var integer + */ + public $datem; //! If this is defined, it is an external user /** @@ -167,8 +167,8 @@ class User extends CommonObject public $contactid; /** - * @var int ID - */ + * @var int ID + */ public $fk_member; /** @@ -176,7 +176,7 @@ class User extends CommonObject */ public $fk_user; public $fk_user_expense_validator; - public $fk_user_holiday_validator; + public $fk_user_holiday_validator; public $clicktodial_url; public $clicktodial_login; @@ -222,10 +222,10 @@ class User extends CommonObject public $fk_warehouse; public $fields = array( - 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - ); + 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + ); const STATUS_DISABLED = 0; @@ -391,7 +391,7 @@ class User extends CommonObject $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; - $this->personal_mobile = $obj->personal_mobile; + $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; $this->personal_email = $obj->personal_email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -427,8 +427,8 @@ class User extends CommonObject $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->fk_user_expense_validator = $obj->fk_user_expense_validator; - $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; + $this->fk_user_expense_validator = $obj->fk_user_expense_validator; + $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; @@ -1032,7 +1032,7 @@ class User extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1122,24 +1122,24 @@ class User extends CommonObject // Remove extrafields if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } // Remove user if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { - $error++; - $this->error = $this->db->lasterror(); - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (!$this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) @@ -1180,7 +1180,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value @@ -1302,7 +1302,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1313,7 +1313,7 @@ class User extends CommonObject */ public function create_from_contact($contact, $login = '', $password = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; $error = 0; @@ -1381,7 +1381,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1391,7 +1391,7 @@ class User extends CommonObject */ public function create_from_member($member, $login = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; // Positionne parametres @@ -1402,6 +1402,7 @@ class User extends CommonObject $this->email = $member->email; $this->fk_member = $member->id; $this->pass = $member->pass; + $this->pass_indatabase_crypted = $member->pass_indatabase_crypted; $this->address = $member->address; $this->zip = $member->zip; $this->town = $member->town; @@ -1417,7 +1418,7 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - $newpass = $this->setPassword($user, $this->pass); + $newpass = $this->setPassword($user, $this->pass, $this->pass_indatabase_crypted); if (is_numeric($newpass) && $newpass < 0) $result = -2; if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty @@ -1456,7 +1457,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * @@ -1464,7 +1465,7 @@ class User extends CommonObject */ public function set_default_rights() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def"; @@ -1523,7 +1524,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); @@ -1541,9 +1542,9 @@ class User extends CommonObject $this->office_phone = trim($this->office_phone); $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); - $this->personal_mobile = trim($this->personal_mobile); + $this->personal_mobile = trim($this->personal_mobile); $this->email = trim($this->email); - $this->personal_email = trim($this->personal_email); + $this->personal_email = trim($this->personal_email); $this->job = trim($this->job); $this->signature = trim($this->signature); @@ -1594,10 +1595,10 @@ class User extends CommonObject $sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'"; $sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; - $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; + $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; $sql .= ", email = '".$this->db->escape($this->email)."'"; - $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", job = '".$this->db->escape($this->job)."'"; $sql .= ", signature = '".$this->db->escape($this->signature)."'"; $sql .= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1609,8 +1610,8 @@ class User extends CommonObject $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); $sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null"); $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".$this->db->escape($this->fk_user)."'" : "null"); - $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); - $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); + $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); + $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); if (isset($this->thm) || $this->thm != '') $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null"); if (isset($this->tjm) || $this->tjm != '') $sql .= ", tjm= ".($this->tjm != '' ? "'".$this->db->escape($this->tjm)."'" : "null"); if (isset($this->salary) || $this->salary != '') $sql .= ", salary= ".($this->salary != '' ? "'".$this->db->escape($this->salary)."'" : "null"); @@ -1810,7 +1811,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion @@ -1819,7 +1820,7 @@ class User extends CommonObject */ public function update_last_login_date() { - // phpcs:enable + // phpcs:enable $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; @@ -1854,7 +1855,7 @@ class User extends CommonObject * @param int $nosyncmember Do not synchronize linked member * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $password_indatabase_crypted = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1863,14 +1864,23 @@ class User extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG); - // If new password not provided, we generate one - if (!$password) + // If password_crypted not provided, try crypt password provided + if(!$password_indatabase_crypted) { - $password = getRandomPassword(false); + // If new password not provided, we generate one + if (!$password) + { + $password = getRandomPassword(false); + } + + // Crypt password + $password_crypted = dol_hash($password); + + } else { + $password_crypted = $password_indatabase_crypted; } - // Crypt password - $password_crypted = dol_hash($password); + // Mise a jour if (!$changelater) @@ -1913,7 +1923,7 @@ class User extends CommonObject if ($result >= 0) { - $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + $result = $adh->setPassword($user, $this->pass, $this->pass_indatabase_crypted, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent if ($result < 0) { $this->error = $adh->error; @@ -1977,7 +1987,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1988,7 +1998,7 @@ class User extends CommonObject */ public function send_password($user, $password = '', $changelater = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; global $dolibarr_main_url_root; @@ -2002,19 +2012,19 @@ class User extends CommonObject $outputlangs = new Translate("", $conf); if (isset($this->conf->MAIN_LANG_DEFAULT) - && $this->conf->MAIN_LANG_DEFAULT != 'auto') + && $this->conf->MAIN_LANG_DEFAULT != 'auto') { // If user has defined its own language (rare because in most cases, auto is used) $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT); } if ($user->conf->MAIN_LANG_DEFAULT) { - $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); - } + $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } else { // If user has not defined its own language, we used current language $outputlangs = $langs; } - // Load translation files required by the page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "errors", "users", "other")); $appli = constant('DOL_APPLICATION_TITLE'); @@ -2057,8 +2067,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } - $mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -2068,8 +2078,8 @@ class User extends CommonObject '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2094,7 +2104,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * @@ -2102,7 +2112,7 @@ class User extends CommonObject */ public function fetch_clicktodial() { - // phpcs:enable + // phpcs:enable $sql = "SELECT url, login, pass, poste "; $sql .= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql .= " WHERE u.fk_user = ".$this->id; @@ -2132,15 +2142,15 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return int <0 if KO, >0 if OK - */ - public function update_clicktodial() - { - // phpcs:enable + */ + public function update_clicktodial() + { + // phpcs:enable $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; @@ -2170,10 +2180,10 @@ class User extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2184,7 +2194,7 @@ class User extends CommonObject */ public function SetInGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2235,7 +2245,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2246,7 +2256,7 @@ class User extends CommonObject */ public function RemoveFromGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2333,7 +2343,7 @@ class User extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; + if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; @@ -2427,8 +2437,8 @@ class User extends CommonObject $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpictoimg) { - $paddafterimage = ''; - if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; + $paddafterimage = ''; + if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; // Only picto if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo @@ -2482,7 +2492,7 @@ class User extends CommonObject $linkend = ''; } - if ($option == 'nolink') + if ($option == 'nolink') { $linkstart = ''; $linkend = ''; @@ -2506,17 +2516,17 @@ class User extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of a status of user (active, inactive) - * - * @param int $status Id status + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status of user (active, inactive) + * + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -2549,7 +2559,7 @@ class User extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN; @@ -2567,7 +2577,7 @@ class User extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -2593,7 +2603,7 @@ class User extends CommonObject 'LDAP_FIELD_SKYPE' => 'skype', 'LDAP_FIELD_TWITTER' => 'twitter', 'LDAP_FIELD_FACEBOOK' => 'facebook', - 'LDAP_FIELD_LINKEDIN' => 'linkedin' + 'LDAP_FIELD_LINKEDIN' => 'linkedin' ); // Champs @@ -2677,22 +2687,22 @@ class User extends CommonObject if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; } - if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; - if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { - $usergroup = new UserGroup($this->db); - $groupslist = $usergroup->listGroupsForUser($this->id); - $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; - if (!empty($groupslist)) { - foreach ($groupslist as $groupforuser) { - $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list - break; - } - } - } - if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; + if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; + if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { + $usergroup = new UserGroup($this->db); + $groupslist = $usergroup->listGroupsForUser($this->id); + $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; + if (!empty($groupslist)) { + foreach ($groupslist as $groupforuser) { + $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list + break; + } + } + } + if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; - return $info; - } + return $info; + } /** @@ -2719,7 +2729,7 @@ class User extends CommonObject $this->note_public = 'This is a note public'; $this->note_private = 'This is a note private'; $this->email = 'email@specimen.com'; - $this->personal_email = 'personalemail@specimen.com'; + $this->personal_email = 'personalemail@specimen.com'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', @@ -2729,7 +2739,7 @@ class User extends CommonObject $this->office_phone = '0999999999'; $this->office_fax = '0999999998'; $this->user_mobile = '0999999997'; - $this->personal_mobile = '0999999996'; + $this->personal_mobile = '0999999996'; $this->admin = 0; $this->login = 'dolibspec'; $this->pass = 'dolibspec'; @@ -2854,7 +2864,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2863,7 +2873,7 @@ class User extends CommonObject */ public function update_ldap2dolibarr(&$ldapuser) { - // phpcs:enable + // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) global $user, $conf; @@ -2894,7 +2904,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * @@ -2903,7 +2913,7 @@ class User extends CommonObject */ public function get_children() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; @@ -2962,7 +2972,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the hierarchy/tree of users into an array. * Set and return this->users that is an array sorted according to tree with arrays of: @@ -2976,9 +2986,9 @@ class User extends CommonObject * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - public function get_full_tree($deleteafterid = 0, $filter = '') - { - // phpcs:enable + public function get_full_tree($deleteafterid = 0, $filter = '') + { + // phpcs:enable global $conf, $user; global $hookmanager; @@ -3078,8 +3088,8 @@ class User extends CommonObject * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children() */ - public function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids = array(); if (isset($this->cache_childids[$this->id])) @@ -3107,7 +3117,7 @@ class User extends CommonObject return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3116,9 +3126,9 @@ class User extends CommonObject * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - public function build_path_from_id_user($id_user, $protection = 0) - { - // phpcs:enable + public function build_path_from_id_user($id_user, $protection = 0) + { + // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); if (!empty($this->users[$id_user]['fullpath'])) @@ -3171,7 +3181,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load metrics this->nb for dashboard * @@ -3179,7 +3189,7 @@ class User extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable $this->nb = array(); @@ -3215,7 +3225,7 @@ class User extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3242,7 +3252,7 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3252,7 +3262,7 @@ class User extends CommonObject */ public function user_get_property($rowid, $mode) { - // phpcs:enable + // phpcs:enable $user_property = ''; if (empty($rowid)) return ''; @@ -3294,8 +3304,8 @@ class User extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND', $entityfilter = false) - { - global $conf, $user; + { + global $conf, $user; $sql = "SELECT t.rowid"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t '; @@ -3370,8 +3380,8 @@ class User extends CommonObject } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } From 478f927df3667dca551eca96c0a2f08c07b038e5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 27 Jan 2020 09:58:18 +0000 Subject: [PATCH 09/41] Fixing style errors. --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ff5639b91ad..8809873acc6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1875,7 +1875,6 @@ class User extends CommonObject // Crypt password $password_crypted = dol_hash($password); - } else { $password_crypted = $password_indatabase_crypted; } From ad2e10a679f082c7c16a0d1f9c65d7866c212778 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 27 Jan 2020 11:01:13 +0100 Subject: [PATCH 10/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/langs/es_ES/zapier.lang | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 htdocs/langs/es_ES/zapier.lang diff --git a/htdocs/langs/es_ES/zapier.lang b/htdocs/langs/es_ES/zapier.lang new file mode 100644 index 00000000000..6b28c81832e --- /dev/null +++ b/htdocs/langs/es_ES/zapier.lang @@ -0,0 +1,28 @@ +# Copyright (C) 2019 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 +# 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 . + +# +# Generic +# + +# Module label 'ModuleZapierForDolibarrName' +ModuleZapierForDolibarrName = Zapier para Dolibarr +# Module description 'ModuleZapierForDolibarrDesc' +ModuleZapierForDolibarrDesc = Zapier para el módulo Dolibarr + +# +# Admin page +# +ZapierForDolibarrSetup = Configuración de Zapier para Dolibarr From ed269a387f0740ec506844ba054e80cc6c8f5e3a Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Tue, 28 Jan 2020 09:25:49 +0100 Subject: [PATCH 11/41] FIX: #11975 When a product is split between multiple pages in a document, prices/quantity/etc appear on the last relevant page --- .../commande/doc/pdf_einstein.modules.php | 7 ++++++- .../commande/doc/pdf_eratosthene.modules.php | 16 ++++++++++++++-- .../modules/contract/doc/pdf_strato.modules.php | 8 +++++++- .../expedition/doc/pdf_espadon.modules.php | 16 ++++++++++++++-- .../expedition/doc/pdf_rouget.modules.php | 16 ++++++++++++++-- .../expensereport/doc/pdf_standard.modules.php | 8 +++++++- .../modules/facture/doc/pdf_crabe.modules.php | 16 ++++++++++++++-- .../modules/facture/doc/pdf_sponge.modules.php | 16 ++++++++++++++-- .../modules/livraison/doc/pdf_typhon.modules.php | 8 +++++++- .../modules/project/doc/pdf_baleine.modules.php | 8 +++++++- .../modules/project/doc/pdf_beluga.modules.php | 8 +++++++- .../project/doc/pdf_timespent.modules.php | 8 +++++++- .../modules/propale/doc/pdf_azur.modules.php | 16 ++++++++++++++-- .../modules/propale/doc/pdf_cyan.modules.php | 16 ++++++++++++++-- .../reception/doc/pdf_squille.modules.php | 16 ++++++++++++++-- .../modules/stock/doc/pdf_standard.modules.php | 8 +++++++- .../stock/doc/pdf_stdmovement.modules.php | 8 +++++++- .../supplier_invoice/pdf/pdf_canelle.modules.php | 8 +++++++- .../supplier_order/pdf/pdf_cornas.modules.php | 16 ++++++++++++++-- .../supplier_order/pdf/pdf_muscadet.modules.php | 16 ++++++++++++++-- .../doc/pdf_standard.modules.php | 8 +++++++- .../supplier_proposal/doc/pdf_aurore.modules.php | 16 ++++++++++++++-- 22 files changed, 230 insertions(+), 33 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 075ba0efb84..30fd293533b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -440,7 +440,12 @@ class pdf_einstein extends ModelePDFCommandes else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; } } else // No pagebreak diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 6342cd6ce74..b1dbca4dc56 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -572,7 +572,13 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -610,7 +616,13 @@ class pdf_eratosthene extends ModelePDFCommandes else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index badf7343295..c0cc4845aa5 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -391,7 +391,13 @@ class pdf_strato extends ModelePDFContract else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 0e74faaa56d..3b917275040 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -433,7 +433,13 @@ class pdf_espadon extends ModelePdfExpedition $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } @@ -475,7 +481,13 @@ class pdf_espadon extends ModelePdfExpedition else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 0e9db902662..705b3db4064 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -452,7 +452,13 @@ class pdf_rouget extends ModelePdfExpedition $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -494,7 +500,13 @@ class pdf_rouget extends ModelePdfExpedition else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index a2cefcf9ff0..2892b6196f3 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -385,7 +385,13 @@ class pdf_standard extends ModeleExpenseReport else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index fa661610d3b..48c1710f74f 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -494,7 +494,13 @@ class pdf_crabe extends ModelePDFFactures $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -534,7 +540,13 @@ class pdf_crabe extends ModelePDFFactures else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 2911cf5d5bc..d838dd970a4 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -600,7 +600,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -639,7 +645,13 @@ class pdf_sponge extends ModelePDFFactures else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 00268810ce8..4d659ca193a 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -409,7 +409,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 910ef3ec1cf..79941dba8d6 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -362,7 +362,13 @@ class pdf_baleine extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index b26b46604ff..4072f22bf58 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -512,7 +512,13 @@ class pdf_beluga extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 27822545fa2..0c1eba3c9ac 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -293,7 +293,13 @@ class pdf_timespent extends ModelePDFProjects else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + $forcedesconsamepage=1; if ($forcedesconsamepage) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9219de5863c..67496a7597c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -502,7 +502,13 @@ class pdf_azur extends ModelePDFPropales $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -543,7 +549,13 @@ class pdf_azur extends ModelePDFPropales else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 1e67ac6485c..308a67bedcc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -582,7 +582,13 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } @@ -624,7 +630,13 @@ class pdf_cyan extends ModelePDFPropales else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 125c56960ca..93204a44a4b 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -374,7 +374,13 @@ class pdf_squille extends ModelePdfReception $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -417,7 +423,13 @@ class pdf_squille extends ModelePdfReception else { // We found a page break - $showpricebeforepagebreak = 0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 97c0744c121..292e551a1eb 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -383,7 +383,13 @@ class pdf_standard extends ModelePDFStock else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 4f59c2510b4..19986161413 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -543,7 +543,13 @@ class pdf_stdmovement extends ModelePDFMovement else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 32926e098e3..e1d6133ab39 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -430,7 +430,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 8ff4c3ad429..25962f3b45d 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -523,7 +523,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -564,7 +570,13 @@ class pdf_cornas extends ModelePDFSuppliersOrders else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index a30232f0b41..60658bc8e59 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -445,7 +445,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -492,7 +498,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index e8b97224aad..0d3f3569c56 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -365,7 +365,13 @@ class pdf_standard extends ModelePDFSuppliersPayments else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index ff8ab76c674..0bd15e86403 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -430,7 +430,13 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->setPage($pageposbefore+1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -480,7 +486,13 @@ class pdf_aurore extends ModelePDFSupplierProposal else { // We found a page break - $showpricebeforepagebreak=0; + + // Allows data in the first page if description is long enough to break in multiples pages + if(!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) + $showpricebeforepagebreak = 1; + else + $showpricebeforepagebreak = 0; + } } else // No pagebreak From 5dcd5e5b87bd06136976447539fe9573fedcfd58 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 28 Jan 2020 08:29:00 +0000 Subject: [PATCH 12/41] Fixing style errors. --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 2 -- htdocs/core/modules/contract/doc/pdf_strato.modules.php | 1 - htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 2 -- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 -- htdocs/core/modules/expensereport/doc/pdf_standard.modules.php | 1 - htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 -- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 -- htdocs/core/modules/livraison/doc/pdf_typhon.modules.php | 1 - htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 -- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 -- htdocs/core/modules/reception/doc/pdf_squille.modules.php | 2 -- htdocs/core/modules/stock/doc/pdf_standard.modules.php | 1 - htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php | 1 - .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 1 - htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php | 2 -- htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php | 2 -- .../core/modules/supplier_payment/doc/pdf_standard.modules.php | 1 - .../core/modules/supplier_proposal/doc/pdf_aurore.modules.php | 2 -- 18 files changed, 29 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index b1dbca4dc56..250f8095b05 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -578,7 +578,6 @@ class pdf_eratosthene extends ModelePDFCommandes $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -622,7 +621,6 @@ class pdf_eratosthene extends ModelePDFCommandes $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index c0cc4845aa5..0058ad524f4 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -397,7 +397,6 @@ class pdf_strato extends ModelePDFContract $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 3b917275040..5706ce5d7fa 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -439,7 +439,6 @@ class pdf_espadon extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } @@ -487,7 +486,6 @@ class pdf_espadon extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 705b3db4064..a19d98748ee 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -458,7 +458,6 @@ class pdf_rouget extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -506,7 +505,6 @@ class pdf_rouget extends ModelePdfExpedition $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 2892b6196f3..c1654aa0aec 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -391,7 +391,6 @@ class pdf_standard extends ModeleExpenseReport $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 48c1710f74f..6b6c6bb2beb 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -500,7 +500,6 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -546,7 +545,6 @@ class pdf_crabe extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index d838dd970a4..0df384cdeb6 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -606,7 +606,6 @@ class pdf_sponge extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -651,7 +650,6 @@ class pdf_sponge extends ModelePDFFactures $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 4d659ca193a..88a51c7c94f 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -415,7 +415,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 67496a7597c..222858750a7 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -508,7 +508,6 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -555,7 +554,6 @@ class pdf_azur extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 308a67bedcc..db9b5a3818d 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -588,7 +588,6 @@ class pdf_cyan extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } @@ -636,7 +635,6 @@ class pdf_cyan extends ModelePDFPropales $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 93204a44a4b..f1c2eba89e4 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -380,7 +380,6 @@ class pdf_squille extends ModelePdfReception $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (isset($imglinesize['width']) && isset($imglinesize['height'])) @@ -429,7 +428,6 @@ class pdf_squille extends ModelePdfReception $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 292e551a1eb..b2898c2fbac 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -389,7 +389,6 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 19986161413..362f17c7e9c 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -549,7 +549,6 @@ class pdf_stdmovement extends ModelePDFMovement $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index e1d6133ab39..26329ac889f 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -436,7 +436,6 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php index 25962f3b45d..6d3fe584eb3 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_cornas.modules.php @@ -529,7 +529,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -576,7 +575,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 60658bc8e59..5bad5b6be24 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -451,7 +451,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -504,7 +503,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 0d3f3569c56..836d7c04072 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -371,7 +371,6 @@ class pdf_standard extends ModelePDFSuppliersPayments $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 0bd15e86403..6b57a81af5a 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -436,7 +436,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } if (!empty($imglinesize['width']) && !empty($imglinesize['height'])) @@ -492,7 +491,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $showpricebeforepagebreak = 1; else $showpricebeforepagebreak = 0; - } } else // No pagebreak From 9f7b51938ff4361c98c457d5f77d7bb55749625e Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Tue, 28 Jan 2020 10:52:33 +0100 Subject: [PATCH 13/41] FIX: #12908 User login with credentials from self-subscription form fails --- htdocs/adherents/class/adherent.class.php | 34 +-- htdocs/user/class/user.class.php | 343 +++++++++++----------- 2 files changed, 189 insertions(+), 188 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4dbdb519831..0aa7bcbf6ea 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -641,7 +641,7 @@ class Adherent extends CommonObject $isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED)?0:1; // If password to set differs from the one found into database - $result=$this->setPassword($user, $this->pass, $this->pass_indatabase_crypted, $isencrypted, $notrigger, $nosyncuserpass); + $result=$this->setPassword($user, $this->pass, $isencrypted, $notrigger, $nosyncuserpass); if (! $nbrowsaffected) $nbrowsaffected++; } } @@ -964,9 +964,10 @@ class Adherent extends CommonObject * @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut) * @param int $notrigger 1=Ne declenche pas les triggers * @param int $nosyncuser Do not synchronize linked user + * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $password_indatabase_crypted = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0, $alreadyencrypted = 0) { global $conf, $langs; @@ -974,23 +975,22 @@ class Adherent extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted); - // If password_crypted not provided, try crypt password provided - if(!$password_indatabase_crypted) + // If new password not provided, we generate one + if (! $password) { - // If new password not provided, we generate one - if (!$password) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $password=getRandomPassword(false); - } - - // Crypt password - $password_crypted = dol_hash($password); - - } else { - $password_crypted = $password_indatabase_crypted; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $password=getRandomPassword(false); } + // Crypt password + if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); + else $password_crypted = $password; + + $password_indatabase = ''; + if (! $isencrypted) + { + $password_indatabase = $password; + } $this->db->begin(); @@ -1032,7 +1032,7 @@ class Adherent extends CommonObject if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, $this->pass_indatabase_crypted, 0, 0, 1); + $result=$luser->setPassword($user, $this->pass, 0, 0, 1, 1); if ($result < 0) { $this->error=$luser->error; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8809873acc6..98bc2a7c7b0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -75,34 +75,34 @@ class User extends CommonObject public $personal_email; - /** - * @var array array of socialnetworks - */ - public $socialnetworks; + /** + * @var array array of socialnetworks + */ + public $socialnetworks; - /** - * Skype username - * @var string - * @deprecated - */ + /** + * Skype username + * @var string + * @deprecated + */ public $skype; - /** - * Twitter username - * @var string - * @deprecated - */ + /** + * Twitter username + * @var string + * @deprecated + */ public $twitter; - /** - * Facebook username - * @var string - * @deprecated - */ + /** + * Facebook username + * @var string + * @deprecated + */ public $facebook; - /** - * Linkedin username - * @var string - * @deprecated - */ + /** + * Linkedin username + * @var string + * @deprecated + */ public $linkedin; public $job; // job position @@ -121,7 +121,7 @@ class User extends CommonObject public $office_phone; public $office_fax; public $user_mobile; - public $personal_mobile; + public $personal_mobile; public $admin; public $login; public $api_key; @@ -139,18 +139,18 @@ class User extends CommonObject public $pass_indatabase_crypted; /** - * Date creation record (datec) - * - * @var integer - */ - public $datec; + * Date creation record (datec) + * + * @var integer + */ + public $datec; /** - * Date modification record (tms) - * - * @var integer - */ - public $datem; + * Date modification record (tms) + * + * @var integer + */ + public $datem; //! If this is defined, it is an external user /** @@ -167,8 +167,8 @@ class User extends CommonObject public $contactid; /** - * @var int ID - */ + * @var int ID + */ public $fk_member; /** @@ -176,7 +176,7 @@ class User extends CommonObject */ public $fk_user; public $fk_user_expense_validator; - public $fk_user_holiday_validator; + public $fk_user_holiday_validator; public $clicktodial_url; public $clicktodial_login; @@ -222,10 +222,10 @@ class User extends CommonObject public $fk_warehouse; public $fields = array( - 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - ); + 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + ); const STATUS_DISABLED = 0; @@ -391,7 +391,7 @@ class User extends CommonObject $this->office_phone = $obj->office_phone; $this->office_fax = $obj->office_fax; $this->user_mobile = $obj->user_mobile; - $this->personal_mobile = $obj->personal_mobile; + $this->personal_mobile = $obj->personal_mobile; $this->email = $obj->email; $this->personal_email = $obj->personal_email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -427,8 +427,8 @@ class User extends CommonObject $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->fk_user_expense_validator = $obj->fk_user_expense_validator; - $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; + $this->fk_user_expense_validator = $obj->fk_user_expense_validator; + $this->fk_user_holiday_validator = $obj->fk_user_holiday_validator; $this->default_range = $obj->default_range; $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; @@ -1032,7 +1032,7 @@ class User extends CommonObject * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs - * @return void + * @return void */ public function setCategories($categories) { @@ -1122,24 +1122,24 @@ class User extends CommonObject // Remove extrafields if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result = $this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } // Remove user if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if (!$this->db->query($sql)) - { - $error++; - $this->error = $this->db->lasterror(); - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + if (!$this->db->query($sql)) + { + $error++; + $this->error = $this->db->lasterror(); + } } if (!$error) @@ -1180,7 +1180,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->login = trim($this->login); if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value @@ -1302,7 +1302,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1313,7 +1313,7 @@ class User extends CommonObject */ public function create_from_contact($contact, $login = '', $password = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; $error = 0; @@ -1381,7 +1381,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1391,7 +1391,7 @@ class User extends CommonObject */ public function create_from_member($member, $login = '') { - // phpcs:enable + // phpcs:enable global $conf, $user, $langs; // Positionne parametres @@ -1418,7 +1418,9 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - $newpass = $this->setPassword($user, $this->pass, $this->pass_indatabase_crypted); + if(!$this->pass && $this->pass_indatabase_crypted) $newpass = $this->setPassword($user, $this->pass_indatabase_crypted, 0, 0, 0, 1); + else $newpass = $this->setPassword($user, $this->pass); + if (is_numeric($newpass) && $newpass < 0) $result = -2; if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty @@ -1457,7 +1459,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * @@ -1465,7 +1467,7 @@ class User extends CommonObject */ public function set_default_rights() { - // phpcs:enable + // phpcs:enable global $conf; $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def"; @@ -1524,7 +1526,7 @@ class User extends CommonObject if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = ucwords($this->lastname); if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = strtoupper($this->lastname); - if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); + if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords($this->firstname); $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); @@ -1542,9 +1544,9 @@ class User extends CommonObject $this->office_phone = trim($this->office_phone); $this->office_fax = trim($this->office_fax); $this->user_mobile = trim($this->user_mobile); - $this->personal_mobile = trim($this->personal_mobile); + $this->personal_mobile = trim($this->personal_mobile); $this->email = trim($this->email); - $this->personal_email = trim($this->personal_email); + $this->personal_email = trim($this->personal_email); $this->job = trim($this->job); $this->signature = trim($this->signature); @@ -1595,10 +1597,10 @@ class User extends CommonObject $sql .= ", office_phone = '".$this->db->escape($this->office_phone)."'"; $sql .= ", office_fax = '".$this->db->escape($this->office_fax)."'"; $sql .= ", user_mobile = '".$this->db->escape($this->user_mobile)."'"; - $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; + $sql .= ", personal_mobile = '".$this->db->escape($this->personal_mobile)."'"; $sql .= ", email = '".$this->db->escape($this->email)."'"; - $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; - $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; + $sql .= ", personal_email = '".$this->db->escape($this->personal_email)."'"; + $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", job = '".$this->db->escape($this->job)."'"; $sql .= ", signature = '".$this->db->escape($this->signature)."'"; $sql .= ", accountancy_code = '".$this->db->escape($this->accountancy_code)."'"; @@ -1610,8 +1612,8 @@ class User extends CommonObject $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null"); $sql .= ", openid = ".($this->openid ? "'".$this->db->escape($this->openid)."'" : "null"); $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".$this->db->escape($this->fk_user)."'" : "null"); - $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); - $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); + $sql .= ", fk_user_expense_validator = ".($this->fk_user_expense_validator > 0 ? "'".$this->db->escape($this->fk_user_expense_validator)."'" : "null"); + $sql .= ", fk_user_holiday_validator = ".($this->fk_user_holiday_validator > 0 ? "'".$this->db->escape($this->fk_user_holiday_validator)."'" : "null"); if (isset($this->thm) || $this->thm != '') $sql .= ", thm= ".($this->thm != '' ? "'".$this->db->escape($this->thm)."'" : "null"); if (isset($this->tjm) || $this->tjm != '') $sql .= ", tjm= ".($this->tjm != '' ? "'".$this->db->escape($this->tjm)."'" : "null"); if (isset($this->salary) || $this->salary != '') $sql .= ", salary= ".($this->salary != '' ? "'".$this->db->escape($this->salary)."'" : "null"); @@ -1811,7 +1813,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion @@ -1820,7 +1822,7 @@ class User extends CommonObject */ public function update_last_login_date() { - // phpcs:enable + // phpcs:enable $now = dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; @@ -1853,9 +1855,10 @@ class User extends CommonObject * @param int $changelater 1=Change password only after clicking on confirm email * @param int $notrigger 1=Does not launch triggers * @param int $nosyncmember Do not synchronize linked member + * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $password_indatabase_crypted = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $alreadyencrypted = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1864,21 +1867,15 @@ class User extends CommonObject dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG); - // If password_crypted not provided, try crypt password provided - if(!$password_indatabase_crypted) + // If new password not provided, we generate one + if (!$password) { - // If new password not provided, we generate one - if (!$password) - { - $password = getRandomPassword(false); - } - - // Crypt password - $password_crypted = dol_hash($password); - } else { - $password_crypted = $password_indatabase_crypted; + $password = getRandomPassword(false); } + // Crypt password + if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); + else $password_crypted = $password; // Mise a jour @@ -1922,7 +1919,11 @@ class User extends CommonObject if ($result >= 0) { - $result = $adh->setPassword($user, $this->pass, $this->pass_indatabase_crypted, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + + if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent + else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted + + if ($result < 0) { $this->error = $adh->error; @@ -1986,7 +1987,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1997,7 +1998,7 @@ class User extends CommonObject */ public function send_password($user, $password = '', $changelater = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs; global $dolibarr_main_url_root; @@ -2011,19 +2012,19 @@ class User extends CommonObject $outputlangs = new Translate("", $conf); if (isset($this->conf->MAIN_LANG_DEFAULT) - && $this->conf->MAIN_LANG_DEFAULT != 'auto') + && $this->conf->MAIN_LANG_DEFAULT != 'auto') { // If user has defined its own language (rare because in most cases, auto is used) $outputlangs->getDefaultLang($this->conf->MAIN_LANG_DEFAULT); } if ($user->conf->MAIN_LANG_DEFAULT) { - $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); - } + $outputlangs->setDefaultLang($user->conf->MAIN_LANG_DEFAULT); + } else { // If user has not defined its own language, we used current language $outputlangs = $langs; } - // Load translation files required by the page + // Load translation files required by the page $outputlangs->loadLangs(array("main", "errors", "users", "other")); $appli = constant('DOL_APPLICATION_TITLE'); @@ -2066,8 +2067,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } - $mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -2077,8 +2078,8 @@ class User extends CommonObject '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2103,7 +2104,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * @@ -2111,7 +2112,7 @@ class User extends CommonObject */ public function fetch_clicktodial() { - // phpcs:enable + // phpcs:enable $sql = "SELECT url, login, pass, poste "; $sql .= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u"; $sql .= " WHERE u.fk_user = ".$this->id; @@ -2141,15 +2142,15 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return int <0 if KO, >0 if OK - */ - public function update_clicktodial() - { - // phpcs:enable + */ + public function update_clicktodial() + { + // phpcs:enable $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial"; @@ -2179,10 +2180,10 @@ class User extends CommonObject $this->error = $this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2193,7 +2194,7 @@ class User extends CommonObject */ public function SetInGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2244,7 +2245,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2255,7 +2256,7 @@ class User extends CommonObject */ public function RemoveFromGroup($group, $entity, $notrigger = 0) { - // phpcs:enable + // phpcs:enable global $conf, $langs, $user; $error = 0; @@ -2342,7 +2343,7 @@ class User extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; + if (!$user->rights->user->user->lire && $user->id != $this->id) $option = 'nolink'; if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg = 0; @@ -2436,8 +2437,8 @@ class User extends CommonObject $result .= (($option == 'nolink') ? '' : $linkstart); if ($withpictoimg) { - $paddafterimage = ''; - if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; + $paddafterimage = ''; + if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-'.($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right').': 3px;"'; // Only picto if ($withpictoimg > 0) $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; // Picto must be a photo @@ -2491,7 +2492,7 @@ class User extends CommonObject $linkend = ''; } - if ($option == 'nolink') + if ($option == 'nolink') { $linkstart = ''; $linkend = ''; @@ -2515,17 +2516,17 @@ class User extends CommonObject return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return label of a status of user (active, inactive) - * - * @param int $status Id status + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of a status of user (active, inactive) + * + * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable global $langs; if (empty($this->labelStatus) || empty($this->labelStatusShort)) @@ -2558,7 +2559,7 @@ class User extends CommonObject */ public function _load_ldap_dn($info, $mode = 0) { - // phpcs:enable + // phpcs:enable global $conf; $dn = ''; if ($mode == 0) $dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN; @@ -2576,7 +2577,7 @@ class User extends CommonObject */ public function _load_ldap_info() { - // phpcs:enable + // phpcs:enable global $conf, $langs; $info = array(); @@ -2602,7 +2603,7 @@ class User extends CommonObject 'LDAP_FIELD_SKYPE' => 'skype', 'LDAP_FIELD_TWITTER' => 'twitter', 'LDAP_FIELD_FACEBOOK' => 'facebook', - 'LDAP_FIELD_LINKEDIN' => 'linkedin' + 'LDAP_FIELD_LINKEDIN' => 'linkedin' ); // Champs @@ -2686,22 +2687,22 @@ class User extends CommonObject if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; } - if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; - if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { - $usergroup = new UserGroup($this->db); - $groupslist = $usergroup->listGroupsForUser($this->id); - $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; - if (!empty($groupslist)) { - foreach ($groupslist as $groupforuser) { - $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list - break; - } - } - } - if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; + if (!empty($conf->global->LDAP_FIELD_USERID))$info[$conf->global->LDAP_FIELD_USERID] = $this->id; + if (!empty($info[$conf->global->LDAP_FIELD_GROUPID])) { + $usergroup = new UserGroup($this->db); + $groupslist = $usergroup->listGroupsForUser($this->id); + $info[$conf->global->LDAP_FIELD_GROUPID] = '1'; + if (!empty($groupslist)) { + foreach ($groupslist as $groupforuser) { + $info[$conf->global->LDAP_FIELD_GROUPID] = $groupforuser->id; //Select first group in list + break; + } + } + } + if (!empty($this->firstname) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORY) && !empty($conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX)) $info[$conf->global->LDAP_FIELD_HOMEDIRECTORY] = "{$conf->global->LDAP_FIELD_HOMEDIRECTORYPREFIX}/$this->firstname"; - return $info; - } + return $info; + } /** @@ -2728,7 +2729,7 @@ class User extends CommonObject $this->note_public = 'This is a note public'; $this->note_private = 'This is a note private'; $this->email = 'email@specimen.com'; - $this->personal_email = 'personalemail@specimen.com'; + $this->personal_email = 'personalemail@specimen.com'; $this->socialnetworks = array( 'skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', @@ -2738,7 +2739,7 @@ class User extends CommonObject $this->office_phone = '0999999999'; $this->office_fax = '0999999998'; $this->user_mobile = '0999999997'; - $this->personal_mobile = '0999999996'; + $this->personal_mobile = '0999999996'; $this->admin = 0; $this->login = 'dolibspec'; $this->pass = 'dolibspec'; @@ -2863,7 +2864,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2872,7 +2873,7 @@ class User extends CommonObject */ public function update_ldap2dolibarr(&$ldapuser) { - // phpcs:enable + // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) global $user, $conf; @@ -2903,7 +2904,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * @@ -2912,7 +2913,7 @@ class User extends CommonObject */ public function get_children() { - // phpcs:enable + // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; $sql .= " WHERE fk_user = ".$this->id; @@ -2971,7 +2972,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the hierarchy/tree of users into an array. * Set and return this->users that is an array sorted according to tree with arrays of: @@ -2985,9 +2986,9 @@ class User extends CommonObject * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - public function get_full_tree($deleteafterid = 0, $filter = '') - { - // phpcs:enable + public function get_full_tree($deleteafterid = 0, $filter = '') + { + // phpcs:enable global $conf, $user; global $hookmanager; @@ -3087,8 +3088,8 @@ class User extends CommonObject * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children() */ - public function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids = array(); if (isset($this->cache_childids[$this->id])) @@ -3116,7 +3117,7 @@ class User extends CommonObject return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3125,9 +3126,9 @@ class User extends CommonObject * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - public function build_path_from_id_user($id_user, $protection = 0) - { - // phpcs:enable + public function build_path_from_id_user($id_user, $protection = 0) + { + // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); if (!empty($this->users[$id_user]['fullpath'])) @@ -3180,7 +3181,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load metrics this->nb for dashboard * @@ -3188,7 +3189,7 @@ class User extends CommonObject */ public function load_state_board() { - // phpcs:enable + // phpcs:enable $this->nb = array(); @@ -3224,7 +3225,7 @@ class User extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information + * @param null|array $moreparams Array to provide more information * @return int 0 if KO, 1 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) @@ -3251,7 +3252,7 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3261,7 +3262,7 @@ class User extends CommonObject */ public function user_get_property($rowid, $mode) { - // phpcs:enable + // phpcs:enable $user_property = ''; if (empty($rowid)) return ''; @@ -3303,8 +3304,8 @@ class User extends CommonObject * @return int <0 if KO, >0 if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND', $entityfilter = false) - { - global $conf, $user; + { + global $conf, $user; $sql = "SELECT t.rowid"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t '; @@ -3379,8 +3380,8 @@ class User extends CommonObject } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } From ae95cc68690e44957dc3245fb647918931411142 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 28 Jan 2020 10:00:14 +0000 Subject: [PATCH 14/41] Fixing style errors. --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 98bc2a7c7b0..af23dca5e96 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1919,7 +1919,6 @@ class User extends CommonObject if ($result >= 0) { - if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted From cc09257fcde9ff177a1b07ee0986606566e2158c Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 3 Feb 2020 10:04:58 +0100 Subject: [PATCH 15/41] Withdrawing changes --- htdocs/adherents/class/adherent.class.php | 8 +++----- htdocs/user/class/user.class.php | 17 ++++------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0aa7bcbf6ea..ec4042cdf88 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -964,10 +964,9 @@ class Adherent extends CommonObject * @param int $isencrypted 0 ou 1 si il faut crypter le mot de passe en base (0 par defaut) * @param int $notrigger 1=Ne declenche pas les triggers * @param int $nosyncuser Do not synchronize linked user - * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0, $alreadyencrypted = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -983,8 +982,7 @@ class Adherent extends CommonObject } // Crypt password - if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); - else $password_crypted = $password; + $password_crypted = dol_hash($password); $password_indatabase = ''; if (! $isencrypted) @@ -1032,7 +1030,7 @@ class Adherent extends CommonObject if ($result >= 0) { - $result=$luser->setPassword($user, $this->pass, 0, 0, 1, 1); + $result=$luser->setPassword($user, $this->pass, 0, 0, 1); if ($result < 0) { $this->error=$luser->error; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index af23dca5e96..9bfe66d9dec 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1402,7 +1402,6 @@ class User extends CommonObject $this->email = $member->email; $this->fk_member = $member->id; $this->pass = $member->pass; - $this->pass_indatabase_crypted = $member->pass_indatabase_crypted; $this->address = $member->address; $this->zip = $member->zip; $this->town = $member->town; @@ -1418,9 +1417,7 @@ class User extends CommonObject $result = $this->create($user); if ($result > 0) { - if(!$this->pass && $this->pass_indatabase_crypted) $newpass = $this->setPassword($user, $this->pass_indatabase_crypted, 0, 0, 0, 1); - else $newpass = $this->setPassword($user, $this->pass); - + $newpass = $this->setPassword($user, $this->pass); if (is_numeric($newpass) && $newpass < 0) $result = -2; if ($result > 0 && $member->fk_soc) // If member is linked to a thirdparty @@ -1855,10 +1852,9 @@ class User extends CommonObject * @param int $changelater 1=Change password only after clicking on confirm email * @param int $notrigger 1=Does not launch triggers * @param int $nosyncmember Do not synchronize linked member - * @param int $alreadyencrypted 1 = password is already encrypted (0 by default) * @return string If OK return clear password, 0 if no change, < 0 if error */ - public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0, $alreadyencrypted = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -1874,9 +1870,7 @@ class User extends CommonObject } // Crypt password - if ($alreadyencrypted != 1) $password_crypted = dol_hash($password); - else $password_crypted = $password; - + $password_crypted = dol_hash($password); // Mise a jour if (!$changelater) @@ -1919,10 +1913,7 @@ class User extends CommonObject if ($result >= 0) { - if ($alreadyencrypted != 1) $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent - else $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1, 0, 1); // Dont encrypt the password cause is already encrypted - - + $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent if ($result < 0) { $this->error = $adh->error; From bc3a210d12add514e6f96f1ec61bef5f6bd2a995 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 3 Feb 2020 11:46:18 +0100 Subject: [PATCH 16/41] FIX compatibility with multicompany (avoid duplicate data) --- htdocs/holiday/class/holiday.class.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 66a118c744b..1e3567549a9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1658,19 +1658,19 @@ class Holiday extends CommonObject { // Si utilisateur de Dolibarr - $sql = "SELECT u.rowid"; + $sql = "SELECT DISTINCT u.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; + $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " OR u.entity = 0)"; // Show always superadmin } else { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE u.entity IN (".getEntity('user').")"; } $sql.= " AND u.statut > 0"; if ($filters) $sql.=$filters; @@ -1754,18 +1754,20 @@ class Holiday extends CommonObject // List for Dolibarr users if ($type) { - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; - $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; + $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " OR u.entity = 0)"; // Show always superadmin } else - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + { + $sql.= " WHERE u.entity IN (".getEntity('user').")"; + } $sql.= " AND u.statut > 0"; if ($filters) $sql.=$filters; From e74e63941d6914241a60d5855a891cda1d9a14e8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 3 Feb 2020 11:55:55 +0100 Subject: [PATCH 17/41] FIX use "usergroup" instead "user" --- htdocs/holiday/class/holiday.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1e3567549a9..31723379314 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1665,7 +1665,7 @@ class Holiday extends CommonObject { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = u.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; $sql.= " OR u.entity = 0)"; // Show always superadmin } else @@ -1761,7 +1761,7 @@ class Holiday extends CommonObject { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = u.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; $sql.= " OR u.entity = 0)"; // Show always superadmin } else From eb5ac0d9a9c53cf6f3d343c802f660a2ec541e45 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 3 Feb 2020 14:28:57 +0100 Subject: [PATCH 18/41] fix url field in edit mode societe/card.php --- htdocs/societe/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b6bef4473f3..ab8256f6473 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1988,7 +1988,7 @@ else print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).''; print ''; print ''.img_picto('', 'globe').' '.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).''; - print ''; + print ''; if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { From 36461afea95663b573f0c9287ef8ef1faaa13807 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 14:54:35 +0100 Subject: [PATCH 19/41] FIX Creation of Stripe card from backoffice must return a clean message --- htdocs/langs/en_US/stripe.lang | 1 + htdocs/societe/paymentmodes.php | 6 ++-- htdocs/stripe/class/stripe.class.php | 47 +++++++++++++++++++++------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/htdocs/langs/en_US/stripe.lang b/htdocs/langs/en_US/stripe.lang index cfc0620db5c..5541250d9a6 100644 --- a/htdocs/langs/en_US/stripe.lang +++ b/htdocs/langs/en_US/stripe.lang @@ -68,3 +68,4 @@ ToOfferALinkForTestWebhook=Link to setup Stripe WebHook to call the IPN (test mo ToOfferALinkForLiveWebhook=Link to setup Stripe WebHook to call the IPN (live mode) PaymentWillBeRecordedForNextPeriod=Payment will be recorded for the next period. ClickHereToTryAgain=Click here to try again... +CreationOfPaymentModeMustBeDoneFromStripeInterface=Due to Strong Customer Authenticatin rules, creation of a card must be done from Stripe backoffice. You can click here to switch on Stripe customer record: %s \ No newline at end of file diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 1952fb8304c..21602dae3c4 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -546,16 +546,14 @@ if (empty($reshook)) if (!$error) { // Creation of Stripe card + update of societe_account + // Note that with the new Stripe API, option to create a card is no more available, instead an error message will be returned to + // ask to create the crdit card from Stripe backoffice. $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); if (!$card) { $error++; setEventMessages($stripe->error, $stripe->errors, 'errors'); } - else - { - $stripecard = $card->id; - } } } } diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 931cfbfa83e..f5656387192 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -680,18 +680,18 @@ class Stripe extends CommonObject /** - * Get the Stripe card of a company payment mode (with option to create it on Stripe if not linked yet) + * Get the Stripe card of a company payment mode (option to create it on Stripe if not linked yet is no more available on new Stripe API) * * @param \Stripe\StripeCustomer $cu Object stripe customer * @param CompanyPaymentMode $object Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity) * @param string $stripeacc ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect * @param int $status Status (0=test, 1=live) - * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card + * @param int $createifnotlinkedtostripe 1=Create the stripe card and the link if the card is not yet linked to a stripe card. Deprecated with new Stripe API and SCA. * @return \Stripe\StripeCard|\Stripe\PaymentMethod|null Stripe Card or null if not found */ public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0) { - global $conf, $user; + global $conf, $user, $langs; $card = null; @@ -754,27 +754,54 @@ class Stripe extends CommonObject //$a = \Stripe\Stripe::getApiKey(); //var_dump($a);var_dump($stripeacc);exit; - dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard); + if (! $card) + { + $this->error = 'Creation of card on Stripe has failed'; + } } else { - // TODO - dol_syslog("Error: This case is not supported", LOG_ERR); + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; + if ($status) + { + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; + } + $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + + //dol_syslog("Error: This case is not supported", LOG_ERR); + $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe); } } else { if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION)) { + dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard)); $card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc)); + if (! $card) + { + $this->error = 'Creation of card on Stripe has failed'; + } } else { - // TODO - dol_syslog("Error: This case is not supported", LOG_ERR); + $connect = ''; + if (!empty($stripeacc)) $connect = $stripeacc.'/'; + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$cu->id; + if ($status) + { + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$cu->id; + } + $urtoswitchonstripe = ' '.img_picto($langs->trans('ShowInStripe'), 'globe').''; + + //dol_syslog("Error: This case is not supported", LOG_ERR); + $this->error = $langs->trans('CreationOfPaymentModeMustBeDoneFromStripeInterface', $urtoswitchonstripe); } } @@ -792,10 +819,6 @@ class Stripe extends CommonObject $this->error = $this->db->lasterror(); } } - else - { - $this->error = 'Call to cu->source->create return empty card'; - } } catch (Exception $e) { From d4ae8b81e4d461bcce675a30a79ee6e11d94a560 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 20:49:21 +0100 Subject: [PATCH 20/41] Card examples --- htdocs/stripe/admin/stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index c26f1ea709c..838cc5ca37a 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -467,7 +467,7 @@ $token = ''; include DOL_DOCUMENT_ROOT.'/core/tpl/onlinepaymentlinks.tpl.php'; -print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000000000003220 (3DSecure2 required)', '4000000000000101', '4000000000000069', '4000000000000341')); +print info_admin($langs->trans("ExampleOfTestCreditCard", '4242424242424242 (no 3DSecure) or 4000000000003063 (3DSecure required) or 4000002760003184 (3DSecure2 required on all transaction) or 4000003800000446 (3DSecure2 required the off-seesion allowed)', '4000000000000101', '4000000000000069', '4000000000000341')); if (!empty($conf->use_javascript_ajax)) { From c367c6f34eb12ab9bdab6bb8a370a891353b9268 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 Feb 2020 21:17:45 +0100 Subject: [PATCH 21/41] Avoid warning --- htdocs/core/tpl/extrafields_list_search_param.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_list_search_param.tpl.php b/htdocs/core/tpl/extrafields_list_search_param.tpl.php index ca72293365a..6e6d6305106 100644 --- a/htdocs/core/tpl/extrafields_list_search_param.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_param.tpl.php @@ -8,7 +8,7 @@ if (empty($conf) || !is_object($conf)) } // Loop to complete $param for extrafields -if (!empty($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... +if (!empty($search_array_options) && is_array($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... { if (empty($search_options_pattern)) $search_options_pattern = 'search_options_'; From d93a597a1eb62db89392aa44b79b73ba19e7c6bb Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 4 Feb 2020 09:17:02 +0100 Subject: [PATCH 22/41] Fix Compatbility with Multicompany Before : Show all projects of all entities Now : Show only projects that are allowed by permissions --- htdocs/core/boxes/box_project.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index e7281708802..5e06e154987 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -3,6 +3,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Frederic France * Copyright (C) 2016 Juan José Menent + * Copyright (C) 2020 Pierre Ardoin * * 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 @@ -99,6 +100,7 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects + $sql .= " AND entity IN (".getEntity('projet').")"; // Only current entity or severals if permission ok if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; From bb9f4c8ec38d491acd1448811a1bf1179e518c92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Feb 2020 14:34:40 +0100 Subject: [PATCH 23/41] Fix var_dump --- htdocs/mrp/class/mo.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a87ab150070..2f364c359fa 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -513,7 +513,6 @@ class Mo extends CommonObject return $resarray; } else { $this->error = $this->db->lasterror(); - var_dump($this->error); return array(); } } From c5da131749add87d34156ae21701373616cf97b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Feb 2020 14:40:11 +0100 Subject: [PATCH 24/41] Fix param not defined --- htdocs/mrp/class/mo.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 2f364c359fa..e677c64efc0 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -558,9 +558,10 @@ class Mo extends CommonObject * Erase and update the line to produce. * * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, >0 if OK */ - public function updateProduction(User $user) + public function updateProduction(User $user, $notrigger = true) { $error = 0; @@ -592,7 +593,7 @@ class Mo extends CommonObject $moline->role = 'toproduce'; $moline->position = 1; - $resultline = $moline->create($user); + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -624,7 +625,7 @@ class Mo extends CommonObject $moline->qty_frozen = $line->qty_frozen; $moline->disable_stock_change = $line->disable_stock_change; - $resultline = $moline->create($user); + $resultline = $moline->create($user, false); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; From af7a5b510d6706fb6ad6e7c70b13f5d424fde49d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Feb 2020 14:47:30 +0100 Subject: [PATCH 25/41] Fix phpcs --- htdocs/compta/cashcontrol/cashcontrol_card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 4c60434619a..8e83e6a33a4 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -345,7 +345,8 @@ if ($action == "create" || $action == "start") print ''; $array = array(); - for($i = 1; $i <= max(1, $conf->global->TAKEPOS_NUM_TERMINALS); $i++) { + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for($i = 1; $i <= $numterminals; $i++) { $array[$i] = $i; } $selectedposnumber = 0; $showempty = 1; From 0b891d5e0cc7251595e0b757b1bd5fb7af4390ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 4 Feb 2020 19:33:20 +0100 Subject: [PATCH 26/41] FIX Count of Stripe payment mode must take test/live into account --- htdocs/core/lib/company.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index f108c5cc04f..3f7536368f1 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -208,6 +208,8 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; $sql .= " WHERE fk_soc = ".$object->id; + $sql .= " AND status = ".$servicestatus; + $resql = $db->query($sql); if ($resql) { From 262d889700ac6fb2fb149c149799ccfedcce133e Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 5 Feb 2020 08:50:51 +0100 Subject: [PATCH 27/41] Update box_project.php --- htdocs/core/boxes/box_project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 5e06e154987..d3670d05ee1 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -100,7 +100,7 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects - $sql .= " AND entity IN (".getEntity('projet').")"; // Only current entity or severals if permission ok + $sql .= " AND entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; From d5b74a8ca3d1fc210c0d60160cf8e2d42415f125 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 5 Feb 2020 09:06:43 +0100 Subject: [PATCH 28/41] Update box_project.php --- htdocs/core/boxes/box_project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index d3670d05ee1..ca9618aab9a 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -100,7 +100,7 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects - $sql .= " AND entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " WHERE entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; From 81ed70ffc7ac61844088e1e664324e5fdacb8e78 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Wed, 5 Feb 2020 09:18:39 +0100 Subject: [PATCH 29/41] Update box_project.php --- htdocs/core/boxes/box_project.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index ca9618aab9a..071e4b013ec 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -99,8 +99,8 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE p.fk_statut = 1"; // Only open projects - $sql.= " WHERE entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " WHERE entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " AND p.fk_statut = 1"; // Only open projects if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; From c3cf9e62b3bad4145fa1f145f9863e84c2b046df Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 5 Feb 2020 11:31:02 +0100 Subject: [PATCH 30/41] FIX links in products/services index --- htdocs/product/index.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index caeb5e5d873..246d50e5c3e 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -143,31 +143,31 @@ print ''.$langs->trans("Statistics").'product->enabled)) { $statProducts = ''; - $statProducts.= ''.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).''; + $statProducts.= ''.$langs->trans("ProductsNotOnSell").''.round($prodser[0][0]).''; $statProducts.= ""; $statProducts.= ''; - $statProducts.= ''.$langs->trans("ProductsOnSaleOnly").''.round($prodser[0][1]).''; + $statProducts.= ''.$langs->trans("ProductsOnSaleOnly").''.round($prodser[0][1]).''; $statProducts.= ""; $statProducts.= ''; - $statProducts.= ''.$langs->trans("ProductsOnPurchaseOnly").''.round($prodser[0][2]).''; + $statProducts.= ''.$langs->trans("ProductsOnPurchaseOnly").''.round($prodser[0][2]).''; $statProducts.= ""; $statProducts.= ''; - $statProducts.= ''.$langs->trans("ProductsOnSellAndOnBuy").''.round($prodser[0][3]).''; + $statProducts.= ''.$langs->trans("ProductsOnSellAndOnBuy").''.round($prodser[0][3]).''; $statProducts.= ""; } if (! empty($conf->service->enabled)) { $statServices = ''; - $statServices.= ''.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).''; + $statServices.= ''.$langs->trans("ServicesNotOnSell").''.round($prodser[1][0]).''; $statServices.= ""; $statServices.= ''; - $statServices.= ''.$langs->trans("ServicesOnSaleOnly").''.round($prodser[1][1]).''; + $statServices.= ''.$langs->trans("ServicesOnSaleOnly").''.round($prodser[1][1]).''; $statServices.= ""; $statServices.= ''; - $statServices.= ''.$langs->trans("ServicesOnPurchaseOnly").''.round($prodser[1][2]).''; + $statServices.= ''.$langs->trans("ServicesOnPurchaseOnly").''.round($prodser[1][2]).''; $statServices.= ""; $statServices.= ''; - $statServices.= ''.$langs->trans("ServicesOnSellAndOnBuy").''.round($prodser[1][3]).''; + $statServices.= ''.$langs->trans("ServicesOnSellAndOnBuy").''.round($prodser[1][3]).''; $statServices.= ""; } $total=0; From 94fd2b40c73448181ea035907f8fc9f7f09e5e8e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 5 Feb 2020 12:04:27 +0100 Subject: [PATCH 31/41] new fix Count of Stripe payment mode must take test/live into account fix error message for if no stripe enabled https://github.com/Dolibarr/dolibarr/commit/0b891d5e0cc7251595e0b757b1bd5fb7af4390ff --- htdocs/core/lib/company.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 3f7536368f1..30fad0b9f8f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -207,8 +207,8 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; - $sql .= " WHERE fk_soc = ".$object->id; - $sql .= " AND status = ".$servicestatus; + $sql .= " WHERE n.fk_soc = ".$object->id; + if (!empty($conf->stripe->enabled)) $sql .= " AND n.status = ".$servicestatus; $resql = $db->query($sql); if ($resql) From efcd4d0c632c0e792ac70370e4b0fa2c001fdb45 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Tue, 4 Feb 2020 09:00:31 +0100 Subject: [PATCH 32/41] Fix unset gender property in contact class --- htdocs/contact/class/contact.class.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 56ba2e24def..465dc4a1e16 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -988,19 +988,25 @@ class Contact extends CommonObject } + /** - * Set property ->gender from property ->civility_id + * Set the property "gender" of this class, based on the property "civility_id" + * or use property "civility_code" as fallback, when "civility_id" is not available. * * @return void */ public function setGenderFromCivility() { - unset($this->gender); - if (in_array($this->civility_id, array('MR'))) { - $this->gender = 'man'; - } elseif (in_array($this->civility_id, array('MME', 'MLE'))) { - $this->gender = 'woman'; - } + unset($this->gender); + + if (in_array($this->civility_id, array('MR')) || in_array($this->civility_code, array('MR'))) + { + $this->gender = 'man'; + } + elseif(in_array($this->civility_id, array('MME','MLE')) || in_array($this->civility_code, array('MME','MLE'))) + { + $this->gender = 'woman'; + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From 63ba601906cb9e0fda349dd06f0968bc48f3330b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 12:39:00 +0100 Subject: [PATCH 33/41] Update box_project.php --- htdocs/core/boxes/box_project.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 071e4b013ec..9b3920590d2 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -99,7 +99,7 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " WHERE entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok + $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok $sql.= " AND p.fk_statut = 1"; // Only open projects if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users From f8daed7f565b08c4bae34d544adda7d075a05068 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 12:49:56 +0100 Subject: [PATCH 34/41] Update company.lib.php --- htdocs/core/lib/company.lib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 30fad0b9f8f..2e5583610db 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -208,8 +208,12 @@ function societe_prepare_head(Societe $object) $sql = "SELECT COUNT(n.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_rib as n"; $sql .= " WHERE n.fk_soc = ".$object->id; - if (!empty($conf->stripe->enabled)) $sql .= " AND n.status = ".$servicestatus; - + if (empty($conf->stripe->enabled)) { + $sql .= " AND n.stripe_card_ref IS NULL"; + } else { + $sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".$servicestatus."))"; + } + $resql = $db->query($sql); if ($resql) { From d35994e5db1a79ddea4babe94f466589f8b8a69a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 13:25:51 +0100 Subject: [PATCH 35/41] Update holiday.class.php --- htdocs/holiday/class/holiday.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 31723379314..78210d08bc9 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1656,9 +1656,12 @@ class Holiday extends CommonObject { if ($type) { - // Si utilisateur de Dolibarr - - $sql = "SELECT DISTINCT u.rowid"; + // If user of Dolibarr + $sql = "SELECT"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql .= " DISTINCT"; + } + $sql.= " u.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) From c101c3dd55ec96f86e23c29618f6a1c4e0ef05ad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 13:27:22 +0100 Subject: [PATCH 36/41] Update holiday.class.php --- htdocs/holiday/class/holiday.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 78210d08bc9..04ccf239766 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1757,7 +1757,12 @@ class Holiday extends CommonObject // List for Dolibarr users if ($type) { - $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + // If user of Dolibarr + $sql = "SELECT"; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql .= " DISTINCT"; + } + $sql = " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) From 9100b8a5486857f964b577e9c81d612ea6253317 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 13:41:10 +0100 Subject: [PATCH 37/41] FIX SQL request and phpunit --- htdocs/holiday/class/holiday.class.php | 2 +- test/phpunit/HolidayTest.php | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 66a118c744b..0c058313ad6 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1712,7 +1712,7 @@ class Holiday extends CommonObject // We want only list of vacation balance for user ids $sql = "SELECT DISTINCT cpu.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; - $sql.= " WHERE cpu.fk_user = u.user"; + $sql.= " WHERE cpu.fk_user = u.rowid"; if ($filters) $sql.=$filters; $resql=$this->db->query($sql); diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index ce3312ba441..190496cf5bf 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -247,21 +247,17 @@ class HolidayTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; - //$localobject->fetch($localobject->id); + $result = $localobject->fetchUsers(true, true, ''); + $this->assertNotEquals($result, -1); - /* - $result=$localobject->getNomUrl(1); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertNotEquals($result, ''); + $result = $localobject->fetchUsers(true, false, ''); + $this->assertNotEquals($result, -1); - $result=$localobject->getFullAddress(1); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $result = $localobject->fetchUsers(false, true, ''); + $this->assertNotEquals($result, -1); - $localobject->info($localobject->id); - print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; - $this->assertNotEquals($localobject->date_creation, ''); - */ + $result = $localobject->fetchUsers(false, false, ''); + $this->assertNotEquals($result, -1); return $localobject->id; } From a36cf1f86beb63cfe5bda715885bc06bce8ebfd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 14:08:13 +0100 Subject: [PATCH 38/41] Fix phpunit --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1bbeb869995..25f1d9675bb 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1762,7 +1762,7 @@ class Holiday extends CommonObject if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " DISTINCT"; } - $sql = " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; + $sql.= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) From 220f02805d0f8a9cc2b0062bff527e131f96c56e Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sun, 2 Feb 2020 21:02:43 +0100 Subject: [PATCH 39/41] Update image path after move image directory We need change path after move image in the commit: https://github.com/Dolibarr/dolibarr/commit/de4183ea6552e917ac33f8416f784340966f2a8d#diff-7af3f43d430a17d6e548d766fbacecc2 Conflicts: htdocs/core/class/dolreceiptprinter.class.php --- htdocs/core/class/dolreceiptprinter.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 1d445614981..ba46419d39c 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -514,7 +514,7 @@ class dolReceiptPrinter extends Printer { global $conf; $error = 0; - $img = EscposImage::load(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png'); + $img = EscposImage::load(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo_bw.png'); //$this->profile = CapabilityProfile::load("TM-T88IV"); $ret = $this->initPrinter($printerid); if ($ret>0) { From c015707cbc0add5467044cbfd87d37240eb3aa3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 14:14:59 +0100 Subject: [PATCH 40/41] Fix Only dolibarr logos are in root of theme --- htdocs/core/lib/security2.lib.php | 2 +- htdocs/core/lib/ticket.lib.php | 2 +- htdocs/public/members/new.php | 2 +- htdocs/theme/{ => common}/login_logo.png | Bin htdocs/user/passwordforgotten.php | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename htdocs/theme/{ => common}/login_logo.png (100%) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 8d3adfa2df7..18d1e9c680a 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -221,7 +221,7 @@ if (! function_exists('dol_loginfunction')) // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width=0; - $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; + $urllogo=DOL_URL_ROOT.'/theme/common/login_logo.png'; if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index b7c741bd839..fe7fb4ba5a7 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -222,7 +222,7 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Print logo if (! empty($conf->global->TICKET_SHOW_COMPANY_LOGO)) { - $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; + $urllogo = DOL_URL_ROOT . '/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 0649a937822..5b456893bf9 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -101,7 +101,7 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ // Define urllogo $width = 0; - $urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; + $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { diff --git a/htdocs/theme/login_logo.png b/htdocs/theme/common/login_logo.png similarity index 100% rename from htdocs/theme/login_logo.png rename to htdocs/theme/common/login_logo.png diff --git a/htdocs/user/passwordforgotten.php b/htdocs/user/passwordforgotten.php index 62509b3e6cb..461ab8e7b4a 100644 --- a/htdocs/user/passwordforgotten.php +++ b/htdocs/user/passwordforgotten.php @@ -178,7 +178,7 @@ if (!empty($conf->global->MAIN_SECURITY_ENABLE_SENDPASSWORD)) $disabled = ''; // // Show logo (search in order: small company logo, large company logo, theme logo, common logo) $width = 0; $rowspan = 2; -$urllogo = DOL_URL_ROOT.'/theme/login_logo.png'; +$urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); From eca001677817eedb36259cba2fa60dfd3f2e15c8 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 3 Feb 2020 09:50:44 +0100 Subject: [PATCH 41/41] Fix wrong category name on user category card --- htdocs/categories/viewcat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 2b96b293f2d..e5755edd40b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -207,7 +207,7 @@ elseif ($type == Categorie::TYPE_MEMBER) $title = $langs->trans("MembersCateg elseif ($type == Categorie::TYPE_CONTACT) $title = $langs->trans("ContactCategoriesShort"); elseif ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans("AccountsCategoriesShort"); elseif ($type == Categorie::TYPE_PROJECT) $title = $langs->trans("ProjectsCategoriesShort"); -elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("ProjectsCategoriesShort"); +elseif ($type == Categorie::TYPE_USER) $title = $langs->trans("UsersCategoriesShort"); else $title = $langs->trans("Category"); $head = categories_prepare_head($object, $type);