6use Bitrix\Main\Localization\Loc;
27 'LAST_NAME' => (!empty(
$fields[
"LAST_NAME"]) ?
$fields[
"LAST_NAME"] :
''),
28 'PERSONAL_PHOTO' => (!empty(
$fields[
"PERSONAL_PHOTO_ID"]) ? \CFile::makeFileArray(
$fields[
'PERSONAL_PHOTO_ID']) :
false),
29 'EXTERNAL_AUTH_ID' =>
'email',
34 $userFields[
'UF_DEPARTMENT'] =
array();
46 $userFields[
$key] = $value;
51 $mailGroup = self::getMailUserGroup();
52 if (!empty($mailGroup))
54 $userFields[
"GROUP_ID"] = $mailGroup;
70 $handler =
$eventManager->addEventHandlerCompatible(
'main',
'OnUserLoginExternal',
array(
'\Bitrix\Mail\User',
'onLoginExternal'));
73 $USER->login(
'',
'',
'Y');
75 $eventManager->removeEventHandler(
'main',
'OnUserLoginExternal', $handler);
89 if ($token =
$request->get(
'token') ?:
$request->getCookie(
'MAIL_AUTH_TOKEN'))
91 $userRelation = UserRelationsTable::getList(
array(
92 'select' =>
array(
'USER_ID'),
95 '=USER.EXTERNAL_AUTH_ID' =>
'email',
102 $context->getResponse()->addCookie(
new Main\
Web\Cookie(
'MAIL_AUTH_TOKEN', $token));
104 return $userRelation[
'USER_ID'];
127 '=ENTITY_TYPE' => $entityType,
130 $userRelation = UserRelationsTable::getList(
array(
'filter' =>
$filter))->fetch();
132 if (empty($userRelation))
135 $userRelation = UserRelationsTable::getList(
array(
'filter' =>
$filter))->fetch();
138 if (empty($userRelation))
140 if (empty($entityLink))
143 $userRelation =
array(
145 'TOKEN' => base_convert(md5(time().
Main\
Security\Random::getBytes(6)), 16, 36),
147 'ENTITY_TYPE' => $entityType,
149 'ENTITY_LINK' => $entityLink,
153 if (!UserRelationsTable::add($userRelation)->isSuccess())
160 $scheme =
$context->getRequest()->isHttps() ?
'https' :
'http';
161 $domain =
$site[
'SERVER_NAME'] ?: \COption::getOptionString(
'main',
'server_name',
'');
163 if (preg_match(
'/^(?<domain>.+):(?<port>\d+)$/', $domain,
$matches))
170 $port =
$context->getServer()->getServerPort();
173 $port = in_array($port,
array(80, 443)) ?
'' :
':'.$port;
174 $path = ltrim(trim(
$site[
'DIR'],
'/') .
'/pub/entry.php',
'/');
176 $replyTo = sprintf(
'rpl%s@%s', $userRelation[
'TOKEN'], $domain);
177 $backUrl = sprintf(
'%s://%s%s/%s#%s', $scheme, $domain, $port,
$path, $userRelation[
'TOKEN']);
192 $cache = new \CPHPCache();
194 $cacheKey = sprintf(
'%s_%s',
$userId, $entityType);
195 $cacheDir = sprintf(
'/mail/user/forward/%s', bin2hex(
$siteId));
197 if ($cache->initCache(365*24*3600, $cacheKey, $cacheDir))
199 $forwardTo = $cache->getVars();
203 $userRelation = UserRelationsTable::getList(
array(
207 '=ENTITY_TYPE' => $entityType,
212 if (empty($userRelation))
214 $userRelation =
array(
216 'TOKEN' => base_convert(md5(time().
Main\
Security\Random::getBytes(6)), 16, 36),
218 'ENTITY_TYPE' => $entityType
221 if (!UserRelationsTable::add($userRelation)->isSuccess())
230 $domain =
$site[
'SERVER_NAME'] ?: \COption::getOptionString(
'main',
'server_name',
'');
232 if (preg_match(
'/^(?<domain>.+):(?<port>\d+)$/', $domain,
$matches))
235 $forwardTo = sprintf(
'fwd%s@%s', $userRelation[
'TOKEN'], $domain);
237 $cache->startDataCache();
238 $cache->endDataCache($forwardTo);
241 return array($forwardTo);
246 if (!preg_match(
'/^(?<type>rpl|fwd)(?<token>[a-z0-9]+)@(?<domain>.+)/i', $to,
$matches))
255 $userRelation = UserRelationsTable::getList(
array(
267 return $userRelation;
280 $type = $recipient[
'type'];
281 $token = $recipient[
'token'];
297 $error = sprintf(
'Empty message (rcpt: %s)', $to);
301 $attachments = array_filter(
308 $addResult = User\MessageTable::add(
array(
310 'SITE_ID' => $userRelation[
'SITE_ID'],
311 'ENTITY_TYPE' => $userRelation[
'ENTITY_TYPE'],
312 'ENTITY_ID' => $userRelation[
'ENTITY_ID'],
313 'USER_ID' => $userRelation[
'USER_ID'],
316 'ATTACHMENTS' => serialize($attachments),
319 if ($addResult->isSuccess())
322 "\\Bitrix\\Mail\\User::sendEventAgent(".$addResult->getId().
");",
351 if (intval($cnt) > 10)
353 if (
Main\Loader::includeModule(
'im'))
359 $title = preg_replace(
"/\[ATTACHMENT\s*=\s*[^\]]*\]/isu",
"",
$title);
361 $CBXSanitizer = new \CBXSanitizer;
362 $CBXSanitizer->delAllTags();
366 \CIMNotify::add(
array(
369 "NOTIFY_MODULE" =>
"mail",
370 "NOTIFY_EVENT" =>
"user_message_failed",
372 "NOTIFY_MESSAGE" => Loc::getMessage(
"MAIL_USER_MESSAGE_FAILED",
array(
384 $eventId = sprintf(
'onReplyReceived%s',
$messageFields[
'ENTITY_TYPE']);
387 $eventId = sprintf(
'onForwardReceived%s',
$messageFields[
'ENTITY_TYPE']);
391 if (!empty($eventId))
393 $attachments =
array();
396 $tmpAttachments = unserialize(
$messageFields[
'ATTACHMENTS'], [
'allowed_classes' =>
false]);
397 if (is_array($tmpAttachments))
399 foreach($tmpAttachments as
$key => $uploadFile)
401 $file = \CFile::makeFileArray($uploadFile);
407 $file[
'name'] =
$key;
408 $attachments[
$key] = $file;
422 'attachments' => $attachments
427 foreach (
$event->getResults() as $eventResult)
429 if ($eventResult->getType() == \
Bitrix\
Main\EventResult::ERROR)
434 $pPERIOD = 10 + (60 * $cnt);
435 return "\\Bitrix\\Mail\\User::sendEventAgent(".$messageId.
", ".$cnt.
");";
455 if ($mailInvitedGroup)
457 $res[] = intval($mailInvitedGroup);
466 if(preg_match(
"/\\.bitrix24\\.([a-z]+|com\\.br)$/i", BX24_HOST_NAME))
468 $domain = BX24_HOST_NAME;
472 $domain = str_replace(
".",
"-", BX24_HOST_NAME).
".bitrix24.com";
475 $defaultEmailFrom =
"info@".$domain;
480 if ($defaultEmailFrom ==
'')
486 return $defaultEmailFrom;
504 "=EXTERNAL_AUTH_ID" =>
'email'
509 ||
Main\
Config\Option::get(
"main",
"new_user_registration_email_confirmation",
"N") ==
"Y"
512 $filter[
"CONFIRM_CODE"] =
false;
518 'select' =>
array(
"ID",
"EMAIL",
"NAME",
"LAST_NAME",
"SECOND_NAME",
"LOGIN")
524 "NAME_FORMATTED" => (
525 !empty(
$user[
"NAME"])
526 || !empty(
$user[
"LAST_NAME"])
527 ? \CUser::formatName($nameTemplate,
$user)
530 "EMAIL" =>
$user[
"EMAIL"]
539 if (array_key_exists(
'SERVER_NAME',
$fields))
541 static::clearTokensCache();
547 static::clearTokensCache();
552 $cache = new \CPHPCache();
553 $cache->cleanDir(
'/mail/user/forward');
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static parseReply(array &$message)
static parseForward(array &$message)
static onLoginExternal(&$params)
static getReplyTo($siteId, $userId, $entityType, $entityId, $entityLink=null, $backurl=null)
static getUserRelation($token)
static onEmailReceived($to, $message, $recipient, $userRelation, &$error)
static clearTokensCache()
static getUserData($userList, $nameTemplate)
static getMailUserGroup()
static parseEmailRecipient($to)
static handleServerNameUpdate()
static getForwardTo($siteId, $userId, $entityType)
static sendEventAgent($messageId=0, $cnt=0)
static getDefaultEmailFrom($serverName=false)
static handleSiteUpdate($fields)
static get($moduleId, $name, $default="", $siteId=false)
static loadMessages($file)
static isModuleInstalled($moduleName)
static getList(array $parameters=array())
static getByPrimary($primary, array $parameters=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if($request->getPost('Update') !==null) elseif( $request->getPost( 'Apply') !==null) elseif($request->getPost('RestoreDefaults') !==null) $backUrl
IsModuleInstalled($module_id)
$GLOBALS['____1690880296']
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']