Show user on external calender events
This commit is contained in:
parent
3281d5ec17
commit
ba98db934d
@ -1061,12 +1061,21 @@ if (count($listofextcals))
|
|||||||
$event->id = $icalevent['UID'];
|
$event->id = $icalevent['UID'];
|
||||||
$event->ref = $event->id;
|
$event->ref = $event->id;
|
||||||
|
|
||||||
$event->icalname = $namecal;
|
$userId = $userstatic->findUserIdByEmail($namecal);
|
||||||
|
if(!empty($userId))
|
||||||
|
{
|
||||||
|
$event->userassigned[$userId] = $userId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$event->icalname = $namecal;
|
||||||
|
$event->type_code = "ICALEVENT";
|
||||||
|
}
|
||||||
|
|
||||||
$event->icalcolor = $colorcal;
|
$event->icalcolor = $colorcal;
|
||||||
$usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
|
$usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
|
||||||
$event->datep = $datestart + $usertime;
|
$event->datep = $datestart + $usertime;
|
||||||
$event->datef = $dateend + $usertime;
|
$event->datef = $dateend + $usertime;
|
||||||
$event->type_code = "ICALEVENT";
|
|
||||||
|
|
||||||
if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY'];
|
if ($icalevent['SUMMARY']) $event->label = $icalevent['SUMMARY'];
|
||||||
elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1);
|
elseif ($icalevent['DESCRIPTION']) $event->label = dol_nl2br($icalevent['DESCRIPTION'], 1);
|
||||||
|
|||||||
@ -3236,5 +3236,46 @@ class User extends CommonObject
|
|||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache the SQL results of the function "findUserIdByEmail($email)"
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $findUserIdByEmailCache;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a user by the given e-mail or part of a e-mail and return its user id when found
|
||||||
|
*
|
||||||
|
* @param string $email The full e-mail or a part of a e-mail
|
||||||
|
* @return int|null The id of the user when found, otherwise null
|
||||||
|
*/
|
||||||
|
public function findUserIdByEmail($email)
|
||||||
|
{
|
||||||
|
if($this->findUserIdByEmailCache[$email])
|
||||||
|
{
|
||||||
|
return $this->findUserIdByEmailCache[$email];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT rowid';
|
||||||
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'user';
|
||||||
|
$sql .= ' WHERE email LIKE "%'.$email.'%"';
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if (!$resql)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
if (!$obj)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->findUserIdByEmailCache[$email] = (int)$obj->rowid;
|
||||||
|
|
||||||
|
return (int)$obj->rowid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user