ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUserSettingsConfig.php
Go to the documentation of this file.
1 <?php
2 
24 {
25  public const HIDE_PREFIX = "usr_settings_hide_";
26  public const DISABLED_PREFIX = "usr_settings_disable_";
30  protected array $setting;
31  protected ?ilSetting $settings;
32 
33  public function __construct(
34  ilSetting $settings = null
35  ) {
36  global $DIC;
37 
38  $this->settings = (is_null($settings))
39  ? $DIC->settings()
40  : $settings;
41  $this->setting = $this->settings->getAll();
42  }
43 
47  public function isVisibleAndChangeable(
48  string $field
49  ): bool {
50  return $this->isVisible($field) && $this->isChangeable($field);
51  }
52 
56  public function isVisible(
57  string $field
58  ): bool {
59  return (!(isset($this->setting[self::HIDE_PREFIX . $field]) &&
60  $this->setting[self::HIDE_PREFIX . $field] == 1));
61  }
62 
66  public function isChangeable(
67  string $field
68  ): bool {
69  return (!(isset($this->setting[self::DISABLED_PREFIX . $field]) &&
70  $this->setting[self::DISABLED_PREFIX . $field] == 1));
71  }
72 
76  public function setVisible(string $field, bool $visible): void
77  {
78  if (!$visible) {
79  $this->settings->set(self::HIDE_PREFIX . $field, "1");
80  $this->setting[self::HIDE_PREFIX . $field] = 1;
81  } else {
82  $this->settings->delete(self::HIDE_PREFIX . $field);
83  unset($this->setting[self::HIDE_PREFIX . $field]);
84  }
85  }
86 
90  public function setChangeable(string $field, bool $changeable): void
91  {
92  if (!$changeable) {
93  $this->settings->set(self::DISABLED_PREFIX . $field, "1");
94  $this->setting[self::DISABLED_PREFIX . $field] = 1;
95  } else {
96  $this->settings->delete(self::DISABLED_PREFIX . $field);
97  unset($this->setting[self::DISABLED_PREFIX . $field]);
98  }
99  }
100 }
isVisible(string $field)
Is setting visible to user?
isChangeable(string $field)
Is setting changeable by user?
global $DIC
Definition: feed.php:28
isVisibleAndChangeable(string $field)
Is field visible and changeable by user?
setVisible(string $field, bool $visible)
Set a profile field being visible.
__construct(ilSetting $settings=null)
setChangeable(string $field, bool $changeable)
Set a profile field being changeable.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...