Merge pull request #13198 from seamuslee001/event_search_561
[civicrm-core.git] / CRM / Utils / Token.php
index 68991c6dc3ca8b3425b79f02bcae2d64778fb27a..e3bdcc102b9b02525450be95701a771271490733 100644 (file)
@@ -1157,7 +1157,7 @@ class CRM_Utils_Token {
    * Gives required details of contacts in an indexed array format so we
    * can iterate in a nice loop and do token evaluation
    *
-   * @param $contactIDs
+   * @param array $contactIDs
    * @param array $returnProperties
    *   Of required properties.
    * @param bool $skipOnHold Don't return on_hold contact info also.
@@ -1186,7 +1186,7 @@ class CRM_Utils_Token {
   ) {
 
     $params = array();
-    foreach ($contactIDs as $key => $contactID) {
+    foreach ($contactIDs as $contactID) {
       $params[] = array(
         CRM_Core_Form::CB_PREFIX . $contactID,
         '=',
@@ -1215,7 +1215,7 @@ class CRM_Utils_Token {
       $fields = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields()),
         array('display_name', 'checksum', 'contact_id')
       );
-      foreach ($fields as $key => $val) {
+      foreach ($fields as $val) {
         // The unavailable fields are not available as tokens, do not have a one-2-one relationship
         // with contacts and are expensive to resolve.
         // @todo see CRM-17253 - there are some other fields (e.g note) that should be excluded
@@ -1239,12 +1239,12 @@ class CRM_Utils_Token {
 
     $contactDetails = &$details[0];
 
-    foreach ($contactIDs as $key => $contactID) {
+    foreach ($contactIDs as $contactID) {
       if (array_key_exists($contactID, $contactDetails)) {
         if (!empty($contactDetails[$contactID]['preferred_communication_method'])
         ) {
           $communicationPreferences = array();
-          foreach ($contactDetails[$contactID]['preferred_communication_method'] as $key => $val) {
+          foreach ($contactDetails[$contactID]['preferred_communication_method'] as $val) {
             if ($val) {
               $communicationPreferences[$val] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_communication_method', $val);
             }
@@ -1404,8 +1404,8 @@ class CRM_Utils_Token {
         $greetingTokens = $remainingTokens;
         reset($greetingTokens);
         $greetingsReturnProperties = array();
-        while (list($key) = each($greetingTokens)) {
-          $props = array_flip(CRM_Utils_Array::value($key, $greetingTokens));
+        foreach ($greetingTokens as $value) {
+          $props = array_flip($value);
           $props = array_fill_keys(array_keys($props), 1);
           $greetingsReturnProperties = $greetingsReturnProperties + $props;
         }
@@ -1762,6 +1762,7 @@ class CRM_Utils_Token {
               'id' => $membership['membership_type_id'],
               'return' => 'minimum_fee',
             ));
+          $value = CRM_Utils_Money::format($value, NULL, NULL, TRUE);
         }
         catch (CiviCRM_API3_Exception $e) {
           // we can anticipate we will get an error if the minimum fee is set to 'NULL' because of the way the