2021-08-19 15:46:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class RetailUser
|
|
|
|
*/
|
|
|
|
class RetailUser extends CUser
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return int|mixed|string|null
|
|
|
|
*/
|
|
|
|
public function GetID()
|
|
|
|
{
|
|
|
|
$rsUser = CUser::GetList(($by = 'ID'), ($order = 'DESC'), ['LOGIN' => 'retailcrm']);
|
|
|
|
|
|
|
|
if ($arUser = $rsUser->Fetch()) {
|
|
|
|
return $arUser['ID'];
|
2022-03-02 15:40:53 +03:00
|
|
|
}
|
2021-08-19 15:46:03 +03:00
|
|
|
|
2022-03-02 15:40:53 +03:00
|
|
|
$retailUser = new CUser;
|
|
|
|
$userPassword = uniqid();
|
2021-08-19 15:46:03 +03:00
|
|
|
|
2022-03-02 15:40:53 +03:00
|
|
|
$arFields = [
|
|
|
|
'NAME' => 'retailcrm',
|
|
|
|
'LAST_NAME' => 'retailcrm',
|
|
|
|
'EMAIL' => 'retailcrm@retailcrm.com',
|
|
|
|
'LOGIN' => 'retailcrm',
|
|
|
|
'LID' => 'ru',
|
|
|
|
'ACTIVE' => 'Y',
|
|
|
|
'GROUP_ID' => [2],
|
|
|
|
'PASSWORD' => $userPassword,
|
|
|
|
'CONFIRM_PASSWORD' => $userPassword,
|
|
|
|
];
|
2021-08-19 15:46:03 +03:00
|
|
|
|
2022-03-02 15:40:53 +03:00
|
|
|
$id = $retailUser->Add($arFields);
|
2021-08-19 15:46:03 +03:00
|
|
|
|
2022-03-02 15:40:53 +03:00
|
|
|
if (!$id) {
|
|
|
|
return null;
|
2021-08-19 15:46:03 +03:00
|
|
|
}
|
2022-03-02 15:40:53 +03:00
|
|
|
|
|
|
|
return $id;
|
2021-08-19 15:46:03 +03:00
|
|
|
}
|
|
|
|
}
|