ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

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 }
user()
Definition: user.php:4
Personal profile publishing mode of a iser.
User settings configuration (what preferences can be visible/changed/...)
settings()
Definition: settings.php:2
ui()
Definition: ui.php:5
$DIC
Definition: xapitoken.php:46

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

+ 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
\ILIAS\UI\Component\Input\Container\Form\Standard

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

189 {
190 $ui = $this->ui;
191 $f = $ui->factory();
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 }
isAwarnessSettingVisible()
Is awareness tool setting visible.
isContactSettingVisible()
Is contact setting visible.

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

Referenced by savePrivacySettings(), and showPrivacySettings().

+ 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.

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 }
ILIAS Setting Class.

Referenced by initPrivacySettingsForm(), and savePrivacySettings().

+ 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.

175 : bool
176 {
177 if (ilBuddySystem::getInstance()->isEnabled() && $this->userSettingVisible('bs_allow_to_contact_me')) {
178 return true;
179 }
180 return false;
181 }

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

Referenced by initPrivacySettingsForm(), and savePrivacySettings().

+ 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.

247 {
249 $form = $this->initPrivacySettingsForm();
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 }
showPrivacySettings($form=null)
General settings form.
$data
Definition: storeScorm.php:23

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

+ 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.

130 {
132 $ui = $this->ui;
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.

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

Referenced by savePrivacySettings().

+ 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.

121 : bool
122 {
123 return $this->user_settings_config->isVisible($setting);
124 }

Referenced by isContactSettingVisible().

+ 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.

112 : bool
113 {
114 return $this->user_settings_config->isVisibleAndChangeable($setting);
115 }

Referenced by savePrivacySettings().

+ 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: