FIX: #12908 User login with credentials from self-subscription form fails
This commit is contained in:
parent
2cb414e17e
commit
540e82102b
@ -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;
|
||||
|
||||
@ -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 = '<!-- picto user --><span class="nopadding userimg'.($morecss ? ' '.$morecss : '').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).'</span>';
|
||||
// Picto must be a photo
|
||||
@ -2482,7 +2492,7 @@ class User extends CommonObject
|
||||
$linkend = '</a>';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user