ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCourseDefinedFieldDefinition Class Reference
+ Collaboration diagram for ilCourseDefinedFieldDefinition:

Public Member Functions

 __construct ($a_obj_id, $a_field_id=0)
 Constructor. More...
 
 getObjId ()
 
 getId ()
 
 getType ()
 
 setType ($a_type)
 
 getName ()
 
 setName ($a_name)
 
 getValues ()
 
 setValues ($a_values)
 
 getValueById ($a_id)
 
 getIdByValue ($a_value)
 
 isRequired ()
 
 enableRequired ($a_status)
 
 setValueOptions ($a_options)
 
 getValueOptions ()
 
 prepareSelectBox ()
 Prepare an array of options for ilUtil::formSelect() More...
 
 prepareValues ($a_values)
 Prepare values from POST. More...
 
 appendValues ($a_values)
 Append Values. More...
 
 deleteValue ($a_id)
 Delete value by id. More...
 
 save ()
 Save. More...
 
 update ()
 Update a field. More...
 
 delete ()
 Delete a field. More...
 

Static Public Member Functions

static _clone ($a_source_id, $a_target_id)
 Clone fields. More...
 
static _deleteByContainer ($a_container_id)
 Delete all fields of a container. More...
 
static _hasFields ($a_container_id)
 Check if there are any define fields. More...
 
static _getFields ($a_container_id, $a_sort=IL_CDF_SORT_NAME)
 Get all fields of a container. More...
 
static _getRequiredFieldIds ($a_obj_id)
 Get required filed id's. More...
 
static _fieldsToInfoString ($a_obj_id)
 Fields to info string. More...
 
static _getFieldIds ($a_container_id, $a_sort=IL_CDF_SORT_ID)
 Get all field ids of a container. More...
 
static _lookupName ($a_field_id)
 Lookup field name. More...
 

Private Member Functions

 read ()
 Read DB entries. More...
 

Private Attributes

 $db
 
 $obj_id
 
 $id
 
 $name
 
 $type
 
 $values
 
 $value_options = array()
 
 $required
 

Detailed Description

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

/

Definition at line 38 of file class.ilCourseDefinedFieldDefinition.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseDefinedFieldDefinition::__construct (   $a_obj_id,
  $a_field_id = 0 
)

Constructor.

@access public

Parameters
intcourse obj_id
intfield_id

Definition at line 58 of file class.ilCourseDefinedFieldDefinition.php.

59 {
60 global $DIC;
61
62 $ilDB = $DIC['ilDB'];
63
64 $this->db = $ilDB;
65 $this->obj_id = $a_obj_id;
66 $this->id = $a_field_id;
67
68 if ($this->id) {
69 $this->read();
70 }
71 }
global $DIC
Definition: saml.php:7
global $ilDB

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _clone()

static ilCourseDefinedFieldDefinition::_clone (   $a_source_id,
  $a_target_id 
)
static

Clone fields.

@access public

Parameters
intsource obj id
inttarget obj_id

Definition at line 82 of file class.ilCourseDefinedFieldDefinition.php.

83 {
84 foreach (ilCourseDefinedFieldDefinition::_getFields($a_source_id) as $field_obj) {
85 $cdf = new ilCourseDefinedFieldDefinition($a_target_id);
86 $cdf->setName($field_obj->getName());
87 $cdf->setType($field_obj->getType());
88 $cdf->setValues($field_obj->getValues());
89 $cdf->setValueOptions($field_obj->getValueOptions());
90 $cdf->enableRequired($field_obj->isRequired());
91 $cdf->save();
92 }
93 }
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.

References _getFields().

Referenced by ilObjCourse\cloneObject(), and ilObjGroup\cloneObject().

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

◆ _deleteByContainer()

static ilCourseDefinedFieldDefinition::_deleteByContainer (   $a_container_id)
static

Delete all fields of a container.

@access public

Parameters
intcontainer_id

Definition at line 103 of file class.ilCourseDefinedFieldDefinition.php.

104 {
105 global $DIC;
106
107 $ilDB = $DIC['ilDB'];
108
109 // Delete user entries
110 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
111 foreach (ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id) as $field_id) {
113 }
114
115 $query = "DELETE FROM crs_f_definitions " .
116 "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " ";
117 $res = $ilDB->manipulate($query);
118 }
static _getFieldIds($a_container_id, $a_sort=IL_CDF_SORT_ID)
Get all field ids of a container.
static _deleteByField($a_field_id)
Delete by field.
$query
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, $query, $res, ilCourseUserData\_deleteByField(), and _getFieldIds().

Referenced by ilObjCourse\delete().

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

◆ _fieldsToInfoString()

static ilCourseDefinedFieldDefinition::_fieldsToInfoString (   $a_obj_id)
static

Fields to info string.

@access public

Parameters
intobj_id

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

180 {
181 global $DIC;
182
183 $ilDB = $DIC['ilDB'];
184
185
186 $query = "SELECT field_name FROM crs_f_definitions " .
187 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer');
188
189 $res = $ilDB->query($query);
190 $fields = array();
191 while ($row = $ilDB->fetchObject($res)) {
192 $fields[] = $row->field_name;
193 }
194 return implode('<br />', $fields);
195 }
$row

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

Referenced by ilObjCourseGUI\infoScreen(), and ilObjGroupGUI\infoScreen().

+ Here is the caller graph for this function:

◆ _getFieldIds()

static ilCourseDefinedFieldDefinition::_getFieldIds (   $a_container_id,
  $a_sort = IL_CDF_SORT_ID 
)
static

Get all field ids of a container.

@access public

Parameters
intcontainer obj_id
Returns
array array of field ids

Definition at line 205 of file class.ilCourseDefinedFieldDefinition.php.

206 {
207 global $DIC;
208
209 $ilDB = $DIC['ilDB'];
210
211 $query = "SELECT field_id FROM crs_f_definitions " .
212 "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " " .
213 "ORDER BY " . IL_CDF_SORT_ID;
214 $res = $ilDB->query($query);
215 while ($row = $ilDB->fetchObject($res)) {
216 $field_ids[] = $row->field_id;
217 }
218 return $field_ids ? $field_ids : array();
219 }

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

Referenced by _deleteByContainer(), _getFields(), and ilCourseUserData\_getValuesByObjId().

+ Here is the caller graph for this function:

◆ _getFields()

static ilCourseDefinedFieldDefinition::_getFields (   $a_container_id,
  $a_sort = IL_CDF_SORT_NAME 
)
static

◆ _getRequiredFieldIds()

static ilCourseDefinedFieldDefinition::_getRequiredFieldIds (   $a_obj_id)
static

Get required filed id's.

@access public

Parameters
intcontainer id

Definition at line 155 of file class.ilCourseDefinedFieldDefinition.php.

156 {
157 global $DIC;
158
159 $ilDB = $DIC['ilDB'];
160
161 $query = "SELECT * FROM crs_f_definitions " .
162 "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
163 "AND field_required = 1";
164 $res = $ilDB->query($query);
165 while ($row = $ilDB->fetchObject($res)) {
166 $req_fields[] = $row->field_id;
167 }
168 return $req_fields ? $req_fields : array();
169 }

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

Referenced by ilCourseUserData\_checkRequired().

+ Here is the caller graph for this function:

◆ _hasFields()

static ilCourseDefinedFieldDefinition::_hasFields (   $a_container_id)
static

Check if there are any define fields.

@access public

Parameters
intcontainer_id

Definition at line 126 of file class.ilCourseDefinedFieldDefinition.php.

127 {
128 return count(ilCourseDefinedFieldDefinition::_getFields($a_container_id));
129 }

References _getFields().

Referenced by ilSubscriberTableGUI\__construct(), ilWaitingListTableGUI\__construct(), ilMemberAgreement\__construct(), ilMemberAgreement\agreementRequired(), ilObjCourseGUI\checkAgreement(), ilObjGroupGUI\checkAgreement(), ilRegistrationGUI\fillAgreement(), ilParticipantTableGUI\initSettings(), ilRegistrationGUI\setAccepted(), ilObjCourseGUI\setSubTabs(), and ilObjGroupGUI\setSubTabs().

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

◆ _lookupName()

static ilCourseDefinedFieldDefinition::_lookupName (   $a_field_id)
static

Lookup field name.

@access public

Parameters
intfield_id

Definition at line 229 of file class.ilCourseDefinedFieldDefinition.php.

230 {
231 global $DIC;
232
233 $ilDB = $DIC['ilDB'];
234
235 $query = "SELECT * FROM crs_f_definitions " .
236 "WHERE field_id = " . $ilDB->quote($a_field_id, 'integer');
237
238 $res = $ilDB->query($query);
240
241 return $row->field_name ? $row->field_name : '';
242 }

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

Referenced by ilMemberExport\write().

+ Here is the caller graph for this function:

◆ appendValues()

ilCourseDefinedFieldDefinition::appendValues (   $a_values)

Append Values.

@access public

Definition at line 356 of file class.ilCourseDefinedFieldDefinition.php.

357 {
358 if (!is_array($a_values)) {
359 return false;
360 }
361 $this->values = array_unique(array_merge($this->values, $a_values));
362 #sort($this->values);
363 return true;
364 }

◆ delete()

ilCourseDefinedFieldDefinition::delete ( )

Delete a field.

@access public

Parameters

Definition at line 441 of file class.ilCourseDefinedFieldDefinition.php.

442 {
443 global $DIC;
444
445 $ilDB = $DIC['ilDB'];
446
447 include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
449
450 $query = "DELETE FROM crs_f_definitions " .
451 "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " ";
452 $res = $ilDB->manipulate($query);
453 }

References $DIC, $ilDB, $query, $res, ilCourseUserData\_deleteByField(), and getId().

+ Here is the call graph for this function:

◆ deleteValue()

ilCourseDefinedFieldDefinition::deleteValue (   $a_id)

Delete value by id.

@access public

Definition at line 371 of file class.ilCourseDefinedFieldDefinition.php.

372 {
373 if (!isset($this->values[$a_id])) {
374 return false;
375 }
376 unset($this->values[$a_id]);
377 array_merge($this->values);
378 $this->update();
379 return true;
380 }

References update().

+ Here is the call graph for this function:

◆ enableRequired()

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

Definition at line 292 of file class.ilCourseDefinedFieldDefinition.php.

293 {
294 $this->required = $a_status;
295 }

Referenced by read().

+ Here is the caller graph for this function:

◆ getId()

ilCourseDefinedFieldDefinition::getId ( )

Definition at line 248 of file class.ilCourseDefinedFieldDefinition.php.

References $id.

Referenced by delete(), prepareSelectBox(), read(), and update().

+ Here is the caller graph for this function:

◆ getIdByValue()

ilCourseDefinedFieldDefinition::getIdByValue (   $a_value)

Definition at line 283 of file class.ilCourseDefinedFieldDefinition.php.

284 {
285 return (($pos = array_search($a_value, $this->values)) === false) ? -1 : $pos;
286 }

◆ getName()

ilCourseDefinedFieldDefinition::getName ( )

Definition at line 260 of file class.ilCourseDefinedFieldDefinition.php.

References $name.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getObjId()

ilCourseDefinedFieldDefinition::getObjId ( )

Definition at line 244 of file class.ilCourseDefinedFieldDefinition.php.

References $obj_id.

Referenced by read(), save(), and update().

+ Here is the caller graph for this function:

◆ getType()

ilCourseDefinedFieldDefinition::getType ( )

Definition at line 252 of file class.ilCourseDefinedFieldDefinition.php.

References $type.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getValueById()

ilCourseDefinedFieldDefinition::getValueById (   $a_id)

Definition at line 276 of file class.ilCourseDefinedFieldDefinition.php.

277 {
278 if (is_array($this->values) and array_key_exists($a_id, $this->values)) {
279 return $this->values[$a_id];
280 }
281 return '';
282 }

◆ getValueOptions()

ilCourseDefinedFieldDefinition::getValueOptions ( )

Definition at line 302 of file class.ilCourseDefinedFieldDefinition.php.

References $value_options.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getValues()

ilCourseDefinedFieldDefinition::getValues ( )

Definition at line 268 of file class.ilCourseDefinedFieldDefinition.php.

269 {
270 return $this->values ? $this->values : array();
271 }

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ isRequired()

ilCourseDefinedFieldDefinition::isRequired ( )

Definition at line 288 of file class.ilCourseDefinedFieldDefinition.php.

References $required.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ prepareSelectBox()

ilCourseDefinedFieldDefinition::prepareSelectBox ( )

Prepare an array of options for ilUtil::formSelect()

@access public

Parameters

Definition at line 315 of file class.ilCourseDefinedFieldDefinition.php.

316 {
317 global $DIC;
318
319 $lng = $DIC['lng'];
320
321 $options = array();
322 $options[0] = $lng->txt('select_one');
323
324 foreach ($this->values as $key => $value) {
325 $options[$this->getId() . '_' . $key] = $value;
326 }
327 return $options;
328 }
$key
Definition: croninfo.php:18
$lng

References $DIC, $key, $lng, PHPMailer\PHPMailer\$options, and getId().

+ Here is the call graph for this function:

◆ prepareValues()

ilCourseDefinedFieldDefinition::prepareValues (   $a_values)

Prepare values from POST.

Parameters
arrayarray of values @access public

Definition at line 336 of file class.ilCourseDefinedFieldDefinition.php.

337 {
338 $tmp_values = array();
339
340 if (!is_array($a_values)) {
341 return false;
342 }
343 foreach ($a_values as $idx => $value) {
344 if (strlen($value)) {
345 $tmp_values[$idx] = $value;
346 }
347 }
348 return $tmp_values ? $tmp_values : array();
349 }

◆ read()

ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

@access private

Definition at line 461 of file class.ilCourseDefinedFieldDefinition.php.

462 {
463 $query = "SELECT * FROM crs_f_definitions " .
464 "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " " .
465 "AND obj_id = " . $this->db->quote($this->getObjId(), 'integer') . " ";
466
467 $res = $this->db->query($query);
469
470 $this->setName($row->field_name);
471 $this->setType($row->field_type);
472 $this->setValues(unserialize($row->field_values));
473 $this->setValueOptions(unserialize($row->field_values_opt));
474 $this->enableRequired($row->field_required);
475 }

References $query, $res, $row, enableRequired(), ilDBConstants\FETCHMODE_OBJECT, getId(), getObjId(), setName(), setType(), setValueOptions(), and setValues().

Referenced by __construct().

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

◆ save()

ilCourseDefinedFieldDefinition::save ( )

Save.

@access public

Definition at line 388 of file class.ilCourseDefinedFieldDefinition.php.

389 {
390 global $DIC;
391
392 $ilDB = $DIC['ilDB'];
393
394 $next_id = $ilDB->nextId('crs_f_definitions');
395 $query = "INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required,field_values_opt) " .
396 "VALUES ( " .
397 $ilDB->quote($next_id, 'integer') . ", " .
398 $this->db->quote($this->getObjId(), 'integer') . ", " .
399 $this->db->quote($this->getName(), "text") . ", " .
400 $this->db->quote($this->getType(), 'integer') . ", " .
401 $this->db->quote(serialize($this->getValues()), 'text') . ", " .
402 $ilDB->quote($this->isRequired(), 'integer') . ", " .
403 $ilDB->quote(serialize($this->getValueOptions()), 'text') . ' ' .
404 ") ";
405 $res = $ilDB->manipulate($query);
406 $this->id = $next_id;
407
408 return true;
409 }

References $DIC, $ilDB, $query, $res, getName(), getObjId(), getType(), getValueOptions(), getValues(), and isRequired().

+ Here is the call graph for this function:

◆ setName()

ilCourseDefinedFieldDefinition::setName (   $a_name)

Definition at line 264 of file class.ilCourseDefinedFieldDefinition.php.

265 {
266 $this->name = $a_name;
267 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

Definition at line 256 of file class.ilCourseDefinedFieldDefinition.php.

257 {
258 $this->type = $a_type;
259 }
$a_type
Definition: workflow.php:92

References $a_type.

Referenced by read().

+ Here is the caller graph for this function:

◆ setValueOptions()

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

Definition at line 297 of file class.ilCourseDefinedFieldDefinition.php.

298 {
299 $this->value_options = $a_options;
300 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

Definition at line 272 of file class.ilCourseDefinedFieldDefinition.php.

273 {
274 $this->values = $a_values;
275 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

@access public

Definition at line 416 of file class.ilCourseDefinedFieldDefinition.php.

417 {
418 global $DIC;
419
420 $ilDB = $DIC['ilDB'];
421
422 $query = "UPDATE crs_f_definitions " .
423 "SET field_name = " . $this->db->quote($this->getName(), 'text') . ", " .
424 "field_type = " . $this->db->quote($this->getType(), 'integer') . ", " .
425 "field_values = " . $this->db->quote(serialize($this->getValues()), 'text') . ", " .
426 "field_required = " . $ilDB->quote($this->isRequired(), 'integer') . ", " .
427 'field_values_opt = ' . $ilDB->quote(serialize($this->getValueOptions()), 'text') . ' ' .
428 "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " " .
429 "AND obj_id = " . $this->db->quote($this->getObjId(), 'integer');
430 $res = $ilDB->manipulate($query);
431 return true;
432 }

References $DIC, $ilDB, $query, $res, getId(), getName(), getObjId(), getType(), getValueOptions(), getValues(), and isRequired().

Referenced by deleteValue().

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

Field Documentation

◆ $db

ilCourseDefinedFieldDefinition::$db
private

Definition at line 40 of file class.ilCourseDefinedFieldDefinition.php.

◆ $id

ilCourseDefinedFieldDefinition::$id
private

Definition at line 43 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by getId().

◆ $name

ilCourseDefinedFieldDefinition::$name
private

Definition at line 44 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by getName().

◆ $obj_id

ilCourseDefinedFieldDefinition::$obj_id
private

Definition at line 41 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by getObjId().

◆ $required

ilCourseDefinedFieldDefinition::$required
private

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

Referenced by isRequired().

◆ $type

ilCourseDefinedFieldDefinition::$type
private

Definition at line 45 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by getType().

◆ $value_options

ilCourseDefinedFieldDefinition::$value_options = array()
private

Definition at line 47 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by getValueOptions().

◆ $values

ilCourseDefinedFieldDefinition::$values
private

Definition at line 46 of file class.ilCourseDefinedFieldDefinition.php.


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