ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Visibility.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Profile;
22
24
30{
31 public const PROFILE_DISABLED = 'n';
33 public const PROFILE_ENABLED_GLOBAL = 'g';
34
35 public function __construct(
36 private readonly Language $lng,
37 private readonly \ilSetting $settings,
38 private readonly \ilObjUser $user
39 ) {
40 }
41
42 public function getMode(): string
43 {
44 $public_profile_pref = $this->user->getPref('public_profile');
45 if ($public_profile_pref === null
46 || !in_array(
47 $public_profile_pref,
48 [
49 self::PROFILE_ENABLED_LOGGED_IN_USERS,
50 self::PROFILE_ENABLED_GLOBAL
51 ]
52 )) {
54 }
55
56 if ($this->settings->get('enable_global_profiles')) {
57 return $public_profile_pref;
58 }
60 }
61
62 public function isEnabled(): bool
63 {
64 return in_array(
65 $this->getMode(),
66 [
67 self::PROFILE_ENABLED_LOGGED_IN_USERS,
68 self::PROFILE_ENABLED_GLOBAL
69 ]
70 );
71 }
72
73 public function getModeInfo(?string $mode = null): string
74 {
75 switch ($this->getMode()) {
77 return $this->lng->txt('usr_public_profile_disabled');
79 return $this->lng->txt('usr_public_profile_logged_in');
81 return $this->lng->txt('usr_public_profile_global');
82 }
83 return '';
84 }
85}
Personal profile publishing mode of a user.
Definition: Visibility.php:30
getModeInfo(?string $mode=null)
Definition: Visibility.php:73
__construct(private readonly Language $lng, private readonly \ilSetting $settings, private readonly \ilObjUser $user)
Definition: Visibility.php:35
User class.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31