Address feedback
This commit is contained in:
parent
22ff5a320f
commit
4c851884e5
@ -1062,7 +1062,7 @@ if (count($listofextcals))
|
|||||||
$event->ref = $event->id;
|
$event->ref = $event->id;
|
||||||
|
|
||||||
$userId = $userstatic->findUserIdByEmail($namecal);
|
$userId = $userstatic->findUserIdByEmail($namecal);
|
||||||
if(!empty($userId))
|
if (!empty($userId) && $userId > 0)
|
||||||
{
|
{
|
||||||
$event->userassigned[$userId] = $userId;
|
$event->userassigned[$userId] = $userId;
|
||||||
$event->percentage = -1;
|
$event->percentage = -1;
|
||||||
|
|||||||
@ -3241,15 +3241,21 @@ class User extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Cache the SQL results of the function "findUserIdByEmail($email)"
|
* Cache the SQL results of the function "findUserIdByEmail($email)"
|
||||||
*
|
*
|
||||||
|
* NOTE: findUserIdByEmailCache[...] === -1 means not found in database
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $findUserIdByEmailCache;
|
private $findUserIdByEmailCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a user by the given e-mail or part of a e-mail and return its user id when found
|
* Find a user by the given e-mail and return it's user id when found
|
||||||
*
|
*
|
||||||
* @param string $email The full e-mail or a part of a e-mail
|
* NOTE:
|
||||||
* @return int|null The id of the user when found, otherwise null
|
* Use AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR
|
||||||
|
* to disable exact e-mail search
|
||||||
|
*
|
||||||
|
* @param string $email The full e-mail (or a part of a e-mail)
|
||||||
|
* @return int <0 = user was not found, >0 = The id of the user
|
||||||
*/
|
*/
|
||||||
public function findUserIdByEmail($email)
|
public function findUserIdByEmail($email)
|
||||||
{
|
{
|
||||||
@ -3258,24 +3264,38 @@ class User extends CommonObject
|
|||||||
return $this->findUserIdByEmailCache[$email];
|
return $this->findUserIdByEmailCache[$email];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->findUserIdByEmailCache[$email] = -1;
|
||||||
|
|
||||||
|
global $conf;
|
||||||
|
|
||||||
$sql = 'SELECT rowid';
|
$sql = 'SELECT rowid';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'user';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'user';
|
||||||
|
|
||||||
|
if (!empty($conf->global->AGENDA_DISABLE_EXACT_USER_EMAIL_COMPARE_FOR_EXTERNAL_CALENDAR))
|
||||||
|
{
|
||||||
$sql .= ' WHERE email LIKE "%'.$email.'%"';
|
$sql .= ' WHERE email LIKE "%'.$email.'%"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql .= ' WHERE email = "'.$email.'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= ' LIMIT 1';
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql)
|
||||||
{
|
{
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
if (!$obj)
|
if (!$obj)
|
||||||
{
|
{
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->findUserIdByEmailCache[$email] = (int) $obj->rowid;
|
$this->findUserIdByEmailCache[$email] = (int) $obj->rowid;
|
||||||
|
|
||||||
return (int)$obj->rowid;
|
return $this->findUserIdByEmailCache[$email];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user