ILIAS  release_8 Revision v8.24
ilProfileChecklistStatus.php
Go to the documentation of this file.
1<?php
2
23{
24 public const STEP_PROFILE_DATA = 0;
25 public const STEP_PUBLISH_OPTIONS = 1;
26 public const STEP_VISIBILITY_OPTIONS = 2;
27
28 public const STATUS_NOT_STARTED = 0;
29 public const STATUS_IN_PROGRESS = 1;
30 public const STATUS_SUCCESSFUL = 2;
32 protected ilObjUser $user;
33
34 protected ilLanguage $lng;
36
37 public function __construct(
38 ?ilLanguage $lng = null,
39 ?ilObjUser $user = null
40 ) {
41 global $DIC;
42
43 $this->lng = is_null($lng)
44 ? $DIC->language()
45 : $lng;
46
47 $this->lng->loadLanguageModule('chatroom');
48 $this->user = is_null($user)
49 ? $DIC->user()
50 : $user;
51
52 $this->settings = $DIC->settings();
53
54 $this->profile_mode = new ilPersonalProfileMode($this->user, $DIC->settings());
55 }
56
57 private function areOnScreenChatOptionsVisible(): bool
58 {
59 $chatSettings = new ilSetting('chatroom');
60
61 return (
62 $chatSettings->get('chat_enabled', '0') &&
63 $chatSettings->get('enable_osc', '0') &&
64 !(bool) $this->settings->get('usr_settings_hide_chat_osc_accept_msg', '0')
65 );
66 }
67
68 private function areChatTypingBroadcastOptionsVisible(): bool
69 {
70 $chatSettings = new ilSetting('chatroom');
71
72 return (
73 $chatSettings->get('chat_enabled', '0') &&
74 !(bool) $this->settings->get('usr_settings_hide_chat_broadcast_typing', '0')
75 );
76 }
77
81 public function getSteps(): array
82 {
84
85 $txt_visibility = $this->anyVisibilitySettings()
86 ? $lng->txt("user_visibility_settings")
87 : $lng->txt("preview");
88
89 return [
90 self::STEP_PROFILE_DATA => $lng->txt("user_profile_data"),
91 self::STEP_PUBLISH_OPTIONS => $lng->txt("user_publish_options"),
92 self::STEP_VISIBILITY_OPTIONS => $txt_visibility
93 ];
94 }
95
99 public function anyVisibilitySettings(): bool
100 {
101 $awrn_set = new ilSetting("awrn");
102 if (
103 $awrn_set->get("awrn_enabled", '0') ||
104 ilBuddySystem::getInstance()->isEnabled() ||
105 $this->areOnScreenChatOptionsVisible() ||
106 $this->areChatTypingBroadcastOptionsVisible()
107 ) {
108 return true;
109 }
110
111 return false;
112 }
113
117 public function getStatus(int $step): int
118 {
119 $status = self::STATUS_NOT_STARTED;
121
122 switch ($step) {
124 if ($user->getPref("profile_personal_data_saved")) {
125 $status = self::STATUS_SUCCESSFUL;
126 }
127
129 $status = self::STATUS_IN_PROGRESS;
130 }
131 break;
132
134 if ($user->getPref("profile_publish_opt_saved")) {
135 $status = self::STATUS_SUCCESSFUL;
136 }
137 break;
138
140 if ($user->getPref("profile_visibility_opt_saved") ||
141 (!$this->anyVisibilitySettings() && $user->getPref("profile_publish_opt_saved"))) {
142 $status = self::STATUS_SUCCESSFUL;
143 }
144 break;
145 }
146
147 return $status;
148 }
149
153 public function getStatusDetails(int $step): string
154 {
157 $status = $this->getStatus($step);
158 $details = "";
159 switch ($step) {
161 if ($status == self::STATUS_SUCCESSFUL) {
162 $details = $lng->txt("user_profile_data_checked");
163 } else {
164 $details = $lng->txt("user_check_profile_data");
165 }
166 break;
167
169 if ($status == self::STATUS_SUCCESSFUL) {
170 $details = $this->profile_mode->getModeInfo();
171 } else {
172 $details = $lng->txt("user_set_publishing_options");
173 }
174 break;
175
177 if ($status == self::STATUS_SUCCESSFUL) {
178 $awrn_set = new ilSetting("awrn");
179 $status = [];
180 if ($awrn_set->get("awrn_enabled", '0')) {
181 $show = ($user->getPref("hide_own_online_status") === "n" ||
182 ($user->getPref("hide_own_online_status") == "" && $this->settings->get("hide_own_online_status") === "n"));
183 $status[] = (!$show)
184 ? $lng->txt("hide_own_online_status")
185 : $lng->txt("show_own_online_status");
186 }
187 if (ilBuddySystem::getInstance()->isEnabled()) {
188 $status[] = ($user->getPref("bs_allow_to_contact_me") !== "y")
189 ? $lng->txt("buddy_allow_to_contact_me_no")
190 : $lng->txt("buddy_allow_to_contact_me_yes");
191 }
192 if ($this->areOnScreenChatOptionsVisible()) {
193 $status[] = ilUtil::yn2tf((string) $this->user->getPref('chat_osc_accept_msg'))
194 ? $lng->txt("chat_use_osc")
195 : $lng->txt("chat_not_use_osc");
196 }
198 $status[] = ilUtil::yn2tf((string) $this->user->getPref('chat_broadcast_typing'))
199 ? $lng->txt("chat_use_typing_broadcast")
200 : $lng->txt("chat_no_use_typing_broadcast");
201 }
202 $details = implode(",<br>", $status);
203 } else {
204 if ($this->anyVisibilitySettings()) {
205 $details = $lng->txt("user_set_visibilty_options");
206 }
207 }
208 break;
209 }
210 return $details;
211 }
212
213
217 public function saveStepSucess(int $step): void
218 {
220 switch ($step) {
222 $user->setPref("profile_personal_data_saved", "1");
223 break;
225 $user->setPref("profile_publish_opt_saved", "1");
226 break;
228 $user->setPref("profile_visibility_opt_saved", "1");
229 break;
230 }
231 $user->update();
232 }
233}
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.
setPref(string $a_keyword, ?string $a_value)
getPref(string $a_keyword)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getStatusDetails(int $step)
Get status details.
__construct(?ilLanguage $lng=null, ?ilObjUser $user=null)
saveStepSucess(int $step)
Save step success.
anyVisibilitySettings()
Any visibility settings?
ilPersonalProfileMode $profile_mode
getStatus(int $step)
Get status of step.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static yn2tf(string $a_yn)
global $DIC
Definition: feed.php:28
array $details
Details for error message relating to last request processed.
Definition: System.php:109