ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilPersonalProfileMode.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
12 const PROFILE_DISABLED = "n";
15
19 protected $user;
20
24 protected $settings;
25
29 protected $lng;
30
35 {
36 global $DIC;
37
38 $this->lng = $DIC->language();
39 $this->user = $user;
40 $this->settings = $settings;
41 }
42
48 public function getMode() : string
49 {
52
53 $pub_prof = in_array($user->prefs["public_profile"], [
54 self::PROFILE_DISABLED,
55 self::PROFILE_ENABLED_LOGGED_IN_USERS,
56 self::PROFILE_ENABLED_GLOBAL
57 ])
58 ? $user->prefs["public_profile"]
60 if (!$settings->get('enable_global_profiles') && $pub_prof == self::PROFILE_ENABLED_GLOBAL) {
62 }
63 return $pub_prof;
64 }
65
71 public function isEnabled() : bool
72 {
73 return in_array($this->getMode(), [self::PROFILE_ENABLED_LOGGED_IN_USERS,
74 self::PROFILE_ENABLED_GLOBAL
75 ]);
76 }
77
84 public function getModeInfo(string $mode = null) : string
85 {
87
88 if (is_null($mode)) {
89 $mode = $this->getMode();
90 }
91 switch ($mode) {
93 return $lng->txt("usr_public_profile_disabled");
94 break;
96 return $lng->txt("usr_public_profile_logged_in");
97 break;
99 return $lng->txt("usr_public_profile_global");
100 break;
101 }
102 }
103}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Personal profile publishing mode of a iser.
getModeInfo(string $mode=null)
Get mode info.
__construct(ilObjUser $user, ilSetting $settings)
Constructor.
ILIAS Setting Class.
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46