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/yandex.market/lib/data/ |
Upload File : |
<?php namespace Yandex\Market\Data; use Bitrix\Main; use Yandex\Market; class UserGroup { use Market\Reference\Concerns\HasOnceStatic; protected static $userGroupsCache = []; public static function getUserGroups($userId) { $userId = (int)$userId; if (!isset(static::$userGroupsCache[$userId])) { static::$userGroupsCache[$userId] = static::loadUserGroups($userId); } return static::$userGroupsCache[$userId]; } protected static function loadUserGroups($userId) { return Main\UserTable::getUserGroupIds($userId); } public static function getDefaults() { return static::onceStatic('loadDefaults'); } protected static function loadDefaults() { $result = Main\UserTable::getUserGroupIds(-1); // bitrix16.0 bug with 0 Main\Type\Collection::normalizeArrayValuesByInt($result); return $result; } public static function getEnum() { return static::onceStatic('loadEnum'); } protected static function loadEnum() { $result = []; $query = Main\GroupTable::getList([ 'filter' => [ '=ACTIVE' => 'Y' ], 'select' => [ 'ID', 'NAME' ], 'order' => [ 'C_SORT' => 'ASC', 'ID' => 'ASC' ], ]); while ($row = $query->fetch()) { $result[] = [ 'ID' => (int)$row['ID'], 'VALUE' => sprintf('[%s] %s', $row['ID'], $row['NAME']), ]; } return $result; } public static function extendGroup($groupId) { $groupId = (int)$groupId; $result = static::getDefaults(); if ($groupId > 0 && !in_array($groupId, $result, true)) { $result[] = $groupId; } return $result; } }