From bcdf19f0ffa750a9bb2146626de871c25f31b7f6 Mon Sep 17 00:00:00 2001 From: AdrianDominik Date: Mon, 27 Jan 2020 10:54:08 +0100 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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