ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilBuddySystem.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 protected static $instance;
12
14 protected static $isEnabled;
15
17 protected $settings;
18
20 protected $user;
21
25 protected function __construct()
26 {
27 global $DIC;
28
29 $this->settings = new ilSetting('buddysystem');
30 $this->user = $DIC['ilUser'];
31 }
32
36 public static function getInstance() : self
37 {
38 if (!(self::$instance instanceof self)) {
39 self::$instance = new self();
40 }
41
42 return self::$instance;
43 }
44
49 public function setSetting(string $keyword, $value) : void
50 {
51 $this->settings->set($keyword, $value);
52 }
53
59 public function getSetting(string $keyword, bool $default = false)
60 {
61 return $this->settings->get($keyword, $default);
62 }
63
67 public function isEnabled() : bool
68 {
69 if (self::$isEnabled !== null) {
70 return self::$isEnabled;
71 }
72
73 if ($this->user->isAnonymous()) {
74 self::$isEnabled = false;
75 return false;
76 }
77
78 self::$isEnabled = (bool) $this->settings->get('enabled', false);
79 return self::$isEnabled;
80 }
81}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Class ilBuddySystem.
getSetting(string $keyword, bool $default=false)
setSetting(string $keyword, $value)
__construct()
ilBuddySystem constructor.
ILIAS Setting Class.
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46