Browse Source

Show all visible extra fields for course coach on About Session page - refs BT#9886 #TMI

Angel Fernando Quiroz Campos 9 years ago
parent
commit
ade8090f09
2 changed files with 17 additions and 35 deletions
  1. 11 29
      main/session/about.php
  2. 6 6
      main/template/default/session/about.tpl

+ 11 - 29
main/session/about.php

@@ -39,15 +39,6 @@ $tagField = $fieldsRepo->findOneBy([
     'variable' => 'tags'
 ]);
 
-$workOrStudyPlaceField = $fieldsRepo->findOneBy([
-    'extraFieldType' => ExtraField::USER_FIELD_TYPE,
-    'variable' => 'work_or_study_place'
-]);
-$officerPositionField = $fieldsRepo->findOneBy([
-    'extraFieldType' => ExtraField::USER_FIELD_TYPE,
-    'variable' => 'officer_position'
-]);
-
 foreach ($sessionCourses as $sessionCourse) {
     $courseVideo = null;
     $courseTags = [];
@@ -75,29 +66,20 @@ foreach ($sessionCourses as $sessionCourse) {
     foreach ($courseCoaches as $courseCoach) {
         $coachData = [
             'complete_name' => $courseCoach->getCompleteName(),
-            'image' => UserManager::getUserPicture($courseCoach->getId(), USER_IMAGE_SIZE_ORIGINAL)
+            'image' => UserManager::getUserPicture($courseCoach->getId(), USER_IMAGE_SIZE_ORIGINAL),
+            'extra_fields' => []
         ];
 
-        if (!is_null($workOrStudyPlaceField)) {
-            $workOrStudyPlaceValue = $fieldValuesRepo->findOneBy([
-                'field' => $workOrStudyPlaceField,
-                'itemId' => $courseCoach->getId()
-            ]);
-
-            if (!is_null($workOrStudyPlaceValue)) {
-                $coachData['work_or_study_place'] = $workOrStudyPlaceValue->getValue();
-            }
-        }
-
-        if (!is_null($officerPositionField)) {
-            $officerPositionValue = $fieldValuesRepo->findOneBy([
-                'field' => $officerPositionField,
-                'itemId' => $courseCoach->getId()
-            ]);
+        $extraFieldValues = $fieldValuesRepo->getVisibleValues(
+            ExtraField::USER_FIELD_TYPE,
+            $courseCoach->getId()
+        );
 
-            if (!is_null($officerPositionValue)) {
-                $coachData['officer_position'] = $officerPositionValue->getValue();
-            }
+        foreach ($extraFieldValues as $value) {
+            $coachData['extra_fields'][] = [
+                'field' => $value->getField()->getDisplayText(),
+                'value' => $value->getValue()
+            ];
         }
 
         $coachesData[] = $coachData;

+ 6 - 6
main/template/default/session/about.tpl

@@ -77,13 +77,13 @@
                                 <div class="row">
                                     <div class="col-xs-7 col-md-7">
                                         <h4>{{ coach.complete_name }}</h4>
-                                        {% if coach.officer_position %}
-                                            <p>{{ coach.officer_position }}</p>
-                                        {% endif %}
 
-                                        {% if coach.work_or_study_place %}
-                                            <p>{{ coach.work_or_study_place }}</p>
-                                        {% endif %}
+                                        {% for extra_field in coach.extra_fields %}
+                                            <dl>
+                                                <dt>{{ extra_field.field }}</dt>
+                                                <dd>{{ extra_field.value }}</dd>
+                                            </dl>
+                                        {% endfor %}
                                     </div>
                                     <div class="col-xs-5 col-md-5">
                                         <div class="text-center">