ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPersonalProfileMode.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  public const PROFILE_DISABLED = "n";
26  public const PROFILE_ENABLED_LOGGED_IN_USERS = "y";
27  public const PROFILE_ENABLED_GLOBAL = "g";
28 
29  protected ilObjUser $user;
30  protected ilSetting $settings;
31  protected ilLanguage $lng;
32 
33  public function __construct(ilObjUser $user, ilSetting $settings)
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  {
44  $user = $this->user;
45  $settings = $this->settings;
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"]
53  : self::PROFILE_DISABLED;
54  if (!$settings->get('enable_global_profiles') && $pub_prof == self::PROFILE_ENABLED_GLOBAL) {
55  $pub_prof = self::PROFILE_ENABLED_LOGGED_IN_USERS;
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  {
75  $lng = $this->lng;
76 
77  if (is_null($mode)) {
78  $mode = $this->getMode();
79  }
80  switch ($mode) {
81  case self::PROFILE_DISABLED:
82  return $lng->txt("usr_public_profile_disabled");
83  case self::PROFILE_ENABLED_LOGGED_IN_USERS:
84  return $lng->txt("usr_public_profile_logged_in");
85  case self::PROFILE_ENABLED_GLOBAL:
86  return $lng->txt("usr_public_profile_global");
87  }
88  return "";
89  }
90 }
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
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...
getModeInfo(string $mode=null)
Get mode info.
global $DIC
Definition: feed.php:28
__construct(ilObjUser $user, ilSetting $settings)