ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $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

References $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 81 of file class.ilCourseDefinedFieldDefinition.php.

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.

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

References $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 178 of file class.ilCourseDefinedFieldDefinition.php.

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 }

References $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 203 of file class.ilCourseDefinedFieldDefinition.php.

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 }

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

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

Get all fields of a container.

@access public

Parameters
intcontainer obj_id
Returns
ilCourseDefinedFieldDefinitions[]

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

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 }

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(), ilMemberAgreementGUI\saveCourseDefinedFields(), ilObjectCustomUserFieldsGUI\saveFields(), ilMemberAgreementGUI\setCourseDefinedFieldValues(), ilRegistrationGUI\showCustomFields(), and ilRegistrationGUI\validateCustomFields().

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

@access public

Parameters
intcontainer id

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

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 }

References $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 125 of file class.ilCourseDefinedFieldDefinition.php.

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

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 226 of file class.ilCourseDefinedFieldDefinition.php.

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);
234 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
235
236 return $row->field_name ? $row->field_name : '';
237 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $query, $res, $row, and DB_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 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.

@access public

Parameters

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

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 }

References $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 370 of file class.ilCourseDefinedFieldDefinition.php.

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 }

References update().

+ Here is the call graph for this function:

◆ enableRequired()

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

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

289 {
290 $this->required = $a_status;
291 }

Referenced by read().

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

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getValues()

ilCourseDefinedFieldDefinition::getValues ( )

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

264 {
265 return $this->values ? $this->values : array();
266 }

Referenced by save(), and update().

+ 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()

@access public

Parameters

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

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 }
global $lng
Definition: privfeed.php:40
if(!is_array($argv)) $options

References $lng, $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 331 of file class.ilCourseDefinedFieldDefinition.php.

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 }

◆ read()

ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

@access private

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

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);
462 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
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 }

References $query, $res, $row, DB_FETCHMODE_OBJECT, enableRequired(), 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 $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 }

References $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 259 of file class.ilCourseDefinedFieldDefinition.php.

260 {
261 $this->name = $a_name;
262 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

252 {
253 $this->type = $a_type;
254 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setValueOptions()

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

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

294 {
295 $this->value_options = $a_options;
296 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

268 {
269 $this->values = $a_values;
270 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

@access public

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

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 }

References $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: