ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 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.

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 {
54 $this->user_id = $ilUser->getId();
55 }
56
57 $this->read();
58 }
read()
Read store settings.
global $ilDB
$ilUser
Definition: imgupload.php:18

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

196 {
197 $query = "DELETE FROM usr_form_settings".
198 " WHERE user_id = ".$this->db->quote($this->user_id,'integer').
199 " AND id = ".$this->db->quote($this->id,'text');
200 $this->db->manipulate($query);
201
202 if($a_reset)
203 {
204 $this->reset();
205 }
206 }
reset()
Remove all settings (internally)

References $query, and reset().

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

224 {
225 $query = "DELETE FROM usr_form_settings".
226 " WHERE id = ".$GLOBALS['ilDB']->quote($a_id,'text');
227 $GLOBALS['ilDB']->manipulate($query);
228
229 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $GLOBALS, and $query.

◆ deleteAllForPrefix()

static ilUserFormSettings::deleteAllForPrefix (   $a_prefix)
static

Delete all entries for prefix.

Parameters
type$a_prefix

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

236 {
237 $query = "DELETE FROM usr_form_settings ".
238 'WHERE '. $GLOBALS['ilDB']->like('id', 'text', $a_prefix.'%');
239
240 $GLOBALS['ilDB']->manipulate($query);
241
242 }

References $GLOBALS, and $query.

Referenced by ilMemberExportSettingsGUI\savePrintViewSettings().

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

212 {
213 global $ilDB;
214 $query = "DELETE FROM usr_form_settings".
215 " WHERE user_id = ".$ilDB->quote($a_user_id,'integer');
216 $ilDB->manipulate($query);
217 }

References $ilDB, and $query.

◆ deleteValue()

ilUserFormSettings::deleteValue (   $a_option)

Delete value.

Parameters
string$a_option

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

129 {
130 if($this->valueExists($a_option))
131 {
132 unset($this->settings[$a_option]);
133 }
134 }
valueExists($a_option)
Does value exist in settings?
settings()
Definition: settings.php:2

References settings(), and 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 93 of file class.ilUserFormSettings.php.

94 {
95 return (bool)$this->getValue($a_option);
96 }
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 290 of file class.ilUserFormSettings.php.

291 {
292 foreach($a_form->getItems() as $item)
293 {
294 if(method_exists($item, "getPostVar"))
295 {
296 $field = $item->getPostVar();
297
298 if($this->valueExists($field))
299 {
300 $value = $this->getValue($field);
301
302 if(method_exists($item, "setDate"))
303 {
304 $date = new ilDateTime($value, IL_CAL_DATETIME);
305 $item->setDate($date);
306 }
307 else if(method_exists($item, "setChecked"))
308 {
309 $item->setChecked((bool)$value);
310 }
311 else if(method_exists($item, "setValue"))
312 {
313 $item->setValue($value);
314 }
315 }
316 }
317 }
318 }
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 104 of file class.ilUserFormSettings.php.

105 {
106 if($this->valueExists($a_option))
107 {
108 return $this->settings[$a_option];
109 }
110 }

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

Returns
type

Definition at line 64 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 249 of file class.ilUserFormSettings.php.

250 {
251 $this->reset();
252
253 foreach($a_form->getItems() as $item)
254 {
255 if(method_exists($item, "getPostVar"))
256 {
257 $field = $item->getPostVar();
258
259 if(method_exists($item, "getDate"))
260 {
261 $value = $item->getDate();
262 if($value && !$value->isNull())
263 {
264 $value = $value->get(IL_CAL_DATETIME);
265 }
266 }
267 else if(method_exists($item, "getChecked"))
268 {
269 $value = $item->getChecked();
270 }
271 else if(method_exists($item, "getMulti") && $item->getMulti())
272 {
273 $value = $item->getMultiValues();
274 }
275 else if(method_exists($item, "getValue"))
276 {
277 $value = $item->getValue();
278 }
279
280 $this->setValue($field, $value);
281 }
282 }
283 }
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 170 of file class.ilUserFormSettings.php.

171 {
172 $query = "SELECT * FROM usr_form_settings".
173 " WHERE user_id = ".$this->db->quote($this->user_id,'integer').
174 " AND id = ".$this->db->quote($this->id,'text');
175 $res = $this->db->query($query);
176
177 if($res->numRows())
178 {
179 $this->has_stored_entry = true;
180 }
181
182 $this->reset();
184 {
185 $this->settings = unserialize($row->settings);
186 }
187 return true;
188 }

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

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

83 {
84 $this->settings = array();
85 }

References 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 (   $a_data)

Set Settings.

Parameters
arrayArray of Settings

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

75 {
76 $this->settings = $a_data;
77 }

References settings().

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

119 {
120 $this->settings[$a_option] = $a_value;
121 }

References settings().

Referenced by importFromForm().

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

151 {
152 $this->delete(false);
153
154 $query = "INSERT INTO usr_form_settings (user_id,id,settings) ".
155 "VALUES( ".
156 $this->db->quote($this->user_id,'integer').", ".
157 $this->db->quote($this->id,'text').", ".
158 $this->db->quote(serialize($this->settings),'text')." ".
159 ")";
160 $this->db->manipulate($query);
161 }

References $query, and settings().

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

143 {
144 return array_key_exists($a_option,(array)$this->settings);
145 }

References 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

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: