ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ChecklistStatus.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Profile;
22
24
29{
30 public const STEP_PROFILE_DATA = 0;
31 public const STEP_PUBLISH_OPTIONS = 1;
32 public const STEP_VISIBILITY_OPTIONS = 2;
33
34 public const STATUS_NOT_STARTED = 0;
35 public const STATUS_IN_PROGRESS = 1;
36 public const STATUS_SUCCESSFUL = 2;
37
38 private \ilSetting $settings_chat;
39 private \ilSetting $settings_awareness;
40
41 public function __construct(
42 private readonly Language $lng,
43 private readonly \ilSetting $settings,
44 private \ilObjUser $user,
45 private readonly Visibility $profile_mode
46 ) {
47 $this->settings_chat = new \ilSetting('chatroom');
48 $this->settings_awareness = new \ilSetting('awrn');
49
50 $this->lng->loadLanguageModule('chatroom');
51 }
55 public function getSteps(): array
56 {
57 $txt_visibility = $this->anyVisibilitySettings()
58 ? $this->lng->txt('user_visibility_settings')
59 : $this->lng->txt('preview');
60
61 return [
62 self::STEP_PROFILE_DATA => $this->lng->txt('user_profile_data'),
63 self::STEP_PUBLISH_OPTIONS => $this->lng->txt('user_publish_options'),
64 self::STEP_VISIBILITY_OPTIONS => $txt_visibility
65 ];
66 }
67
68 public function anyVisibilitySettings(): bool
69 {
70
71 return $this->settings_awareness->get('awrn_enabled', '0') !== '0'
72 || \ilBuddySystem::getInstance()->isEnabled()
75 }
76
77 public function getStatus(int $step): int
78 {
79 switch ($step) {
81 if ($this->user->getProfileIncomplete()) {
83 }
84 if ($this->user->getPref('profile_personal_data_saved')) {
86 }
87 break;
88
90 if ($this->user->getPref('profile_publish_opt_saved')) {
92 }
93 break;
94
96 if ($this->user->getPref('profile_visibility_opt_saved')
97 || !$this->anyVisibilitySettings()
98 && $this->user->getPref('profile_publish_opt_saved')) {
100 }
101 break;
102 }
103
105 }
106
107 public function getStatusDetails(int $step): string
108 {
109 $status = $this->getStatus($step);
110 switch ($step) {
112 if ($status === self::STATUS_SUCCESSFUL) {
113 return $this->lng->txt('user_profile_data_checked');
114 }
115 return $this->lng->txt('user_check_profile_data');
116
118 if ($status === self::STATUS_SUCCESSFUL) {
119 return $this->profile_mode->getModeInfo();
120 }
121 return $this->lng->txt('user_set_publishing_options');
122
124 if ($status === self::STATUS_SUCCESSFUL) {
126 }
127 if ($this->anyVisibilitySettings()) {
128 return $this->lng->txt('user_set_visibilty_options');
129 }
130 break;
131 }
132 return '';
133 }
134
135 public function setStepSucessOnUser(
136 int $step,
137 \ilObjUser $user
138 ): \ilObjUser {
139 switch ($step) {
141 $user->setPref('profile_personal_data_saved', '1');
142 break;
144 $user->setPref('profile_publish_opt_saved', '1');
145 break;
147 $user->setPref('profile_visibility_opt_saved', '1');
148 break;
149 }
150 $this->user = $user;
151 return $user;
152 }
153
154 private function buildStatusArrayForVisibilityOnSuccess(): string
155 {
156 $status = [];
157 if ($this->settings_awareness->get('awrn_enabled', '0') !== '0') {
158 $show = $this->user->getPref('hide_own_online_status') === 'n'
159 || $this->user->getPref('hide_own_online_status') ?? '' === ''
160 && $this->settings->get('hide_own_online_status') === 'n';
161 $status[] = !$show
162 ? $this->lng->txt('hide_own_online_status')
163 : $this->lng->txt('show_own_online_status');
164 }
165 if (\ilBuddySystem::getInstance()->isEnabled()) {
166 $status[] = $this->user->getPref('bs_allow_to_contact_me') !== 'y'
167 ? $this->lng->txt('buddy_allow_to_contact_me_no')
168 : $this->lng->txt('buddy_allow_to_contact_me_yes');
169 }
170 if ($this->areOnScreenChatOptionsVisible()) {
171 $status[] = $this->user->getPref('chat_osc_accept_msg') === 'y'
172 ? $this->lng->txt('chat_use_osc')
173 : $this->lng->txt('chat_not_use_osc');
174 }
175 if ($this->areChatTypingBroadcastOptionsVisible()) {
176 $status[] = $this->user->getPref('chat_broadcast_typing') === 'y'
177 ? $this->lng->txt('chat_use_typing_broadcast')
178 : $this->lng->txt('chat_no_use_typing_broadcast');
179 }
180 return implode(',<br>', $status);
181 }
182
183 private function areOnScreenChatOptionsVisible(): bool
184 {
185 return $this->settings_chat->get('chat_enabled', '0') !== '0'
186 && $this->settings_chat->get('enable_osc', '0') !== '0'
187 && $this->settings->get('usr_settings_hide_chat_osc_accept_msg', '0') === '0';
188 }
189
191 {
192 return $this->settings_chat->get('chat_enabled', '0')
193 && $this->settings->get('usr_settings_hide_chat_broadcast_typing', '0') === '0';
194 }
195}
__construct(private readonly Language $lng, private readonly \ilSetting $settings, private \ilObjUser $user, private readonly Visibility $profile_mode)
setStepSucessOnUser(int $step, \ilObjUser $user)
Personal profile publishing mode of a user.
Definition: Visibility.php:30
User class.
setPref(string $a_keyword, ?string $a_value)
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