ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

@access public

Parameters
intuser id
intfield id

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

49 {
50 global $DIC;
51
52 $ilDB = $DIC['ilDB'];
53
54 $this->db = $ilDB;
55 $this->user_id = $a_user_id;
56 $this->field_id = $a_field_id;
57
58 if ($this->field_id) {
59 $this->read();
60 }
61 }
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, $ilDB, and read().

+ 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.

@access public

Parameters
intuser id
intobject id
Returns
bool all fields filled

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

107 {
108 global $DIC;
109
110 $ilDB = $DIC['ilDB'];
111
112 include_once('Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php');
114 if (!count($required)) {
115 return true;
116 }
117
118 //$and = ("AND field_id IN (".implode(",",ilUtil::quoteArray($required)).")");
119 $and = "AND " . $ilDB->in('field_id', $required, false, 'integer');
120
121 $query = "SELECT COUNT(*) num_entries FROM crs_user_data " .
122 "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
123 "AND value != '' AND value IS NOT NULL " .
124 $and . " " .
125 " ";
126 $res = $ilDB->query($query);
128
129 return $row->num_entries == count($required);
130 }
static _getRequiredFieldIds($a_obj_id)
Get required filed id's.
$row
$query
foreach($_POST as $key=> $value) $res

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

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

+ 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.

@access public

Parameters

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

159 {
160 global $DIC;
161
162 $ilDB = $DIC['ilDB'];
163
164 $query = "DELETE FROM crs_user_data " .
165 "WHERE field_id = " . $ilDB->quote($a_field_id, 'integer');
166 $res = $ilDB->manipulate($query);
167 }

References $DIC, $ilDB, $query, and $res.

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

+ Here is the caller graph for this function:

◆ _deleteByUser()

static ilCourseUserData::_deleteByUser (   $a_user_id)
static

Delete all entries of an user.

@access public

Parameters
intuser_id

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

141 {
142 global $DIC;
143
144 $ilDB = $DIC['ilDB'];
145
146 $query = "DELETE FROM crs_user_data " .
147 "WHERE usr_id = " . $ilDB->quote($a_user_id, 'integer');
148 $res = $ilDB->manipulate($query);
149 }

References $DIC, $ilDB, $query, and $res.

◆ _getValuesByObjId()

static ilCourseUserData::_getValuesByObjId (   $a_obj_id)
static

Get values by obj_id (for all users)

@access public

Parameters
intobj_id

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

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

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ilCourseUserData::create ( )

Add entry.

@access public

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

215 {
216 global $DIC;
217
218 $ilDB = $DIC['ilDB'];
219
220 $query = "INSERT INTO crs_user_data (value,usr_id,field_id) " .
221 "VALUES( " .
222 $this->db->quote($this->getValue(), 'text') . ", " .
223 $this->db->quote($this->user_id, 'integer') . ", " .
224 $this->db->quote($this->field_id, 'integer') . " " .
225 ")";
226
227 $res = $ilDB->manipulate($query);
228 }

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

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilCourseUserData::delete ( )

insert entry

@access public

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

197 {
198 global $DIC;
199
200 $ilDB = $DIC['ilDB'];
201
202 $query = "DELETE FROM crs_user_data " .
203 "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
204 "AND field_id = " . $this->db->quote($this->field_id, 'integer');
205 $res = $ilDB->manipulate($query);
206 }

References $DIC, $ilDB, $query, and $res.

◆ getValue()

ilCourseUserData::getValue ( )

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

174 {
175 return $this->value;
176 }

References $value.

Referenced by create().

+ Here is the caller graph for this function:

◆ read()

ilCourseUserData::read ( )
private

Read value.

@access private

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

236 {
237 global $DIC;
238
239 $ilDB = $DIC['ilDB'];
240
241 $query = "SELECT * FROM crs_user_data " .
242 "WHERE usr_id = " . $this->db->quote($this->user_id, 'integer') . " " .
243 "AND field_id = " . $this->db->quote($this->field_id, 'integer');
244 $res = $this->db->query($query);
246
247 $this->setValue($row->value);
248 }

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValue()

ilCourseUserData::setValue (   $a_value)

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

170 {
171 $this->value = $a_value;
172 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilCourseUserData::update ( )

update value

@access public

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

185 {
186 $this->delete();
187 $this->create();
188 }

References create().

+ 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: