Last active
June 30, 2018 08:48
-
-
Save nafilimonov/ca9d05ecafa9d3887cafb581d656585b to your computer and use it in GitHub Desktop.
Bitirx. User. События связанные с пользователем
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
//Отправка логина и пароля | |
AddEventHandler("main", "OnAfterUserAdd", array('UserHandler', "CSendUserPass")); | |
//Подстановка e-mail как логин | |
AddEventHandler("main", "OnBeforeUserRegister", array('UserHandler', "OnBeforeUserRegister")); | |
class UserHandler | |
{ | |
public static function CSendUserPass($arFields) | |
{ | |
$event_name = "USER_SEND_LOGIN_AND_PASS"; | |
// Добавление почтового события и шаблона | |
$et = new CEventType; | |
$emess = new CEventMessage; | |
$rsET = $et->GetList(array("TYPE_ID" => $event_name)); | |
$addEventType = ($rsET->Fetch()) ? false : true; | |
if ($addEventType) | |
{ | |
$et->Add(array( | |
"LID" => "ru", | |
"EVENT_NAME" => $event_name, | |
"NAME" => "Отправка логина и пароля пользователю", | |
"DESCRIPTION" => "#EMAIL# - EMail;\n#PASSWORD# - Пароль;\n#LOGIN# - Логин", | |
)); | |
$et->Add(array( | |
"LID" => "en", | |
"EVENT_NAME" => $event_name, | |
"NAME" => "Sending login and password to the user", | |
"DESCRIPTION" => "#EMAIL# - EMail;\n#PASSWORD# - Password;\n#LOGIN# - Login", | |
)); | |
$emess->Add(array( | |
"ACTIVE" => "Y", | |
"EVENT_NAME" => $event_name, | |
"LID" => SITE_ID, | |
"EMAIL_FROM" => "#DEFAULT_EMAIL_FROM#", | |
"EMAIL_TO" => "#EMAIL#", | |
"BCC" => "", | |
"SUBJECT" => "Ваш логин и пароль", | |
"BODY_TYPE" => "text", | |
"MESSAGE" => "#LOGIN# - Логин\n#PASSWORD# - Пароль" | |
)); | |
} | |
if (intval($arFields["ID"])>0) | |
{ | |
$toSend = Array(); | |
$toSend["PASSWORD"] = $arFields["CONFIRM_PASSWORD"]; | |
$toSend["EMAIL"] = $arFields["EMAIL"]; | |
$toSend["LOGIN"] = $arFields["LOGIN"]; | |
CEvent::SendImmediate($event_name, SITE_ID, $toSend); | |
} | |
} | |
function OnBeforeUserRegister(&$arFields) | |
{ | |
if (!empty($arFields['EMAIL'])) | |
{ | |
$arFields['LOGIN'] = $arFields['EMAIL']; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment