当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_Query::legacyConvertFormValues方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_Query::legacyConvertFormValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Query::legacyConvertFormValues方法的具体用法?PHP CRM_Contact_BAO_Query::legacyConvertFormValues怎么用?PHP CRM_Contact_BAO_Query::legacyConvertFormValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_Query的用法示例。


在下文中一共展示了CRM_Contact_BAO_Query::legacyConvertFormValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unserialize

 /**
  * Given an id, extract the formValues of the saved search.
  *
  * @param int $id
  *   The id of the saved search.
  *
  * @return array
  *   the values of the posted saved search used as default values in various Search Form
  */
 public static function &getFormValues($id)
 {
     $fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values');
     $result = NULL;
     if ($fv) {
         // make sure u unserialize - since it's stored in serialized form
         $result = unserialize($fv);
     }
     $specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id');
     foreach ($result as $element => $value) {
         if (CRM_Contact_BAO_Query::isAlreadyProcessedForQueryFormat($value)) {
             $id = CRM_Utils_Array::value(0, $value);
             $value = CRM_Utils_Array::value(2, $value);
             if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
                 $value = CRM_Utils_Array::value(key($value), $value);
             }
             $result[$id] = $value;
             unset($result[$element]);
             continue;
         }
         if (!empty($value) && is_array($value)) {
             if (in_array($element, $specialFields)) {
                 $element = str_replace('member_membership_type_id', 'membership_type_id', $element);
                 $element = str_replace('member_status_id', 'membership_status_id', $element);
                 CRM_Contact_BAO_Query::legacyConvertFormValues($element, $value);
                 $result[$element] = $value;
             } elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
                 $result[$element] = CRM_Utils_Array::value(key($value), $value);
                 if (is_string($result[$element])) {
                     $result[$element] = str_replace("%", '', $result[$element]);
                 }
             }
         }
         if (substr($element, 0, 7) == 'custom_' && (substr($element, -5, 5) == '_from' || substr($element, -3, 3) == '_to')) {
             // Ensure the _relative field is set if from or to are set to ensure custom date
             // fields with 'from' or 'to' values are displayed when the are set in the smart group
             // being loaded. (CRM-17116)
             if (!isset($result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'])) {
                 $result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'] = 0;
             }
         }
         // check to see if we need to convert the old privacy array
         // CRM-9180
         if (!empty($result['privacy'])) {
             if (is_array($result['privacy'])) {
                 $result['privacy_operator'] = 'AND';
                 $result['privacy_toggle'] = 1;
                 if (isset($result['privacy']['do_not_toggle'])) {
                     if ($result['privacy']['do_not_toggle']) {
                         $result['privacy_toggle'] = 2;
                     }
                     unset($result['privacy']['do_not_toggle']);
                 }
                 $result['privacy_options'] = array();
                 foreach ($result['privacy'] as $name => $val) {
                     if ($val) {
                         $result['privacy_options'][] = $name;
                     }
                 }
             }
             unset($result['privacy']);
         }
     }
     return $result;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:74,代码来源:SavedSearch.php

示例2: getFormValues

 /**
  * Given an id, extract the formValues of the saved search.
  *
  * @param int $id
  *   The id of the saved search.
  *
  * @return array
  *   the values of the posted saved search used as default values in various Search Form
  */
 public static function getFormValues($id)
 {
     $fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values');
     $result = NULL;
     if ($fv) {
         // make sure u unserialize - since it's stored in serialized form
         $result = unserialize($fv);
     }
     //CRM-19250: fetch the default date format to format mysql value as per CRM_Core_Error::addDate()
     $dateFormat = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PreferencesDate', 'searchDate', 'date_format', 'name');
     $dateFormat = empty($dateFormat) ? CRM_Core_Config::singleton()->dateInputFormat : $dateFormat;
     $dateFormat = CRM_Utils_Array::value($dateFormat, CRM_Core_SelectValues::datePluginToPHPFormats());
     $specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id');
     foreach ($result as $element => $value) {
         if (CRM_Contact_BAO_Query::isAlreadyProcessedForQueryFormat($value)) {
             $id = CRM_Utils_Array::value(0, $value);
             $value = CRM_Utils_Array::value(2, $value);
             if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
                 $value = CRM_Utils_Array::value(key($value), $value);
             }
             if (strpos($id, '_date_low') !== FALSE || strpos($id, '_date_high') !== FALSE) {
                 $result[$id] = date($dateFormat, strtotime($value));
                 $entityName = strstr($id, '_date', TRUE);
                 $result["{$entityName}_date_relative"] = 0;
             } else {
                 $result[$id] = $value;
             }
             unset($result[$element]);
             continue;
         }
         if (!empty($value) && is_array($value)) {
             if (in_array($element, $specialFields)) {
                 // Remove the element to minimise support for legacy formats. It is stored in $value
                 // so will be re-set with the right name.
                 unset($result[$element]);
                 $element = str_replace('member_membership_type_id', 'membership_type_id', $element);
                 $element = str_replace('member_status_id', 'membership_status_id', $element);
                 CRM_Contact_BAO_Query::legacyConvertFormValues($element, $value);
                 $result[$element] = $value;
             } elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
                 $result[$element] = CRM_Utils_Array::value(key($value), $value);
                 if (is_string($result[$element])) {
                     $result[$element] = str_replace("%", '', $result[$element]);
                 }
             }
         }
         if (substr($element, 0, 7) == 'custom_' && (substr($element, -5, 5) == '_from' || substr($element, -3, 3) == '_to')) {
             // Ensure the _relative field is set if from or to are set to ensure custom date
             // fields with 'from' or 'to' values are displayed when the are set in the smart group
             // being loaded. (CRM-17116)
             if (!isset($result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'])) {
                 $result[CRM_Contact_BAO_Query::getCustomFieldName($element) . '_relative'] = 0;
             }
         }
         // check to see if we need to convert the old privacy array
         // CRM-9180
         if (!empty($result['privacy'])) {
             if (is_array($result['privacy'])) {
                 $result['privacy_operator'] = 'AND';
                 $result['privacy_toggle'] = 1;
                 if (isset($result['privacy']['do_not_toggle'])) {
                     if ($result['privacy']['do_not_toggle']) {
                         $result['privacy_toggle'] = 2;
                     }
                     unset($result['privacy']['do_not_toggle']);
                 }
                 $result['privacy_options'] = array();
                 foreach ($result['privacy'] as $name => $val) {
                     if ($val) {
                         $result['privacy_options'][] = $name;
                     }
                 }
             }
             unset($result['privacy']);
         }
     }
     return $result;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:87,代码来源:SavedSearch.php


注:本文中的CRM_Contact_BAO_Query::legacyConvertFormValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。