ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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.

45 {
46 global $DIC;
47
48 $ilDB = $DIC['ilDB'];
49 $ilUser = $DIC['ilUser'];
50
51 $this->user_id = (int) $a_user_id;
52 $this->id = (string) $a_id;
53 $this->db = $ilDB;
54
55 if (!$this->user_id) {
56 $this->user_id = $ilUser->getId();
57 }
58
59 $this->read();
60 }
read()
Read store settings.
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $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 193 of file class.ilUserFormSettings.php.

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

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

223 {
224 $query = "DELETE FROM usr_form_settings" .
225 " WHERE id = " . $GLOBALS['DIC']['ilDB']->quote($a_id, 'text');
226 $GLOBALS['DIC']['ilDB']->manipulate($query);
227 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64

References $GLOBALS, and $query.

◆ deleteAllForPrefix()

static ilUserFormSettings::deleteAllForPrefix (   $a_prefix)
static

Delete all entries for prefix.

Parameters
type$a_prefix

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

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

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

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

References $DIC, $ilDB, and $query.

◆ deleteValue()

ilUserFormSettings::deleteValue (   $a_option)

Delete value.

Parameters
string$a_option

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

130 {
131 if ($this->valueExists($a_option)) {
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 95 of file class.ilUserFormSettings.php.

96 {
97 return (bool) $this->getValue($a_option);
98 }
getValue($a_option)
Get value.

References getValue().

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

278 {
279 foreach ($a_form->getItems() as $item) {
280 if (method_exists($item, "getPostVar")) {
281 $field = $item->getPostVar();
282
283 if ($this->valueExists($field)) {
284 $value = $this->getValue($field);
285 if ($a_set_post) {
286 $_POST[$item->getPostVar()] = $value;
287 }
288
289 if (method_exists($item, "setDate")) {
290 $date = new ilDateTime($value, IL_CAL_DATETIME);
291 $item->setDate($date);
292 } elseif (method_exists($item, "setChecked")) {
293 $item->setChecked((bool) $value);
294 } elseif (method_exists($item, "setValue")) {
295 $item->setValue($value);
296 }
297 }
298 }
299 }
300 }
$_POST["username"]
const IL_CAL_DATETIME
@classDescription Date and time handling

References $_POST, 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 106 of file class.ilUserFormSettings.php.

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

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

247 {
248 $this->reset();
249
250 foreach ($a_form->getItems() as $item) {
251 if (method_exists($item, "getPostVar")) {
252 $field = $item->getPostVar();
253
254 if (method_exists($item, "getDate")) {
255 $value = $item->getDate();
256 if ($value && !$value->isNull()) {
257 $value = $value->get(IL_CAL_DATETIME);
258 }
259 } elseif (method_exists($item, "getChecked")) {
260 $value = $item->getChecked();
261 } elseif (method_exists($item, "getMulti") && $item->getMulti()) {
262 $value = $item->getMultiValues();
263 } elseif (method_exists($item, "getValue")) {
264 $value = $item->getValue();
265 }
266
267 $this->setValue($field, $value);
268 }
269 }
270 }
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 $this->has_stored_entry = true;
179 }
180
181 $this->reset();
182 if ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
183 $this->settings = unserialize($row->settings);
184 }
185 return true;
186 }
foreach($_POST as $key=> $value) $res

References $query, $res, 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 84 of file class.ilUserFormSettings.php.

85 {
86 $this->settings = array();
87 }

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

77 {
78 $this->settings = $a_data;
79 }

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

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

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: