Skip to content

Commit

Permalink
Extra fields in certificate must be visible and have the filter optio…
Browse files Browse the repository at this point in the history
…n see #7995
  • Loading branch information
jmontoyaa committed Dec 15, 2015
1 parent d529f5f commit 7ed5ee3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions main/inc/lib/document.lib.php
Expand Up @@ -1858,7 +1858,7 @@ static function get_all_info_to_certificate($user_id, $course_id, $is_preview =
$organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName');

//Extra user data information
// Extra user data information
$extra_user_info_data = UserManager::get_extra_user_data(
$user_id,
false,
Expand All @@ -1867,6 +1867,10 @@ static function get_all_info_to_certificate($user_id, $course_id, $is_preview =
true
);

// get extra fields
$extraField = new ExtraField('user');
$extraFields = $extraField->get_all(['filter = ? AND visible = ?' => [1, 1]]);

//Student information
$user_info = api_get_user_info($user_id);
$first_name = $user_info['firstname'];
Expand Down Expand Up @@ -1934,10 +1938,11 @@ static function get_all_info_to_certificate($user_id, $course_id, $is_preview =
'((certificate_barcode))',
);

if (!empty($extra_user_info_data)) {
foreach ($extra_user_info_data as $key_extra => $value_extra) {
$info_to_be_replaced_in_content_html[] = '((' . strtolower($key_extra) . '))';
$info_to_replace_in_content_html[] = $value_extra;
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$valueExtra = isset($extra_user_info_data[$extraField['variable']]) ? $extra_user_info_data[$extraField['variable']] : '';
$info_to_be_replaced_in_content_html[] = '((' . strtolower($extraField['variable']) . '))';
$info_to_replace_in_content_html[] = $valueExtra;
}
}

Expand Down

0 comments on commit 7ed5ee3

Please sign in to comment.