ILIAS  release_7 Revision v7.30-3-g800a261c036
ilProfileChecklistStatus.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
15
19
23 protected $lng;
24
28 protected $settings;
29
33 public function __construct($lng = null, $user = null)
34 {
35 global $DIC;
36
37 $this->lng = is_null($lng)
38 ? $DIC->language()
39 : $lng;
40
41 $this->lng->loadLanguageModule('chatroom');
42 $this->user = is_null($user)
43 ? $DIC->user()
44 : $user;
45
46 $this->settings = $DIC->settings();
47
48 $this->profile_mode = new ilPersonalProfileMode($this->user, $DIC->settings());
49 }
50
54 private function areOnScreenChatOptionsVisible() : bool
55 {
56 $chatSettings = new ilSetting('chatroom');
57 $notificationSettings = new ilSetting('notifications');
58
59 return (
60 $chatSettings->get('enable_osc', false) &&
61 !(bool) $notificationSettings->get('usr_settings_hide_chat_osc_accept_msg', false)
62 );
63 }
64
71 public function getSteps()
72 {
74
75 $txt_visibility = $this->anyVisibilitySettings()
76 ? $lng->txt("user_visibility_settings")
77 : $lng->txt("preview");
78
79 return [
80 self::STEP_PROFILE_DATA => $lng->txt("user_profile_data"),
81 self::STEP_PUBLISH_OPTIONS => $lng->txt("user_publish_options"),
82 self::STEP_VISIBILITY_OPTIONS => $txt_visibility
83 ];
84 }
85
91 public function anyVisibilitySettings() : bool
92 {
93 $awrn_set = new ilSetting("awrn");
94 if (
95 $awrn_set->get("awrn_enabled", false) ||
96 ilBuddySystem::getInstance()->isEnabled() ||
97 $this->areOnScreenChatOptionsVisible()
98 ) {
99 return true;
100 }
101
102 return false;
103 }
104
111 public function getStatus(int $step)
112 {
113 $status = self::STATUS_NOT_STARTED;
114 $user = $this->user;
115
116 switch ($step) {
118 if ($user->getPref("profile_personal_data_saved")) {
119 $status = self::STATUS_SUCCESSFUL;
120 }
121
122 if ($user->getProfileIncomplete()) {
123 $status = self::STATUS_IN_PROGRESS;
124 }
125 break;
126
128 if ($user->getPref("profile_publish_opt_saved")) {
129 $status = self::STATUS_SUCCESSFUL;
130 }
131 break;
132
134 if ($user->getPref("profile_visibility_opt_saved") ||
135 (!$this->anyVisibilitySettings() && $user->getPref("profile_publish_opt_saved"))) {
136 $status = self::STATUS_SUCCESSFUL;
137 }
138 break;
139 }
140
141 return $status;
142 }
143
150 public function getStatusDetails(int $step) : string
151 {
153 $user = $this->user;
154 $status = $this->getStatus($step);
155 $details = "";
156 switch ($step) {
158 if ($status == self::STATUS_SUCCESSFUL) {
159 $details = $lng->txt("user_profile_data_checked");
160 } else {
161 $details = $lng->txt("user_check_profile_data");
162 }
163 break;
164
166 if ($status == self::STATUS_SUCCESSFUL) {
167 $details = $this->profile_mode->getModeInfo();
168 } else {
169 $details = $lng->txt("user_set_publishing_options");
170 }
171 break;
172
174 if ($status == self::STATUS_SUCCESSFUL) {
175 $awrn_set = new ilSetting("awrn");
176 $status = [];
177 if ($awrn_set->get("awrn_enabled", false)) {
178 $show = ($user->getPref("hide_own_online_status") == "n" ||
179 ($user->getPref("hide_own_online_status") == "" && $this->settings->get("hide_own_online_status") == "n"));
180 $status[] = (!$show)
181 ? $lng->txt("hide_own_online_status")
182 : $lng->txt("show_own_online_status");
183 }
184 if (ilBuddySystem::getInstance()->isEnabled()) {
185 $status[] = ($user->getPref("bs_allow_to_contact_me") != "y")
186 ? $lng->txt("buddy_allow_to_contact_me_no")
187 : $lng->txt("buddy_allow_to_contact_me_yes");
188 }
189 if ($this->areOnScreenChatOptionsVisible()) {
190 $status[] = ilUtil::yn2tf($this->user->getPref('chat_osc_accept_msg'))
191 ? $lng->txt("chat_use_osc")
192 : $lng->txt("chat_not_use_osc");
193 }
194 $details = implode(",<br>", $status);
195 } else {
196 if ($this->anyVisibilitySettings()) {
197 $details = $lng->txt("user_set_visibilty_options");
198 }
199 }
200 break;
201 }
202 return $details;
203 }
204
205
211 public function saveStepSucess($step)
212 {
213 $user = $this->user;
214 switch ($step) {
216 $user->setPref("profile_personal_data_saved", "1");
217 break;
219 $user->setPref("profile_publish_opt_saved", "1");
220 break;
222 $user->setPref("profile_visibility_opt_saved", "1");
223 break;
224 }
225 $user->update();
226 }
227}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Personal profile publishing mode of a iser.
getStatusDetails(int $step)
Get status details.
anyVisibilitySettings()
Any visibility settings?
saveStepSucess($step)
Save step success.
__construct($lng=null, $user=null)
Constructor.
getStatus(int $step)
Get status of step.
ILIAS Setting Class.
static yn2tf($a_yn)
convert "y"/"n" to true/false
global $DIC
Definition: goto.php:24
settings()
Definition: settings.php:2