ILIAS  release_8 Revision v8.24
class.ilBuddySystem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected static ?self $instance = null;
28 protected static ?bool $isEnabled = null;
29
31 protected ilObjUser $user;
32
33 protected function __construct()
34 {
35 global $DIC;
36
37 $this->settings = new ilSetting('buddysystem');
38 $this->user = $DIC['ilUser'];
39 }
40
41 public static function getInstance(): self
42 {
43 if (!(self::$instance instanceof self)) {
44 self::$instance = new self();
45 }
46
47 return self::$instance;
48 }
49
54 public function setSetting(string $keyword, string $value): void
55 {
56 $this->settings->set($keyword, $value);
57 }
58
64 public function getSetting(string $keyword, ?string $default = null): ?string
65 {
66 return $this->settings->get($keyword, $default);
67 }
68
69 public function isEnabled(): bool
70 {
71 if (self::$isEnabled !== null) {
72 return self::$isEnabled;
73 }
74
75 if ($this->user->isAnonymous()) {
76 self::$isEnabled = false;
77 return false;
78 }
79
80 self::$isEnabled = (bool) $this->settings->get('enabled', '0');
81 return self::$isEnabled;
82 }
83}
Class ilBuddySystem.
setSetting(string $keyword, string $value)
getSetting(string $keyword, ?string $default=null)
static self $instance
static bool $isEnabled
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28