ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilDB, and read().

59  {
60  global $ilDB;
61 
62  $this->db = $ilDB;
63  $this->obj_id = $a_obj_id;
64  $this->id = $a_field_id;
65 
66  if ($this->id) {
67  $this->read();
68  }
69  }
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 80 of file class.ilCourseDefinedFieldDefinition.php.

References _getFields().

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

81  {
82  foreach (ilCourseDefinedFieldDefinition::_getFields($a_source_id) as $field_obj) {
83  $cdf = new ilCourseDefinedFieldDefinition($a_target_id);
84  $cdf->setName($field_obj->getName());
85  $cdf->setType($field_obj->getType());
86  $cdf->setValues($field_obj->getValues());
87  $cdf->setValueOptions($field_obj->getValueOptions());
88  $cdf->enableRequired($field_obj->isRequired());
89  $cdf->save();
90  }
91  }
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 101 of file class.ilCourseDefinedFieldDefinition.php.

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

Referenced by ilObjCourse\delete().

102  {
103  global $ilDB;
104 
105  // Delete user entries
106  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
107  foreach (ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id) as $field_id) {
109  }
110 
111  $query = "DELETE FROM crs_f_definitions " .
112  "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " ";
113  $res = $ilDB->manipulate($query);
114  }
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 173 of file class.ilCourseDefinedFieldDefinition.php.

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

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

174  {
175  global $ilDB;
176 
177 
178  $query = "SELECT field_name FROM crs_f_definitions " .
179  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer');
180 
181  $res = $ilDB->query($query);
182  $fields = array();
183  while ($row = $ilDB->fetchObject($res)) {
184  $fields[] = $row->field_name;
185  }
186  return implode('<br />', $fields);
187  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 197 of file class.ilCourseDefinedFieldDefinition.php.

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

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

198  {
199  global $ilDB;
200 
201  $query = "SELECT field_id FROM crs_f_definitions " .
202  "WHERE obj_id = " . $ilDB->quote($a_container_id, 'integer') . " " .
203  "ORDER BY " . IL_CDF_SORT_ID;
204  $res = $ilDB->query($query);
205  while ($row = $ilDB->fetchObject($res)) {
206  $field_ids[] = $row->field_id;
207  }
208  return $field_ids ? $field_ids : array();
209  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 135 of file class.ilCourseDefinedFieldDefinition.php.

References _getFieldIds(), array, 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().

136  {
137  foreach (ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id, IL_CDF_SORT_ID) as $field_id) {
138  $fields[] = new ilCourseDefinedFieldDefinition($a_container_id, $field_id);
139  }
140  return $fields ? $fields : array();
141  }
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.
+ 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 151 of file class.ilCourseDefinedFieldDefinition.php.

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

Referenced by ilCourseUserData\_checkRequired().

152  {
153  global $ilDB;
154 
155  $query = "SELECT * FROM crs_f_definitions " .
156  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
157  "AND field_required = 1";
158  $res = $ilDB->query($query);
159  while ($row = $ilDB->fetchObject($res)) {
160  $req_fields[] = $row->field_id;
161  }
162  return $req_fields ? $req_fields : array();
163  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
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 122 of file class.ilCourseDefinedFieldDefinition.php.

References _getFields().

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

123  {
124  return count(ilCourseDefinedFieldDefinition::_getFields($a_container_id));
125  }
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 219 of file class.ilCourseDefinedFieldDefinition.php.

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

Referenced by ilMemberExport\write().

220  {
221  global $ilDB;
222 
223  $query = "SELECT * FROM crs_f_definitions " .
224  "WHERE field_id = " . $ilDB->quote($a_field_id, 'integer');
225 
226  $res = $ilDB->query($query);
228 
229  return $row->field_name ? $row->field_name : '';
230  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ appendValues()

ilCourseDefinedFieldDefinition::appendValues (   $a_values)

Append Values.

public

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

343  {
344  if (!is_array($a_values)) {
345  return false;
346  }
347  $this->values = array_unique(array_merge($this->values, $a_values));
348  #sort($this->values);
349  return true;
350  }

◆ delete()

ilCourseDefinedFieldDefinition::delete ( )

Delete a field.

public

Parameters

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

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

424  {
425  global $ilDB;
426 
427  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
429 
430  $query = "DELETE FROM crs_f_definitions " .
431  "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " ";
432  $res = $ilDB->manipulate($query);
433  }
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 357 of file class.ilCourseDefinedFieldDefinition.php.

References update().

358  {
359  if (!isset($this->values[$a_id])) {
360  return false;
361  }
362  unset($this->values[$a_id]);
363  array_merge($this->values);
364  $this->update();
365  return true;
366  }
+ Here is the call graph for this function:

◆ enableRequired()

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

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

Referenced by read().

281  {
282  $this->required = $a_status;
283  }
+ Here is the caller graph for this function:

◆ getId()

ilCourseDefinedFieldDefinition::getId ( )

Definition at line 236 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 271 of file class.ilCourseDefinedFieldDefinition.php.

272  {
273  return (($pos = array_search($a_value, $this->values)) === false) ? -1 : $pos;
274  }

◆ getName()

ilCourseDefinedFieldDefinition::getName ( )

Definition at line 248 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 232 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 240 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 264 of file class.ilCourseDefinedFieldDefinition.php.

265  {
266  if (is_array($this->values) and array_key_exists($a_id, $this->values)) {
267  return $this->values[$a_id];
268  }
269  return '';
270  }

◆ getValueOptions()

ilCourseDefinedFieldDefinition::getValueOptions ( )

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

References $value_options, and array.

Referenced by save(), and update().

291  {
292  return (array) $this->value_options;
293  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getValues()

ilCourseDefinedFieldDefinition::getValues ( )

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

References array.

Referenced by save(), and update().

257  {
258  return $this->values ? $this->values : array();
259  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isRequired()

ilCourseDefinedFieldDefinition::isRequired ( )

Definition at line 276 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 303 of file class.ilCourseDefinedFieldDefinition.php.

References $key, $lng, $options, array, and getId().

304  {
305  global $lng;
306 
307  $options = array();
308  $options[0] = $lng->txt('select_one');
309 
310  foreach ($this->values as $key => $value) {
311  $options[$this->getId() . '_' . $key] = $value;
312  }
313  return $options;
314  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
$key
Definition: croninfo.php:18
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 322 of file class.ilCourseDefinedFieldDefinition.php.

References array.

323  {
324  $tmp_values = array();
325 
326  if (!is_array($a_values)) {
327  return false;
328  }
329  foreach ($a_values as $idx => $value) {
330  if (strlen($value)) {
331  $tmp_values[$idx] = $value;
332  }
333  }
334  return $tmp_values ? $tmp_values : array();
335  }
Create styles array
The data for the language used.

◆ read()

ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

private

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

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

Referenced by __construct().

442  {
443  $query = "SELECT * FROM crs_f_definitions " .
444  "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " " .
445  "AND obj_id = " . $this->db->quote($this->getObjId(), 'integer') . " ";
446 
447  $res = $this->db->query($query);
449 
450  $this->setName($row->field_name);
451  $this->setType($row->field_type);
452  $this->setValues(unserialize($row->field_values));
453  $this->setValueOptions(unserialize($row->field_values_opt));
454  $this->enableRequired($row->field_required);
455  }
foreach($_POST as $key=> $value) $res
$query
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilCourseDefinedFieldDefinition::save ( )

Save.

public

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

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

375  {
376  global $ilDB;
377 
378  $next_id = $ilDB->nextId('crs_f_definitions');
379  $query = "INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required,field_values_opt) " .
380  "VALUES ( " .
381  $ilDB->quote($next_id, 'integer') . ", " .
382  $this->db->quote($this->getObjId(), 'integer') . ", " .
383  $this->db->quote($this->getName(), "text") . ", " .
384  $this->db->quote($this->getType(), 'integer') . ", " .
385  $this->db->quote(serialize($this->getValues()), 'text') . ", " .
386  $ilDB->quote($this->isRequired(), 'integer') . ", " .
387  $ilDB->quote(serialize($this->getValueOptions()), 'text') . ' ' .
388  ") ";
389  $res = $ilDB->manipulate($query);
390  $this->id = $next_id;
391 
392  return true;
393  }
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 252 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by read().

253  {
254  $this->name = $a_name;
255  }
+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

References $a_type.

Referenced by read().

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

◆ setValueOptions()

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

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

Referenced by read().

286  {
287  $this->value_options = $a_options;
288  }
+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

Referenced by read().

261  {
262  $this->values = $a_values;
263  }
+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

public

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

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

Referenced by deleteValue().

401  {
402  global $ilDB;
403 
404  $query = "UPDATE crs_f_definitions " .
405  "SET field_name = " . $this->db->quote($this->getName(), 'text') . ", " .
406  "field_type = " . $this->db->quote($this->getType(), 'integer') . ", " .
407  "field_values = " . $this->db->quote(serialize($this->getValues()), 'text') . ", " .
408  "field_required = " . $ilDB->quote($this->isRequired(), 'integer') . ", " .
409  'field_values_opt = ' . $ilDB->quote(serialize($this->getValueOptions()), 'text') . ' ' .
410  "WHERE field_id = " . $this->db->quote($this->getId(), 'integer') . " " .
411  "AND obj_id = " . $this->db->quote($this->getObjId(), 'integer');
412  $res = $ilDB->manipulate($query);
413  return true;
414  }
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: