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.

@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 $this->read();
68 }
69 }
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 80 of file class.ilCourseDefinedFieldDefinition.php.

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.

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

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.
$query
foreach($_POST as $key=> $value) $res

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

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 }

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

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 }

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

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 }

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

123 {
124 return count(ilCourseDefinedFieldDefinition::_getFields($a_container_id));
125 }

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

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 }

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

@access public

Parameters

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

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 }

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

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 }

References update().

+ Here is the call graph for this function:

◆ enableRequired()

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

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

281 {
282 $this->required = $a_status;
283 }

Referenced by read().

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

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getValues()

ilCourseDefinedFieldDefinition::getValues ( )

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

257 {
258 return $this->values ? $this->values : array();
259 }

Referenced by save(), and update().

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

@access public

Parameters

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

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 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$key
Definition: croninfo.php:18
global $lng
Definition: privfeed.php:17

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

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 }

◆ read()

ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

@access private

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

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 }

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

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 }

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

253 {
254 $this->name = $a_name;
255 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setType()

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

245 {
246 $this->type = $a_type;
247 }
$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 285 of file class.ilCourseDefinedFieldDefinition.php.

286 {
287 $this->value_options = $a_options;
288 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setValues()

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

261 {
262 $this->values = $a_values;
263 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilCourseDefinedFieldDefinition::update ( )

Update a field.

@access public

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

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 }

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: