ILIAS  release_8 Revision v8.24
class.ilPersonalProfileMode.php
Go to the documentation of this file.
1<?php
2
24{
25 public const PROFILE_DISABLED = "n";
27 public const PROFILE_ENABLED_GLOBAL = "g";
28
29 protected ilObjUser $user;
31 protected ilLanguage $lng;
32
34 {
35 global $DIC;
36
37 $this->lng = $DIC->language();
38 $this->user = $user;
39 $this->settings = $settings;
40 }
41
42 public function getMode(): string
43 {
46
47 $pub_prof = isset($user->prefs["public_profile"]) && in_array($user->prefs["public_profile"], [
48 self::PROFILE_DISABLED,
49 self::PROFILE_ENABLED_LOGGED_IN_USERS,
50 self::PROFILE_ENABLED_GLOBAL
51 ])
52 ? $user->prefs["public_profile"]
54 if (!$settings->get('enable_global_profiles') && $pub_prof == self::PROFILE_ENABLED_GLOBAL) {
56 }
57 return $pub_prof;
58 }
59
63 public function isEnabled(): bool
64 {
65 return in_array($this->getMode(), [self::PROFILE_ENABLED_LOGGED_IN_USERS,
66 self::PROFILE_ENABLED_GLOBAL
67 ]);
68 }
69
73 public function getModeInfo(string $mode = null): string
74 {
76
77 if (is_null($mode)) {
78 $mode = $this->getMode();
79 }
80 switch ($mode) {
82 return $lng->txt("usr_public_profile_disabled");
84 return $lng->txt("usr_public_profile_logged_in");
86 return $lng->txt("usr_public_profile_global");
87 }
88 return "";
89 }
90}
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getModeInfo(string $mode=null)
Get mode info.
__construct(ilObjUser $user, ilSetting $settings)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $a_keyword, ?string $a_default_value=null)
get setting
global $DIC
Definition: feed.php:28