ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCustomUserFieldsHelper Class Reference

Description of class class. More...

+ Collaboration diagram for ilCustomUserFieldsHelper:

Public Member Functions

 __construct ()
 
 getUDFTypes ()
 Get udf types. More...
 
 getPluginForType ($a_type)
 Get plugin for udf type. More...
 
 getActivePlugins ()
 Get plugins for fields. More...
 
 getFormPropertyForDefinition ($definition, $a_changeable=true, $a_default_value=null)
 Get form property for definition. More...
 

Static Public Member Functions

static getInstance ()
 Get instance. More...
 

Private Attributes

 $lng = null
 
 $plugin_admin = null
 
 $logger = null
 

Static Private Attributes

static $instance = null
 

Detailed Description

Description of class class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 11 of file class.ilCustomUserFieldsHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilCustomUserFieldsHelper::__construct ( )

Definition at line 31 of file class.ilCustomUserFieldsHelper.php.

32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->logger = $DIC->logger()->usr();
37 $this->plugin_admin = $DIC['ilPluginAdmin'];
38 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ getActivePlugins()

ilCustomUserFieldsHelper::getActivePlugins ( )

Get plugins for fields.

Parameters
array$def_ids
Returns
ilUDFDefinitionPlugin[]

Definition at line 89 of file class.ilCustomUserFieldsHelper.php.

90 {
91 $plugins = array();
92
93 include_once './Services/User/classes/class.ilUDFDefinitionPlugin.php';
94 foreach (
95 $this->plugin_admin->getActivePluginsForSlot(
99 )
100 as $plugin) {
101 $plug = $this->plugin_admin->getPluginObject(
105 $plugin
106 );
107 if ($plug instanceof ilUDFDefinitionPlugin) {
108 $plugins[] = $plug;
109 }
110 }
111 return $plugins;
112 }
UDF type deefinition plugin.

References XapiProxy\$plugin, ilUDFDefinitionPlugin\UDF_C_NAME, ilUDFDefinitionPlugin\UDF_C_TYPE, and ilUDFDefinitionPlugin\UDF_SLOT_ID.

Referenced by getFormPropertyForDefinition(), getPluginForType(), and getUDFTypes().

+ Here is the caller graph for this function:

◆ getFormPropertyForDefinition()

ilCustomUserFieldsHelper::getFormPropertyForDefinition (   $definition,
  $a_changeable = true,
  $a_default_value = null 
)

Get form property for definition.

Parameters
array$definition
Returns
ilFormPropertyGUI

Definition at line 119 of file class.ilCustomUserFieldsHelper.php.

120 {
121 $fprop = null;
122
123 switch ($definition['field_type']) {
124 case UDF_TYPE_TEXT:
125 $fprop = new ilTextInputGUI(
126 $definition['field_name'],
127 'udf_' . $definition['field_id']
128 );
129 $fprop->setValue($a_default_value);
130 $fprop->setSize(40);
131 $fprop->setMaxLength(255);
132 $fprop->setRequired($definition['required'] ? true : false);
133 if (!$a_changeable && (!$definition['required'] || $a_default_value)) {
134 $fprop->setDisabled(true);
135 }
136 break;
137
138 case UDF_TYPE_WYSIWYG:
139 $fprop = new ilTextAreaInputGUI(
140 $definition['field_name'],
141 'udf_' . $definition['field_id']
142 );
143 $fprop->setValue($a_default_value);
144 $fprop->setUseRte(true);
145 $fprop->setRequired($definition['required'] ? true : false);
146 if (!$a_changeable && (!$definition['required'] || $a_default_value)) {
147 $fprop->setDisabled(true);
148 }
149 break;
150
151 case UDF_TYPE_SELECT:
152 $fprop = new ilSelectInputGUI(
153 $definition['field_name'],
154 'udf_' . $definition['field_id']
155 );
156
157 include_once './Services/User/classes/class.ilUserDefinedFields.php';
158 $user_defined_fields = ilUserDefinedFields::_getInstance();
159
160 $fprop->setOptions($user_defined_fields->fieldValuesToSelectArray($definition['field_values']));
161 $fprop->setValue($a_default_value);
162 $fprop->setRequired($definition['required'] ? true : false);
163 if (!$a_changeable && (!$definition['required'] || $a_default_value)) {
164 $fprop->setDisabled(true);
165 }
166 break;
167
168 default:
169 // should be a plugin
170 foreach ($this->getActivePlugins() as $plugin) {
171 if ($plugin->getDefinitionType() == $definition['field_type']) {
172 $fprop = $plugin->getFormPropertyForDefinition($definition, $a_changeable, $a_default_value);
173 break;
174 }
175 }
176 break;
177 }
178
179 return $fprop;
180 }
const UDF_TYPE_SELECT
const UDF_TYPE_WYSIWYG
const UDF_TYPE_TEXT
getActivePlugins()
Get plugins for fields.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
static _getInstance()
Get instance.

References XapiProxy\$plugin, ilUserDefinedFields\_getInstance(), getActivePlugins(), UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

+ Here is the call graph for this function:

◆ getInstance()

static ilCustomUserFieldsHelper::getInstance ( )
static

Get instance.

Returns
ilCustomUserFieldsHelper

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

45 {
46 if (self::$instance) {
47 return self::$instance;
48 }
49 return self::$instance = new self();
50 }

References $instance.

Referenced by ilAccountRegistrationGUI\__initForm(), ilCustomUserFieldsGUI\create(), ilCustomUserFieldsGUI\initForm(), ilPersonalProfileGUI\initPersonalDataForm(), ilUserDefinedData\lookupData(), and ilCustomUserFieldsGUI\update().

+ Here is the caller graph for this function:

◆ getPluginForType()

ilCustomUserFieldsHelper::getPluginForType (   $a_type)

Get plugin for udf type.

Returns
ilUDFDefinitionPlugin

Definition at line 74 of file class.ilCustomUserFieldsHelper.php.

75 {
76 foreach ($this->getActivePlugins() as $plugin) {
77 if ($plugin->getDefinitionType() == $a_type) {
78 return $plugin;
79 }
80 }
81 return null;
82 }

References XapiProxy\$plugin, and getActivePlugins().

+ Here is the call graph for this function:

◆ getUDFTypes()

ilCustomUserFieldsHelper::getUDFTypes ( )

Get udf types.

Returns
type

Definition at line 56 of file class.ilCustomUserFieldsHelper.php.

57 {
58 $types = array(
59 UDF_TYPE_TEXT => $this->lng->txt('udf_type_text'),
60 UDF_TYPE_SELECT => $this->lng->txt('udf_type_select'),
61 UDF_TYPE_WYSIWYG => $this->lng->txt('udf_type_wysiwyg')
62 );
63 include_once './Services/User/classes/class.ilUDFDefinitionPlugin.php';
64 foreach ($this->getActivePlugins() as $plugin) {
65 $types[$plugin->getDefinitionType()] = $plugin->getDefinitionTypeName();
66 }
67 return $types;
68 }

References XapiProxy\$plugin, getActivePlugins(), UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

+ Here is the call graph for this function:

Field Documentation

◆ $instance

ilCustomUserFieldsHelper::$instance = null
staticprivate

Definition at line 13 of file class.ilCustomUserFieldsHelper.php.

Referenced by getInstance().

◆ $lng

ilCustomUserFieldsHelper::$lng = null
private

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

◆ $logger

ilCustomUserFieldsHelper::$logger = null
private

Definition at line 29 of file class.ilCustomUserFieldsHelper.php.

◆ $plugin_admin

ilCustomUserFieldsHelper::$plugin_admin = null
private

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


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