ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserPrivacySettingsGUI Class Reference

User privacy settings (currently located under "Profile and Privacy") More...

+ Collaboration diagram for ilUserPrivacySettingsGUI:

Public Member Functions

 __construct ()
 constructor More...
 
 executeCommand ()
 execute command More...
 
 workWithUserSetting (string $setting)
 
 userSettingVisible (string $setting)
 
 showPrivacySettings ($form=null)
 General settings form. More...
 
 initPrivacySettingsForm ()
 Init form. More...
 
 savePrivacySettings ()
 Save privacy settings. More...
 

Protected Member Functions

 isAwarnessSettingVisible ()
 Is awareness tool setting visible. More...
 
 isContactSettingVisible ()
 Is contact setting visible. More...
 

Protected Attributes

 $lng
 
 $ctrl
 
 $main_tpl
 
 $user_settings_config
 
 $ui
 
 $user
 
 $settings
 
 $request
 
 $checklist_status
 
 $profile_mode
 

Detailed Description

User privacy settings (currently located under "Profile and Privacy")

Author
killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 10 of file class.ilUserPrivacySettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserPrivacySettingsGUI::__construct ( )

constructor

Definition at line 66 of file class.ilUserPrivacySettingsGUI.php.

References $DIC, settings(), ui(), and user().

67  {
68  global $DIC;
69 
70  $this->main_tpl = $DIC->ui()->mainTemplate();
71  $this->lng = $DIC->language();
72  $this->ctrl = $DIC->ctrl();
73  $this->lng->loadLanguageModule("user");
74  $this->ui = $DIC->ui();
75  $this->user = $DIC->user();
76 
77  $this->request = $DIC->http()->request();
78 
79  $this->user_settings_config = new ilUserSettingsConfig();
80  $this->settings = $DIC->settings();
81  $this->checklist_status = new ilProfileChecklistStatus();
82  $this->profile_mode = new ilPersonalProfileMode($this->user, $this->settings);
83  }
Personal profile publishing mode of a iser.
settings()
Definition: settings.php:2
user()
Definition: user.php:4
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46
User settings configuration (what preferences can be visible/changed/...)
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilUserPrivacySettingsGUI::executeCommand ( )

execute command

Definition at line 88 of file class.ilUserPrivacySettingsGUI.php.

89  {
90  $next_class = $this->ctrl->getNextClass();
91 
92  switch ($next_class) {
93  default:
94  $cmd = $this->ctrl->getCmd("showPrivacySettings");
95  $this->$cmd();
96  break;
97  }
98  $this->main_tpl->printToStdout();
99  }

◆ initPrivacySettingsForm()

ilUserPrivacySettingsGUI::initPrivacySettingsForm ( )

Init form.

Returns

Definition at line 188 of file class.ilUserPrivacySettingsGUI.php.

References $ctrl, Vendor\Package\$f, $lng, $settings, $ui, $user, isAwarnessSettingVisible(), isContactSettingVisible(), and settings().

Referenced by savePrivacySettings(), and showPrivacySettings().

189  {
190  $ui = $this->ui;
191  $f = $ui->factory();
192  $ctrl = $this->ctrl;
193  $lng = $this->lng;
194  $user = $this->user;
196 
197  $fields = [];
198 
199  // hide_own_online_status
200  if ($this->isAwarnessSettingVisible()) {
201  $lng->loadLanguageModule("awrn");
202 
203  $default = ($this->settings->get('hide_own_online_status') == "n")
204  ? $this->lng->txt("user_awrn_show")
205  : $this->lng->txt("user_awrn_hide");
206 
207  $options = array(
208  "x" => $this->lng->txt("user_awrn_default")." (".$default.")",
209  "n" => $this->lng->txt("user_awrn_show"),
210  "y" => $this->lng->txt("user_awrn_hide"));
211  $val = $user->prefs["hide_own_online_status"];
212  if ($val == "") {
213  $val = "x";
214  }
215  $fields["hide_own_online_status"] = $f->input()->field()->select(
216  $lng->txt("awrn_user_show"),
217  $options,
218  $lng->txt("awrn_hide_from_awareness_info"))
219  ->withValue($val)
220  ->withRequired(true)
221  ->withDisabled($settings->get("usr_settings_disable_hide_own_online_status")
222  );
223  }
224 
225  // allow to contact me
226  if ($this->isContactSettingVisible()) {
227  $lng->loadLanguageModule('buddysystem');
228  $fields["bs_allow_to_contact_me"] = $f->input()->field()->checkbox(
229  $lng->txt("buddy_allow_to_contact_me"),
230  $lng->txt("buddy_allow_to_contact_me_info")
231  )
232  ->withValue($user->prefs['bs_allow_to_contact_me'] == 'y')
233  ->withDisabled($settings->get('usr_settings_disable_bs_allow_to_contact_me'));
234  }
235 
236  // section
237  $section1 = $f->input()->field()->section($fields, $lng->txt("user_visibility_settings"));
238 
239  $form_action = $ctrl->getLinkTarget($this, "savePrivacySettings");
240  return $f->input()->container()->form()->standard($form_action, ["sec" => $section1]);
241  }
settings()
Definition: settings.php:2
isAwarnessSettingVisible()
Is awareness tool setting visible.
isContactSettingVisible()
Is contact setting visible.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAwarnessSettingVisible()

ilUserPrivacySettingsGUI::isAwarnessSettingVisible ( )
protected

Is awareness tool setting visible.

Returns
bool

Definition at line 161 of file class.ilUserPrivacySettingsGUI.php.

References userSettingVisible().

Referenced by initPrivacySettingsForm(), and savePrivacySettings().

161  : bool
162  {
163  $awrn_set = new ilSetting("awrn");
164  if ($awrn_set->get("awrn_enabled", false) && $this->userSettingVisible("hide_own_online_status")) {
165  return true;
166  }
167  return false;
168  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isContactSettingVisible()

ilUserPrivacySettingsGUI::isContactSettingVisible ( )
protected

Is contact setting visible.

Returns
bool

Definition at line 175 of file class.ilUserPrivacySettingsGUI.php.

References ilBuddySystem\getInstance(), and userSettingVisible().

Referenced by initPrivacySettingsForm(), and savePrivacySettings().

175  : bool
176  {
177  if (ilBuddySystem::getInstance()->isEnabled() && $this->userSettingVisible('bs_allow_to_contact_me')) {
178  return true;
179  }
180  return false;
181  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePrivacySettings()

ilUserPrivacySettingsGUI::savePrivacySettings ( )

Save privacy settings.

Definition at line 246 of file class.ilUserPrivacySettingsGUI.php.

References $ctrl, $data, $lng, $request, $user, initPrivacySettingsForm(), isAwarnessSettingVisible(), isContactSettingVisible(), showPrivacySettings(), ilProfileChecklistStatus\STEP_VISIBILITY_OPTIONS, and workWithUserSetting().

247  {
249  $form = $this->initPrivacySettingsForm();
250  $lng = $this->lng;
251  $user = $this->user;
252  $ctrl = $this->ctrl;
253 
254  if ($request->getMethod() == "POST") {
255  $form = $form->withRequest($request);
256  $data = $form->getData();
257  if (is_array($data["sec"])) {
258  if ($this->isAwarnessSettingVisible() && $this->workWithUserSetting("hide_own_online_status")) {
259  $val = $data["sec"]["hide_own_online_status"];
260  if ($val == "x") {
261  $val = "";
262  }
263  $user->setPref("hide_own_online_status",
264  $val);
265  }
266  if ($this->isContactSettingVisible() && $this->workWithUserSetting("bs_allow_to_contact_me")) {
267  if ($data["sec"]["bs_allow_to_contact_me"]) {
268  $user->setPref("bs_allow_to_contact_me", "y");
269  } else {
270  $user->setPref("bs_allow_to_contact_me", "n");
271  }
272  }
273  $user->update();
274  $this->checklist_status->saveStepSucess(ilProfileChecklistStatus::STEP_VISIBILITY_OPTIONS);
275  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
276  $ctrl->redirect($this, "");
277  }
278  }
279  $this->showPrivacySettings($form);
280  }
$data
Definition: storeScorm.php:23
isAwarnessSettingVisible()
Is awareness tool setting visible.
showPrivacySettings($form=null)
General settings form.
isContactSettingVisible()
Is contact setting visible.
+ Here is the call graph for this function:

◆ showPrivacySettings()

ilUserPrivacySettingsGUI::showPrivacySettings (   $form = null)

General settings form.

Definition at line 129 of file class.ilUserPrivacySettingsGUI.php.

References $lng, $main_tpl, $ui, $user, ilPublicUserProfileGUI\getEmbeddable(), and initPrivacySettingsForm().

Referenced by savePrivacySettings().

130  {
132  $ui = $this->ui;
133  $user = $this->user;
134  $lng = $this->lng;
135 
136  $html = "";
137  if ($this->checklist_status->anyVisibilitySettings()) {
138  if (is_null($form)) {
139  $form = $this->initPrivacySettingsForm();
140  }
141  $html = $ui->renderer()->render([$form]);
142  }
143 
144  $pub_profile = new ilPublicUserProfileGUI($user->getId());
145  if ($this->profile_mode->isEnabled()) {
146  $html .= $pub_profile->getEmbeddable();
147  } else {
148  if (!$this->checklist_status->anyVisibilitySettings()) {
149  $html .= $ui->renderer()->render([$ui->factory()->messageBox()->info($lng->txt("usr_public_profile_disabled"))]);
150  }
151  }
152 
153  $main_tpl->setContent($html);
154  }
GUI class for public user profile presentation.
getEmbeddable($a_add_goto=false)
get public profile html code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ userSettingVisible()

ilUserPrivacySettingsGUI::userSettingVisible ( string  $setting)
Parameters
string$setting
Returns
bool

Definition at line 121 of file class.ilUserPrivacySettingsGUI.php.

Referenced by isAwarnessSettingVisible(), and isContactSettingVisible().

121  : bool
122  {
123  return $this->user_settings_config->isVisible($setting);
124  }
+ Here is the caller graph for this function:

◆ workWithUserSetting()

ilUserPrivacySettingsGUI::workWithUserSetting ( string  $setting)
Parameters
string$setting
Returns
bool

Definition at line 112 of file class.ilUserPrivacySettingsGUI.php.

Referenced by savePrivacySettings().

112  : bool
113  {
114  return $this->user_settings_config->isVisibleAndChangeable($setting);
115  }
+ Here is the caller graph for this function:

Field Documentation

◆ $checklist_status

ilUserPrivacySettingsGUI::$checklist_status
protected

Definition at line 56 of file class.ilUserPrivacySettingsGUI.php.

◆ $ctrl

ilUserPrivacySettingsGUI::$ctrl
protected

◆ $lng

ilUserPrivacySettingsGUI::$lng
protected

◆ $main_tpl

ilUserPrivacySettingsGUI::$main_tpl
protected

Definition at line 26 of file class.ilUserPrivacySettingsGUI.php.

Referenced by showPrivacySettings().

◆ $profile_mode

ilUserPrivacySettingsGUI::$profile_mode
protected

Definition at line 61 of file class.ilUserPrivacySettingsGUI.php.

◆ $request

ilUserPrivacySettingsGUI::$request
protected

Definition at line 51 of file class.ilUserPrivacySettingsGUI.php.

Referenced by savePrivacySettings().

◆ $settings

ilUserPrivacySettingsGUI::$settings
protected

Definition at line 46 of file class.ilUserPrivacySettingsGUI.php.

Referenced by initPrivacySettingsForm().

◆ $ui

ilUserPrivacySettingsGUI::$ui
protected

◆ $user

ilUserPrivacySettingsGUI::$user
protected

◆ $user_settings_config

ilUserPrivacySettingsGUI::$user_settings_config
protected

Definition at line 31 of file class.ilUserPrivacySettingsGUI.php.


The documentation for this class was generated from the following file: