From 4a4d2898a095028d06f11f0a7e079308cf75aa7d Mon Sep 17 00:00:00 2001 From: merelendor Date: Tue, 9 May 2023 22:45:56 +0300 Subject: [PATCH] API user registration functions ENV params --- api/index.php | 147 ++++++++++-------- .../evolution/catalog.city.team/component.php | 3 + .../evolution/catalog/component.php | 36 ++--- 3 files changed, 105 insertions(+), 81 deletions(-) diff --git a/api/index.php b/api/index.php index d0de24e..0095d77 100644 --- a/api/index.php +++ b/api/index.php @@ -377,14 +377,17 @@ switch($PARAM_1) $company_message = "Вам предоставлен доступ к Личному кабинету следующей организации:

\n\n"; $company_message .= $REQ['org_title'].", ИНН: ".$REQ['inn']."
\n"; - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "CLIENT_USER_INVITE", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "COMPANIES" => $company_message, - ) - ]); + if(SEND_EMAIL_REGISTRATION_JOIN) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "CLIENT_USER_INVITE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "COMPANIES" => $company_message, + ) + ]); + } $user_properties = [ 'COMPANY' => $REQ['org_title'], @@ -464,16 +467,19 @@ switch($PARAM_1) $ID = $user->Add($profile); if (intval($ID) > 0) { - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "USER_INFO", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "ORG_NAME" => $REQ['org_title'], - "LOGIN" => $REQ['email'], - "PASS" => $REQ['password'], - ) - ]); + if(SEND_EMAIL_REGISTRATION_CREATE) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_INFO", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "ORG_NAME" => $REQ['org_title'], + "LOGIN" => $REQ['email'], + "PASS" => $REQ['password'], + ) + ]); + } //new user & new company setCompanyForUser($ID, $REQ); @@ -564,16 +570,19 @@ switch($PARAM_1) $user = new \CUser; $user->Update($user_registered, $profile); - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "USER_INFO", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "ORG_NAME" => (string)$REQ['org_title'], - "LOGIN" => $REQ['email'], - "PASS" => $REQ['password'], - ) - ]); + if(SEND_EMAIL_REGISTRATION_UPDATE) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_INFO", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "ORG_NAME" => (string)$REQ['org_title'], + "LOGIN" => $REQ['email'], + "PASS" => $REQ['password'], + ) + ]); + } print json_encode([ "status" => "success" @@ -613,16 +622,19 @@ switch($PARAM_1) //new user & new company setCompanyForUser($ID, $REQ, true); - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "USER_INFO", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "ORG_NAME" => $REQ['org_title'], - "LOGIN" => $REQ['email'], - "PASS" => $REQ['password'], - ) - ]); + if(SEND_EMAIL_REGISTRATION_COMPANY_NEW_USER) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_INFO", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "ORG_NAME" => $REQ['org_title'], + "LOGIN" => $REQ['email'], + "PASS" => $REQ['password'], + ) + ]); + } print json_encode([ "status" => "success" @@ -997,26 +1009,32 @@ switch($PARAM_1) if($existed_user) { - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "CLIENT_USER_INVITE", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $auth['email'], - "COMPANIES" => $companies_list_message, - ) - ]); + if(SEND_EMAIL_REGISTRATION_COMPANY_INVITE) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "CLIENT_USER_INVITE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $auth['email'], + "COMPANIES" => $companies_list_message, + ) + ]); + } } else { - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "CLIENT_NEW_USER_INVITE", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $auth['email'], - "PASSWORD" => $password, - "COMPANIES" => $companies_list_message, - ) - ]); + if(SEND_EMAIL_REGISTRATION_COMPANY_INVITE_NEW_USER) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "CLIENT_NEW_USER_INVITE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $auth['email'], + "PASSWORD" => $password, + "COMPANIES" => $companies_list_message, + ) + ]); + } } print json_encode([ @@ -1958,14 +1976,17 @@ switch($PARAM_1) if(is_array($ar_user)) { - \Bitrix\Main\Mail\Event::send([ - "EVENT_NAME" => "USER_PASSWORD_RECOVERY_CODE", - "LID" => "s1", - "C_FIELDS" => Array( - "EMAIL" => $REQ['email'], - "CODE" => $REQ['code'], - ) - ]); + if(SEND_EMAIL_PASSWORD_RECOVERY_CODE) + { + \Bitrix\Main\Mail\Event::send([ + "EVENT_NAME" => "USER_PASSWORD_RECOVERY_CODE", + "LID" => "s1", + "C_FIELDS" => Array( + "EMAIL" => $REQ['email'], + "CODE" => $REQ['code'], + ) + ]); + } print json_encode([ "status" => "success", diff --git a/local/components/evolution/catalog.city.team/component.php b/local/components/evolution/catalog.city.team/component.php index 694fe63..25a9c02 100644 --- a/local/components/evolution/catalog.city.team/component.php +++ b/local/components/evolution/catalog.city.team/component.php @@ -27,6 +27,9 @@ if(!empty($arParams['CITY']['LEADER_CRM_ID'])) curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); $response = curl_exec($c); + //print ""; $httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE); curl_close($c); diff --git a/local/components/evolution/catalog/component.php b/local/components/evolution/catalog/component.php index 1d073db..fb6bcf2 100644 --- a/local/components/evolution/catalog/component.php +++ b/local/components/evolution/catalog/component.php @@ -473,24 +473,6 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) $arResult['PAGE_CURRENT'] = $res->NavPageNomer; $arResult['PAGE_COUNT'] = $res->NavPageCount; - if($arResult['MODEL_DISABLED']) - { - $arResult['MODEL'] = null; - $arResult['SELECTED']['MODEL'] = null; - $arResult['SELECTED']['MODEL_ID'] = null; - $arResult['SELECTED']['MODEL_UID'] = null; - $arResult['SHOW_SPECIAL_OFFERS'] = false; - } - - if($arResult['BRAND_DISABLED']) - { - $arResult['BRAND'] = null; - $arResult['SELECTED']['BRAND'] = null; - $arResult['SELECTED']['BRAND_ID'] = null; - $arResult['SELECTED']['BRAND_UID'] = null; - $arResult['SHOW_SPECIAL_OFFERS'] = false; - } - if(!is_null($arParams['REGION'])) { if($arParams['REGION'] === "root") @@ -614,6 +596,24 @@ if($this->StartResultCache(60*60*24, md5(var_export($_POST, true)))) } } + if($arResult['MODEL_DISABLED']) + { + $arResult['MODEL'] = null; + $arResult['SELECTED']['MODEL'] = null; + $arResult['SELECTED']['MODEL_ID'] = null; + $arResult['SELECTED']['MODEL_UID'] = null; + $arResult['SHOW_SPECIAL_OFFERS'] = false; + } + + if($arResult['BRAND_DISABLED']) + { + $arResult['BRAND'] = null; + $arResult['SELECTED']['BRAND'] = null; + $arResult['SELECTED']['BRAND_ID'] = null; + $arResult['SELECTED']['BRAND_UID'] = null; + $arResult['SHOW_SPECIAL_OFFERS'] = false; + } + foreach($breadcrumbs AS $breadcrumb) { $APPLICATION->AddChainItem($breadcrumb['NAME'], $breadcrumb['URL']);