user & company registration and update fixes
This commit is contained in:
parent
c8651d9915
commit
110fb9df25
495
api/index.php
495
api/index.php
@ -119,11 +119,17 @@ function checkRecaptchaRequest($token, $ipAddress)
|
|||||||
return $response_decoded['success'];
|
return $response_decoded['success'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompaniesForUser($user_id)
|
function getCompaniesForUser($user_id, $except_company_id = null)
|
||||||
{
|
{
|
||||||
if(CModule::IncludeModule('iblock'))
|
if(CModule::IncludeModule('iblock'))
|
||||||
{
|
{
|
||||||
$existed_client_as_user_res = CIBlockElement::GetList([ 'id' => 'desc' ], [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'PROPERTY_USERS' => $user_id ], false, []);
|
$filter = [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'PROPERTY_USERS' => $user_id ];
|
||||||
|
if($except_company_id !== null)
|
||||||
|
{
|
||||||
|
$filter['!ID'] = $except_company_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$existed_client_as_user_res = CIBlockElement::GetList([ 'id' => 'desc' ], $filter, false, []);
|
||||||
|
|
||||||
$companies = [];
|
$companies = [];
|
||||||
|
|
||||||
@ -215,6 +221,80 @@ function getUsersForCompany($code)
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCompanyForUser($ID, $REQ, $replace = false)
|
||||||
|
{
|
||||||
|
$user_properties = [
|
||||||
|
'COMPANY' => (string)$REQ['org_title'],
|
||||||
|
'INN' => (string)$REQ['inn'],
|
||||||
|
'KPP' => (string)$REQ['kpp'],
|
||||||
|
'OGRN' => (string)$REQ['ogrn'],
|
||||||
|
'ADMINS' => [ $ID ],
|
||||||
|
'USERS' => [ $ID ],
|
||||||
|
];
|
||||||
|
|
||||||
|
$ar_new_client = [
|
||||||
|
'IBLOCK_ID' => IBLOCK_ID_CLIENTS,
|
||||||
|
'NAME' => $REQ['org_title'],
|
||||||
|
'CODE' => $REQ['crm_id'],
|
||||||
|
'PROPERTY_VALUES' => $user_properties,
|
||||||
|
'ACTIVE' => 'Y', // активен
|
||||||
|
];
|
||||||
|
|
||||||
|
$admins_to_remove = [];
|
||||||
|
|
||||||
|
$new_client = new CIBlockElement;
|
||||||
|
if($new_client_id = $new_client->Add($ar_new_client))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$existed_client_res = CIBlockElement::GetList([ 'id' => 'desc' ], [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'CODE' => $REQ['crm_id'] ], false, []);
|
||||||
|
while ($existed_client_element = $existed_client_res->GetNextElement())
|
||||||
|
{
|
||||||
|
$existed_client_record = $existed_client_element->GetFields();
|
||||||
|
$existed_client_record['PROPERTIES'] = $existed_client_element->GetProperties();
|
||||||
|
|
||||||
|
if($replace)
|
||||||
|
{
|
||||||
|
$admins = [];
|
||||||
|
$users = [];
|
||||||
|
|
||||||
|
$admins_to_remove = $existed_client_record['PROPERTIES']['ADMINS']['VALUE'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$admins = $existed_client_record['PROPERTIES']['ADMINS']['VALUE'];
|
||||||
|
$users = $existed_client_record['PROPERTIES']['USERS']['VALUE'];
|
||||||
|
}
|
||||||
|
|
||||||
|
array_push($admins, $ID);
|
||||||
|
array_push($users, $ID);
|
||||||
|
|
||||||
|
$admins = array_unique($admins);
|
||||||
|
$users = array_unique($users);
|
||||||
|
|
||||||
|
$updated_fields = [
|
||||||
|
'PROPERTY_VALUES' => [
|
||||||
|
'ADMINS' => $admins,
|
||||||
|
'USERS' => $users,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
CIBlockElement::SetPropertyValuesEx($existed_client_record['ID'], IBLOCK_ID_CLIENTS, [ 'ADMINS' => $admins, 'USERS' => $users, ]);
|
||||||
|
|
||||||
|
foreach($admins_to_remove AS $admin_to_remove_id)
|
||||||
|
{
|
||||||
|
$another_user_companies = getCompaniesForUser($admin_to_remove_id, $existed_client_record['ID']);
|
||||||
|
|
||||||
|
if(count($another_user_companies) === 0)
|
||||||
|
{
|
||||||
|
\CUser::Delete($admin_to_remove_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($_SERVER['REMOTE_USER'] && strpos($_SERVER['REMOTE_USER'], "Bearer") > -1)
|
if($_SERVER['REMOTE_USER'] && strpos($_SERVER['REMOTE_USER'], "Bearer") > -1)
|
||||||
{
|
{
|
||||||
$token = str_replace("Bearer ", "", $_SERVER['REMOTE_USER']);
|
$token = str_replace("Bearer ", "", $_SERVER['REMOTE_USER']);
|
||||||
@ -292,119 +372,130 @@ switch($PARAM_1)
|
|||||||
{
|
{
|
||||||
if($auth['username'] !== 'crm') { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); die(); }
|
if($auth['username'] !== 'crm') { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); die(); }
|
||||||
|
|
||||||
$user_registered = false;
|
$profile = [
|
||||||
|
"XML_ID" => $REQ['crm_id'],
|
||||||
|
"LOGIN" => $REQ['email'],
|
||||||
|
"NAME" => $REQ['firstname'],
|
||||||
|
"SECOND_NAME" => $REQ['secondname'],
|
||||||
|
"LAST_NAME" => $REQ['lastname'],
|
||||||
|
"EMAIL" => $REQ['email'],
|
||||||
|
"UF_ORG_TITLE" => (string)$REQ['org_title'],
|
||||||
|
"UF_INN" => (string)$REQ['inn'],
|
||||||
|
"UF_KPP" => (string)$REQ['kpp'],
|
||||||
|
"UF_OGRN" => (string)$REQ['ogrn'],
|
||||||
|
"UF_PHONE_NUMBER" => (int)$REQ['phone'],
|
||||||
|
];
|
||||||
|
|
||||||
$existed_users_res = \CUser::GetList(["ID" => "ASC"], false, [ "XML_ID" => $REQ['crm_id'] ], []);
|
$user_registered_id = null;
|
||||||
|
$company_registered_id = null;
|
||||||
|
|
||||||
|
$existed_users_res = \CUser::GetList(["ID" => "ASC"], false, [ "LOGIN" => $REQ['email'] ], []);
|
||||||
while($existed_user = $existed_users_res->Fetch())
|
while($existed_user = $existed_users_res->Fetch())
|
||||||
{
|
{
|
||||||
$user_registered = true;
|
$user_registered_id = $existed_user["ID"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($user_registered)
|
$existed_client_as_admin_res = CIBlockElement::GetList([ 'ID' => 'ASC' ], [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'CODE' => $REQ['crm_id'] ], false, []);
|
||||||
|
while ($existed_client_as_admin_element = $existed_client_as_admin_res->GetNextElement())
|
||||||
{
|
{
|
||||||
print json_encode([
|
$existed_client_as_admin_record = $existed_client_as_admin_element->GetFields();
|
||||||
"status" => "error",
|
$company_registered_id = $existed_client_as_admin_record['ID'];
|
||||||
"error" => "user_already_registered",
|
|
||||||
"message" => "User already registered",
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$user = new \CUser;
|
|
||||||
$profile = [
|
|
||||||
"XML_ID" => $REQ['crm_id'],
|
|
||||||
"LOGIN" => $REQ['email'],
|
|
||||||
"NAME" => $REQ['firstname'],
|
|
||||||
"SECOND_NAME" => $REQ['secondname'],
|
|
||||||
"LAST_NAME" => $REQ['lastname'],
|
|
||||||
"PASSWORD" => $REQ['password'],
|
|
||||||
"CONFIRM_PASSWORD" => $REQ['password'],
|
|
||||||
"EMAIL" => $REQ['email'],
|
|
||||||
"UF_ORG_TITLE" => (string)$REQ['org_title'],
|
|
||||||
"UF_INN" => (string)$REQ['inn'],
|
|
||||||
"UF_KPP" => (string)$REQ['kpp'],
|
|
||||||
"UF_OGRN" => (string)$REQ['ogrn'],
|
|
||||||
"UF_PHONE_NUMBER" => (int)$REQ['phone'],
|
|
||||||
];
|
|
||||||
|
|
||||||
$ID = $user->Add($profile);
|
if($user_registered_id !== null)
|
||||||
if (intval($ID) > 0)
|
{
|
||||||
|
//user exists
|
||||||
|
|
||||||
|
if($company_registered_id === null)
|
||||||
{
|
{
|
||||||
|
//new company for user
|
||||||
|
setCompanyForUser($user_registered_id, $REQ);
|
||||||
|
|
||||||
|
$company_message = "Вам предоставлен доступ к Личному кабинету следующей организации:<br><br>\n\n";
|
||||||
|
$company_message .= $REQ['org_title'].", ИНН: ".$REQ['inn']."<br>\n";
|
||||||
|
|
||||||
\Bitrix\Main\Mail\Event::send([
|
\Bitrix\Main\Mail\Event::send([
|
||||||
"EVENT_NAME" => "USER_INFO",
|
"EVENT_NAME" => "CLIENT_USER_INVITE",
|
||||||
"LID" => "s1",
|
"LID" => "s1",
|
||||||
"C_FIELDS" => Array(
|
"C_FIELDS" => Array(
|
||||||
"EMAIL" => $REQ['email'],
|
"EMAIL" => $REQ['email'],
|
||||||
"ORG_NAME" => $REQ['org_title'],
|
"COMPANIES" => $company_message,
|
||||||
"LOGIN" => $REQ['email'],
|
|
||||||
"PASS" => $REQ['password'],
|
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user_properties = [
|
|
||||||
'COMPANY' => $REQ['org_title'],
|
|
||||||
'INN' => (string)$REQ['inn'],
|
|
||||||
'KPP' => (string)$REQ['kpp'],
|
|
||||||
'OGRN' => (string)$REQ['ogrn'],
|
|
||||||
'ADMINS' => [ $ID ],
|
|
||||||
'USERS' => [ $ID ],
|
|
||||||
];
|
|
||||||
|
|
||||||
$ar_new_client = [
|
|
||||||
'IBLOCK_ID' => IBLOCK_ID_CLIENTS,
|
|
||||||
'NAME' => $REQ['org_title'],
|
|
||||||
'CODE' => $REQ['crm_id'],
|
|
||||||
'PROPERTY_VALUES' => $user_properties,
|
|
||||||
'ACTIVE' => 'Y', // активен
|
|
||||||
];
|
|
||||||
|
|
||||||
$new_client = new CIBlockElement;
|
|
||||||
if($new_client_id = $new_client->Add($ar_new_client))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$existed_client_res = CIBlockElement::GetList([ 'id' => 'desc' ], [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'CODE' => $REQ['crm_id'] ], false, []);
|
|
||||||
while ($existed_client_element = $existed_client_res->GetNextElement())
|
|
||||||
{
|
|
||||||
$existed_client_record = $existed_client_element->GetFields();
|
|
||||||
$existed_client_record['PROPERTIES'] = $existed_client_element->GetProperties();
|
|
||||||
|
|
||||||
$admins = $existed_client_record['PROPERTIES']['ADMINS']['VALUE'];
|
|
||||||
$users = $existed_client_record['PROPERTIES']['USERS']['VALUE'];
|
|
||||||
|
|
||||||
array_push($admins, $ID);
|
|
||||||
array_push($users, $ID);
|
|
||||||
|
|
||||||
$admins = array_unique($admins);
|
|
||||||
$users = array_unique($users);
|
|
||||||
|
|
||||||
$updated_fields = [
|
|
||||||
'PROPERTY_VALUES' => [
|
|
||||||
'ADMINS' => $admins,
|
|
||||||
'USERS' => $users,
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
CIBlockElement::SetPropertyValuesEx($existed_client_record['ID'], IBLOCK_ID_CLIENTS, [ 'ADMINS' => $admins, 'USERS' => $users, ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print json_encode([
|
print json_encode([
|
||||||
"status" => "success"
|
"status" => "success"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error = $user->LAST_ERROR;
|
|
||||||
//echo "<pre>".print_r($arFields, true)."</pre>";
|
|
||||||
//echo $error;
|
|
||||||
|
|
||||||
print json_encode([
|
print json_encode([
|
||||||
"status" => "error",
|
"status" => "error",
|
||||||
"error" => "wrong_payload",
|
"error" => "company_already_registered",
|
||||||
"message" => $error,
|
"message" => "Company already registered",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($company_registered_id === null)
|
||||||
|
{
|
||||||
|
$user = new \CUser;
|
||||||
|
|
||||||
|
$profile["PASSWORD"] = $REQ['password'];
|
||||||
|
$profile["CONFIRM_PASSWORD"] = $REQ['password'];
|
||||||
|
|
||||||
|
$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'],
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
|
||||||
|
//new user & new company
|
||||||
|
setCompanyForUser($ID, $REQ);
|
||||||
|
|
||||||
|
print json_encode([
|
||||||
|
"status" => "success"
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error = $user->LAST_ERROR;
|
||||||
|
//echo "<pre>".print_r($arFields, true)."</pre>";
|
||||||
|
//echo $error;
|
||||||
|
|
||||||
|
print json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"error" => "wrong_payload",
|
||||||
|
"message" => $error,
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"error" => "company_already_registered",
|
||||||
|
"message" => "Company already registered",
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,42 +507,51 @@ switch($PARAM_1)
|
|||||||
{
|
{
|
||||||
if($auth['username'] !== 'crm') { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); die(); }
|
if($auth['username'] !== 'crm') { header('HTTP/1.0 401 Unauthorized'); print json_encode(["status" => "error", "error" => "unauthorized", "message" => "Unauthorized"]); die(); }
|
||||||
|
|
||||||
$user_registered = false;
|
$profile = [
|
||||||
|
"XML_ID" => $REQ['crm_id'],
|
||||||
|
"LOGIN" => $REQ['email'],
|
||||||
|
"NAME" => $REQ['firstname'],
|
||||||
|
"SECOND_NAME" => $REQ['secondname'],
|
||||||
|
"LAST_NAME" => $REQ['lastname'],
|
||||||
|
"EMAIL" => $REQ['email'],
|
||||||
|
"UF_ORG_TITLE" => (string)$REQ['org_title'],
|
||||||
|
"UF_INN" => (string)$REQ['inn'],
|
||||||
|
"UF_KPP" => (string)$REQ['kpp'],
|
||||||
|
"UF_OGRN" => (string)$REQ['ogrn'],
|
||||||
|
"UF_PHONE_NUMBER" => (int)$REQ['phone'],
|
||||||
|
];
|
||||||
|
|
||||||
$existed_users_res = \CUser::GetList(["ID" => "ASC"], false, [ "XML_ID" => $REQ['crm_id'] ], []);
|
$user_registered = null;
|
||||||
|
$company_registered_id = null;
|
||||||
|
$company_registered = null;
|
||||||
|
|
||||||
|
$existed_users_res = \CUser::GetList(["ID" => "ASC"], false, [ "LOGIN" => $REQ['email'] ], []);
|
||||||
while($existed_user = $existed_users_res->Fetch())
|
while($existed_user = $existed_users_res->Fetch())
|
||||||
{
|
{
|
||||||
$user_registered = true;
|
$user_registered = $existed_user['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
$user = new \CUser;
|
$existed_client_as_admin_res = CIBlockElement::GetList([ 'ID' => 'ASC' ], [ 'IBLOCK_ID' => IBLOCK_ID_CLIENTS, 'CODE' => $REQ['crm_id'] ], false, []);
|
||||||
$profile = [
|
while ($existed_client_as_admin_element = $existed_client_as_admin_res->GetNextElement())
|
||||||
"XML_ID" => $REQ['crm_id'],
|
{
|
||||||
"LOGIN" => $REQ['email'],
|
$existed_client_as_admin_record = $existed_client_as_admin_element->GetFields();
|
||||||
"NAME" => $REQ['firstname'],
|
$company_registered_id = $existed_client_as_admin_record['ID'];
|
||||||
"SECOND_NAME" => $REQ['secondname'],
|
}
|
||||||
"LAST_NAME" => $REQ['lastname'],
|
|
||||||
"PASSWORD" => $REQ['password'],
|
|
||||||
"CONFIRM_PASSWORD" => $REQ['password'],
|
|
||||||
"EMAIL" => $REQ['email'],
|
|
||||||
"UF_ORG_TITLE" => (string)$REQ['org_title'],
|
|
||||||
"UF_INN" => (string)$REQ['inn'],
|
|
||||||
"UF_KPP" => (string)$REQ['kpp'],
|
|
||||||
"UF_OGRN" => (string)$REQ['ogrn'],
|
|
||||||
"UF_PHONE_NUMBER" => (int)$REQ['phone'],
|
|
||||||
];
|
|
||||||
|
|
||||||
$user->Update($existed_user['ID'], $profile);
|
if($user_registered !== null)
|
||||||
|
{
|
||||||
|
// user exists
|
||||||
|
|
||||||
if($user->LAST_ERROR)
|
if($company_registered_id !== null)
|
||||||
{
|
|
||||||
print json_encode([
|
|
||||||
"status" => "error",
|
|
||||||
"error" => "wrong_payload",
|
|
||||||
"message" => $user->LAST_ERROR,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
//existed company
|
||||||
|
|
||||||
|
$profile["PASSWORD"] = $REQ['password'];
|
||||||
|
$profile["CONFIRM_PASSWORD"] = $REQ['password'];
|
||||||
|
|
||||||
|
$user = new \CUser;
|
||||||
|
$user->Update($user_registered, $profile);
|
||||||
|
|
||||||
\Bitrix\Main\Mail\Event::send([
|
\Bitrix\Main\Mail\Event::send([
|
||||||
"EVENT_NAME" => "USER_INFO",
|
"EVENT_NAME" => "USER_INFO",
|
||||||
"LID" => "s1",
|
"LID" => "s1",
|
||||||
@ -463,22 +563,127 @@ switch($PARAM_1)
|
|||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//"PASSWORD" => $REQ['password'],
|
||||||
|
//"CONFIRM_PASSWORD" => $REQ['password'],
|
||||||
|
|
||||||
|
//print json_encode([
|
||||||
|
// "status" => "error",
|
||||||
|
// "error" => "company_already_registered",
|
||||||
|
// "message" => "Company already registered",
|
||||||
|
//]);
|
||||||
|
|
||||||
print json_encode([
|
print json_encode([
|
||||||
"status" => "success"
|
"status" => "success"
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//new company
|
||||||
|
//setCompanyForUser($user_registered_id, $REQ);
|
||||||
|
|
||||||
|
print json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"error" => "no_company_for_update",
|
||||||
|
"message" => "No company for update",
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// new user
|
||||||
|
|
||||||
|
if($company_registered_id !== null)
|
||||||
|
{
|
||||||
|
//existed company
|
||||||
|
//THIS!
|
||||||
|
|
||||||
|
$profile["PASSWORD"] = $REQ['password'];
|
||||||
|
$profile["CONFIRM_PASSWORD"] = $REQ['password'];
|
||||||
|
|
||||||
|
$user = new \CUser;
|
||||||
|
$ID = $user->Add($profile);
|
||||||
|
|
||||||
|
if (intval($ID) > 0)
|
||||||
|
{
|
||||||
|
//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'],
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
|
||||||
|
print json_encode([
|
||||||
|
"status" => "success"
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"error" => "wrong_payload",
|
||||||
|
"message" => $user->LAST_ERROR,
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//no company
|
||||||
|
|
||||||
|
print json_encode([
|
||||||
|
"status" => "error",
|
||||||
|
"error" => "no_company_for_update",
|
||||||
|
"message" => "No company for update",
|
||||||
|
]);
|
||||||
|
|
||||||
|
die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$user_registered)
|
/* *******************************
|
||||||
|
\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($user->LAST_ERROR)
|
||||||
{
|
{
|
||||||
print json_encode([
|
print json_encode([
|
||||||
"status" => "error",
|
"status" => "error",
|
||||||
"error" => "unknown_user",
|
"error" => "wrong_payload",
|
||||||
"message" => "Unknown user",
|
"message" => $user->LAST_ERROR,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print json_encode([
|
||||||
|
"status" => "success"
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
die();
|
die();
|
||||||
|
******************************* */
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -821,8 +1026,10 @@ switch($PARAM_1)
|
|||||||
|
|
||||||
if(count($user_companies) === 0)
|
if(count($user_companies) === 0)
|
||||||
{
|
{
|
||||||
$user = new CUser;
|
\CUser::Delete($removed_user_id);
|
||||||
$user->Update($removed_user_id, [ "BLOCKED" => "Y" ]);
|
|
||||||
|
//$user = new CUser;
|
||||||
|
//$user->Update($removed_user_id, [ "BLOCKED" => "Y" ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1505,7 +1712,7 @@ switch($PARAM_1)
|
|||||||
{
|
{
|
||||||
$user = new \CUser;
|
$user = new \CUser;
|
||||||
$login_result = $user->Login($REQ['email'], $REQ['password'], "N");
|
$login_result = $user->Login($REQ['email'], $REQ['password'], "N");
|
||||||
|
|
||||||
if($login_result == 1)
|
if($login_result == 1)
|
||||||
{
|
{
|
||||||
$existed_user_res = \CUser::GetByLogin($REQ['email']);
|
$existed_user_res = \CUser::GetByLogin($REQ['email']);
|
||||||
@ -2031,27 +2238,27 @@ switch($PARAM_1)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "vizitka":
|
case "vizitka":
|
||||||
{
|
{
|
||||||
//define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/vizitka/tmp/log.txt");
|
//define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/vizitka/tmp/log.txt");
|
||||||
//AddMessage2Log("_REQUEST['guid'] => ".$_REQUEST['guid'], "my_module_id");
|
//AddMessage2Log("_REQUEST['guid'] => ".$_REQUEST['guid'], "my_module_id");
|
||||||
|
|
||||||
$c = curl_init();
|
|
||||||
curl_setopt($c, CURLOPT_URL, API_HOST."/site/GetUserBusinessCard/?guid=".$_REQUEST['guid']);
|
|
||||||
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
|
|
||||||
curl_setopt($c, CURLOPT_TIMEOUT, 30);
|
|
||||||
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
|
|
||||||
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
|
|
||||||
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
|
||||||
|
|
||||||
$response = curl_exec($c) or die(curl_error($c));
|
$c = curl_init();
|
||||||
|
curl_setopt($c, CURLOPT_URL, API_HOST."/site/GetUserBusinessCard/?guid=".$_REQUEST['guid']);
|
||||||
curl_close($c);
|
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
|
||||||
print $response;
|
curl_setopt($c, CURLOPT_TIMEOUT, 30);
|
||||||
|
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
||||||
|
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
|
curl_setopt($c, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
||||||
|
|
||||||
die();
|
$response = curl_exec($c) or die(curl_error($c));
|
||||||
}
|
|
||||||
break;
|
curl_close($c);
|
||||||
|
print $response;
|
||||||
|
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,7 +31,7 @@ $this->setFrameMode(true);
|
|||||||
<? foreach($periods AS $period): ?>
|
<? foreach($periods AS $period): ?>
|
||||||
<div class="month">
|
<div class="month">
|
||||||
<p><?= $period['PROPERTIES']['MONTH']['VALUE']; ?></p>
|
<p><?= $period['PROPERTIES']['MONTH']['VALUE']; ?></p>
|
||||||
<p><?= $period['PREVIEW_TEXT']; ?></p>
|
<p><?= str_replace(["<p>", "</p>"], ["", "<br>"], $period['PREVIEW_TEXT']); ?></p>
|
||||||
</div>
|
</div>
|
||||||
<? endforeach; ?>
|
<? endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user