ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilUserDefinedFields Class Reference

Additional user data fields definition. More...

+ Collaboration diagram for ilUserDefinedFields:

Public Member Functions

 _getInstance ()
 fetchFieldIdFromImportId ($a_import_id)
 fetchFieldIdFromName ($a_name)
 getDefinitions ()
 getDefinition ($a_id)
 getVisibleDefinitions ()
 getRegistrationDefinitions ()
 getSearchableDefinitions ()
 getCourseExportableFields ()
 get
 setFieldName ($a_name)
 getFieldName ()
 setFieldType ($a_type)
 getFieldType ()
 setFieldValues ($a_values)
 getFieldValues ()
 enableVisible ($a_visible)
 enabledVisible ()
 enableChangeable ($a_changeable)
 enabledChangeable ()
 enableRequired ($a_required)
 enabledRequired ()
 enableSearchable ($a_searchable)
 enabledSearchable ()
 enableExport ($a_export)
 enabledExport ()
 enableCourseExport ($a_course_export)
 enabledCourseExport ()
 enableVisibleRegistration ($a_visible_registration)
 enabledVisibleRegistration ()
 fieldValuesToSelectArray ($a_values)
 validateValues ()
 nameExists ($a_field_name)
 add ()
 delete ($a_id)
 update ($a_id)
 __read ()
 deleteValue ($a_field_id, $a_value_id)
 toXML ()
 addToXML ($xml_writer)
 add user defined field data to xml (using usr dtd)
 _newInstance ()

Data Fields

 $db = null
 $definitions = array()

Private Member Functions

 __construct ()
 Constructor is private -> use getInstance These definition are used e.g in User XML import.

Private Attributes

 $field_visible_registration = 0

Detailed Description

Additional user data fields definition.

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilUserDefinedFields.php 21958 2009-09-28 02:27:15Z bheyser

Definition at line 19 of file class.ilUserDefinedFields.php.

Constructor & Destructor Documentation

ilUserDefinedFields::__construct ( )
private

Constructor is private -> use getInstance These definition are used e.g in User XML import.

To avoid instances of this class for every user object during import, it caches this object in a singleton.

Definition at line 33 of file class.ilUserDefinedFields.php.

References $ilDB, and __read().

{
global $ilDB;
$this->db =& $ilDB;
$this->__read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilUserDefinedFields::__read ( )

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

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

Referenced by __construct(), add(), delete(), deleteValue(), and update().

{
global $ilSetting;
$query = "SELECT * FROM udf_definition ";
$res = $this->db->query($query);
$this->definitions = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->definitions[$row->field_id]['field_id'] = $row->field_id;
$this->definitions[$row->field_id]['field_name'] = $row->field_name;
$this->definitions[$row->field_id]['field_type'] = $row->field_type;
$this->definitions[$row->field_id]['il_id'] = 'il_'.$ilSetting->get('inst_id',0).'_udf_'.$row->field_id;
$tmp = (array) unserialize($row->field_values);
sort($tmp);
$this->definitions[$row->field_id]['field_values'] = $tmp;
$this->definitions[$row->field_id]['visible'] = $row->visible;
$this->definitions[$row->field_id]['changeable'] = $row->changeable;
$this->definitions[$row->field_id]['required'] = $row->required;
$this->definitions[$row->field_id]['searchable'] = $row->searchable;
$this->definitions[$row->field_id]['export'] = $row->export;
$this->definitions[$row->field_id]['course_export'] = $row->course_export;
$this->definitions[$row->field_id]['visib_reg'] = $row->registration_visible;
}
return true;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::_getInstance ( )

Definition at line 42 of file class.ilUserDefinedFields.php.

Referenced by ilUserSearchOptions\__appendUserDefinedFields(), ilObjUserGUI\__checkUserDefinedRequiredFields(), ilCustomUserFieldSettingsTableGUI\__construct(), ilObjUserGUI\__showUserDefinedFields(), ilUserDefinedData\addToXML(), ilObjUserFolderGUI\askDeleteFieldObject(), ilAccountRegistrationGUI\checkUserDefinedRequiredFields(), ilMemberExport\createCSV(), ilObjUserFolderGUI\deleteFieldObject(), ilObjUserFolderGUI\deleteValueObject(), ilObjUserFolderGUI\editSelectFieldObject(), ilObjUserFolderGUI\editTextFieldObject(), ilObjUserFolderGUI\editWysiwygFieldObject(), ilPublicUserProfileGUI\getHTML(), ilExportUserSettings\getOrderedExportableFields(), ilObjUserFolder\getUserDefinedExportFields(), ilObjUserGUI\getValues(), ilPersonalProfileGUI\ilPersonalProfileGUI(), ilUserImportParser\importEndTag(), ilObjUserGUI\initForm(), ilLDAPAttributeToUser\initUserDefinedFields(), ilLDAPSettingsGUI\initUserDefinedFields(), ilObjUserFolderGUI\listUserDefinedFieldsObject(), ilObjUserFolderGUI\saveFieldObject(), ilMemberExportGUI\show(), ilAccountRegistrationGUI\showUserDefinedFields(), ilUserXMLWriter\start(), ilUserDefinedData\update(), ilObjUserFolderGUI\updateFieldsObject(), ilObjUserFolderGUI\updateSelectFieldObject(), ilObjUserFolderGUI\updateTextFieldObject(), and ilObjUserFolderGUI\updateWysiwygFieldObject().

{
static $udf = null;
if(!is_object($udf))
{
return $udf = new ilUserDefinedFields();
}
return $udf;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::_newInstance ( )

Definition at line 492 of file class.ilUserDefinedFields.php.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient().

{
static $udf = null;
return $udf = new ilUserDefinedFields();
}

+ Here is the caller graph for this function:

ilUserDefinedFields::add ( )

Definition at line 299 of file class.ilUserDefinedFields.php.

References $ilDB, __read(), enabledChangeable(), enabledCourseExport(), enabledExport(), enabledRequired(), enabledSearchable(), enabledVisible(), enabledVisibleRegistration(), getFieldName(), getFieldType(), and getFieldValues().

{
global $ilDB;
// Add definition entry
$next_id = $ilDB->nextId('udf_definition');
$values = array(
'field_id' => array('integer',$next_id),
'field_name' => array('text',$this->getFieldName()),
'field_type' => array('integer', (int) $this->getFieldType()),
'field_values' => array('clob',serialize($this->getFieldValues())),
'visible' => array('integer', (int) $this->enabledVisible()),
'changeable' => array('integer', (int) $this->enabledChangeable()),
'required' => array('integer', (int) $this->enabledRequired()),
'searchable' => array('integer', (int) $this->enabledSearchable()),
'export' => array('integer', (int) $this->enabledExport()),
'course_export' => array('integer', (int) $this->enabledCourseExport()),
'registration_visible' => array('integer', (int) $this->enabledVisibleRegistration()));
$ilDB->insert('udf_definition',$values);
// add table field in usr_defined_data
$field_id = $next_id;
// $ilDB->addTableColumn('udf_data','f_'.$field_id, array("type" => "text", "length" => 4000, "notnull" => false));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilUserDefinedFields::addToXML (   $xml_writer)

add user defined field data to xml (using usr dtd)

Parameters
$xml_writer

Definition at line 460 of file class.ilUserDefinedFields.php.

References getDefinitions(), and UDF_TYPE_SELECT.

Referenced by toXML().

{
$xml_writer->xmlStartTag ("UDFDefinitions");
foreach($this->getDefinitions() as $definition)
{
$attributes = array(
"Id" => $definition ["il_id"],
"Type" => $definition["field_type"] == UDF_TYPE_SELECT? "SELECT" : "TEXT",
"Visible" => $definition["visible"]? "TRUE" : "FALSE",
"Changeable" => $definition["changeable"]? "TRUE" : "FALSE",
"Required" => $definition["required"]? "TRUE" : "FALSE",
"Searchable" => $definition["searchable"]? "TRUE" : "FALSE",
"CourseExport" => $definition["course_export"]? "TRUE" : "FALSE",
"Export" => $definition["export"]? "TRUE" : "FALSE",
"RegistrationVisible" => $definition["visib_reg"]? "TRUE" : "FALSE"
);
$xml_writer->xmlStartTag ("UDFDefinition", $attributes);
$xml_writer->xmlElement('UDFName', null, $definition['field_name']);
if ($definition["field_type"] == UDF_TYPE_SELECT ) {
$field_values = $definition["field_values"];
foreach ($field_values as $field_value)
{
$xml_writer->xmlElement('UDFValue', null, $field_value);
}
}
$xml_writer->xmlEndTag ("UDFDefinition");
}
$xml_writer->xmlEndTag ("UDFDefinitions");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUserDefinedFields::delete (   $a_id)

Definition at line 330 of file class.ilUserDefinedFields.php.

References $ilDB, $query, $res, __read(), and ilUserDefinedData\deleteEntriesOfField().

{
global $ilDB;
// Delete definitions
$query = "DELETE FROM udf_definition ".
"WHERE field_id = ".$this->db->quote($a_id,'integer')." ";
$res = $ilDB->manipulate($query);
// Delete usr_data entries
// $ilDB->dropTableColumn('udf_data','f_'.$a_id);
include_once("./Services/User/classes/class.ilUserDefinedData.php");
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilUserDefinedFields::deleteValue (   $a_field_id,
  $a_value_id 
)

Definition at line 406 of file class.ilUserDefinedFields.php.

References $ilDB, __read(), ilUserDefinedData\deleteFieldValue(), and getDefinition().

{
global $ilDB;
$definition = $this->getDefinition($a_field_id);
$counter = 0;
$new_values = array();
foreach($definition['field_values'] as $value)
{
if($counter++ != $a_value_id)
{
$new_values[] = $value;
}
else
{
$old_value = $value;
}
}
$values = array(
'field_values' => array('clob',serialize($new_values)));
$ilDB->update('udf_definition',$values,array('field_id' => array('integer',$a_field_id)));
// sets value to '' where old value is $old_value
include_once("./Services/User/classes/class.ilUserDefinedData.php");
ilUserDefinedData::deleteFieldValue($a_field_id, $old_value);
/* wrong place...
$query = "UPDATE udf_data ".
"SET `f_".$a_field_id."` = '' ".
"WHERE `f_".$this->db->quote($a_field_id)."` = ".$this->db->quote($old_value,'text')."";
$this->db->query($query);*/
// fianally read data
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilUserDefinedFields::enableChangeable (   $a_changeable)

Definition at line 204 of file class.ilUserDefinedFields.php.

{
$this->field_changeable = $a_changeable;
}
ilUserDefinedFields::enableCourseExport (   $a_course_export)

Definition at line 236 of file class.ilUserDefinedFields.php.

{
$this->field_course_export = $a_course_export;
}
ilUserDefinedFields::enabledChangeable ( )

Definition at line 208 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_changeable;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledCourseExport ( )

Definition at line 240 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_course_export;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledExport ( )

Definition at line 232 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_export;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledRequired ( )

Definition at line 216 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_required;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledSearchable ( )

Definition at line 224 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_searchable;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledVisible ( )

Definition at line 200 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_visible;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::enabledVisibleRegistration ( )

Definition at line 249 of file class.ilUserDefinedFields.php.

References $field_visible_registration.

Referenced by add(), and update().

+ Here is the caller graph for this function:

ilUserDefinedFields::enableExport (   $a_export)

Definition at line 228 of file class.ilUserDefinedFields.php.

{
$this->field_export = $a_export;
}
ilUserDefinedFields::enableRequired (   $a_required)

Definition at line 212 of file class.ilUserDefinedFields.php.

{
$this->field_required = $a_required;
}
ilUserDefinedFields::enableSearchable (   $a_searchable)

Definition at line 220 of file class.ilUserDefinedFields.php.

{
$this->field_searchable = $a_searchable;
}
ilUserDefinedFields::enableVisible (   $a_visible)

Definition at line 196 of file class.ilUserDefinedFields.php.

{
$this->field_visible = $a_visible;
}
ilUserDefinedFields::enableVisibleRegistration (   $a_visible_registration)

Definition at line 245 of file class.ilUserDefinedFields.php.

{
$this->field_visible_registration = $a_visible_registration;
}
ilUserDefinedFields::fetchFieldIdFromImportId (   $a_import_id)

Definition at line 53 of file class.ilUserDefinedFields.php.

References $ilSetting.

{
global $ilSetting;
if(!strlen($a_import_id))
{
return 0;
}
$parts = explode('_',$a_import_id);
if($parts[0] != 'il')
{
return 0;
}
if($parts[1] != $ilSetting->get('inst_id',0))
{
return 0;
}
if($parts[2] != 'udf')
{
return 0;
}
if($parts[3])
{
// Check if field exists
if(is_array($this->definitions["$parts[3]"]))
{
return $parts[3];
}
}
return 0;
}
ilUserDefinedFields::fetchFieldIdFromName (   $a_name)

Definition at line 85 of file class.ilUserDefinedFields.php.

{
foreach($this->definitions as $definition)
{
if($definition['field_name'] == $a_name)
{
return $definition['field_id'];
}
}
return 0;
}
ilUserDefinedFields::fieldValuesToSelectArray (   $a_values)

Definition at line 254 of file class.ilUserDefinedFields.php.

{
foreach($a_values as $value)
{
$values[$value] = $value;
}
return $values ? $values : array();
}
ilUserDefinedFields::getCourseExportableFields ( )

get

public

Parameters

Definition at line 151 of file class.ilUserDefinedFields.php.

{
foreach($this->definitions as $id => $definition)
{
if($definition['course_export'])
{
$cexp_definition[$id] = $definition;
}
}
return $cexp_definition ? $cexp_definition : array();
}
ilUserDefinedFields::getDefinition (   $a_id)

Definition at line 102 of file class.ilUserDefinedFields.php.

Referenced by deleteValue().

{
return is_array($this->definitions[$a_id]) ? $this->definitions[$a_id] : array();
}

+ Here is the caller graph for this function:

ilUserDefinedFields::getDefinitions ( )

Definition at line 97 of file class.ilUserDefinedFields.php.

Referenced by addToXML().

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

+ Here is the caller graph for this function:

ilUserDefinedFields::getFieldName ( )

Definition at line 168 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_name;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::getFieldType ( )

Definition at line 176 of file class.ilUserDefinedFields.php.

Referenced by add(), and update().

{
return $this->field_type;
}

+ Here is the caller graph for this function:

ilUserDefinedFields::getFieldValues ( )

Definition at line 191 of file class.ilUserDefinedFields.php.

Referenced by add(), update(), and validateValues().

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

+ Here is the caller graph for this function:

ilUserDefinedFields::getRegistrationDefinitions ( )

Definition at line 120 of file class.ilUserDefinedFields.php.

{
foreach($this->definitions as $id => $definition)
{
if($definition['visib_reg'])
{
$visible_definition[$id] = $definition;
}
}
return $visible_definition ? $visible_definition : array();
}
ilUserDefinedFields::getSearchableDefinitions ( )

Definition at line 132 of file class.ilUserDefinedFields.php.

{
foreach($this->definitions as $id => $definition)
{
if($definition['searchable'])
{
$searchable_definition[$id] = $definition;
}
}
return $searchable_definition ? $searchable_definition : array();
}
ilUserDefinedFields::getVisibleDefinitions ( )

Definition at line 107 of file class.ilUserDefinedFields.php.

{
foreach($this->definitions as $id => $definition)
{
if($definition['visible'])
{
$visible_definition[$id] = $definition;
}
}
return $visible_definition ? $visible_definition : array();
}
ilUserDefinedFields::nameExists (   $a_field_name)

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

References $ilDB, $query, and $res.

{
global $ilDB;
$query = "SELECT * FROM udf_definition ".
"WHERE field_name = ".$this->db->quote($a_field_name,'text')." ";
$res = $ilDB->query($query);
return (bool) $res->numRows();
}
ilUserDefinedFields::setFieldName (   $a_name)

Definition at line 164 of file class.ilUserDefinedFields.php.

{
$this->field_name = $a_name;
}
ilUserDefinedFields::setFieldType (   $a_type)

Definition at line 172 of file class.ilUserDefinedFields.php.

{
$this->field_type = $a_type;
}
ilUserDefinedFields::setFieldValues (   $a_values)

Definition at line 180 of file class.ilUserDefinedFields.php.

{
$this->field_values = array();
foreach($a_values as $value)
{
if(strlen($value))
{
$this->field_values[] = $value;
}
}
}
ilUserDefinedFields::toXML ( )

Definition at line 446 of file class.ilUserDefinedFields.php.

References addToXML().

{
include_once 'classes/class.ilXmlWriter.php';
$xml_writer = new ilXmlWriter();
$this->addToXML ($xml_writer);
return $xml_writer->xmlDumpMem(false);
}

+ Here is the call graph for this function:

ilUserDefinedFields::update (   $a_id)

Definition at line 349 of file class.ilUserDefinedFields.php.

References $ilDB, __read(), enabledChangeable(), enabledCourseExport(), enabledExport(), enabledRequired(), enabledSearchable(), enabledVisible(), enabledVisibleRegistration(), getFieldName(), getFieldType(), and getFieldValues().

{
global $ilDB;
$values = array(
'field_name' => array('text',$this->getFieldName()),
'field_type' => array('integer', (int) $this->getFieldType()),
'field_values' => array('clob',serialize($this->getFieldValues())),
'visible' => array('integer', (int) $this->enabledVisible()),
'changeable' => array('integer', (int) $this->enabledChangeable()),
'required' => array('integer', (int) $this->enabledRequired()),
'searchable' => array('integer', (int) $this->enabledSearchable()),
'export' => array('integer', (int) $this->enabledExport()),
'course_export' => array('integer', (int) $this->enabledCourseExport()),
'registration_visible' => array('integer', (int) $this->enabledVisibleRegistration()));
$ilDB->update('udf_definition',$values,array('field_id' => array('integer',$a_id)));
$this->__read();
return true;
}

+ Here is the call graph for this function:

ilUserDefinedFields::validateValues ( )

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

References getFieldValues(), UDF_DUPLICATE_VALUES, and UDF_NO_VALUES.

{
$number = 0;
$unique = array();
foreach($this->getFieldValues() as $value)
{
if(!strlen($value))
{
continue;
}
$number++;
$unique[$value] = $value;
}
if(!count($unique))
{
return UDF_NO_VALUES;
}
if($number != count($unique))
{
}
return 0;
}

+ Here is the call graph for this function:

Field Documentation

ilUserDefinedFields::$db = null

Definition at line 21 of file class.ilUserDefinedFields.php.

ilUserDefinedFields::$definitions = array()

Definition at line 22 of file class.ilUserDefinedFields.php.

ilUserDefinedFields::$field_visible_registration = 0
private

Definition at line 24 of file class.ilUserDefinedFields.php.

Referenced by enabledVisibleRegistration().


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