37 public static function getIconData($email, $name, $lastName =
null)
40 'INITIALS' => static::getInitials($email, $name, $lastName),
41 'COLOR' => static::getRandomColor(),
72 public static function getInitials($email, $name =
null, $lastName =
null)
74 if ($lastName && mb_substr($lastName, 0, 1) && $name && mb_substr($name, 0, 1))
76 return mb_strtoupper(mb_substr($name, 0, 1).mb_substr($lastName, 0, 1));
79 $name = trim(preg_replace(
'/([0-9]|[-&\/\'#,+()~%.":*?<>{}])/m',
'',$name));
81 $name = explode(
' ', $name);
83 if (is_array($name) && isset($name[0]) && $name[0])
85 if (isset($name[1]) && $name[1])
87 return mb_strtoupper(mb_substr($name[0], 0, 1).mb_substr($name[1], 0, 1));
91 return mb_strtoupper(mb_substr($name[0], 0, 1));
94 return mb_strtoupper(mb_substr($email, 0, 1));
110 $mails = explode(
',', $mailsField);
112 foreach ($mails as $mail)
115 $address = new \Bitrix\Main\Mail\Address($mail);
116 $emailToAdd = $nameToAdd =
'';
117 if ($address->validate())
119 $emailToAdd = $address->getEmail();
120 $nameToAdd = trim($address->getName());
125 'USER_ID' => intval($userId),
126 'NAME' => $nameToAdd ? $nameToAdd : explode(
'@', $emailToAdd)[0],
127 'ICON' => static::getIconData($emailToAdd, $nameToAdd),
128 'EMAIL' => $emailToAdd,
129 'ADDED_FROM' => $addedFrom,