ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilUserFormSettings Class Reference
+ Collaboration diagram for ilUserFormSettings:

Public Member Functions

 __construct ($a_id, $a_user_id=null)
 Constructor. 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)
 Export settings from form. More...
 

Static Public Member Functions

static deleteAllForUser ($a_user_id)
 Delete all settings for user id. More...
 

Protected Member Functions

 read ()
 Read store settings. More...
 

Protected Attributes

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

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 43 of file class.ilUserFormSettings.php.

44 {
45 global $ilDB, $ilUser;
46
47 $this->user_id = (int)$a_user_id;
48 $this->id = (string)$a_id;
49 $this->db = $ilDB;
50
51 if(!$this->user_id)
52 {
53 $this->user_id = $ilUser->getId();
54 }
55
56 $this->read();
57 }
read()
Read store settings.
global $ilDB
global $ilUser
Definition: imgupload.php:15

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

+ 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 180 of file class.ilUserFormSettings.php.

181 {
182 $query = "DELETE FROM usr_form_settings".
183 " WHERE user_id = ".$this->db->quote($this->user_id,'integer').
184 " AND id = ".$this->db->quote($this->id,'text');
185 $this->db->manipulate($query);
186
187 if($a_reset)
188 {
189 $this->reset();
190 }
191 }
reset()
Remove all settings (internally)

References $query, and reset().

+ Here is the call graph for this function:

◆ deleteAllForUser()

static ilUserFormSettings::deleteAllForUser (   $a_user_id)
static

Delete all settings for user id.

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

197 {
198 $query = "DELETE FROM usr_form_settings".
199 " WHERE user_id = ".$this->db->quote($a_user_id,'integer');
200 $this->db->manipulate($query);
201 }

References $query.

◆ deleteValue()

ilUserFormSettings::deleteValue (   $a_option)

Delete value.

Parameters
string$a_option

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

119 {
120 if($this->valueExists($a_option))
121 {
122 unset($this->settings[$a_option]);
123 }
124 }
valueExists($a_option)
Does value exist in settings?

References valueExists().

+ Here is the call 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 83 of file class.ilUserFormSettings.php.

84 {
85 return (bool)$this->getValue($a_option);
86 }
getValue($a_option)
Get value.

References getValue().

+ Here is the call graph for this function:

◆ exportToForm()

ilUserFormSettings::exportToForm ( ilPropertyFormGUI  $a_form)

Export settings from form.

Parameters
ilPropertyFormGUI$a_form

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

250 {
251 foreach($a_form->getItems() as $item)
252 {
253 if(method_exists($item, "getPostVar"))
254 {
255 $field = $item->getPostVar();
256
257 if($this->valueExists($field))
258 {
259 $value = $this->getValue($field);
260
261 if(method_exists($item, "setDate"))
262 {
263 $date = new ilDateTime($value, IL_CAL_DATETIME);
264 $item->setDate($date);
265 }
266 else if(method_exists($item, "setChecked"))
267 {
268 $item->setChecked((bool)$value);
269 }
270 else if(method_exists($item, "setValue"))
271 {
272 $item->setValue($value);
273 }
274 }
275 }
276 }
277 }
const IL_CAL_DATETIME
@classDescription Date and time handling

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

+ Here is the call graph for this function:

◆ getValue()

ilUserFormSettings::getValue (   $a_option)

Get value.

Parameters
string$a_option
Returns
mixed

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

95 {
96 if($this->valueExists($a_option))
97 {
98 return $this->settings[$a_option];
99 }
100 }

References valueExists().

Referenced by enabled(), and exportToForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importFromForm()

ilUserFormSettings::importFromForm ( ilPropertyFormGUI  $a_form)

Import settings from form.

Parameters
ilPropertyFormGUI$a_form

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

209 {
210 $this->reset();
211
212 foreach($a_form->getItems() as $item)
213 {
214 if(method_exists($item, "getPostVar"))
215 {
216 $field = $item->getPostVar();
217
218 if(method_exists($item, "getDate"))
219 {
220 $value = $item->getDate();
221 if($value && !$value->isNull())
222 {
223 $value = $value->get(IL_CAL_DATETIME);
224 }
225 }
226 else if(method_exists($item, "getChecked"))
227 {
228 $value = $item->getChecked();
229 }
230 else if(method_exists($item, "getMulti") && $item->getMulti())
231 {
232 $value = $item->getMultiValues();
233 }
234 else if(method_exists($item, "getValue"))
235 {
236 $value = $item->getValue();
237 }
238
239 $this->setValue($field, $value);
240 }
241 }
242 }
setValue($a_option, $a_value)
Set value.

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

+ Here is the call graph for this function:

◆ read()

ilUserFormSettings::read ( )
protected

Read store settings.

@access private

Parameters

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

161 {
162 $query = "SELECT * FROM usr_form_settings".
163 " WHERE user_id = ".$this->db->quote($this->user_id,'integer').
164 " AND id = ".$this->db->quote($this->id,'text');
165 $res = $this->db->query($query);
166
167 $this->reset();
168 if($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
169 {
170 $this->settings = unserialize($row->settings);
171 }
172 return true;
173 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $query, $res, $row, DB_FETCHMODE_OBJECT, and reset().

Referenced by __construct().

+ 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 72 of file class.ilUserFormSettings.php.

73 {
74 $this->settings = array();
75 }

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

+ Here is the caller graph for this function:

◆ set()

ilUserFormSettings::set (   $a_data)

Set Settings.

Parameters
arrayArray of Settings

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

65 {
66 $this->settings = $a_data;
67 }

◆ setValue()

ilUserFormSettings::setValue (   $a_option,
  $a_value 
)

Set value.

Parameters
string$a_option
mmixed$a_value

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

109 {
110 $this->settings[$a_option] = $a_value;
111 }

Referenced by importFromForm().

+ Here is the caller graph for this function:

◆ store()

ilUserFormSettings::store ( )

Store settings in DB.

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

141 {
142 $this->delete(false);
143
144 $query = "INSERT INTO usr_form_settings (user_id,id,settings) ".
145 "VALUES( ".
146 $this->db->quote($this->user_id,'integer').", ".
147 $this->db->quote($this->id,'text').", ".
148 $this->db->quote(serialize($this->settings),'text')." ".
149 ")";
150 $this->db->manipulate($query);
151 }

References $query.

◆ valueExists()

ilUserFormSettings::valueExists (   $a_option)

Does value exist in settings?

Parameters
string$a_option
Returns
bool

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

133 {
134 return array_key_exists($a_option,(array)$this->settings);
135 }

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

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilUserFormSettings::$db
protected

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

◆ $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: