ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserFormSettings Class Reference
+ Collaboration diagram for ilUserFormSettings:

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

 read ()
 Read store settings.

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

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.

References $ilUser, and read().

{
global $ilDB, $ilUser;
$this->user_id = (int)$a_user_id;
$this->id = (string)$a_id;
$this->db = $ilDB;
if(!$this->user_id)
{
$this->user_id = $ilUser->getId();
}
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilUserFormSettings::delete (   $a_reset = true)

Delete user related data.

Parameters
bool$a_reset

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

References $query, and reset().

{
$query = "DELETE FROM usr_form_settings".
" WHERE user_id = ".$this->db->quote($this->user_id,'integer').
" AND id = ".$this->db->quote($this->id,'text');
$this->db->manipulate($query);
if($a_reset)
{
$this->reset();
}
}

+ Here is the call graph for this function:

static ilUserFormSettings::deleteAllForUser (   $a_user_id)
static

Delete all settings for user id.

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

References $query.

{
$query = "DELETE FROM usr_form_settings".
" WHERE user_id = ".$this->db->quote($a_user_id,'integer');
$this->db->manipulate($query);
}
ilUserFormSettings::deleteValue (   $a_option)

Delete value.

Parameters
string$a_option

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

References valueExists().

{
if($this->valueExists($a_option))
{
unset($this->settings[$a_option]);
}
}

+ Here is the call graph for this function:

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.

References getValue().

{
return (bool)$this->getValue($a_option);
}

+ Here is the call graph for this function:

ilUserFormSettings::exportToForm ( ilPropertyFormGUI  $a_form)

Export settings from form.

Parameters
ilPropertyFormGUI$a_form

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

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

{
foreach($a_form->getItems() as $item)
{
if(method_exists($item, "getPostVar"))
{
$field = $item->getPostVar();
if($this->valueExists($field))
{
$value = $this->getValue($field);
if(method_exists($item, "setDate"))
{
$date = new ilDateTime($value, IL_CAL_DATETIME);
$item->setDate($date);
}
else if(method_exists($item, "setValue"))
{
$item->setValue($value);
if(method_exists($item, "setChecked"))
{
$item->setChecked(true);
}
}
}
}
}
}

+ Here is the call graph for this function:

ilUserFormSettings::getValue (   $a_option)

Get value.

Parameters
string$a_option
Returns
mixed

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

References valueExists().

Referenced by enabled(), and exportToForm().

{
if($this->valueExists($a_option))
{
return $this->settings[$a_option];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserFormSettings::importFromForm ( ilPropertyFormGUI  $a_form)

Import settings from form.

Parameters
ilPropertyFormGUI$a_form

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

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

{
$this->reset();
foreach($a_form->getItems() as $item)
{
if(method_exists($item, "getPostVar"))
{
$field = $item->getPostVar();
if(method_exists($item, "getDate"))
{
$value = $item->getDate();
if($value && !$value->isNull())
{
$value = $value->get(IL_CAL_DATETIME);
}
}
else if(method_exists($item, "getMulti") && $item->getMulti())
{
$value = $item->getMultiValues();
}
else if(method_exists($item, "getValue"))
{
$value = $item->getValue();
}
$this->setValue($field, $value);
}
}
}

+ Here is the call graph for this function:

ilUserFormSettings::read ( )
protected

Read store settings.

private

Parameters

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

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

Referenced by __construct().

{
$query = "SELECT * FROM usr_form_settings".
" WHERE user_id = ".$this->db->quote($this->user_id,'integer').
" AND id = ".$this->db->quote($this->id,'text');
$res = $this->db->query($query);
$this->reset();
if($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->settings = unserialize($row->settings);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserFormSettings::reset ( )

Remove all settings (internally)

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

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

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

+ Here is the caller graph for this function:

ilUserFormSettings::set (   $a_data)

Set Settings.

Parameters
arrayArray of Settings

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

{
$this->settings = $a_data;
}
ilUserFormSettings::setValue (   $a_option,
  $a_value 
)

Set value.

Parameters
string$a_option
mmixed$a_value

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

Referenced by importFromForm().

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

+ Here is the caller graph for this function:

ilUserFormSettings::store ( )

Store settings in DB.

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

References $query.

{
$this->delete(false);
$query = "INSERT INTO usr_form_settings (user_id,id,settings) ".
"VALUES( ".
$this->db->quote($this->user_id,'integer').", ".
$this->db->quote($this->id,'text').", ".
$this->db->quote(serialize($this->settings),'text')." ".
")";
$this->db->manipulate($query);
}
ilUserFormSettings::valueExists (   $a_option)

Does value exist in settings?

Parameters
string$a_option
Returns
bool

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

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

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

+ Here is the caller graph for this function:

Field Documentation

ilUserFormSettings::$db
protected

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

ilUserFormSettings::$id
protected

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

ilUserFormSettings::$settings = array()
protected

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

ilUserFormSettings::$user_id
protected

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


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