1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Configuration.php
См. документацию.
1<?php
2namespace Bitrix\Im\Configuration;
3
4use Bitrix\Iblock\ORM\Query;
5use Bitrix\Im\Model\OptionAccessTable;
6use Bitrix\Im\Model\OptionGroupTable;
7use Bitrix\Im\Model\OptionStateTable;
8use Bitrix\Im\Model\OptionUserTable;
9use Bitrix\Im\V2\Settings\CacheManager;
10use Bitrix\Main\Application;
11use Bitrix\Main\ArgumentException;
12use Bitrix\Main\Config\Option;
13use Bitrix\Main\Data\Cache;
14use Bitrix\Main\DB\SqlQueryException;
15use Bitrix\Main\Entity\Query\Filter\ConditionTree;
16use Bitrix\Main\Loader;
17use Bitrix\Main\Localization\Loc;
18use Bitrix\Main\ObjectPropertyException;
19use Bitrix\Main\ORM\Fields\Relations\Reference;
20use Bitrix\Main\ORM\Query\Join;
21use Bitrix\Main\SystemException;
22use Bitrix\Main\UserAccessTable;
23use Exception;
24
26{
27 public const DEFAULT_PRESET_NAME = 'default';
28 public const DEFAULT_PRESET_SETTING_NAME = 'default_configuration_preset';
29 protected const DEFAULT_SORT = 100;
30
31 public const USER_PRESET_SORT = 1000000;
32
33 public const NOTIFY_GROUP = 'notify';
34 public const GENERAL_GROUP = 'general';
35
36 protected const CACHE_TTL = 31536000; //one year
37 protected const CACHE_NAME = 'user_preset';
38 protected const CACHE_DIR = '/im/option/';
39
40 protected static $defaultPresetId = null;
41
42 public static function getDefaultPresetId(): int
43 {
44 if (self::$defaultPresetId)
45 {
46 return self::$defaultPresetId;
47 }
48 $row =
49 OptionGroupTable::query()
50 ->addSelect('ID')
51 ->where('NAME', self::DEFAULT_PRESET_NAME)
52 ->fetch()
53 ;
54
55 if ($row['ID'])
56 {
57 self::$defaultPresetId = (int)$row['ID'];
58
59 return self::$defaultPresetId;
60 }
61
62 return self::createDefaultPreset();
63 }
64
65 public static function createDefaultPreset(): int
66 {
67 $defaultGroupId =
70 'SORT' => 0,
71 'CREATE_BY_ID' => 0,
72 ])
73 ->getId()
74 ;
75
76 $generalDefaultSettings = General::getDefaultSettings();
77 General::setSettings($defaultGroupId, $generalDefaultSettings);
78
79 $notifySettings = Notification::getSimpleNotifySettings($generalDefaultSettings);
80 Notification::setSettings($defaultGroupId, $notifySettings);
81
82 Option::set('im', self::DEFAULT_PRESET_SETTING_NAME, (int)$defaultGroupId);
83
84 if (Loader::includeModule('intranet'))
85 {
86 $topDepartmentId = Department::getTopDepartmentId();
87 OptionAccessTable::add([
88 'GROUP_ID' => $defaultGroupId,
89 'ACCESS_CODE' => $topDepartmentId ? 'DR' . $topDepartmentId : 'AU'
90 ]);
91 }
92
93 return (int)$defaultGroupId;
94 }
95
108 public static function getUserPreset(int $userId): array
109 {
110 $preset = self::getUserPresetFromCache($userId);
111
112 if (!empty($preset))
113 {
114 $preset['notify']['settings'] =
115 array_replace_recursive(
117 ($preset['notify']['settings'] ?? [])
118 )
119 ;
120
121 $preset['general']['settings'] =
122 array_replace_recursive(
124 ($preset['general']['settings'] ?? [])
125 )
126 ;
127
128 return $preset;
129 }
130
131 $query = OptionGroupTable::query()
132 ->setSelect([
133 'ID',
134 'NAME',
135 'SORT',
136 'USER_ID',
137 'NOTIFY_GROUP_ID' => 'OPTION_USER.NOTIFY_GROUP_ID',
138 'GENERAL_GROUP_ID' => 'OPTION_USER.GENERAL_GROUP_ID'
139 ])
140 ->registerRuntimeField(
141 'OPTION_USER',
142 new Reference(
143 'OPTION_USER',
144 OptionUserTable::class,
145 Join::on('this.ID', 'ref.NOTIFY_GROUP_ID')
146 ->logic('or')
147 ->whereColumn('this.ID', 'ref.GENERAL_GROUP_ID'),
148 ['join_type' => Join::TYPE_INNER]
149 )
150 )
151 ->where('OPTION_USER.USER_ID', $userId)
152 ->setLimit(2)
153 ;
154
155 $rows = $query->fetchAll();
156
157 if (empty($rows))
158 {
159 $presetId = self::restoreBindings($userId);
160
161 if ($presetId === self::getDefaultPresetId())
162 {
163 $userPreset = self::getDefaultUserPreset();
164 }
165 else
166 {
167 $preset = self::getPreset($presetId);
168 $userPreset = [
169 'notify' => $preset,
170 'general' => $preset,
171 ];
172 }
173
174 self::setUserPresetInCache($userId, $userPreset);
175
176 return $userPreset;
177 }
178
179 $notifyPreset = [];
180 $generalPreset = [];
181 foreach ($rows as $preset)
182 {
183 if ((int)$preset['ID'] === (int)$preset['NOTIFY_GROUP_ID'])
184 {
185 $notifyPreset = [
186 'id' => $preset['ID'],
187 'name' => self::getPresetName($preset),
188 'sort' => $preset['SORT'],
189 'userId' => $preset['USER_ID'],
190 'settings' => Notification::getGroupSettings((int)$preset['ID'])
191 ];
192 }
193
194 if ((int)$preset['ID'] === (int)$preset['GENERAL_GROUP_ID'])
195 {
196 $generalPreset = [
197 'id' => $preset['ID'],
198 'name' => self::getPresetName($preset),
199 'sort' => $preset['SORT'],
200 'userId' => $preset['USER_ID'],
201 'settings' => General::getGroupSettings((int)$preset['ID'])
202 ];
203 }
204 }
205
206 //TODO extraordinary bag with not existing group from database
207 if (empty($notifyPreset))
208 {
209 $notifyPreset = self::getDefaultUserPreset()['notify'];
210 }
211 if (empty($generalPreset))
212 {
213 $generalPreset = self::getDefaultUserPreset()['general'];
214 }
215
216 $userPreset = [
217 'notify' => $notifyPreset,
218 'general' => $generalPreset
219 ];
220 self::setUserPresetInCache($userId, $userPreset);
221
222 return $userPreset;
223 }
224
234 public static function getPreset(int $id): array
235 {
237 $settings['general'] = General::getGroupSettings($id);
238
239 $row =
240 OptionGroupTable::query()
241 ->setSelect([
242 'NAME',
243 'SORT',
244 'USER_ID'
245 ])
246 ->where('ID', $id)
247 ->fetch()
248 ;
249
250 return [
251 'id' => $id,
252 'name' => $row['NAME'],
253 'sort' => (int)$row['SORT'],
254 'userId' => $row['USER_ID'],
255 'settings' => $settings,
256 ];
257 }
258
259 public static function getDefaultUserPreset(): array
260 {
261 $generalPreset = [
262 'settings' => General::getDefaultSettings(),
263 'id' => self::getDefaultPresetId(),
264 'sort' => 0,
265 'name' => self::getPresetName(['NAME' =>'default'])
266 ];
267
268 $notifyPreset = [
269 'settings' => Notification::getDefaultSettings(),
270 'id' => self::getDefaultPresetId(),
271 'sort' => 0,
272 'name' => self::getPresetName(['NAME' =>'default'])
273 ];
274
275 return [
276 'notify' => $notifyPreset,
277 'general' => $generalPreset
278 ];
279 }
280
288 public static function getUserPresetIds(int $userId): ?array
289 {
290 $ids =
291 OptionUserTable::query()
292 ->setSelect(['NOTIFY_GROUP_ID', 'GENERAL_GROUP_ID'])
293 ->where('USER_ID', $userId)
294 ->fetch()
295 ;
296
297 if ($ids === false)
298 {
299 return null;
300 }
301
302 return [
303 'notify' => (int)$ids['NOTIFY_GROUP_ID'],
304 'general' => (int)$ids['GENERAL_GROUP_ID']
305 ];
306 }
307
317 public static function getListAvailablePresets(int $userId): array
318 {
319 $query =
320 OptionGroupTable::query()
321 ->setSelect(['ID', 'NAME'])
322 ->registerRuntimeField(
323 'OPTION_ACCESS',
324 new Reference(
325 'OPTION_ACCESS',
326 OptionAccessTable::class,
327 Join::on('this.ID', 'ref.GROUP_ID'),
328 ['join_type' => Join::TYPE_INNER]
329 )
330 )
331 ->registerRuntimeField(
332 'USER_ACCESS',
333 new Reference(
334 'USER_ACCESS',
335 UserAccessTable::class,
336 Join::on('this.OPTION_ACCESS.ACCESS_CODE', 'ref.ACCESS_CODE'),
337 ['join_type' => Join::TYPE_INNER]
338 )
339 )
340 ->where('USER_ACCESS.USER_ID', $userId)
341 ;
342 $presets = [];
343 foreach ($query->exec() as $row)
344 {
345 $presets[] = [
346 'id' => $row['ID'],
347 'name' => self::getPresetName($row),
348 ];
349 }
350
351 return $presets;
352 }
353
363 public static function createUserPreset(int $userId, array $settings = []): int
364 {
365 $groupId = self::createPersonalGroup($userId);
366
367 if (empty($settings))
368 {
369 return $groupId;
370 }
371
372 Notification::setSettings($groupId, $settings['notify']);
373 General::setSettings($groupId, $settings['general']);
374
375 $bindingPresetToUser = [];
376 if (!empty($settings['notify']))
377 {
378 $bindingPresetToUser['NOTIFY_GROUP_ID'] = $groupId;
379 }
380 if (!empty($settings['general']))
381 {
382 $bindingPresetToUser['GENERAL_GROUP_ID'] = $groupId;
383 }
384
385 if (!empty($bindingPresetToUser))
386 {
387 OptionUserTable::update($userId, $bindingPresetToUser);
388 }
389
390
391 return $groupId;
392 }
393
401 public static function restoreBindings(int $userId): int
402 {
403 $userPreset = OptionGroupTable::query()
404 ->addSelect('ID')
405 ->where('USER_ID', $userId)
406 ->setLimit(1)
407 ->fetch()
408 ;
409
410 $presetId = $userPreset ? (int)$userPreset['ID'] : self::getDefaultPresetId();
411
412 $insertFields = [
413 'USER_ID' => $userId,
414 'GENERAL_GROUP_ID' => $presetId,
415 'NOTIFY_GROUP_ID' => $presetId
416 ];
417 $updateFields = [
418 'GENERAL_GROUP_ID' => $presetId,
419 'NOTIFY_GROUP_ID' => $presetId,
420 ];
421
422 OptionUserTable::merge($insertFields, $updateFields);
423
424 return $presetId;
425 }
426
445 public static function createSharedPreset(
446 array $accessCodes,
447 string $presetName,
448 int $creatorId,
449 array $settings = [],
450 int $sort = self::DEFAULT_SORT,
451 bool $force = false
452 ): ?int
453 {
454 if ($sort >= self::USER_PRESET_SORT)
455 {
456 return null;
457 }
458
459 $newGroupId = self::createSharedGroup($presetName, $accessCodes, $creatorId, $sort);
460
461 if (empty($settings))
462 {
463 return $newGroupId;
464 }
465
466 Notification::setSettings($newGroupId, $settings['notify']);
467 General::setSettings($newGroupId, $settings['general']);
468
469 $rowCandidates =
470 UserAccessTable::query()
471 ->addSelect('USER_ID')
472 ->registerRuntimeField(
473 'OPTION_USER_TABLE',
474 new Reference(
475 'OPTION_USER_TABLE',
476 OptionUserTable::class,
477 Join::on('this.USER_ID', 'ref.USER_ID'),
478 ['join_type' => Join::TYPE_INNER]
479 )
480 )
481 ->whereIn('ACCESS_CODE', $accessCodes)
482 ;
483 $candidates = [];
484 foreach ($rowCandidates->exec() as $rowCandidate)
485 {
486 $candidates[] = $rowCandidate['USER_ID'];
487 }
488
489 if ($force)
490 {
491 OptionUserTable::updateMulti(
492 $candidates,
493 [
494 'NOTIFY_GROUP_ID' => $newGroupId,
495 'GENERAL_GROUP_ID' => $newGroupId
496 ],
497 true
498 );
499
500 return $newGroupId;
501 }
502 //the priority of the group must be taken into account
503 self::updateGroupForUsers($newGroupId, $candidates, $sort, self::NOTIFY_GROUP);
504 self::updateGroupForUsers($newGroupId, $candidates, $sort, self::GENERAL_GROUP);
505 self::cleanUsersCache($candidates);
506
507 return $newGroupId;
508 }
509
515 public static function updateNameSharedPreset(int $presetId, int $modifyId, string $newName): void
516 {
517 OptionGroupTable::update(
518 $presetId,
519 [
520 'NAME' => $newName,
521 'MODIFY_BY_ID' => $modifyId
522 ]
523 );
524
525 $query =
526 OptionUserTable::query()
527 ->addSelect('USER_ID')
528 ->where(\Bitrix\Main\ORM\Query\Query::filter()
529 ->logic('or')
530 ->where('GENERAL_GROUP_ID', $presetId)
531 ->where('NOTIFY_GROUP_ID', $presetId)
532 )
533 ;
534 $usersId = [];
535 foreach($query->exec() as $row)
536 {
537 $usersId[] = (int)$row['USER_ID'];
538 }
539
540 self::cleanUsersCache($usersId);
541 }
542
550 public static function updatePresetSettings(int $presetId, int $modifyId, array $settings): void
551 {
552 Notification::updateGroupSettings($presetId, $settings['notify']);
553 General::updateGroupSettings($presetId, $settings['general']);
554
555 $query =
556 OptionUserTable::query()
557 ->addSelect('USER_ID')
558 ->where(\Bitrix\Main\ORM\Query\Query::filter()
559 ->logic('or')
560 ->where('GENERAL_GROUP_ID', $presetId)
561 ->where('NOTIFY_GROUP_ID', $presetId)
562 )
563 ;
564 $usersId = [];
565 foreach($query->exec() as $row)
566 {
567 $usersId[] = (int)$row['USER_ID'];
568 }
569
570 self::cleanUsersCache($usersId);
571
572 OptionGroupTable::update(
573 $presetId,
574 [
575 'MODIFY_BY_ID' => $modifyId
576 ]
577 );
578 }
579
585 public static function deletePreset(int $presetId): bool
586 {
587 if ($presetId === self::getDefaultPresetId())
588 {
589 return false;
590 }
591
592 self::replaceGroupForUsers($presetId, self::NOTIFY_GROUP);
593 self::replaceGroupForUsers($presetId, self::GENERAL_GROUP);
594
595 self::deleteGroup($presetId);
596
597 return true;
598 }
599
607 public static function setExistingPresetToUsers(int $presetId, array $userList, bool $force = false): void
608 {
609 //the priority of the group must be taken into account
610 if (!$force)
611 {
612 $sort =
613 OptionGroupTable::query()
614 ->addSelect('SORT')
615 ->where('ID', $presetId)
616 ->fetch()['SORT'];
617
618 $query =
619 OptionUserTable::query()
620 ->addSelect('USER_ID')
621 ->registerRuntimeField(
622 'OPTION_GROUP',
623 new Reference(
624 'OPTION_GROUP',
625 OptionGroupTable::class,
626 Join::on('this.GROUP_ID', 'ref.ID'),
627 ['join_type' => Join::TYPE_INNER]
628 )
629 )
630 ->whereIn('USER_ID', $userList)
631 ->where('OPTION_GROUP.SORT', '>=', (int)$sort)
632 ;
633
634 $users = [];
635 foreach ($query->exec() as $user)
636 {
637 $users = $user['USER_ID'];
638 }
639 $userList = $users;
640 }
641
642 OptionUserTable::updateMulti(
643 $userList,
644 [
645 'NOTIFY_GROUP_ID' => $presetId,
646 'GENERAL_GROUP_ID' => $presetId
647 ],
648 true
649 );
650
651 self::cleanUsersCache($userList);
652 }
653
659 public static function chooseExistingPreset(int $presetId, int $userId): void
660 {
661 OptionUserTable::update(
662 $userId,
663 [
664 'NOTIFY_GROUP_ID' => $presetId,
665 'GENERAL_GROUP_ID' => $presetId
666 ]
667 );
668
669 CacheManager::getUserCache($userId)->clearCache();
670 }
671
677 private static function replaceGroupForUsers(int $groupId, string $groupType): void
678 {
679 $rowUsers =
680 OptionUserTable::query()
681 ->addSelect('USER_ID')
682 ;
683
684 if ($groupType === self::NOTIFY_GROUP)
685 {
686 $rowUsers->where('NOTIFY_GROUP_ID', $groupId);
687 }
688 elseif ($groupType === self::GENERAL_GROUP)
689 {
690 $rowUsers->where('GENERAL_GROUP_ID', $groupId);
691 }
692
693 $usersId = [];
694 foreach ($rowUsers->exec() as $user)
695 {
696 $usersId[] = (int)$user['USER_ID'];
697 self::replaceGroupForUser((int)$user['USER_ID'], $groupId, $groupType);
698 }
699
700 self::cleanUsersCache($usersId);
701 }
702
703
710 private static function replaceGroupForUser(int $userId, int $groupId, string $groupType): void
711 {
712 $query =
713 OptionGroupTable::query()
714 ->addSelect('ID')
715 ->registerRuntimeField(
716 'OPTION_ACCESS',
717 new Reference(
718 'OPTION_ACCESS',
719 OptionAccessTable::class,
720 Join::on('this.ID', 'ref.GROUP_ID'),
721 ['join_type' => Join::TYPE_INNER]
722 )
723 )
724 ->registerRuntimeField(
725 'USER_ACCESS',
726 new Reference(
727 'USER_ACCESS',
728 UserAccessTable::class,
729 Join::on('this.OPTION_ACCESS.ACCESS_CODE', 'ref.ACCESS_CODE'),
730 ['join_type' => Join::TYPE_INNER]
731 )
732 )
733 ->registerRuntimeField(
734 'OPTION_USER',
735 new Reference(
736 'OPTION_USER',
737 OptionUserTable::class,
738 Join::on('this.USER_ACCESS.USER_ID', 'ref.USER_ID'),
739 ['join_type' => Join::TYPE_INNER]
740 )
741 )
742 ->registerRuntimeField(
743 'OPTION_STATE',
744 new Reference(
745 'OPTION_STATE',
746 OptionStateTable::class,
747 Join::on('this.ID', 'ref.GROUP_ID'),
748 ['join_type' => Join::TYPE_INNER]
749 )
750 )
751 ->where('OPTION_USER.USER_ID', $userId)
752 ->where('ID', '!=', $groupId)
753 ->where(Query::expr()->count('OPTION_STATE.NAME'), '>', 0)
754 ->setOrder(['SORT' => 'DESC', 'ID' => 'DESC'])
755 ->setLimit(1)
756 ;
757 $replacedGroup = $query->fetch()['ID'];
758
759 if ($groupType === self::NOTIFY_GROUP)
760 {
761 OptionUserTable::update($userId, ['NOTIFY_GROUP_ID' => $replacedGroup]);
762 }
763 elseif ($groupType === self::GENERAL_GROUP)
764 {
765 OptionUserTable::update($userId, ['GENERAL_GROUP_ID' => $replacedGroup]);
766 }
767 }
768
774 protected static function deleteGroup(int $groupId): void
775 {
777
778 $connection->query(
779 "DELETE FROM b_im_option_state WHERE GROUP_ID = $groupId"
780 );
781
782 $connection->query(
783 "DELETE FROM b_im_option_access WHERE GROUP_ID = $groupId"
784 );
785
786 $connection->query(
787 "DELETE FROM b_im_option_group WHERE ID = $groupId"
788 );
789 }
790
798 protected static function createSharedGroup(
799 string $name,
800 array $accessCodes,
801 int $creator,
802 int $sort = self::DEFAULT_SORT
803 ): int
804 {
805 $newGroupId =
806 OptionGroupTable::add([
807 'NAME' => $name,
808 'SORT' => $sort,
809 'CREATE_BY_ID' => $creator
810 ])->getId()
811 ;
812
813 $rows = [];
814 foreach ($accessCodes as $accessCode)
815 {
816 $rows[] = [
817 'GROUP_ID' => $newGroupId,
818 'ACCESS_CODE' => $accessCode
819 ];
820 }
821 OptionAccessTable::addMulti($rows, true);
822
823 return $newGroupId;
824 }
825
834 protected static function createPersonalGroup(int $creator)
835 {
836 $newGroupId =
837 OptionGroupTable::add([
838 'USER_ID' => $creator,
839 'SORT' => self::USER_PRESET_SORT,
840 'CREATE_BY_ID' => $creator,
841 ])->getId()
842 ;
843
844 OptionAccessTable::add([
845 'GROUP_ID' => $newGroupId,
846 'ACCESS_CODE' => 'U' . $creator,
847 ]);
848
849 return $newGroupId;
850 }
851
857 private static function updateGroupForUsers(int $groupId, array $candidates, int $sort, string $groupType): void
858 {
859 $join = new ConditionTree();
860
861 if ($groupType === self::GENERAL_GROUP)
862 {
863 $join = Join::on('this.GENERAL_GROUP_ID', 'ref.ID');
864 }
865 elseif ($groupType === self::NOTIFY_GROUP)
866 {
867 $join = Join::on('this.NOTIFY_GROUP_ID', 'ref.ID');
868 }
869
870 $query =
871 OptionUserTable::query()
872 ->addSelect('USER_ID')
873 ->registerRuntimeField(
874 'OPTION_GROUP',
875 new Reference(
876 'OPTION_GROUP',
877 OptionGroupTable::class,
878 $join,
879 ['join_type' => Join::TYPE_INNER]
880 )
881 )
882 ->whereIn('USER_ID', $candidates)
883 ->where('OPTION_GROUP.SORT', '<=', $sort)
884 ;
885
886 $users = [];
887 foreach ($query->exec() as $row)
888 {
889 $users[] = $row["USER_ID"];
890 }
891
892
893 if ($groupType === self::GENERAL_GROUP)
894 {
895 OptionUserTable::updateMulti($users, ['GENERAL_GROUP_ID' => $groupId]);
896 }
897 elseif ($groupType === self::NOTIFY_GROUP)
898 {
899 OptionUserTable::updateMulti($users, ['NOTIFY_GROUP_ID' => $groupId]);
900 }
901 }
902
903 private static function getPresetName($preset): string
904 {
905 switch ($preset['NAME'])
906 {
907 case '':
908 return Loc::getMessage("IM_CONFIGURATION_PERSONAL_PRESET_NAME");
909 case 'default':
910 return Loc::getMessage("IM_CONFIGURATION_DEFAULT_PRESET_NAME");
911 default:
912 return $preset['NAME'];
913 }
914 }
915
916
917 public static function getUserPresetFromCache(int $userId): array
918 {
919 $result = [];
920 $userCache = CacheManager::getUserCache($userId);
921 $currentUserPresets = $userCache->getValue();
922
923 if (isset($currentUserPresets['notifyPreset']))
924 {
925 $notifyPresetCache = CacheManager::getPresetCache($currentUserPresets['notifyPreset']);
926 $notifyPreset = $notifyPresetCache->getValue();
927 if (!empty($notifyPreset))
928 {
929 $result['notify'] = [
930 'id' => $notifyPreset['id'],
931 'name' => $notifyPreset['name'],
932 'sort' => $notifyPreset['sort'],
933 'settings' => $notifyPreset['notify']
934 ];
935 }
936 }
937
938 if (isset($currentUserPresets['generalPreset']))
939 {
940 $generalPresetCache = CacheManager::getPresetCache($currentUserPresets['generalPreset']);
941 $generalPreset = $generalPresetCache->getValue();
942 if (!empty($generalPreset))
943 {
944 $result['general'] = [
945 'id' => $generalPreset['id'],
946 'name' => $generalPreset['name'],
947 'sort' => $generalPreset['sort'],
948 'settings' => $generalPreset['general']
949 ];
950 }
951 }
952
953 return $result;
954 }
955
956 private static function setUserPresetInCache(int $userId, array $preset): void
957 {
958 CacheManager::getUserCache($userId)->clearCache();
959 CacheManager::getPresetCache($preset['general']['id'])->clearCache();
960 CacheManager::getPresetCache($preset['notify']['id'])->clearCache();
961
962 CacheManager::getUserCache($userId)->setValue([
963 CacheManager::GENERAL_PRESET => $preset['general']['id'],
964 CacheManager::NOTIFY_PRESET => $preset['notify']['id'],
965 ]);
966
967 if ($preset['general']['id'] === $preset['notify']['id'])
968 {
969 CacheManager::getPresetCache($preset['general']['id'])->setValue([
970 'id' => $preset['general']['id'],
971 'name' => $preset['general']['name'],
972 'sort' => $preset['general']['sort'],
973 'general' => $preset['general']['settings'],
974 'notify' => $preset['notify']['settings'],
975 ]);
976
977 return;
978 }
979
980 CacheManager::getPresetCache($preset['general']['id'])->setValue([
981 'id' => $preset['general']['id'],
982 'name' => $preset['general']['name'],
983 'sort' => $preset['general']['sort'],
984 'general' => $preset['general']['settings'],
985 ]);
986
987 CacheManager::getPresetCache($preset['notify']['id'])->setValue([
988 'id' => $preset['notify']['id'],
989 'name' => $preset['notify']['name'],
990 'sort' => $preset['notify']['sort'],
991 'notify' => $preset['notify']['settings'],
992 ]);
993 }
994
1001 public static function cleanUsersCache(array $usersId): void
1002 {
1003 $cache = Cache::createInstance();
1004 foreach ($usersId as $userId)
1005 {
1006 $cacheName = self::CACHE_NAME."_$userId";
1007 $cache->clean($cacheName, self::CACHE_DIR);
1008 }
1009 }
1010
1017 public static function cleanUserCache(int $userId): void
1018 {
1019 $cache = Cache::createInstance();
1020 $cacheName = self::CACHE_NAME."_$userId";
1021 $cache->clean($cacheName, self::CACHE_DIR);
1022 }
1023
1029 public static function cleanAllCache(): void
1030 {
1031 $cache = Cache::createInstance();
1032 $cache->cleanDir(self::CACHE_DIR);
1033 }
1034
1035}
$connection
Определения actionsdefinitions.php:38
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getUserPresetFromCache(int $userId)
Определения Configuration.php:917
static chooseExistingPreset(int $presetId, int $userId)
Определения Configuration.php:659
static setExistingPresetToUsers(int $presetId, array $userList, bool $force=false)
Определения Configuration.php:607
static createUserPreset(int $userId, array $settings=[])
Определения Configuration.php:363
static createSharedGroup(string $name, array $accessCodes, int $creator, int $sort=self::DEFAULT_SORT)
Определения Configuration.php:798
static updateNameSharedPreset(int $presetId, int $modifyId, string $newName)
Определения Configuration.php:515
static cleanUserCache(int $userId)
Определения Configuration.php:1017
static deleteGroup(int $groupId)
Определения Configuration.php:774
static updatePresetSettings(int $presetId, int $modifyId, array $settings)
Определения Configuration.php:550
static cleanUsersCache(array $usersId)
Определения Configuration.php:1001
static getPreset(int $id)
Определения Configuration.php:234
static getUserPresetIds(int $userId)
Определения Configuration.php:288
static getListAvailablePresets(int $userId)
Определения Configuration.php:317
static deletePreset(int $presetId)
Определения Configuration.php:585
static createSharedPreset(array $accessCodes, string $presetName, int $creatorId, array $settings=[], int $sort=self::DEFAULT_SORT, bool $force=false)
Определения Configuration.php:445
static getUserPreset(int $userId)
Определения Configuration.php:108
static restoreBindings(int $userId)
Определения Configuration.php:401
static createPersonalGroup(int $creator)
Определения Configuration.php:834
static getTopDepartmentId()
Определения Department.php:102
static updateGroupSettings(int $groupId, array $settings)
Определения General.php:478
static setSettings(int $groupId, array $settings=[], bool $forInitialize=false)
Определения General.php:149
static getDefaultSettings()
Определения General.php:95
static getGroupSettings(int $groupId)
Определения General.php:410
static updateGroupSettings(int $groupId, array $settings)
Определения Notification.php:543
static setSettings(int $groupId, array $settings=[], bool $forInitialize=false)
Определения Notification.php:624
static getDefaultSettings()
Определения Notification.php:347
static getGroupSettings(int $groupId)
Определения Notification.php:488
static getSimpleNotifySettings(array $generalSettings)
Определения Notification.php:404
static getConnection($name="")
Определения application.php:638
static set($moduleId, $name, $value="", $siteId="")
Определения option.php:261
static includeModule($moduleName)
Определения loader.php:67
static add(array $data)
Определения datamanager.php:877
$userList
Определения discount_coupon_list.php:276
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$query
Определения get_search.php:11
$name
Определения menu_edit.php:35
Определения chain.php:3
$user
Определения mysql_to_pgsql.php:33
$settings
Определения product_settings.php:43
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$rows
Определения options.php:264