Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/grain.iiko/lib/ |
Upload File : |
<?php namespace Grain\Iiko; use \Bitrix\Main\Config\Option; class OrderUser { public static function getByPhone($phone,$newUserProps) { $phone = \NormalizePhone($phone,7); if(!$phone) return false; $user = \Bitrix\Main\UserTable::getRow(array( 'filter' => array( '=LOGIN' => $phone, ), 'select' => array('ID') )); if($user['ID']) { return $user['ID']; } else { $user = new \CUser; $fields = self::getDefaultData(array_merge($newUserProps,array('PHONE'=>$phone))); $fields = array_merge($newUserProps,$fields); $addRes = $user->Add($fields); if(!intval($addRes)) $GLOBALS['APPLICATION']->ThrowException($user->LAST_ERROR); return intval($addRes); } } public static function getDefaultData($userProps) { $userEmail = isset($userProps['EMAIL']) ? trim((string)$userProps['EMAIL']) : ''; $userPhone = $userProps['PHONE']; if(!$userPhone) return false; if(!$userEmail) $userEmail = $userPhone.'@autouser.autouser'; $newName = ''; $newLastName = ''; $fio = isset($userProps['FIO']) ? trim((string)$userProps['FIO']) : ''; if (!empty($fio)) { $arNames = explode(' ', $fio); if (isset($arNames[1])) { $newName = $arNames[1]; $newLastName = $arNames[0]; } else { $newName = $arNames[0]; } } $groupIds = []; $defaultGroups = Option::get('main', 'new_user_registration_def_group', ''); if (!empty($defaultGroups)) { $groupIds = explode(',', $defaultGroups); } $arPolicy = $GLOBALS["USER"]->GetGroupPolicy($groupIds); $passwordMinLength = (int)$arPolicy['PASSWORD_LENGTH']; if ($passwordMinLength <= 0) { $passwordMinLength = 6; } $passwordChars = array( 'abcdefghijklnmopqrstuvwxyz', 'ABCDEFGHIJKLNMOPQRSTUVWXYZ', '0123456789', ); if ($arPolicy['PASSWORD_PUNCTUATION'] === 'Y') { $passwordChars[] = ",.<>/?;:'\"[]{}\|`~!@#\$%^&*()-_+="; } $newPassword = randString($passwordMinLength + 2, $passwordChars); return array( 'EMAIL' => $userEmail, 'LOGIN' => $userPhone, 'NAME' => $newName, 'LAST_NAME' => $newLastName, 'PASSWORD' => $newPassword, 'PASSWORD_CONFIRM' => $newPassword, 'GROUP_ID' => $groupIds ); } }