ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilUserFormSettings Class Reference
+ Collaboration diagram for ilUserFormSettings:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 read ()
 Read store settings. More...
 

Protected Attributes

 $db
 
 $user_id
 
 $id
 
 $settings = array()
 

Private Attributes

 $has_stored_entry = false
 

Detailed Description

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

/

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

Constructor & Destructor Documentation

◆ __construct()

ilUserFormSettings::__construct (   $a_id,
  $a_user_id = null 
)

Constructor.

Parameters
int$a_user_id
int$a_id

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

References $ilDB, $ilUser, read(), and string.

45  {
46  global $ilDB, $ilUser;
47 
48  $this->user_id = (int) $a_user_id;
49  $this->id = (string) $a_id;
50  $this->db = $ilDB;
51 
52  if (!$this->user_id) {
53  $this->user_id = $ilUser->getId();
54  }
55 
56  $this->read();
57  }
Add rich text string
$ilUser
Definition: imgupload.php:18
global $ilDB
read()
Read store settings.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilUserFormSettings::delete (   $a_reset = true)

Delete user related data.

Parameters
bool$a_reset

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

References $query, and reset().

191  {
192  $query = "DELETE FROM usr_form_settings" .
193  " WHERE user_id = " . $this->db->quote($this->user_id, 'integer') .
194  " AND id = " . $this->db->quote($this->id, 'text');
195  $this->db->manipulate($query);
196 
197  if ($a_reset) {
198  $this->reset();
199  }
200  }
reset()
Remove all settings (internally)
$query
+ Here is the call graph for this function:

◆ deleteAllForId()

static ilUserFormSettings::deleteAllForId (   $a_id)
static

Delete for id.

Parameters
string$a_id

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

References $GLOBALS, and $query.

218  {
219  $query = "DELETE FROM usr_form_settings" .
220  " WHERE id = " . $GLOBALS['ilDB']->quote($a_id, 'text');
221  $GLOBALS['ilDB']->manipulate($query);
222  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query

◆ deleteAllForPrefix()

static ilUserFormSettings::deleteAllForPrefix (   $a_prefix)
static

Delete all entries for prefix.

Parameters
type$a_prefix

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

References $GLOBALS, and $query.

Referenced by ilMemberExportSettingsGUI\savePrintViewSettings().

229  {
230  $query = "DELETE FROM usr_form_settings " .
231  'WHERE ' . $GLOBALS['ilDB']->like('id', 'text', $a_prefix . '%');
232 
233  $GLOBALS['ilDB']->manipulate($query);
234  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query
+ Here is the caller graph for this function:

◆ deleteAllForUser()

static ilUserFormSettings::deleteAllForUser (   $a_user_id)
static

Delete all settings for user id.

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

References $ilDB, and $query.

206  {
207  global $ilDB;
208  $query = "DELETE FROM usr_form_settings" .
209  " WHERE user_id = " . $ilDB->quote($a_user_id, 'integer');
210  $ilDB->manipulate($query);
211  }
$query
global $ilDB

◆ deleteValue()

ilUserFormSettings::deleteValue (   $a_option)

Delete value.

Parameters
string$a_option

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

References settings(), and valueExists().

Referenced by ilAttendanceList\initForm().

127  {
128  if ($this->valueExists($a_option)) {
129  unset($this->settings[$a_option]);
130  }
131  }
valueExists($a_option)
Does value exist in settings?
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enabled()

ilUserFormSettings::enabled (   $a_option)

Check if a specific option is enabled.

Parameters
string$a_option
Returns
bool

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

References getValue().

93  {
94  return (bool) $this->getValue($a_option);
95  }
getValue($a_option)
Get value.
+ Here is the call graph for this function:

◆ exportToForm()

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

Export settings from form.

Parameters
ilPropertyFormGUI$a_form

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

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

273  {
274  foreach ($a_form->getItems() as $item) {
275  if (method_exists($item, "getPostVar")) {
276  $field = $item->getPostVar();
277 
278  if ($this->valueExists($field)) {
279  $value = $this->getValue($field);
280  if ($a_set_post) {
281  $_POST[$item->getPostVar()] = $value;
282  }
283 
284  if (method_exists($item, "setDate")) {
285  $date = new ilDateTime($value, IL_CAL_DATETIME);
286  $item->setDate($date);
287  } elseif (method_exists($item, "setChecked")) {
288  $item->setChecked((bool) $value);
289  } elseif (method_exists($item, "setValue")) {
290  $item->setValue($value);
291  }
292  }
293  }
294  }
295  }
valueExists($a_option)
Does value exist in settings?
const IL_CAL_DATETIME
getValue($a_option)
Get value.
Date and time handling
$_POST["username"]
+ Here is the call graph for this function:

◆ getValue()

ilUserFormSettings::getValue (   $a_option)

Get value.

Parameters
string$a_option
Returns
mixed

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

References settings(), and valueExists().

Referenced by enabled(), and exportToForm().

104  {
105  if ($this->valueExists($a_option)) {
106  return $this->settings[$a_option];
107  }
108  }
valueExists($a_option)
Does value exist in settings?
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasStoredEntry()

ilUserFormSettings::hasStoredEntry ( )

Check if entry exist.

Returns
type

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

References $has_stored_entry.

◆ importFromForm()

ilUserFormSettings::importFromForm ( ilPropertyFormGUI  $a_form)

Import settings from form.

Parameters
ilPropertyFormGUI$a_form

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

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

242  {
243  $this->reset();
244 
245  foreach ($a_form->getItems() as $item) {
246  if (method_exists($item, "getPostVar")) {
247  $field = $item->getPostVar();
248 
249  if (method_exists($item, "getDate")) {
250  $value = $item->getDate();
251  if ($value && !$value->isNull()) {
252  $value = $value->get(IL_CAL_DATETIME);
253  }
254  } elseif (method_exists($item, "getChecked")) {
255  $value = $item->getChecked();
256  } elseif (method_exists($item, "getMulti") && $item->getMulti()) {
257  $value = $item->getMultiValues();
258  } elseif (method_exists($item, "getValue")) {
259  $value = $item->getValue();
260  }
261 
262  $this->setValue($field, $value);
263  }
264  }
265  }
const IL_CAL_DATETIME
setValue($a_option, $a_value)
Set value.
reset()
Remove all settings (internally)
+ Here is the call graph for this function:

◆ read()

ilUserFormSettings::read ( )
protected

Read store settings.

private

Parameters

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

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

Referenced by __construct().

168  {
169  $query = "SELECT * FROM usr_form_settings" .
170  " WHERE user_id = " . $this->db->quote($this->user_id, 'integer') .
171  " AND id = " . $this->db->quote($this->id, 'text');
172  $res = $this->db->query($query);
173 
174  if ($res->numRows()) {
175  $this->has_stored_entry = true;
176  }
177 
178  $this->reset();
179  if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
180  $this->settings = unserialize($row->settings);
181  }
182  return true;
183  }
foreach($_POST as $key=> $value) $res
reset()
Remove all settings (internally)
$query
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilUserFormSettings::reset ( )

Remove all settings (internally)

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

References array, and settings().

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

82  {
83  $this->settings = array();
84  }
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set()

ilUserFormSettings::set (   $a_data)

Set Settings.

Parameters
arrayArray of Settings

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

References settings().

74  {
75  $this->settings = $a_data;
76  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ setValue()

ilUserFormSettings::setValue (   $a_option,
  $a_value 
)

Set value.

Parameters
string$a_option
mmixed$a_value

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

References settings().

Referenced by importFromForm().

117  {
118  $this->settings[$a_option] = $a_value;
119  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store()

ilUserFormSettings::store ( )

Store settings in DB.

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

References $query, and settings().

148  {
149  $this->delete(false);
150 
151  $query = "INSERT INTO usr_form_settings (user_id,id,settings) " .
152  "VALUES( " .
153  $this->db->quote($this->user_id, 'integer') . ", " .
154  $this->db->quote($this->id, 'text') . ", " .
155  $this->db->quote(serialize($this->settings), 'text') . " " .
156  ")";
157  $this->db->manipulate($query);
158  }
$query
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

◆ valueExists()

ilUserFormSettings::valueExists (   $a_option)

Does value exist in settings?

Parameters
string$a_option
Returns
bool

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

References array, and settings().

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

140  {
141  return array_key_exists($a_option, (array) $this->settings);
142  }
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilUserFormSettings::$db
protected

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

◆ $has_stored_entry

ilUserFormSettings::$has_stored_entry = false
private

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

Referenced by hasStoredEntry().

◆ $id

ilUserFormSettings::$id
protected

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

◆ $settings

ilUserFormSettings::$settings = array()
protected

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

◆ $user_id

ilUserFormSettings::$user_id
protected

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


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