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


PHP CRM_Contact_BAO_Query::fixWhereValues方法代码示例

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


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

示例1: convertFormValues

 static function convertFormValues(&$formValues, $wildcard = 0, $useEquals = FALSE)
 {
     $params = array();
     if (empty($formValues)) {
         return $params;
     }
     foreach ($formValues as $id => $values) {
         if ($id == 'privacy') {
             if (is_array($formValues['privacy'])) {
                 $op = CRM_Utils_Array::value('do_not_toggle', $formValues['privacy']) ? '=' : '!=';
                 foreach ($formValues['privacy'] as $key => $value) {
                     if ($value) {
                         $params[] = array($key, $op, $value, 0, 0);
                     }
                 }
             }
         } elseif ($id == 'email_on_hold') {
             if ($formValues['email_on_hold']['on_hold']) {
                 $params[] = array('on_hold', '=', $formValues['email_on_hold']['on_hold'], 0, 0);
             }
         } elseif (preg_match('/_date_relative$/', $id) || $id == 'event_relative') {
             if ($id == 'event_relative') {
                 $fromRange = 'event_start_date_low';
                 $toRange = 'event_end_date_high';
             } else {
                 $dateComponent = explode('_date_relative', $id);
                 $fromRange = "{$dateComponent[0]}_date_low";
                 $toRange = "{$dateComponent[0]}_date_high";
             }
             if (array_key_exists($fromRange, $formValues) && array_key_exists($toRange, $formValues)) {
                 CRM_Contact_BAO_Query::fixDateValues($formValues[$id], $formValues[$fromRange], $formValues[$toRange]);
                 continue;
             }
         } else {
             $values = CRM_Contact_BAO_Query::fixWhereValues($id, $values, $wildcard, $useEquals);
             if (!$values) {
                 continue;
             }
             $params[] = $values;
         }
     }
     return $params;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:43,代码来源:Query.php

示例2: convertFormValues


//.........这里部分代码省略.........
  *   2 => array('BETWEEN' => array(1,60),
  *   3 => null
  *   4 => null
  *  );
  *
  * There are some examples of the syntax in
  * https://github.com/civicrm/civicrm-core/tree/master/api/v3/examples/Relationship
  *
  * More notes at CRM_Core_DAO::createSQLFilter
  *
  * and a list of supported operators in CRM_Core_DAO
  *
  * @param array $formValues
  * @param int $wildcard
  * @param bool $useEquals
  *
  * @param string $apiEntity
  *
  * @param array $entityReferenceFields
  *   Field names of any entity reference fields (which will need reformatting to IN syntax).
  *
  * @return array
  */
 public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals = FALSE, $apiEntity = NULL, $entityReferenceFields = array())
 {
     $params = array();
     if (empty($formValues)) {
         return $params;
     }
     foreach ($formValues as $id => $values) {
         if (self::isAlreadyProcessedForQueryFormat($values)) {
             $params[] = $values;
             continue;
         }
         self::legacyConvertFormValues($id, $values);
         // The form uses 1 field to represent two db fields
         if ($id == 'contact_type' && $values && (!is_array($values) || !array_intersect(array_keys($values), CRM_Core_DAO::acceptedSQLOperators()))) {
             $contactType = array();
             $subType = array();
             foreach ((array) $values as $key => $type) {
                 $types = explode('__', is_numeric($type) ? $key : $type);
                 $contactType[$types[0]] = $types[0];
                 // Add sub-type if specified
                 if (!empty($types[1])) {
                     $subType[$types[1]] = $types[1];
                 }
             }
             $params[] = array('contact_type', 'IN', $contactType, 0, 0);
             if ($subType) {
                 $params[] = array('contact_sub_type', 'IN', $subType, 0, 0);
             }
         } elseif ($id == 'privacy') {
             if (is_array($formValues['privacy'])) {
                 $op = !empty($formValues['privacy']['do_not_toggle']) ? '=' : '!=';
                 foreach ($formValues['privacy'] as $key => $value) {
                     if ($value) {
                         $params[] = array($key, $op, $value, 0, 0);
                     }
                 }
             }
         } elseif ($id == 'email_on_hold') {
             if ($formValues['email_on_hold']['on_hold']) {
                 $params[] = array('on_hold', '=', $formValues['email_on_hold']['on_hold'], 0, 0);
             }
         } elseif (substr($id, 0, 7) == 'custom_' && (substr($id, -9, 9) == '_relative' || substr($id, -5, 5) == '_from' || substr($id, -3, 3) == '_to')) {
             self::convertCustomDateRelativeFields($formValues, $params, $values, $id);
         } elseif (preg_match('/_date_relative$/', $id) || $id == 'event_relative' || $id == 'case_from_relative' || $id == 'case_to_relative' || $id == 'participant_relative') {
             if ($id == 'event_relative') {
                 $fromRange = 'event_start_date_low';
                 $toRange = 'event_end_date_high';
             } elseif ($id == 'participant_relative') {
                 $fromRange = 'participant_register_date_low';
                 $toRange = 'participant_register_date_high';
             } elseif ($id == 'case_from_relative') {
                 $fromRange = 'case_from_start_date_low';
                 $toRange = 'case_from_start_date_high';
             } elseif ($id == 'case_to_relative') {
                 $fromRange = 'case_to_end_date_low';
                 $toRange = 'case_to_end_date_high';
             } else {
                 $dateComponent = explode('_date_relative', $id);
                 $fromRange = "{$dateComponent[0]}_date_low";
                 $toRange = "{$dateComponent[0]}_date_high";
             }
             if (array_key_exists($fromRange, $formValues) && array_key_exists($toRange, $formValues)) {
                 CRM_Contact_BAO_Query::fixDateValues($formValues[$id], $formValues[$fromRange], $formValues[$toRange]);
                 continue;
             }
         } elseif (in_array($id, $entityReferenceFields) && !empty($values) && is_string($values) && strpos($values, ',') != FALSE) {
             $params[] = array($id, 'IN', explode(',', $values), 0, 0);
         } else {
             $values = CRM_Contact_BAO_Query::fixWhereValues($id, $values, $wildcard, $useEquals, $apiEntity);
             if (!$values) {
                 continue;
             }
             $params[] = $values;
         }
     }
     return $params;
 }
开发者ID:hazemtorab,项目名称:civicrm-core,代码行数:101,代码来源:Query.php

示例3: convertFormValues

 /**
  * Convert values from form-appropriate to query-object appropriate.
  *
  * The query object is increasingly supporting the sql-filter syntax which is the most flexible syntax.
  * So, ideally we would convert all fields to look like
  *  array(
  *   0 => $fieldName
  *   // Set the operator for legacy reasons, but it is ignored
  *   1 =>  '='
  *   // array in sql filter syntax
  *   2 => array('BETWEEN' => array(1,60),
  *   3 => null
  *   4 => null
  *  );
  *
  * There are some examples of the syntax in
  * https://github.com/civicrm/civicrm-core/tree/master/api/v3/examples/Relationship
  *
  * More notes at CRM_Core_DAO::createSQLFilter
  *
  * and a list of supported operators in CRM_Core_DAO
  *
  * @param array $formValues
  * @param int $wildcard
  * @param bool $useEquals
  *
  * @param string $apiEntity
  *
  * @param array $entityReferenceFields
  *   Field names of any entity reference fields (which will need reformatting to IN syntax).
  *
  * @return array
  */
 public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals = FALSE, $apiEntity = NULL, $entityReferenceFields = array())
 {
     $params = array();
     if (empty($formValues)) {
         return $params;
     }
     foreach ($formValues as $id => $values) {
         self::legacyConvertFormValues($id, $values);
         if (self::isAlreadyProcessedForQueryFormat($values)) {
             $params[] = $values;
             continue;
         }
         if ($id == 'privacy') {
             if (is_array($formValues['privacy'])) {
                 $op = !empty($formValues['privacy']['do_not_toggle']) ? '=' : '!=';
                 foreach ($formValues['privacy'] as $key => $value) {
                     if ($value) {
                         $params[] = array($key, $op, $value, 0, 0);
                     }
                 }
             }
         } elseif ($id == 'email_on_hold') {
             if ($formValues['email_on_hold']['on_hold']) {
                 $params[] = array('on_hold', '=', $formValues['email_on_hold']['on_hold'], 0, 0);
             }
         } elseif (substr($id, 0, 7) == 'custom_' && (substr($id, -9, 9) == '_relative' || substr($id, -5, 5) == '_from' || substr($id, -3, 3) == '_to')) {
             self::convertCustomDateRelativeFields($formValues, $params, $values, $id);
         } elseif (preg_match('/_date_relative$/', $id) || $id == 'event_relative' || $id == 'case_from_relative' || $id == 'case_to_relative' || $id == 'participant_relative') {
             if ($id == 'event_relative') {
                 $fromRange = 'event_start_date_low';
                 $toRange = 'event_end_date_high';
             } elseif ($id == 'participant_relative') {
                 $fromRange = 'participant_register_date_low';
                 $toRange = 'participant_register_date_high';
             } elseif ($id == 'case_from_relative') {
                 $fromRange = 'case_from_start_date_low';
                 $toRange = 'case_from_start_date_high';
             } elseif ($id == 'case_to_relative') {
                 $fromRange = 'case_to_end_date_low';
                 $toRange = 'case_to_end_date_high';
             } else {
                 $dateComponent = explode('_date_relative', $id);
                 $fromRange = "{$dateComponent[0]}_date_low";
                 $toRange = "{$dateComponent[0]}_date_high";
             }
             if (array_key_exists($fromRange, $formValues) && array_key_exists($toRange, $formValues)) {
                 CRM_Contact_BAO_Query::fixDateValues($formValues[$id], $formValues[$fromRange], $formValues[$toRange]);
                 continue;
             }
         } elseif (in_array($id, $entityReferenceFields) && !empty($values) && is_string($values) && strpos($values, ',') != FALSE) {
             $params[] = array($id, 'IN', explode(',', $values), 0, 0);
         } else {
             $values = CRM_Contact_BAO_Query::fixWhereValues($id, $values, $wildcard, $useEquals, $apiEntity);
             if (!$values) {
                 continue;
             }
             $params[] = $values;
         }
     }
     return $params;
 }
开发者ID:hoegrammer,项目名称:civicrm-core,代码行数:94,代码来源:Query.php

示例4: convertFormValues

 static function convertFormValues(&$formValues, $wildcard = 0, $useEquals = false)
 {
     $params = array();
     if (empty($formValues)) {
         return $params;
     }
     foreach ($formValues as $id => $values) {
         if ($id == 'privacy') {
             if (is_array($formValues['privacy'])) {
                 $op = CRM_Utils_Array::value('do_not_toggle', $formValues['privacy']) ? '=' : '!=';
                 foreach ($formValues['privacy'] as $key => $value) {
                     if ($value) {
                         $params[] = array($key, $op, $value, 0, 0);
                     }
                 }
             }
         } else {
             if ($id == 'email_on_hold') {
                 if ($formValues['email_on_hold']['on_hold']) {
                     $params[] = array('on_hold', '=', $formValues['email_on_hold']['on_hold'], 0, 0);
                 }
             } else {
                 $values =& CRM_Contact_BAO_Query::fixWhereValues($id, $values, $wildcard, $useEquals);
                 if (!$values) {
                     continue;
                 }
                 $params[] = $values;
             }
         }
     }
     return $params;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:Query.php


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