ILIAS  release_8 Revision v8.23
ilExportFieldsInfo Class Reference
+ Collaboration diagram for ilExportFieldsInfo:

Public Member Functions

 getType ()
 
 isExportable ($a_field_name)
 Check if field is exportable. More...
 
 getFieldsInfo ()
 Get informations (exportable) about user data profile fields public. More...
 
 getExportableFields ()
 Get Exportable Fields. More...
 
 getSelectableFieldsInfo (int $a_obj_id)
 Get selectable fields. More...
 
 exportableFieldsToInfoString ()
 Get exportable fields as info string. More...
 
 sortExportFields ()
 sort Exports fields User for Name Presentation Guideline More...
 

Static Public Member Functions

static _getInstanceByType (string $a_type)
 Get Singleton Instance. More...
 

Private Member Functions

 __construct (string $a_type)
 Private Singleton Constructor. More...
 
 read ()
 Read info about exportable fields. More...
 

Private Attributes

ilSetting $settings
 
ilLanguage $lng
 
string $obj_type = ''
 
array $possible_fields = array()
 

Static Private Attributes

static array $instances = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilExportFieldsInfo::__construct ( string  $a_type)
private

Private Singleton Constructor.

Use getInstance private

Definition at line 35 of file class.ilExportFieldsInfo.php.

References $DIC, ILIAS\Repository\lng(), read(), and ILIAS\Repository\settings().

36  {
37  global $DIC;
38 
39  $this->lng = $DIC->language();
40  $this->settings = $DIC->settings();
41  $this->obj_type = $a_type;
42 
43  $this->read();
44  }
global $DIC
Definition: feed.php:28
read()
Read info about exportable fields.
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByType()

◆ exportableFieldsToInfoString()

ilExportFieldsInfo::exportableFieldsToInfoString ( )

Get exportable fields as info string.

Returns
string info page string

Definition at line 162 of file class.ilExportFieldsInfo.php.

References getExportableFields(), and ILIAS\Repository\lng().

162  : string
163  {
164  $fields = [];
165  foreach ($this->getExportableFields() as $field) {
166  $fields[] = $this->lng->txt($field);
167  }
168  return implode('<br />', $fields);
169  }
getExportableFields()
Get Exportable Fields.
+ Here is the call graph for this function:

◆ getExportableFields()

ilExportFieldsInfo::getExportableFields ( )

Get Exportable Fields.

Definition at line 82 of file class.ilExportFieldsInfo.php.

Referenced by exportableFieldsToInfoString(), and getSelectableFieldsInfo().

82  : array
83  {
84  $fields = [];
85  foreach ($this->possible_fields as $field => $exportable) {
86  if ($exportable) {
87  $fields[] = $field;
88  }
89  }
90  return $fields;
91  }
+ Here is the caller graph for this function:

◆ getFieldsInfo()

ilExportFieldsInfo::getFieldsInfo ( )

Get informations (exportable) about user data profile fields public.

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

References $possible_fields.

74  : array
75  {
77  }

◆ getSelectableFieldsInfo()

ilExportFieldsInfo::getSelectableFieldsInfo ( int  $a_obj_id)

Get selectable fields.

Definition at line 96 of file class.ilExportFieldsInfo.php.

References $DIC, ilCourseDefinedFieldDefinition\_getFields(), ilUserDefinedFields\_getInstance(), getExportableFields(), getType(), ilBookingEntry\hasObjectBookingEntries(), and ILIAS\Repository\lng().

96  : array
97  {
98  global $DIC;
99 
100  $user = $DIC->user();
101 
102  $fields = [];
103  foreach ($this->getExportableFields() as $field) {
104  switch ($field) {
105  case 'lastname':
106  case 'firstname':
107  break;
108 
109  case 'username':
110  $fields['login']['txt'] = $this->lng->txt('login');
111  $fields['login']['default'] = 1;
112  break;
113 
114  default:
115  // #18795
116  $caption = ($field == "title")
117  ? "person_title"
118  : $field;
119  $fields[$field]['txt'] = $this->lng->txt($caption);
120  $fields[$field]['default'] = 0;
121  break;
122  }
123  }
124 
125  if (ilBookingEntry::hasObjectBookingEntries($a_obj_id, $user->getId())) {
126  $this->lng->loadLanguageModule('dateplaner');
127  $fields['consultation_hour']['txt'] = $this->lng->txt('cal_ch_field_ch');
128  $fields['consultation_hour']['default'] = 0;
129  }
130 
131  $udf = [];
132  if ($this->getType() == 'crs') {
133  $udf = ilUserDefinedFields::_getInstance()->getCourseExportableFields();
134  } elseif ($this->getType() == 'grp') {
135  $udf = ilUserDefinedFields::_getInstance()->getGroupExportableFields();
136  }
137  if ($udf) {
138  foreach ($udf as $field_id => $field) {
139  $fields['udf_' . $field_id]['txt'] = $field['field_name'];
140  $fields['udf_' . $field_id]['default'] = 0;
141  }
142  }
143 
145  foreach ($cdf as $def) {
146  $fields['odf_' . $def->getId()]['txt'] = $def->getName();
147  $fields['odf_' . $def->getId()]['default'] = 0;
148  }
149 
150  if (count($cdf)) {
151  // add last edit
152  $fields['odf_last_update']['txt'] = $this->lng->txt($this->getType() . '_cdf_tbl_last_edit');
153  $fields['odf_last_update']['default'] = 0;
154  }
155  return $fields;
156  }
static hasObjectBookingEntries(int $a_obj_id, int $a_usr_id)
Check if object has assigned consultation hour appointments.
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
global $DIC
Definition: feed.php:28
getExportableFields()
Get Exportable Fields.
+ Here is the call graph for this function:

◆ getType()

ilExportFieldsInfo::getType ( )

Definition at line 57 of file class.ilExportFieldsInfo.php.

References $obj_type.

Referenced by getSelectableFieldsInfo(), and read().

57  : string
58  {
59  return $this->obj_type;
60  }
+ Here is the caller graph for this function:

◆ isExportable()

ilExportFieldsInfo::isExportable (   $a_field_name)

Check if field is exportable.

Definition at line 65 of file class.ilExportFieldsInfo.php.

65  : bool
66  {
67  return array_key_exists($a_field_name, $this->possible_fields);
68  }

◆ read()

ilExportFieldsInfo::read ( )
private

Read info about exportable fields.

Definition at line 174 of file class.ilExportFieldsInfo.php.

References $data, ILIAS\LTI\ToolProvider\$key, getType(), and ILIAS\Repository\settings().

Referenced by __construct().

174  : void
175  {
176  $profile = new ilUserProfile();
177  $profile->skipGroup('settings');
178 
179  foreach ($profile->getStandardFields() as $key => $data) {
180  if ($this->getType() == 'crs') {
181  if (!array_key_exists('course_export_hide', $data) || !$data['course_export_hide']) {
182  if (isset($data['course_export_fix_value']) && $data['course_export_fix_value']) {
183  $this->possible_fields[$key] = $data['course_export_fix_value'];
184  } else {
185  $this->possible_fields[$key] = 0;
186  }
187  }
188  } elseif ($this->getType() == 'grp') {
189  if (!array_key_exists('group_export_hide', $data) || !$data['group_export_hide']) {
190  if (isset($data['group_export_fix_value']) and $data['group_export_fix_value']) {
191  $this->possible_fields[$key] = $data['group_export_fix_value'];
192  } else {
193  $this->possible_fields[$key] = 0;
194  }
195  }
196  }
197  }
198  $settings_all = $this->settings->getAll();
199 
200  $field_part_limit = 5;
201  $field_prefix = '';
202  switch ($this->getType()) {
203  case 'crs':
204  $field_prefix = 'usr_settings_course_export_';
205  $field_part_limit = 5;
206  break;
207 
208  case 'grp':
209  $field_prefix = 'usr_settings_group_export_';
210  $field_part_limit = 5;
211  break;
212  }
213 
214  foreach ($settings_all as $key => $value) {
215  if ($field_prefix && stristr($key, $field_prefix) and $value) {
216  // added limit for mantis 11096
217  $field_parts = explode('_', $key, $field_part_limit);
218  $field = $field_parts[count($field_parts) - 1];
219  if (array_key_exists($field, $this->possible_fields)) {
220  $this->possible_fields[$field] = 1;
221  }
222  }
223  }
224  }
Class ilUserProfile.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortExportFields()

ilExportFieldsInfo::sortExportFields ( )

sort Exports fields User for Name Presentation Guideline

Definition at line 229 of file class.ilExportFieldsInfo.php.

References ILIAS\LTI\ToolProvider\$key.

229  : void
230  {
231  $start_order = array("lastname" => array(), "firstname" => array(), "username" => array());
232 
233  foreach ($start_order as $key => $value) {
234  if (isset($this->possible_fields[$key])) {
235  $start_order[$key] = $this->possible_fields[$key];
236  unset($this->possible_fields[$key]);
237  } else {
238  unset($start_order[$key]);
239  }
240  }
241 
242  if (count($start_order) > 0) {
243  $this->possible_fields = array_merge($start_order, $this->possible_fields);
244  }
245  }
string $key
Consumer key/client ID value.
Definition: System.php:193

Field Documentation

◆ $instances

array ilExportFieldsInfo::$instances = []
staticprivate

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

◆ $lng

ilLanguage ilExportFieldsInfo::$lng
private

Definition at line 27 of file class.ilExportFieldsInfo.php.

◆ $obj_type

string ilExportFieldsInfo::$obj_type = ''
private

Definition at line 28 of file class.ilExportFieldsInfo.php.

Referenced by getType().

◆ $possible_fields

array ilExportFieldsInfo::$possible_fields = array()
private

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

Referenced by getFieldsInfo().

◆ $settings

ilSetting ilExportFieldsInfo::$settings
private

Definition at line 26 of file class.ilExportFieldsInfo.php.


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