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


PHP CRM_Core_BAO_CustomField::getFieldObject方法代码示例

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


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

示例1: getCustomOption

 /**
  * Returns all active options ordered by weight for a given field
  *
  * @param  int      $fieldId         field whose options are needed
  * @param  boolean  $inactiveNeeded  do we need inactive options ?
  *
  * @return array $customOption all active options for fieldId
  * @static
  */
 static function getCustomOption($fieldID, $inactiveNeeded = FALSE)
 {
     $options = array();
     if (!$fieldID) {
         return $options;
     }
     $field = CRM_Core_BAO_CustomField::getFieldObject($fieldID);
     // get the option group id
     $optionGroupID = $field->option_group_id;
     if (!$optionGroupID) {
         return $options;
     }
     $optionValues = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroupID);
     foreach ($optionValues as $id => $value) {
         if (!$inactiveNeeded && empty($value['is_active'])) {
             continue;
         }
         $options[$id] = array();
         $options[$id]['id'] = $id;
         $options[$id]['label'] = $value['label'];
         $options[$id]['value'] = $value['value'];
     }
     CRM_Utils_Hook::customFieldOptions($fieldID, $options, TRUE);
     return $options;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:34,代码来源:CustomOption.php

示例2: getOptionListSelector

 /**
  * wrapper for ajax option selector.
  *
  * @param array $params
  *   Associated array for params record id.
  *
  * @return array
  *   associated array of option list
  *   -rp = rowcount
  *   -page= offset
  */
 public static function getOptionListSelector(&$params)
 {
     $options = array();
     //get the default value from custom fields
     $customFieldBAO = new CRM_Core_BAO_CustomField();
     $customFieldBAO->id = $params['fid'];
     if ($customFieldBAO->find(TRUE)) {
         $defaultValue = $customFieldBAO->default_value;
         $fieldHtmlType = $customFieldBAO->html_type;
     } else {
         CRM_Core_Error::fatal();
     }
     $defVal = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($defaultValue, 1, -1));
     // format the params
     $params['offset'] = ($params['page'] - 1) * $params['rp'];
     $params['rowCount'] = $params['rp'];
     $field = CRM_Core_BAO_CustomField::getFieldObject($params['fid']);
     // get the option group id
     $optionGroupID = $field->option_group_id;
     if (!$optionGroupID) {
         return $options;
     }
     $queryParams = array(1 => array($optionGroupID, 'Integer'));
     $total = "SELECT COUNT(*) FROM civicrm_option_value WHERE option_group_id = %1";
     $params['total'] = CRM_Core_DAO::singleValueQuery($total, $queryParams);
     $limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
     $orderBy = ' ORDER BY options.weight asc';
     $query = "SELECT * FROM civicrm_option_value as options WHERE option_group_id = %1 {$orderBy} {$limit}";
     $dao = CRM_Core_DAO::executeQuery($query, $queryParams);
     $links = CRM_Custom_Page_Option::actionLinks();
     $fields = array('id', 'label', 'value');
     $config = CRM_Core_Config::singleton();
     while ($dao->fetch()) {
         $options[$dao->id] = array();
         foreach ($fields as $k) {
             $options[$dao->id][$k] = $dao->{$k};
         }
         $action = array_sum(array_keys($links));
         $class = 'crm-entity';
         // update enable/disable links depending on custom_field properties.
         if ($dao->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $class .= ' disabled';
             $action -= CRM_Core_Action::DISABLE;
         }
         if ($fieldHtmlType == 'CheckBox' || $fieldHtmlType == 'AdvMulti-Select' || $fieldHtmlType == 'Multi-Select') {
             if (in_array($dao->value, $defVal)) {
                 $options[$dao->id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
             } else {
                 $options[$dao->id]['is_default'] = '';
             }
         } else {
             if ($defaultValue == $dao->value) {
                 $options[$dao->id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
             } else {
                 $options[$dao->id]['is_default'] = '';
             }
         }
         $options[$dao->id]['class'] = $dao->id . ',' . $class;
         $options[$dao->id]['is_active'] = !empty($dao->is_active) ? 'Yes' : 'No';
         $options[$dao->id]['links'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'fid' => $params['fid'], 'gid' => $params['gid']), ts('more'), FALSE, 'customOption.row.actions', 'customOption', $dao->id);
     }
     return $options;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:76,代码来源:CustomOption.php


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