ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 {
12  const STEP_PROFILE_DATA = 0;
15 
16  const STATUS_NOT_STARTED = 0;
17  const STATUS_IN_PROGRESS = 1;
18  const STATUS_SUCCESSFUL = 2;
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  {
58  $lng = $this->lng;
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  {
95  $status = self::STATUS_NOT_STARTED;
96  $user = $this->user;
97 
98  switch ($step) {
99  case self::STEP_PROFILE_DATA:
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;
107  case self::STEP_PUBLISH_OPTIONS:
108  if ($user->getPref("profile_publish_opt_saved")) {
109  $status = self::STATUS_SUCCESSFUL;
110  };
111  break;
112  case self::STEP_VISIBILITY_OPTIONS:
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  {
131  $lng = $this->lng;
132  $user = $this->user;
133  $status = $this->getStatus($step);
134  $details = "";
135  switch ($step) {
136  case self::STEP_PROFILE_DATA:
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 
144  case self::STEP_PUBLISH_OPTIONS:
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 
152  case self::STEP_VISIBILITY_OPTIONS:
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) {
189  case self::STEP_PROFILE_DATA:
190  $user->setPref("profile_personal_data_saved", "1");
191  break;
192  case self::STEP_PUBLISH_OPTIONS:
193  $user->setPref("profile_publish_opt_saved", "1");
194  break;
195  case self::STEP_VISIBILITY_OPTIONS:
196  $user->setPref("profile_visibility_opt_saved", "1");
197  break;
198  }
199  $user->update();
200  }
201 }
saveStepSucess($step)
Save step success.
Personal profile publishing mode of a iser.
settings()
Definition: settings.php:2
anyVisibilitySettings()
Any visibility settings?
user()
Definition: user.php:4
getStatusDetails(int $step)
Get status details.
getStatus(int $step)
Get status of step.
$DIC
Definition: xapitoken.php:46
__construct($lng=null, $user=null)
Constructor.