12 private const FEATURE_OPTION =
'feature_calendar_open_events_enabled';
14 private static ?
self $instance;
18 self::$instance ??=
new self();
20 return self::$instance;
27 $userId = (int)CurrentUser::get()->getId();
30 return $this->isEnabled(
$userId) && Loader::includeModule(
'im');
35 \CUserOptions::SetOption(
36 category: Common::CALENDAR_MODULE_ID,
37 name: $this->getOptionName(),
45 \CUserOptions::DeleteOption(
46 category: Common::CALENDAR_MODULE_ID,
47 name: $this->getOptionName(),
55 moduleId: Common::CALENDAR_MODULE_ID,
56 name: $this->getOptionName(),
64 moduleId: Common::CALENDAR_MODULE_ID,
65 name: $this->getOptionName(),
70 private function isEnabled(
int $userId): bool
72 $enabledForEveryone = $this->isEnabledForEveryone();
74 if ($enabledForEveryone)
79 return $this->isEnabledForUser(
$userId);
82 private function isEnabledForEveryone(): bool
84 return Config\Option::get(
85 moduleId: Common::CALENDAR_MODULE_ID,
86 name: $this->getOptionName(),
91 private function isEnabledForUser(
int $userId): bool
93 return \CUserOptions::GetOption(
94 category: Common::CALENDAR_MODULE_ID,
95 name: $this->getOptionName(),
101 private function getOptionName(): string
103 return self::FEATURE_OPTION;
106 private function __construct()
static set($moduleId, $name, $value="", $siteId="")