CRM-14463 - Fix custom address fields to support location type
[civicrm-core.git] / CRM / Profile / Page / Dynamic.php
index d66d1b547c8c4b9e539ad8bfebd0f6e145b54d3f..7d9b17ccdbeb21c33869670c5846b18ec525b765 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -317,8 +317,16 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page {
       $profileFields = array();
       $labels = array();
 
+      //CRM-14338
+      $nullValueIndex = ' ';
       foreach ($fields as $name => $field) {
-        $labels[$field['title']] = preg_replace('/\s+|\W+/', '_', $name);
+        if ( isset($labels[$field['title']]) ) {
+          $labels[$field['title'].$nullValueIndex] = preg_replace('/\s+|\W+/', '_', $name);
+          $nullValueIndex .= $nullValueIndex;
+        }
+        else {
+          $labels[$field['title']] = preg_replace('/\s+|\W+/', '_', $name);
+        }
       }
 
       foreach ($values as $title => $value) {
@@ -333,6 +341,8 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page {
     }
 
     $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'name');
+    $this->assign('ufGroupName', $name);
+    CRM_Utils_Hook::viewProfile($name);
 
     if (strtolower($name) == 'summary_overlay') {
       $template->assign('overlayProfile', TRUE);
@@ -369,7 +379,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page {
     // invoke the pagRun hook, CRM-3906
     CRM_Utils_Hook::pageRun($this);
 
-    return trim($template->fetch($this->getTemplateFileName()));
+    return trim($template->fetch($this->getHookedTemplateFileName()));
   }
 
   function checkTemplateFileExists($suffix = '') {