Merge remote branch 'canonical/master' into merge-20140930
[civicrm-core.git] / CRM / Utils / Token.php
index 12e21758e27056f244eb86d934f8d5b72117b5e7..0e58f6e12dda537c21e573e3adcbd9fa682a9dd5 100644 (file)
@@ -1720,7 +1720,12 @@ class CRM_Utils_Token {
       // Group by entity
       else {
         $split = explode('.', trim($k, '{}'));
-        $entity = isset($split[1]) ? ucfirst($split[0]) : 'Contact';
+        if (isset($split[1])) {
+          $entity = array_key_exists($split[1], CRM_Core_DAO_Address::export()) ? 'Address' : ucfirst($split[0]);
+        }
+        else {
+          $entity = 'Contact';
+        }
         $sorted[ts($entity)][] = array('id' => $k, 'text' => $v);
       }
     }