ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
50 public function setSetting(string $keyword, string $value): void
51 {
52 $this->settings->set($keyword, $value);
53 }
54
55 public function getSetting(string $keyword, ?string $default = null): ?string
56 {
57 return $this->settings->get($keyword, $default);
58 }
59
60 public function isEnabled(): bool
61 {
62 if (self::$isEnabled !== null) {
63 return self::$isEnabled;
64 }
65
66 if ($this->user->isAnonymous()) {
67 self::$isEnabled = false;
68 return false;
69 }
70
71 self::$isEnabled = (bool) $this->settings->get('enabled', '0');
72 return self::$isEnabled;
73 }
74}
Class ilBuddySystem.
setSetting(string $keyword, string $value)
getSetting(string $keyword, ?string $default=null)
static self $instance
static bool $isEnabled
User class.
ILIAS Setting Class.
global $DIC
Definition: shib_login.php:26