ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilUserFormSettings Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilUserFormSettings:

Public Member Functions

 __construct (string $a_id, ?int $a_user_id=null)
 
 hasStoredEntry ()
 Check if entry exist. More...
 
 set (array $a_data)
 
 reset ()
 
 enabled (string $a_option)
 Check if a specific option is enabled. More...
 
 getValue (string $a_option)
 Get value. More...
 
 setValue (string $a_option, $a_value)
 
 deleteValue (string $a_option)
 Delete value. More...
 
 valueExists (string $a_option)
 Does value exist in settings? More...
 
 store ()
 
 delete (bool $a_reset=true)
 Delete user related data. More...
 
 importFromForm (ilPropertyFormGUI $a_form)
 Import settings from form. More...
 
 exportToForm (ilPropertyFormGUI $a_form, bool $a_set_post=false)
 Export settings to form. More...
 

Static Public Member Functions

static deleteAllForUser (int $a_user_id)
 Delete all settings for user id. More...
 
static deleteAllForId (string $a_id)
 Delete for id. More...
 
static deleteAllForPrefix (string $a_prefix)
 Delete all entries for prefix. More...
 

Protected Member Functions

 read ()
 

Protected Attributes

ilDBInterface $db
 
int $user_id
 
string $id
 
array $settings = array()
 

Private Attributes

bool $has_stored_entry = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 22 of file class.ilUserFormSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilUserFormSettings::__construct ( string  $a_id,
?int  $a_user_id = null 
)

Definition at line 30 of file class.ilUserFormSettings.php.

References $DIC, $ilDB, $ilUser, ILIAS\Repository\int(), and read().

33  {
34  global $DIC;
35 
36  $ilDB = $DIC['ilDB'];
37  $ilUser = $DIC['ilUser'];
38 
39  $this->user_id = (int) $a_user_id;
40  $this->id = $a_id;
41  $this->db = $ilDB;
42 
43  if (!$this->user_id) {
44  $this->user_id = $ilUser->getId();
45  }
46 
47  $this->read();
48  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilUserFormSettings::delete ( bool  $a_reset = true)

Delete user related data.

Definition at line 150 of file class.ilUserFormSettings.php.

References $query, and reset().

150  : void
151  {
152  $query = "DELETE FROM usr_form_settings" .
153  " WHERE user_id = " . $this->db->quote($this->user_id, 'integer') .
154  " AND id = " . $this->db->quote($this->id, 'text');
155  $this->db->manipulate($query);
156 
157  if ($a_reset) {
158  $this->reset();
159  }
160  }
$query
+ Here is the call graph for this function:

◆ deleteAllForId()

static ilUserFormSettings::deleteAllForId ( string  $a_id)
static

Delete for id.

Definition at line 178 of file class.ilUserFormSettings.php.

References $GLOBALS, and $query.

178  : void
179  {
180  $query = "DELETE FROM usr_form_settings" .
181  " WHERE id = " . $GLOBALS['DIC']['ilDB']->quote($a_id, 'text');
182  $GLOBALS['DIC']['ilDB']->manipulate($query);
183  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$query

◆ deleteAllForPrefix()

static ilUserFormSettings::deleteAllForPrefix ( string  $a_prefix)
static

Delete all entries for prefix.

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

References $GLOBALS, and $query.

Referenced by ilMemberExportSettingsGUI\savePrintViewSettings().

188  : void
189  {
190  $query = "DELETE FROM usr_form_settings " .
191  'WHERE ' . $GLOBALS['DIC']['ilDB']->like('id', 'text', $a_prefix . '%');
192 
193  $GLOBALS['DIC']['ilDB']->manipulate($query);
194  }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$query
+ Here is the caller graph for this function:

◆ deleteAllForUser()

static ilUserFormSettings::deleteAllForUser ( int  $a_user_id)
static

Delete all settings for user id.

Definition at line 165 of file class.ilUserFormSettings.php.

References $DIC, $ilDB, and $query.

165  : void
166  {
167  global $DIC;
168 
169  $ilDB = $DIC['ilDB'];
170  $query = "DELETE FROM usr_form_settings" .
171  " WHERE user_id = " . $ilDB->quote($a_user_id, 'integer');
172  $ilDB->manipulate($query);
173  }
global $DIC
Definition: feed.php:28
$query

◆ deleteValue()

ilUserFormSettings::deleteValue ( string  $a_option)

Delete value.

Definition at line 102 of file class.ilUserFormSettings.php.

References ILIAS\Repository\settings(), and valueExists().

102  : void
103  {
104  if ($this->valueExists($a_option)) {
105  unset($this->settings[$a_option]);
106  }
107  }
valueExists(string $a_option)
Does value exist in settings?
+ Here is the call graph for this function:

◆ enabled()

ilUserFormSettings::enabled ( string  $a_option)

Check if a specific option is enabled.

Definition at line 74 of file class.ilUserFormSettings.php.

References getValue().

74  : bool
75  {
76  return (bool) $this->getValue($a_option);
77  }
getValue(string $a_option)
Get value.
+ Here is the call graph for this function:

◆ exportToForm()

ilUserFormSettings::exportToForm ( ilPropertyFormGUI  $a_form,
bool  $a_set_post = false 
)

Export settings to form.

Definition at line 229 of file class.ilUserFormSettings.php.

References ilPropertyFormGUI\getItems(), getValue(), IL_CAL_DATETIME, and valueExists().

232  : void {
233  foreach ($a_form->getItems() as $item) {
234  if (method_exists($item, "getPostVar")) {
235  $field = $item->getPostVar();
236 
237  if ($this->valueExists($field)) {
238  $value = $this->getValue($field);
239 
240  if (method_exists($item, "setDate")) {
241  $date = new ilDateTime($value, IL_CAL_DATETIME);
242  $item->setDate($date);
243  } elseif (method_exists($item, "setChecked")) {
244  $item->setChecked((bool) $value);
245  } elseif (method_exists($item, "setValue")) {
246  $item->setValue($value);
247  }
248  }
249  }
250  }
251  }
const IL_CAL_DATETIME
getValue(string $a_option)
Get value.
valueExists(string $a_option)
Does value exist in settings?
+ Here is the call graph for this function:

◆ getValue()

ilUserFormSettings::getValue ( string  $a_option)

Get value.

Returns
mixed

Definition at line 83 of file class.ilUserFormSettings.php.

References ILIAS\Repository\settings(), and valueExists().

Referenced by enabled(), and exportToForm().

84  {
85  if ($this->valueExists($a_option)) {
86  return $this->settings[$a_option];
87  }
88  return null;
89  }
valueExists(string $a_option)
Does value exist in settings?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasStoredEntry()

ilUserFormSettings::hasStoredEntry ( )

Check if entry exist.

Definition at line 53 of file class.ilUserFormSettings.php.

References $has_stored_entry.

53  : bool
54  {
56  }

◆ importFromForm()

ilUserFormSettings::importFromForm ( ilPropertyFormGUI  $a_form)

Import settings from form.

Definition at line 199 of file class.ilUserFormSettings.php.

References ilPropertyFormGUI\getItems(), IL_CAL_DATETIME, reset(), and setValue().

199  : void
200  {
201  $this->reset();
202  $value = null;
203 
204  foreach ($a_form->getItems() as $item) {
205  if (method_exists($item, "getPostVar")) {
206  $field = $item->getPostVar();
207 
208  if (method_exists($item, "getDate")) {
209  $value = $item->getDate();
210  if ($value && !$value->isNull()) {
211  $value = $value->get(IL_CAL_DATETIME);
212  }
213  } elseif (method_exists($item, "getChecked")) {
214  $value = $item->getChecked();
215  } elseif (method_exists($item, "getMulti") && $item->getMulti()) {
216  $value = $item->getMultiValues();
217  } elseif (method_exists($item, "getValue")) {
218  $value = $item->getValue();
219  }
220 
221  $this->setValue($field, $value);
222  }
223  }
224  }
const IL_CAL_DATETIME
setValue(string $a_option, $a_value)
+ Here is the call graph for this function:

◆ read()

ilUserFormSettings::read ( )
protected

Definition at line 130 of file class.ilUserFormSettings.php.

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, reset(), and ILIAS\Repository\settings().

Referenced by __construct().

130  : void
131  {
132  $query = "SELECT * FROM usr_form_settings" .
133  " WHERE user_id = " . $this->db->quote($this->user_id, 'integer') .
134  " AND id = " . $this->db->quote($this->id, 'text');
135  $res = $this->db->query($query);
136 
137  if ($res->numRows()) {
138  $this->has_stored_entry = true;
139  }
140 
141  $this->reset();
142  if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
143  $this->settings = unserialize($row->settings, ['allowed_classes' => false]);
144  }
145  }
$res
Definition: ltiservices.php:69
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilUserFormSettings::reset ( )

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

References ILIAS\Repository\settings().

Referenced by delete(), importFromForm(), and read().

66  : void
67  {
68  $this->settings = array();
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

ilUserFormSettings::set ( array  $a_data)
Parameters
arrayArray of Settings

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

References ILIAS\Repository\settings().

61  : void // Missing array type.
62  {
63  $this->settings = $a_data;
64  }
+ Here is the call graph for this function:

◆ setValue()

ilUserFormSettings::setValue ( string  $a_option,
  $a_value 
)
Parameters
mixed$a_value

Definition at line 94 of file class.ilUserFormSettings.php.

References ILIAS\Repository\settings().

Referenced by importFromForm().

94  : void
95  {
96  $this->settings[$a_option] = $a_value;
97  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store()

ilUserFormSettings::store ( )

Definition at line 117 of file class.ilUserFormSettings.php.

References $query, and ILIAS\Repository\settings().

117  : void
118  {
119  $this->delete(false);
120 
121  $query = "INSERT INTO usr_form_settings (user_id,id,settings) " .
122  "VALUES( " .
123  $this->db->quote($this->user_id, 'integer') . ", " .
124  $this->db->quote($this->id, 'text') . ", " .
125  $this->db->quote(serialize($this->settings), 'text') . " " .
126  ")";
127  $this->db->manipulate($query);
128  }
$query
+ Here is the call graph for this function:

◆ valueExists()

ilUserFormSettings::valueExists ( string  $a_option)

Does value exist in settings?

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

References ILIAS\Repository\settings().

Referenced by deleteValue(), exportToForm(), and getValue().

112  : bool
113  {
114  return array_key_exists($a_option, $this->settings);
115  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilUserFormSettings::$db
protected

Definition at line 24 of file class.ilUserFormSettings.php.

◆ $has_stored_entry

bool ilUserFormSettings::$has_stored_entry = false
private

Definition at line 28 of file class.ilUserFormSettings.php.

Referenced by hasStoredEntry().

◆ $id

string ilUserFormSettings::$id
protected

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

◆ $settings

array ilUserFormSettings::$settings = array()
protected

Definition at line 27 of file class.ilUserFormSettings.php.

◆ $user_id

int ilUserFormSettings::$user_id
protected

Definition at line 25 of file class.ilUserFormSettings.php.


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