3namespace Bitrix\Im\Configuration;
6use Bitrix\Im\V2\Settings\CacheManager;
7use Bitrix\Main\ArgumentException;
9use Bitrix\Main\ObjectPropertyException;
10use Bitrix\Main\Result;
11use Bitrix\Main\SystemException;
18 private const GENERAL =
'general';
19 private const NOTIFY =
'notify';
21 private const PRIVACY_SEARCH =
'privacySearch';
22 private const STATUS =
'status';
33 $result->addError(
new Error($exception->getMessage(), $exception->getCode()));
53 !array_key_exists(self::NOTIFY,
$settings)
54 || !array_key_exists(self::GENERAL,
$settings)
57 $result->addError(
new Error(
'Incorrect data when receiving chat settings', 400));
67 if (isset(
$settings[
'general'][
'notifyScheme']) &&
$settings[
'general'][
'notifyScheme'] ===
'simple')
83 CacheManager::getUserCache(
$userId)->clearCache();
89 $userPresetId = $userPresetId[
'ID'];
93 CacheManager::getPresetCache($userPresetId)->clearCache();
103 if (!in_array(
$type, [self::NOTIFY, self::GENERAL],
true))
105 $result->addError(
new Error(
'Incorrect data when receiving chat settings', 400));
115 $userPresetId = $userPresetId[
'ID'] ??
null;
117 if (
$type === self::NOTIFY)
122 $preset[
'general'] = [];
130 if (
$type === self::GENERAL)
141 $preset[
'notify'] = [];
151 CacheManager::getPresetCache($userPresetId)->clearCache();
152 CacheManager::getUserCache(
$userId)->clearCache();
160 COption::GetOptionString(
'im',
'migration_to_new_settings') ===
'Y'
167 $lastConvertedId = COption::GetOptionInt(
'im',
'last_converted_user');
168 return $userId < $lastConvertedId;
174 $notifyScheme = $generalSettings->getValue(
'notifyScheme');
176 if ($notifyScheme !==
'expert')
180 return $generalSettings->getValue(
'notifySchemeSendSite');
184 return $generalSettings->getValue(
'notifySchemeSendEmail');
188 return $generalSettings->getValue(
'notifySchemeSendPush');
192 return $generalSettings->getValue(
'notifySchemeSendXmpp');
199 private static function sendSettingsChangeEvent(
int $userId,
array $generalSettings): void
202 if (isset($generalSettings[
'openDesktopFromPanel']) && CModule::IncludeModule(
'pull'))
206 'command' =>
'settingsUpdate',
209 'openDesktopFromPanel' => $generalSettings[
'openDesktopFromPanel'],
216 private static function disableUserSearch(
int $userId,
array $generalSettings): void
220 array_key_exists(self::PRIVACY_SEARCH, $generalSettings)
221 && $defaultSettings[self::PRIVACY_SEARCH] === $generalSettings[self::PRIVACY_SEARCH]
229 private static function enableUserSearch(
int $userId,
array $generalSettings): void
231 if (isset($generalSettings[self::PRIVACY_SEARCH]))
238 'UF_IM_SEARCH' => $generalSettings[self::PRIVACY_SEARCH],
244 private static function updateUserStatus(
int $userId,
array $generalSettings): void
246 if (isset($generalSettings[self::STATUS]))
248 \CIMStatus::Set(
$userId, [
'STATUS' => $generalSettings[self::STATUS]]);
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static chooseExistingPreset(int $presetId, int $userId)
const DEFAULT_PRESET_SETTING_NAME
static createUserPreset(int $userId, array $settings=[])
static updatePresetSettings(int $presetId, int $modifyId, array $settings)
static getUserPreset(int $userId)
static createWithUserId(int $userId)
static updateGroupSettings(int $groupId, array $settings)
static getDefaultSettings()
static getUserSettings(int $userId)
static isUserMigrated(int $userId)
static getNotifyAccess($userId, $moduleId, $eventId, $type)
static setUserSetting(int $userId, string $type, array $settings)
static setUserSettings(int $userId, array $settings)
static isSettingsMigrated()
static updateGroupSettings(int $groupId, array $settings)
static getSimpleNotifySettings(array $generalSettings)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
global $USER_FIELD_MANAGER