ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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  {
68  $this->read();
69  }
70  }
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 81 of file class.ilCourseDefinedFieldDefinition.php.

References _getFields().

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

82  {
83  foreach(ilCourseDefinedFieldDefinition::_getFields($a_source_id) as $field_obj)
84  {
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 $ilDB, $query, $res, ilCourseUserData\_deleteByField(), and _getFieldIds().

Referenced by ilObjCourse\delete().

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

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

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

179  {
180  global $ilDB;
181 
182 
183  $query = "SELECT field_name FROM crs_f_definitions ".
184  "WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer');
185 
186  $res = $ilDB->query($query);
187  $fields = array();
188  while($row = $ilDB->fetchObject($res))
189  {
190  $fields[] = $row->field_name;
191  }
192  return implode('<br />',$fields);
193  }
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 203 of file class.ilCourseDefinedFieldDefinition.php.

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

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

204  {
205  global $ilDB;
206 
207  $query = "SELECT field_id FROM crs_f_definitions ".
208  "WHERE obj_id = ".$ilDB->quote($a_container_id,'integer')." ".
209  "ORDER BY ".IL_CDF_SORT_ID;
210  $res = $ilDB->query($query);
211  while($row = $ilDB->fetchObject($res))
212  {
213  $field_ids[] = $row->field_id;
214  }
215  return $field_ids ? $field_ids : array();
216  }
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 138 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().

139  {
140  foreach(ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id,IL_CDF_SORT_ID) as $field_id)
141  {
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.
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 155 of file class.ilCourseDefinedFieldDefinition.php.

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

Referenced by ilCourseUserData\_checkRequired().

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

126  {
127  return count(ilCourseDefinedFieldDefinition::_getFields($a_container_id));
128  }
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 226 of file class.ilCourseDefinedFieldDefinition.php.

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

Referenced by ilMemberExport\write().

227  {
228  global $ilDB;
229 
230  $query = "SELECT * FROM crs_f_definitions ".
231  "WHERE field_id = ".$ilDB->quote($a_field_id,'integer');
232 
233  $res = $ilDB->query($query);
235 
236  return $row->field_name ? $row->field_name : '';
237  }
global $ilDB
+ Here is the caller graph for this function:

◆ appendValues()

ilCourseDefinedFieldDefinition::appendValues (   $a_values)

Append Values.

public

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

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

◆ delete()

ilCourseDefinedFieldDefinition::delete ( )

Delete a field.

public

Parameters

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

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

438  {
439  global $ilDB;
440 
441  include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
443 
444  $query = "DELETE FROM crs_f_definitions ".
445  "WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ";
446  $res = $ilDB->manipulate($query);
447  }
static _deleteByField($a_field_id)
Delete by field.
global $ilDB
+ Here is the call graph for this function:

◆ deleteValue()

ilCourseDefinedFieldDefinition::deleteValue (   $a_id)

Delete value by id.

public

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

References update().

371  {
372  if(!isset($this->values[$a_id]))
373  {
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 288 of file class.ilCourseDefinedFieldDefinition.php.

Referenced by read().

289  {
290  $this->required = $a_status;
291  }
+ Here is the caller graph for this function:

◆ getId()

ilCourseDefinedFieldDefinition::getId ( )

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

280  {
281  return (($pos = array_search($a_value,$this->values)) === false) ? -1 : $pos;
282  }

◆ getName()

ilCourseDefinedFieldDefinition::getName ( )

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

272  {
273  if(is_array($this->values) and array_key_exists($a_id,$this->values))
274  {
275  return $this->values[$a_id];
276  }
277  return '';
278  }

◆ getValueOptions()

ilCourseDefinedFieldDefinition::getValueOptions ( )

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

References $value_options, and array.

Referenced by save(), and update().

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

◆ getValues()

ilCourseDefinedFieldDefinition::getValues ( )

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

References array.

Referenced by save(), and update().

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

◆ isRequired()

ilCourseDefinedFieldDefinition::isRequired ( )

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

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

312  {
313  global $lng;
314 
315  $options = array();
316  $options[0] = $lng->txt('select_one');
317 
318  foreach($this->values as $key => $value)
319  {
320  $options[$this->getId().'_'.$key] = $value;
321  }
322  return $options;
323  }
if(!is_array($argv)) $options
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ 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 331 of file class.ilCourseDefinedFieldDefinition.php.

References array.

332  {
333  $tmp_values = array();
334 
335  if(!is_array($a_values))
336  {
337  return false;
338  }
339  foreach($a_values as $idx => $value)
340  {
341  if(strlen($value))
342  {
343  $tmp_values[$idx] = $value;
344  }
345  }
346  return $tmp_values ? $tmp_values : array();
347  }
Create styles array
The data for the language used.

◆ read()

ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

private

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

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

Referenced by __construct().

456  {
457  $query = "SELECT * FROM crs_f_definitions ".
458  "WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ".
459  "AND obj_id = ".$this->db->quote($this->getObjId(),'integer')." ";
460 
461  $res = $this->db->query($query);
463 
464  $this->setName($row->field_name);
465  $this->setType($row->field_type);
466  $this->setValues(unserialize($row->field_values));
467  $this->setValueOptions(unserialize($row->field_values_opt));
468  $this->enableRequired($row->field_required);
469  }
+ 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 $ilDB, $query, $res, getName(), getObjId(), getType(), getValueOptions(), getValues(), and isRequired().

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

◆ setName()

ilCourseDefinedFieldDefinition::setName (   $a_name)

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

Referenced by read().

260  {
261  $this->name = $a_name;
262  }
+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

References $a_type.

Referenced by read().

252  {
253  $this->type = $a_type;
254  }
$a_type
Definition: workflow.php:93
+ Here is the caller graph for this function:

◆ setValueOptions()

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

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

Referenced by read().

294  {
295  $this->value_options = $a_options;
296  }
+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

Referenced by read().

268  {
269  $this->values = $a_values;
270  }
+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

public

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

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

Referenced by deleteValue().

415  {
416  global $ilDB;
417 
418  $query = "UPDATE crs_f_definitions ".
419  "SET field_name = ".$this->db->quote($this->getName(),'text').", ".
420  "field_type = ".$this->db->quote($this->getType(),'integer').", ".
421  "field_values = ".$this->db->quote(serialize($this->getValues()),'text').", ".
422  "field_required = ".$ilDB->quote($this->isRequired(),'integer').", ".
423  'field_values_opt = '.$ilDB->quote(serialize($this->getValueOptions()),'text').' '.
424  "WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ".
425  "AND obj_id = ".$this->db->quote($this->getObjId(),'integer');
426  $res = $ilDB->manipulate($query);
427  return true;
428  }
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: