ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseUserData Class Reference
+ Collaboration diagram for ilCourseUserData:

Public Member Functions

 __construct ($a_user_id, $a_field_id=0)
 Contructor.
 setValue ($a_value)
 getValue ()
 update ()
 update value
 delete ()
 insert entry
 create ()
 Add entry.

Static Public Member Functions

static _getValuesByObjId ($a_obj_id)
 Get values by obj_id (for all users)
static _checkRequired ($a_usr_id, $a_obj_id)
 Check required fields.
static _deleteByUser ($a_user_id)
 Delete all entries of an user.
static _deleteByField ($a_field_id)
 Delete by field.

Private Member Functions

 read ()
 Read value.

Private Attributes

 $db
 $user_id
 $field_id
 $value

Detailed Description

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
$Id$

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

Constructor & Destructor Documentation

ilCourseUserData::__construct (   $a_user_id,
  $a_field_id = 0 
)

Contructor.

public

Parameters
intuser id
intfield id

Definition at line 48 of file class.ilCourseUserData.php.

References read().

{
global $ilDB;
$this->db = $ilDB;
$this->user_id = $a_user_id;
$this->field_id = $a_field_id;
if($this->field_id)
{
$this->read();
}
}

+ Here is the call graph for this function:

Member Function Documentation

static ilCourseUserData::_checkRequired (   $a_usr_id,
  $a_obj_id 
)
static

Check required fields.

public

Parameters
intuser id
intobject id
Returns
bool all fields filled

Definition at line 105 of file class.ilCourseUserData.php.

References $res, ilCourseDefinedFieldDefinition\_getRequiredFieldIds(), DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

Referenced by ilObjCourseGUI\checkAgreement(), and ilCourseAgreementGUI\init().

{
global $ilDB;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
if(!count($required))
{
return true;
}
$and = ("AND field_id IN (".implode(",",ilUtil::quoteArray($required)).")");
$query = "SELECT COUNT(*) as num_entries FROM crs_user_data ".
"WHERE usr_id = ".$ilDB->quote($a_usr_id)." ".
"AND value != '' ".
$and;
$res = $ilDB->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
return $row->num_entries == count($required);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseUserData::_deleteByField (   $a_field_id)
static

Delete by field.

public

Parameters

Definition at line 152 of file class.ilCourseUserData.php.

Referenced by ilCourseDefinedFieldDefinition\_deleteByContainer(), and ilCourseDefinedFieldDefinition\delete().

{
global $ilDB;
$query = "DELETE FROM crs_user_data ".
"WHERE field_id = ".$ilDB->quote($a_field_id);
$ilDB->query($query);
}

+ Here is the caller graph for this function:

static ilCourseUserData::_deleteByUser (   $a_user_id)
static

Delete all entries of an user.

public

Parameters
intuser_id

Definition at line 135 of file class.ilCourseUserData.php.

{
global $ilDB;
$query = "DELETE FROM crs_user_data ".
"WHERE usr_id = ".$ilDB->quote($a_user_id);
$ilDB->query($query);
}
static ilCourseUserData::_getValuesByObjId (   $a_obj_id)
static

Get values by obj_id (for all users)

public

Parameters
intobj_id

Definition at line 70 of file class.ilCourseUserData.php.

References $res, ilCourseDefinedFieldDefinition\_getFieldIds(), DB_FETCHMODE_OBJECT, and ilUtil\quoteArray().

Referenced by ilMemberExport\readCourseSpecificFieldsData().

{
global $ilDB;
include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
if(!count($field_ids))
{
return array();
}
$where = ("WHERE field_id IN (".implode(",",ilUtil::quoteArray($field_ids)).") ");
$query = "SELECT * FROM crs_user_data ".
$where;
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$user_data[$row->usr_id][$row->field_id] = $row->value;
}
return $user_data ? $user_data : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserData::create ( )

Add entry.

public

Definition at line 202 of file class.ilCourseUserData.php.

References getValue().

Referenced by update().

{
$query = "INSERT INTO crs_user_data SET ".
"value = ".$this->db->quote($this->getValue()).", ".
"usr_id = ".$this->db->quote($this->user_id).", ".
"field_id = ".$this->db->quote($this->field_id)." ";
$this->db->query($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserData::delete ( )

insert entry

public

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

{
$query = "DELETE FROM crs_user_data ".
"WHERE usr_id = ".$this->db->quote($this->user_id)." ".
"AND field_id = ".$this->db->quote($this->field_id);
$this->db->query($query);
}
ilCourseUserData::getValue ( )

Definition at line 165 of file class.ilCourseUserData.php.

References $value.

Referenced by create().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilCourseUserData::read ( )
private

Read value.

private

Definition at line 216 of file class.ilCourseUserData.php.

References $res, DB_FETCHMODE_OBJECT, and setValue().

Referenced by __construct().

{
$query = "SELECT * FROM crs_user_data ".
"WHERE usr_id = ".$this->db->quote($this->user_id)." ".
"AND field_id = ".$this->db->quote($this->field_id);
$res = $this->db->query($query);
$row = $res->fetchRow(DB_FETCHMODE_OBJECT);
$this->setValue($row->value);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseUserData::setValue (   $a_value)

Definition at line 161 of file class.ilCourseUserData.php.

Referenced by ilCourseAgreementGUI\checkCourseDefinedFields(), read(), and ilCourseRegistrationGUI\validateCourseDefinedFields().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

ilCourseUserData::update ( )

update value

public

Definition at line 176 of file class.ilCourseUserData.php.

References create().

{
$this->delete();
$this->create();
}

+ Here is the call graph for this function:

Field Documentation

ilCourseUserData::$db
private

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

ilCourseUserData::$field_id
private

Definition at line 36 of file class.ilCourseUserData.php.

ilCourseUserData::$user_id
private

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

ilCourseUserData::$value
private

Definition at line 37 of file class.ilCourseUserData.php.

Referenced by getValue().


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