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


PHP CRM_Utils_Hook::custom方法代码示例

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


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

示例1: create

 /**
  * @param array $customParams
  *
  * @throws Exception
  */
 public static function create(&$customParams)
 {
     if (empty($customParams) || !is_array($customParams)) {
         return;
     }
     foreach ($customParams as $tableName => $tables) {
         foreach ($tables as $index => $fields) {
             $sqlOP = NULL;
             $hookID = NULL;
             $hookOP = NULL;
             $entityID = NULL;
             $isMultiple = FALSE;
             $set = array();
             $params = array();
             $count = 1;
             foreach ($fields as $field) {
                 if (!$sqlOP) {
                     $entityID = $field['entity_id'];
                     $hookID = $field['custom_group_id'];
                     $isMultiple = $field['is_multiple'];
                     if (array_key_exists('id', $field)) {
                         $sqlOP = "UPDATE {$tableName} ";
                         $where = " WHERE  id = %{$count}";
                         $params[$count] = array($field['id'], 'Integer');
                         $count++;
                         $hookOP = 'edit';
                     } else {
                         $sqlOP = "INSERT INTO {$tableName} ";
                         $where = NULL;
                         $hookOP = 'create';
                     }
                 }
                 // fix the value before we store it
                 $value = $field['value'];
                 $type = $field['type'];
                 switch ($type) {
                     case 'StateProvince':
                         $type = 'Integer';
                         if (is_array($value)) {
                             $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
                             $type = 'String';
                         } elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
                             //fix for multi select state, CRM-3437
                             $mulValues = explode(',', $value);
                             $validStates = array();
                             foreach ($mulValues as $key => $stateVal) {
                                 $states = array();
                                 $states['state_province'] = trim($stateVal);
                                 CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvince(), TRUE);
                                 if (empty($states['state_province_id'])) {
                                     CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), TRUE);
                                 }
                                 $validStates[] = CRM_Utils_Array::value('state_province_id', $states);
                             }
                             $value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validStates);
                             $type = 'String';
                         } elseif (!$value) {
                             // CRM-3415
                             // using type of timestamp allows us to sneak in a null into db
                             // gross but effective hack
                             $value = NULL;
                             $type = 'Timestamp';
                         } else {
                             $type = 'String';
                         }
                         break;
                     case 'Country':
                         $type = 'Integer';
                         $mulValues = explode(',', $value);
                         if (is_array($value)) {
                             $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
                             $type = 'String';
                         } elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
                             //fix for multi select country, CRM-3437
                             $mulValues = explode(',', $value);
                             $validCountries = array();
                             foreach ($mulValues as $key => $countryVal) {
                                 $countries = array();
                                 $countries['country'] = trim($countryVal);
                                 CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::country(), TRUE);
                                 if (empty($countries['country_id'])) {
                                     CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::countryIsoCode(), TRUE);
                                 }
                                 $validCountries[] = CRM_Utils_Array::value('country_id', $countries);
                             }
                             $value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validCountries);
                             $type = 'String';
                         } elseif (!$value) {
                             // CRM-3415
                             // using type of timestamp allows us to sneak in a null into db
                             // gross but effective hack
                             $value = NULL;
                             $type = 'Timestamp';
                         } else {
                             $type = 'String';
//.........这里部分代码省略.........
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:CustomValueTable.php

示例2: deleteCustomValue

 /**
  * Delete option value give an option value and custom group id.
  *
  * @param int $customValueID
  *   Custom value ID.
  * @param int $customGroupID
  *   Custom group ID.
  *
  * @return void
  */
 public static function deleteCustomValue($customValueID, $customGroupID)
 {
     // first we need to find custom value table, from custom group ID
     $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupID, 'table_name');
     // delete custom value from corresponding custom value table
     $sql = "DELETE FROM {$tableName} WHERE id = {$customValueID}";
     CRM_Core_DAO::executeQuery($sql);
     CRM_Utils_Hook::custom('delete', $customGroupID, NULL, $customValueID);
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:19,代码来源:CustomValue.php


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