ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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->user = is_null($user)
42 ? $DIC->user()
43 : $user;
44
45 $this->settings = $DIC->settings();
46
47 $this->profile_mode = new ilPersonalProfileMode($this->user, $DIC->settings());
48 }
49
56 public function getSteps()
57 {
59
60 $txt_visibility = $this->anyVisibilitySettings()
61 ? $lng->txt("user_visibility_settings")
62 : $lng->txt("preview");
63
64 return [
65 self::STEP_PROFILE_DATA => $lng->txt("user_profile_data"),
66 self::STEP_PUBLISH_OPTIONS => $lng->txt("user_publish_options"),
67 self::STEP_VISIBILITY_OPTIONS => $txt_visibility
68 ];
69 }
70
76 public function anyVisibilitySettings() : bool
77 {
78 $awrn_set = new ilSetting("awrn");
79 if ($awrn_set->get("awrn_enabled", false) ||
80 ilBuddySystem::getInstance()->isEnabled()) {
81 return true;
82 }
83
84 return false;
85 }
86
93 public function getStatus(int $step)
94 {
96 $user = $this->user;
97
98 switch ($step) {
100 if ($user->getPref("profile_personal_data_saved")) {
101 $status = self::STATUS_SUCCESSFUL;
102 };
103 if ($user->getProfileIncomplete()) {
104 $status = self::STATUS_IN_PROGRESS;
105 }
106 break;
108 if ($user->getPref("profile_publish_opt_saved")) {
109 $status = self::STATUS_SUCCESSFUL;
110 };
111 break;
113 if ($user->getPref("profile_visibility_opt_saved") ||
114 (!$this->anyVisibilitySettings() && $user->getPref("profile_publish_opt_saved"))) {
115 $status = self::STATUS_SUCCESSFUL;
116 };
117 break;
118 }
119
120 return $status;
121 }
122
129 public function getStatusDetails(int $step) : string
130 {
132 $user = $this->user;
133 $status = $this->getStatus($step);
134 $details = "";
135 switch ($step) {
137 if ($status == self::STATUS_SUCCESSFUL) {
138 $details = $lng->txt("user_profile_data_checked");
139 } else {
140 $details = $lng->txt("user_check_profile_data");
141 }
142 break;
143
145 if ($status == self::STATUS_SUCCESSFUL) {
146 $details = $this->profile_mode->getModeInfo();
147 } else {
148 $details = $lng->txt("user_set_publishing_options");
149 }
150 break;
151
153 if ($status == self::STATUS_SUCCESSFUL) {
154 $awrn_set = new ilSetting("awrn");
155 $status = [];
156 if ($awrn_set->get("awrn_enabled", false)) {
157 $show = ($user->getPref("hide_own_online_status") == "n" ||
158 ($user->getPref("hide_own_online_status") == "" && $this->settings->get("hide_own_online_status") == "n"));
159 $status[] = (!$show)
160 ? $lng->txt("hide_own_online_status")
161 : $lng->txt("show_own_online_status");
162 }
163 if (ilBuddySystem::getInstance()->isEnabled()) {
164 $status[] = ($user->getPref("bs_allow_to_contact_me") != "y")
165 ? $lng->txt("buddy_allow_to_contact_me_no")
166 : $lng->txt("buddy_allow_to_contact_me_yes");
167 }
168 $details = implode(",<br>", $status);
169 } else {
170 if ($this->anyVisibilitySettings()) {
171 $details = $lng->txt("user_set_visibilty_options");
172 }
173 }
174 break;
175 }
176 return $details;
177 }
178
179
185 public function saveStepSucess($step)
186 {
187 $user = $this->user;
188 switch ($step) {
190 $user->setPref("profile_personal_data_saved", "1");
191 break;
193 $user->setPref("profile_publish_opt_saved", "1");
194 break;
196 $user->setPref("profile_visibility_opt_saved", "1");
197 break;
198 }
199 $user->update();
200 }
201}
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.
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46