ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUserDefinedFieldsPlaceholderValues.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  private $placeholder;
13 
17  private $objectHelper;
18 
23 
27  private $ilUtilHelper;
28 
34  public function __construct(
38  ) {
39  $this->placeholder = array();
40 
41  if (null === $objectHelper) {
43  }
44  $this->objectHelper = $objectHelper;
45 
46  if (null === $userDefinedFieldsObject) {
48  }
49  $this->userDefinedFieldsObject = $userDefinedFieldsObject;
50 
51  if (null === $ilUtilHelper) {
53  }
54  $this->ilUtilHelper = $ilUtilHelper;
55  }
56 
71  public function getPlaceholderValues(int $userId, int $objId)
72  {
74  $user = $this->objectHelper->getInstanceByObjId($userId);
75  if (!$user instanceof ilObjUser) {
76  throw new ilException('The entered id: ' . $userId . ' is not an user object');
77  }
78 
79  $userDefinedFields = $this->userDefinedFieldsObject->getDefinitions();
80 
81  $placeholder = array();
82  foreach ($userDefinedFields as $field) {
83  if ($field['certificate']) {
84  $placeholderText = '#' . str_replace(' ', '_', strtoupper($field['field_name']));
85 
86  $userDefinedData = $user->getUserDefinedData();
87 
88  $userDefinedFieldValue = '';
89  if (isset($userDefinedData['f_' . $field['field_id']])) {
90  $userDefinedFieldValue = $this->ilUtilHelper->prepareFormOutput($userDefinedData['f_' . $field['field_id']]);
91  }
92 
93  $placeholder[$placeholderText] = $userDefinedFieldValue;
94  }
95  }
96 
97  return $placeholder;
98  }
99 
111  public function getPlaceholderValuesForPreview(int $userId, int $objId)
112  {
113  $userDefinedFields = $this->userDefinedFieldsObject->getDefinitions();
114 
115  $placeholder = array();
116  foreach ($userDefinedFields as $field) {
117  if ($field['certificate']) {
118  $placeholderText = '#' . str_replace(' ', '_', strtoupper($field['field_name']));
119 
120  $placeholder[$placeholderText] = $field['field_name'];
121  }
122  }
123 
124  return $placeholder;
125  }
126 }
static _getInstance()
Get instance.
Additional user data fields definition.
__construct(ilCertificateObjectHelper $objectHelper=null, ilUserDefinedFields $userDefinedFieldsObject=null, ilCertificateUtilHelper $ilUtilHelper=null)
$user
Definition: migrateto20.php:57
Just a wrapper class to create Unit Test for other classes.
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the &#39;getPlaceholderValues&#39; method, this method is used to create a plac...