ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCourseUserData Class Reference
+ Collaboration diagram for ilCourseUserData:

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

 read ()
 Read value. More...
 

Private Attributes

 $db
 
 $user_id
 
 $field_id
 
 $value
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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 $ilDB, and read().

49  {
50  global $ilDB;
51 
52  $this->db = $ilDB;
53  $this->user_id = $a_user_id;
54  $this->field_id = $a_field_id;
55 
56  if ($this->field_id) {
57  $this->read();
58  }
59  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ _checkRequired()

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 102 of file class.ilCourseUserData.php.

References $ilDB, $query, $res, $row, ilCourseDefinedFieldDefinition\_getRequiredFieldIds(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjGroupGUI\checkAgreement(), ilObjCourseGUI\checkAgreement(), and ilMemberAgreementGUI\init().

103  {
104  global $ilDB;
105 
106  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
108  if (!count($required)) {
109  return true;
110  }
111 
112  //$and = ("AND field_id IN (".implode(",",ilUtil::quoteArray($required)).")");
113  $and = "AND " . $ilDB->in('field_id', $required, false, 'integer');
114 
115  $query = "SELECT COUNT(*) num_entries FROM crs_user_data " .
116  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
117  "AND value != '' AND value IS NOT NULL " .
118  $and . " " .
119  " ";
120  $res = $ilDB->query($query);
122 
123  return $row->num_entries == count($required);
124  }
static _getRequiredFieldIds($a_obj_id)
Get required filed id's.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteByField()

static ilCourseUserData::_deleteByField (   $a_field_id)
static

Delete by field.

public

Parameters

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

References $ilDB, $query, and $res.

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

151  {
152  global $ilDB;
153 
154  $query = "DELETE FROM crs_user_data " .
155  "WHERE field_id = " . $ilDB->quote($a_field_id, 'integer');
156  $res = $ilDB->manipulate($query);
157  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _deleteByUser()

static ilCourseUserData::_deleteByUser (   $a_user_id)
static

Delete all entries of an user.

public

Parameters
intuser_id

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

References $ilDB, $query, and $res.

135  {
136  global $ilDB;
137 
138  $query = "DELETE FROM crs_user_data " .
139  "WHERE usr_id = " . $ilDB->quote($a_user_id, 'integer');
140  $res = $ilDB->manipulate($query);
141  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ _getValuesByObjId()

static ilCourseUserData::_getValuesByObjId (   $a_obj_id)
static

Get values by obj_id (for all users)

public

Parameters
intobj_id

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

References $ilDB, $query, $res, $row, ilCourseDefinedFieldDefinition\_getFieldIds(), array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjGroupGUI\addCustomData(), ilAttendanceList\getNonMemberUserData(), ilCourseMembershipGUI\getPrintMemberData(), ilGroupParticipantsTableGUI\parse(), ilCourseParticipantsTableGUI\parse(), ilMemberExport\readCourseSpecificFieldsData(), ilSubscriberTableGUI\readSubscriberData(), ilWaitingListTableGUI\readUserData(), and ilMemberAgreementGUI\setCourseDefinedFieldValues().

70  {
71  global $ilDB;
72 
73  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
74  $field_ids = ilCourseDefinedFieldDefinition::_getFieldIds($a_obj_id);
75  if (!count($field_ids)) {
76  return array();
77  }
78 
79  $where = "WHERE " . $ilDB->in('field_id', $field_ids, false, 'integer');
80  $query = "SELECT * FROM crs_user_data " .
81  $where;
82 
83  $res = $ilDB->query($query);
84  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
85  $user_data[$row->usr_id][$row->field_id] = $row->value;
86  }
87 
88  return $user_data ? $user_data : array();
89  }
static _getFieldIds($a_container_id, $a_sort=IL_CDF_SORT_ID)
Get all field ids of a container.
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilCourseUserData::create ( )

Add entry.

public

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

References $ilDB, $query, $res, and getValue().

Referenced by update().

203  {
204  global $ilDB;
205 
206  $query = "INSERT INTO crs_user_data (value,usr_id,field_id) " .
207  "VALUES( " .
208  $this->db->quote($this->getValue(), 'text') . ", " .
209  $this->db->quote($this->user_id, 'integer') . ", " .
210  $this->db->quote($this->field_id, 'integer') . " " .
211  ")";
212 
213  $res = $ilDB->manipulate($query);
214  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilCourseUserData::delete ( )

insert entry

public

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

References $ilDB, $query, and $res.

187  {
188  global $ilDB;
189 
190  $query = "DELETE FROM crs_user_data " .
191  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
192  "AND field_id = " . $this->db->quote($this->field_id, 'integer');
193  $res = $ilDB->manipulate($query);
194  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB

◆ getValue()

ilCourseUserData::getValue ( )

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

References $value.

Referenced by create().

164  {
165  return $this->value;
166  }
+ Here is the caller graph for this function:

◆ read()

ilCourseUserData::read ( )
private

Read value.

private

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

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and setValue().

Referenced by __construct().

222  {
223  global $ilDB;
224 
225  $query = "SELECT * FROM crs_user_data " .
226  "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
227  "AND field_id = " . $this->db->quote($this->field_id, 'integer');
228  $res = $this->db->query($query);
230 
231  $this->setValue($row->value);
232  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValue()

ilCourseUserData::setValue (   $a_value)

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

Referenced by read(), ilMemberAgreementGUI\saveCourseDefinedFields(), and ilRegistrationGUI\validateCustomFields().

160  {
161  $this->value = $a_value;
162  }
+ Here is the caller graph for this function:

◆ update()

ilCourseUserData::update ( )

update value

public

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

References create().

175  {
176  $this->delete();
177  $this->create();
178  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCourseUserData::$db
private

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

◆ $field_id

ilCourseUserData::$field_id
private

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

◆ $user_id

ilCourseUserData::$user_id
private

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

◆ $value

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: