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.

public

Parameters
intcourse obj_id
intfield_id

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

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

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
+ Here is the call graph for this function:

Member Function Documentation

◆ _clone()

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

Clone fields.

public

Parameters
intsource obj id
inttarget obj_id

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

References _getFields().

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

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

public

Parameters
intcontainer_id

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

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

Referenced by ilObjCourse\delete().

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  }
global $DIC
Definition: saml.php:7
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.
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:

◆ _fieldsToInfoString()

static ilCourseDefinedFieldDefinition::_fieldsToInfoString (   $a_obj_id)
static

Fields to info string.

public

Parameters
intobj_id

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

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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.

public

Parameters
intcontainer obj_id
Returns
array array of field ids

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

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _getFields()

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

Get all fields of a container.

public

Parameters
intcontainer obj_id
Returns
ilCourseDefinedFieldDefinitions[]

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

References _getFieldIds(), and IL_CDF_SORT_ID.

Referenced by _clone(), _hasFields(), ilMemberAgreementGUI\addCustomFields(), ilMemberExport\getOrderedExportableFields(), ilExportFieldsInfo\getSelectableFieldsInfo(), ilObjCourseGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilMemberExportGUI\initSettingsForm(), ilObjectCustomUserFieldsGUI\listFields(), ilAttendanceList\readOrderedExportableFields(), ilMemberAgreementGUI\saveCourseDefinedFields(), ilObjectCustomUserFieldsGUI\saveFields(), ilMemberAgreementGUI\setCourseDefinedFieldValues(), ilRegistrationGUI\showCustomFields(), and ilRegistrationGUI\validateCustomFields().

140  {
141  foreach (ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id, IL_CDF_SORT_ID) as $field_id) {
142  $fields[] = new ilCourseDefinedFieldDefinition($a_container_id, $field_id);
143  }
144  return $fields ? $fields : array();
145  }
static _getFieldIds($a_container_id, $a_sort=IL_CDF_SORT_ID)
Get all field ids of a container.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRequiredFieldIds()

static ilCourseDefinedFieldDefinition::_getRequiredFieldIds (   $a_obj_id)
static

Get required filed id's.

public

Parameters
intcontainer id

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

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

Referenced by ilCourseUserData\_checkRequired().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ _hasFields()

static ilCourseDefinedFieldDefinition::_hasFields (   $a_container_id)
static

Check if there are any define fields.

public

Parameters
intcontainer_id

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

References _getFields().

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

127  {
128  return count(ilCourseDefinedFieldDefinition::_getFields($a_container_id));
129  }
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
+ 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.

public

Parameters
intfield_id

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

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

Referenced by ilMemberExport\write().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ appendValues()

ilCourseDefinedFieldDefinition::appendValues (   $a_values)

Append Values.

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.

public

Parameters

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

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

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  }
global $DIC
Definition: saml.php:7
static _deleteByField($a_field_id)
Delete by field.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteValue()

ilCourseDefinedFieldDefinition::deleteValue (   $a_id)

Delete value by id.

public

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

References update().

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  }
+ Here is the call graph for this function:

◆ enableRequired()

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

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

Referenced by read().

293  {
294  $this->required = $a_status;
295  }
+ 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.

Referenced by save(), and update().

269  {
270  return $this->values ? $this->values : array();
271  }
+ 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()

public

Parameters

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

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

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  }
global $DIC
Definition: saml.php:7
$lng
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ prepareValues()

ilCourseDefinedFieldDefinition::prepareValues (   $a_values)

Prepare values from POST.

Parameters
arrayarray of values 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.

private

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

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

Referenced by __construct().

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  }
foreach($_POST as $key=> $value) $res
$query
$row
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilCourseDefinedFieldDefinition::save ( )

Save.

public

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ setName()

ilCourseDefinedFieldDefinition::setName (   $a_name)

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

Referenced by read().

265  {
266  $this->name = $a_name;
267  }
+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

References $a_type.

Referenced by read().

257  {
258  $this->type = $a_type;
259  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ setValueOptions()

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

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

Referenced by read().

298  {
299  $this->value_options = $a_options;
300  }
+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

Referenced by read().

273  {
274  $this->values = $a_values;
275  }
+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

public

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

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

Referenced by deleteValue().

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  }
global $DIC
Definition: saml.php:7
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:

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: