ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUserSettingsConfig.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 HIDE_PREFIX = "usr_settings_hide_";
13  const DISABLED_PREFIX = "usr_settings_disable_";
14 
18  public function __construct(ilSetting $settings = null)
19  {
20  global $DIC;
21 
22  $this->settings = (is_null($settings))
23  ? $DIC->settings()
24  : $settings;
25  $this->setting = $this->settings->getAll();
26  }
27 
33  public function isVisibleAndChangeable($field) : bool
34  {
35  return $this->isVisible($field) && $this->isChangeable($field);
36  }
37 
43  public function isVisible(string $field) : bool
44  {
45  return (!(isset($this->setting[self::HIDE_PREFIX . $field]) &&
46  $this->setting[self::HIDE_PREFIX . $field] == 1));
47  }
48 
54  public function isChangeable(string $field) : bool
55  {
56  return (!(isset($this->setting[self::DISABLED_PREFIX . $field]) &&
57  $this->setting[self::DISABLED_PREFIX . $field] == 1));
58  }
59 
65  public function setVisible(string $field, bool $visible)
66  {
67  if (!$visible) {
68  $this->settings->set(self::HIDE_PREFIX . $field, "1");
69  $this->setting[self::HIDE_PREFIX . $field] = 1;
70  } else {
71  $this->settings->delete(self::HIDE_PREFIX . $field);
72  unset($this->setting[self::HIDE_PREFIX . $field]);
73  }
74  }
75 
81  public function setChangeable(string $field, bool $changeable)
82  {
83  if (!$changeable) {
84  $this->settings->set(self::DISABLED_PREFIX . $field, "1");
85  $this->setting[self::DISABLED_PREFIX . $field] = 1;
86  } else {
87  $this->settings->delete(self::DISABLED_PREFIX . $field);
88  unset($this->setting[self::DISABLED_PREFIX . $field]);
89  }
90  }
91 }
isVisibleAndChangeable($field)
Is field visible and changeable by user?
settings()
Definition: settings.php:2
isVisible(string $field)
Is setting visible to user?
isChangeable(string $field)
Is setting changeable by user?
setVisible(string $field, bool $visible)
Set a profile field being visible.
__construct(ilSetting $settings=null)
Constructor.
setChangeable(string $field, bool $changeable)
Set a profile field being changeable.
$DIC
Definition: xapitoken.php:46
User settings configuration (what preferences can be visible/changed/...)