ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 = []
 

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.

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: shib_login.php:26

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

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

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 }

References reset().

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

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 }
$GLOBALS["DIC"]
Definition: wac.php:54

References $GLOBALS.

◆ deleteAllForPrefix()

static ilUserFormSettings::deleteAllForPrefix ( string  $a_prefix)
static

Delete all entries for prefix.

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

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 }

References $GLOBALS.

Referenced by ilMemberExportSettingsGUI\savePrintViewSettings().

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

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 }

References $DIC, and $ilDB.

◆ deleteValue()

ilUserFormSettings::deleteValue ( string  $a_option)

Delete value.

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

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?

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

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

74 : bool
75 {
76 return (bool) $this->getValue($a_option);
77 }
getValue(string $a_option)
Get value.

References getValue().

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

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
@classDescription Date and time handling

References getValue(), IL_CAL_DATETIME, and valueExists().

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

84 {
85 if ($this->valueExists($a_option)) {
86 return $this->settings[$a_option];
87 }
88 return null;
89 }

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

Referenced by enabled(), and exportToForm().

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

53 : bool
54 {
56 }

References $has_stored_entry.

◆ importFromForm()

ilUserFormSettings::importFromForm ( ilPropertyFormGUI  $a_form)

Import settings from form.

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

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 }
setValue(string $a_option, $a_value)

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

+ Here is the call graph for this function:

◆ read()

ilUserFormSettings::read ( )
protected

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

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

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

Referenced by __construct().

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

66 : void
67 {
68 $this->settings = [];
69 }

References ILIAS\Repository\settings().

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

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

61 : void // Missing array type.
62 {
63 $this->settings = $a_data;
64 }

References ILIAS\Repository\settings().

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

94 : void
95 {
96 $this->settings[$a_option] = $a_value;
97 }

References ILIAS\Repository\settings().

Referenced by importFromForm().

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

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 }

References ILIAS\Repository\settings().

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

112 : bool
113 {
114 return array_key_exists($a_option, $this->settings);
115 }

References ILIAS\Repository\settings().

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

+ 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 = []
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: