ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
58  $this->read();
59  }
60  }
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 105 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().

106  {
107  global $ilDB;
108 
109  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
111  if(!count($required))
112  {
113  return true;
114  }
115 
116  //$and = ("AND field_id IN (".implode(",",ilUtil::quoteArray($required)).")");
117  $and = "AND ".$ilDB->in('field_id',$required,false,'integer');
118 
119  $query = "SELECT COUNT(*) num_entries FROM crs_user_data ".
120  "WHERE usr_id = ".$ilDB->quote($a_usr_id ,'integer')." ".
121  "AND value != '' AND value IS NOT NULL ".
122  $and." ".
123  " ";
124  $res = $ilDB->query($query);
126 
127  return $row->num_entries == count($required);
128  }
static _getRequiredFieldIds($a_obj_id)
Get required filed id's.
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 155 of file class.ilCourseUserData.php.

References $ilDB, $query, and $res.

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

156  {
157  global $ilDB;
158 
159  $query = "DELETE FROM crs_user_data ".
160  "WHERE field_id = ".$ilDB->quote($a_field_id ,'integer');
161  $res = $ilDB->manipulate($query);
162  }
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 138 of file class.ilCourseUserData.php.

References $ilDB, $query, and $res.

139  {
140  global $ilDB;
141 
142  $query = "DELETE FROM crs_user_data ".
143  "WHERE usr_id = ".$ilDB->quote($a_user_id ,'integer');
144  $res = $ilDB->manipulate($query);
145 
146  }
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 70 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().

71  {
72  global $ilDB;
73 
74  include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
75  $field_ids = ilCourseDefinedFieldDefinition::_getFieldIds($a_obj_id);
76  if(!count($field_ids))
77  {
78  return array();
79  }
80 
81  $where = "WHERE ".$ilDB->in('field_id',$field_ids,false,'integer');
82  $query = "SELECT * FROM crs_user_data ".
83  $where;
84 
85  $res = $ilDB->query($query);
86  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
87  {
88  $user_data[$row->usr_id][$row->field_id] = $row->value;
89  }
90 
91  return $user_data ? $user_data : array();
92  }
static _getFieldIds($a_container_id, $a_sort=IL_CDF_SORT_ID)
Get all field ids of a container.
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 207 of file class.ilCourseUserData.php.

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

Referenced by update().

208  {
209  global $ilDB;
210 
211  $query = "INSERT INTO crs_user_data (value,usr_id,field_id) ".
212  "VALUES( ".
213  $this->db->quote($this->getValue() ,'text').", ".
214  $this->db->quote($this->user_id ,'integer').", ".
215  $this->db->quote($this->field_id ,'integer')." ".
216  ")";
217 
218  $res = $ilDB->manipulate($query);
219  }
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 191 of file class.ilCourseUserData.php.

References $ilDB, $query, and $res.

192  {
193  global $ilDB;
194 
195  $query = "DELETE FROM crs_user_data ".
196  "WHERE usr_id = ".$this->db->quote($this->user_id ,'integer')." ".
197  "AND field_id = ".$this->db->quote($this->field_id ,'integer');
198  $res = $ilDB->manipulate($query);
199  }
global $ilDB

◆ getValue()

ilCourseUserData::getValue ( )

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

References $value.

Referenced by create().

169  {
170  return $this->value;
171  }
+ Here is the caller graph for this function:

◆ read()

ilCourseUserData::read ( )
private

Read value.

private

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

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

Referenced by __construct().

227  {
228  global $ilDB;
229 
230  $query = "SELECT * FROM crs_user_data ".
231  "WHERE usr_id = ".$this->db->quote($this->user_id ,'integer')." ".
232  "AND field_id = ".$this->db->quote($this->field_id ,'integer');
233  $res = $this->db->query($query);
235 
236  $this->setValue($row->value);
237 
238  }
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 164 of file class.ilCourseUserData.php.

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

165  {
166  $this->value = $a_value;
167  }
+ Here is the caller graph for this function:

◆ update()

ilCourseUserData::update ( )

update value

public

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

References create().

180  {
181  $this->delete();
182  $this->create();
183  }
+ 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: