ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseDefinedFieldDefinition Class Reference
+ Collaboration diagram for ilCourseDefinedFieldDefinition:

Public Member Functions

 __construct ($a_obj_id, $a_field_id=0)
 Constructor.
 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()
 prepareValues ($a_values)
 Prepare values from POST.
 appendValues ($a_values)
 Append Values.
 deleteValue ($a_id)
 Delete value by id.
 save ()
 Save.
 update ()
 Update a field.
 delete ()
 Delete a field.

Static Public Member Functions

static _clone ($a_source_id, $a_target_id)
 Clone fields.
static _deleteByContainer ($a_container_id)
 Delete all fields of a container.
static _hasFields ($a_container_id)
 Check if there are any define fields.
static _getFields ($a_container_id, $a_sort=IL_CDF_SORT_NAME)
 Get all fields of a container.
static _getRequiredFieldIds ($a_obj_id)
 Get required filed id's.
static _fieldsToInfoString ($a_obj_id)
 Fields to info string.
static _getFieldIds ($a_container_id, $a_sort=IL_CDF_SORT_ID)
 Get all field ids of a container.
static _lookupName ($a_field_id)
 Lookup field name.

Private Member Functions

 read ()
 Read DB entries.

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

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 read().

{
global $ilDB;
$this->db = $ilDB;
$this->obj_id = $a_obj_id;
$this->id = $a_field_id;
if($this->id)
{
$this->read();
}
}

+ Here is the call graph for this function:

Member Function Documentation

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

{
foreach(ilCourseDefinedFieldDefinition::_getFields($a_source_id) as $field_obj)
{
$cdf = new ilCourseDefinedFieldDefinition($a_target_id);
$cdf->setName($field_obj->getName());
$cdf->setType($field_obj->getType());
$cdf->setValues($field_obj->getValues());
$cdf->setValueOptions($field_obj->getValueOptions());
$cdf->enableRequired($field_obj->isRequired());
$cdf->save();
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 $query, $res, ilCourseUserData\_deleteByField(), and _getFieldIds().

Referenced by ilObjCourse\delete().

{
global $ilDB;
// Delete user entries
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
foreach(ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id) as $field_id)
{
}
$query = "DELETE FROM crs_f_definitions ".
"WHERE obj_id = ".$ilDB->quote($a_container_id,'integer')." ";
$res = $ilDB->manipulate($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
global $ilDB;
$query = "SELECT field_name FROM crs_f_definitions ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer');
$res = $ilDB->query($query);
$fields = array();
while($row = $ilDB->fetchObject($res))
{
$fields[] = $row->field_name;
}
return implode('<br />',$fields);
}

+ Here is the caller graph for this function:

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

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

{
global $ilDB;
$query = "SELECT field_id FROM crs_f_definitions ".
"WHERE obj_id = ".$ilDB->quote($a_container_id,'integer')." ".
"ORDER BY ".IL_CDF_SORT_ID;
$res = $ilDB->query($query);
while($row = $ilDB->fetchObject($res))
{
$field_ids[] = $row->field_id;
}
return $field_ids ? $field_ids : array();
}

+ Here is the caller graph for this function:

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(), and IL_CDF_SORT_ID.

Referenced by _clone(), _hasFields(), ilMemberExport\addCourseField(), ilMemberAgreementGUI\addCustomFields(), ilMemberExport\getOrderedExportableFields(), ilExportFieldsInfo\getSelectableFieldsInfo(), ilObjCourseGUI\infoScreen(), ilObjGroupGUI\infoScreen(), ilObjectCustomUserFieldsGUI\listFields(), ilMemberAgreementGUI\saveCourseDefinedFields(), ilObjectCustomUserFieldsGUI\saveFields(), ilMemberExportGUI\show(), ilRegistrationGUI\showCustomFields(), ilRegistrationGUI\validateCustomFields(), and ilMemberExport\write().

{
foreach(ilCourseDefinedFieldDefinition::_getFieldIds($a_container_id,IL_CDF_SORT_ID) as $field_id)
{
$fields[] = new ilCourseDefinedFieldDefinition($a_container_id,$field_id);
}
return $fields ? $fields : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Referenced by ilCourseUserData\_checkRequired().

{
global $ilDB;
$query = "SELECT * FROM crs_f_definitions ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
"AND field_required = 1";
$res = $ilDB->query($query);
while($row = $ilDB->fetchObject($res))
{
$req_fields[] = $row->field_id;
}
return $req_fields ? $req_fields : array();
}

+ Here is the caller graph for this function:

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(), ilMemberAgreement\agreementRequired(), ilObjGroupGUI\checkAgreement(), ilObjCourseGUI\checkAgreement(), ilRegistrationGUI\fillAgreement(), ilMemberExport\getOrderedExportableFields(), ilRegistrationGUI\setAccepted(), ilObjCourseGUI\setSubTabs(), and ilObjGroupGUI\setSubTabs().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseDefinedFieldDefinition::_lookupName (   $a_field_id)
static

Lookup field name.

public

Parameters
intfield_id

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

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

Referenced by ilMemberExport\write().

{
global $ilDB;
$query = "SELECT * FROM crs_f_definitions ".
"WHERE field_id = ".$ilDB->quote($a_field_id,'integer');
$res = $ilDB->query($query);
return $row->field_name ? $row->field_name : '';
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::appendValues (   $a_values)

Append Values.

public

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

{
if(!is_array($a_values))
{
return false;
}
$this->values = array_unique(array_merge($this->values,$a_values));
#sort($this->values);
return true;
}
ilCourseDefinedFieldDefinition::delete ( )

Delete a field.

public

Parameters

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

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

{
global $ilDB;
include_once('Modules/Course/classes/Export/class.ilCourseUserData.php');
$query = "DELETE FROM crs_f_definitions ".
"WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ";
$res = $ilDB->manipulate($query);
}

+ Here is the call graph for this function:

ilCourseDefinedFieldDefinition::deleteValue (   $a_id)

Delete value by id.

public

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

References update().

{
if(!isset($this->values[$a_id]))
{
return false;
}
unset($this->values[$a_id]);
array_merge($this->values);
$this->update();
return true;
}

+ Here is the call graph for this function:

ilCourseDefinedFieldDefinition::enableRequired (   $a_status)

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

Referenced by read().

{
$this->required = $a_status;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getId ( )

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

References $id.

Referenced by delete(), prepareSelectBox(), read(), and update().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getIdByValue (   $a_value)

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

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

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

References $name.

Referenced by save(), and update().

{
return $this->name;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getObjId ( )

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

References $obj_id.

Referenced by read(), save(), and update().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getType ( )

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

References $type.

Referenced by save(), and update().

{
return $this->type;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getValueById (   $a_id)

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

{
if(is_array($this->values) and array_key_exists($a_id,$this->values))
{
return $this->values[$a_id];
}
return '';
}
ilCourseDefinedFieldDefinition::getValueOptions ( )

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

References $value_options.

Referenced by save(), and update().

{
return (array) $this->value_options;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::getValues ( )

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

Referenced by save(), and update().

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

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::isRequired ( )

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

References $required.

Referenced by save(), and update().

{
return (bool) $this->required;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::prepareSelectBox ( )

Prepare an array of options for ilUtil::formSelect()

public

Parameters

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

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

{
global $lng;
$options = array();
$options[0] = $lng->txt('select_one');
foreach($this->values as $key => $value)
{
$options[$this->getId().'_'.$key] = $value;
}
return $options;
}

+ Here is the call graph for this function:

ilCourseDefinedFieldDefinition::prepareValues (   $a_values)

Prepare values from POST.

Parameters
arrayarray of values public

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

{
$tmp_values = array();
if(!is_array($a_values))
{
return false;
}
foreach($a_values as $idx => $value)
{
if(strlen($value))
{
$tmp_values[$idx] = $value;
}
}
return $tmp_values ? $tmp_values : array();
}
ilCourseDefinedFieldDefinition::read ( )
private

Read DB entries.

private

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

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

Referenced by __construct().

{
$query = "SELECT * FROM crs_f_definitions ".
"WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ".
"AND obj_id = ".$this->db->quote($this->getObjId(),'integer')." ";
$res = $this->db->query($query);
$this->setName($row->field_name);
$this->setType($row->field_type);
$this->setValues(unserialize($row->field_values));
$this->setValueOptions(unserialize($row->field_values_opt));
$this->enableRequired($row->field_required);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::save ( )

Save.

public

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

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

{
global $ilDB;
$next_id = $ilDB->nextId('crs_f_definitions');
$query = "INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required,field_values_opt) ".
"VALUES ( ".
$ilDB->quote($next_id,'integer').", ".
$this->db->quote($this->getObjId(),'integer').", ".
$this->db->quote($this->getName(),"text").", ".
$this->db->quote($this->getType(),'integer').", ".
$this->db->quote(serialize($this->getValues()),'text').", ".
$ilDB->quote($this->isRequired(),'integer').", ".
$ilDB->quote(serialize($this->getValueOptions()),'text').' '.
") ";
$res = $ilDB->manipulate($query);
$this->id = $next_id;
return true;
}

+ Here is the call graph for this function:

ilCourseDefinedFieldDefinition::setName (   $a_name)

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

Referenced by read().

{
$this->name = $a_name;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::setType (   $a_type)

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

Referenced by read().

{
$this->type = $a_type;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::setValueOptions (   $a_options)

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

Referenced by read().

{
$this->value_options = $a_options;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::setValues (   $a_values)

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

Referenced by read().

{
$this->values = $a_values;
}

+ Here is the caller graph for this function:

ilCourseDefinedFieldDefinition::update ( )

Update a field.

public

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

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

Referenced by deleteValue().

{
global $ilDB;
$query = "UPDATE crs_f_definitions ".
"SET field_name = ".$this->db->quote($this->getName(),'text').", ".
"field_type = ".$this->db->quote($this->getType(),'integer').", ".
"field_values = ".$this->db->quote(serialize($this->getValues()),'text').", ".
"field_required = ".$ilDB->quote($this->isRequired(),'integer').", ".
'field_values_opt = '.$ilDB->quote(serialize($this->getValueOptions()),'text').' '.
"WHERE field_id = ".$this->db->quote($this->getId(),'integer')." ".
"AND obj_id = ".$this->db->quote($this->getObjId(),'integer');
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCourseDefinedFieldDefinition::$db
private

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

ilCourseDefinedFieldDefinition::$id
private

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

Referenced by getId().

ilCourseDefinedFieldDefinition::$name
private

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

Referenced by getName().

ilCourseDefinedFieldDefinition::$obj_id
private

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

Referenced by getObjId().

ilCourseDefinedFieldDefinition::$required
private

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

Referenced by isRequired().

ilCourseDefinedFieldDefinition::$type
private

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

Referenced by getType().

ilCourseDefinedFieldDefinition::$value_options = array()
private

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

Referenced by getValueOptions().

ilCourseDefinedFieldDefinition::$values
private

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


The documentation for this class was generated from the following file: