34 $this->userId = $userId;
38 $bindings = $cache->getValue();
47 return $result->setResult(
true);
51 OptionUserTable::query()
52 ->addSelect(
'NOTIFY_GROUP_ID')
53 ->addSelect(
'GENERAL_GROUP_ID')
54 ->where(
'USER_ID', $userId)
68 $presetId = Configuration::restoreBindings($userId);
84 return $result->setResult(
true);
89 $settingsBeforeUpdate = ($settingsConfiguration[
'name'] ===
'pinnedChatSort')
94 if (!$this->generalPreset->isPersonal($this->userId))
96 $personalPreset = Preset::getPersonal($this->userId);
98 if ($personalPreset->isExist())
100 $this->generalPreset = $personalPreset;
104 $personalPreset = Preset::getInstance();
105 $personalPreset->initPersonal($this->userId);
106 $this->generalPreset = $personalPreset;
109 $this->generalPreset->bindToUser($this->userId, [Preset::BIND_GENERAL]);
113 $this->generalPreset->general->updateSetting($settingsConfiguration);
116 if (!$this->generalPreset->general->shouldUpdateSimpleNotifySettings($settingsConfiguration))
122 if (!$this->notifyPreset->isPersonal($this->userId))
125 $this->notifyPreset->
bindToUser($this->userId, [Preset::BIND_NOTIFY]);
129 $simpleSchema = $this->generalPreset->general->getSimpleNotifyScheme();
130 $this->notifyPreset->notify->updateSimpleSettings($simpleSchema);
141 if (!$this->notifyPreset->isPersonal($this->userId))
152 $this->notifyPreset->bindToUser($this->userId, [Preset::BIND_NOTIFY]);
156 $this->notifyPreset->notify->updateSetting($settingsConfiguration);
165 return \CIMStatus::Set($this->userId, [
'STATUS' =>
$status]);
170 if ($this->generalPreset->getId() ===
null)
172 $this->recoveryBinding(Preset::BIND_GENERAL);
175 if ($this->generalPreset->general ===
null)
177 $this->generalPreset = Preset::getDefaultPreset();
180 return $this->generalPreset->general->toRestFormat();
185 if ($this->notifyPreset->getId() ===
null)
187 $this->recoveryBinding(Preset::BIND_NOTIFY);
190 if ($this->notifyPreset->notify ===
null)
192 $this->notifyPreset = Preset::getDefaultPreset();
195 return $this->notifyPreset->notify->toRestFormat();
200 $this->updateUserSearch($settingConfiguration);
201 $this->openDesktopFromPanel($settingConfiguration);
203 if (isset($settingsBeforeUpdate))
205 $this->updatePinSortCost($settingConfiguration, $settingsBeforeUpdate);
209 private function updateUserSearch(
array $settingsConfiguration): void
211 $defaultSettings = General::getDefaultSettings();
214 $settingsConfiguration[
'name'] ===
Entity\General::PRIVACY_SEARCH
215 && $this->checkUserSearch($settingsConfiguration[
'value'])
221 : $settingsConfiguration[
'value']
228 'UF_IM_SEARCH' => $value
234 private function checkUserSearch($settingValue): bool
236 return in_array($settingValue, [General::PRIVACY_RESULT_ALL, General::PRIVACY_RESULT_CONTACT],
true);
239 private function recoveryBinding(
string $toEntity)
241 $userPreset = Preset::getPersonal($this->userId);
244 $userPreset->isExist()
246 : Preset::getDefaultPreset()
248 $bindingPreset->bindToUser($this->userId, [$toEntity]);
250 if ($toEntity === Preset::BIND_GENERAL)
252 $this->generalPreset = $bindingPreset;
256 $this->notifyPreset = $bindingPreset;
262 private function openDesktopFromPanel(
array $settingsConfiguration): void
265 $settingsConfiguration[
'name'] === Entity\General::OPEN_DESKTOP_FROM_PANEL
266 && CModule::IncludeModule(
'pull')
269 Event::add($this->userId, [
271 'command' =>
'settingsUpdate',
274 'openDesktopFromPanel' => $settingsConfiguration[
'value'],
283 return $this->generalPreset->isPersonal($this->userId);
288 return $this->generalPreset->getId();
291 private function updatePinSortCost(
array $settingsConfiguration,
array $settingsBeforeUpdate): void
293 if ($settingsConfiguration[
'name'] ===
'pinnedChatSort'
294 && $settingsConfiguration[
'value'] !==
'byDate'
297 if ($settingsBeforeUpdate[
'pinnedChatSort'] !==
'byCost')
299 Recent::updatePinSortCost($this->userId);
static getUserTypeManager()