本文整理汇总了PHP中CRM_Core_BAO_CustomOption::valuesByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomOption::valuesByID方法的具体用法?PHP CRM_Core_BAO_CustomOption::valuesByID怎么用?PHP CRM_Core_BAO_CustomOption::valuesByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomOption
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomOption::valuesByID方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $userRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded = false, $useRequired = true, $search = false, $label = null)
{
// we use $_POST directly, since we dont want to use session memory, CRM-4677
if (isset($_POST['_qf_Relationship_refresh']) && ($_POST['_qf_Relationship_refresh'] == 'Search' || $_POST['_qf_Relationship_refresh'] == 'Search Again')) {
$useRequired = 0;
}
$field =& new CRM_Core_DAO_CustomField();
$field->id = $fieldId;
if (!$field->find(true)) {
CRM_Core_Error::fatal();
}
// Fixed for Issue CRM-2183
if ($field->html_type == 'TextArea' && $search) {
$field->html_type = 'Text';
}
if (!isset($label)) {
$label = $field->label;
}
/**
* at some point in time we might want to split the below into small functions
**/
switch ($field->html_type) {
case 'Text':
if ($field->is_search_range && $search) {
$qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
$qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
} else {
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, ($useRequired || $useRequired && $field->is_required) && !$search);
}
break;
case 'TextArea':
$attributes = '';
if ($field->note_rows) {
$attributes .= 'rows=' . $field->note_rows;
} else {
$attributes .= 'rows=4';
}
if ($field->note_columns) {
$attributes .= ' cols=' . $field->note_columns;
} else {
$attributes .= ' cols=60';
}
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $attributes, ($useRequired || $useRequired && $field->is_required) && !$search);
break;
case 'Select Date':
if ($field->is_search_range && $search) {
$qf->addDate($elementName . '_from', $label . ' - ' . ts('From'), false, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years));
$qf->addDate($elementName . '_to', ts('To'), false, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years));
} else {
$required = ($useRequired || $useRequired && $field->is_required) && !$search;
$qf->addDate($elementName, $label, $required, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years));
}
break;
case 'Radio':
$choice = array();
if ($field->data_type != 'Boolean') {
$customOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
foreach ($customOption as $v => $l) {
$choice[] = $qf->createElement('radio', null, '', $l, (string) $v, $field->attributes);
}
$qf->addGroup($choice, $elementName, $label);
} else {
$choice[] = $qf->createElement('radio', null, '', ts('Yes'), '1', $field->attributes);
$choice[] = $qf->createElement('radio', null, '', ts('No'), '0', $field->attributes);
$qf->addGroup($choice, $elementName, $label);
}
if (($useRequired || $useRequired && $field->is_required) && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Select':
$selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
$qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, ($useRequired || $useRequired && $field->is_required) && !$search);
break;
//added for select multiple
//added for select multiple
case 'AdvMulti-Select':
$selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
$include =& $qf->addElement('advmultiselect', $elementName, $label, $selectOption, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
$include->setButtonAttributes('add', array('value' => ts('Add >>')));
$include->setButtonAttributes('remove', array('value' => ts('<< Remove')));
if (($useRequired || $useRequired && $field->is_required) && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
}
break;
case 'Multi-Select':
$selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
//.........这里部分代码省略.........
示例2: autocomplete
static function autocomplete($value, $options)
{
if ($value) {
$selectOption = CRM_Core_BAO_CustomOption::valuesByID($options['fieldID'], $options['optionGroupID']);
if (!in_array($value, $selectOption)) {
return FALSE;
}
}
return TRUE;
}
示例3: autocomplete
static function autocomplete($value, $options)
{
if ($value) {
require_once 'CRM/Core/BAO/CustomOption.php';
$selectOption =& CRM_Core_BAO_CustomOption::valuesByID($options['fieldID'], $options['optionGroupID']);
if (!in_array($value, $selectOption)) {
return false;
}
}
return true;
}
示例4: autocomplete
/**
* Function to fetch the values
*/
function autocomplete(&$config)
{
$fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
$optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
$label = CRM_Utils_Type::escape($_GET['s'], 'String');
require_once 'CRM/Core/BAO/CustomOption.php';
$selectOption =& CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
$completeList = null;
foreach ($selectOption as $id => $value) {
if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
echo $completeList = "{$value}|{$id}\n";
}
}
exit;
}
示例5: autocomplete
/**
* Function to fetch the values
*/
static function autocomplete()
{
$fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
$optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
$label = CRM_Utils_Type::escape($_GET['s'], 'String');
$selectOption = CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
$completeList = NULL;
foreach ($selectOption as $id => $value) {
if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
echo $completeList = "{$value}|{$id}\n";
}
}
CRM_Utils_System::civiExit();
}
示例6: autocomplete
/**
* Function to fetch the values
*/
static function autocomplete()
{
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('cfid', 'ogid', 'sigts'));
if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['sigts'] + self::AUTOCOMPLETE_TTL || !$signer->validate($_REQUEST['sig'], $_REQUEST)) {
CRM_Utils_System::civiExit();
}
$fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
$optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
$label = CRM_Utils_Type::escape($_GET['s'], 'String');
$selectOption = CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
$completeList = NULL;
foreach ($selectOption as $id => $value) {
if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
echo $completeList = "{$value}|{$id}\n";
}
}
CRM_Utils_System::civiExit();
}
示例7: addQuickFormElement
/**
* This function for building custom fields
*
* @param object $qf form object (reference)
* @param string $elementName name of the custom field
* @param boolean $inactiveNeeded
* @param boolean $userRequired true if required else false
* @param boolean $search true if used for search else false
* @param string $label label for custom field
*
* @access public
* @static
*/
public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded = FALSE, $useRequired = TRUE, $search = FALSE, $label = NULL)
{
// we use $_POST directly, since we dont want to use session memory, CRM-4677
if (isset($_POST['_qf_Relationship_refresh']) && ($_POST['_qf_Relationship_refresh'] == 'Search' || $_POST['_qf_Relationship_refresh'] == 'Search Again')) {
$useRequired = FALSE;
}
$field = self::getFieldObject($fieldId);
// Custom field HTML should indicate group+field name
$groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id);
$dataCrmCustomVal = $groupName . ':' . $field->name;
$dataCrmCustomAttr = 'data-crm-custom="' . $dataCrmCustomVal . '"';
$field->attributes .= $dataCrmCustomAttr;
// Fixed for Issue CRM-2183
if ($field->html_type == 'TextArea' && $search) {
$field->html_type = 'Text';
}
// FIXME: Why are select state/country separate widget types?
if (in_array($field->html_type, array('Select', 'Multi-Select', 'Select State/Province', 'Multi-Select State/Province', 'Select Country', 'Multi-Select Country'))) {
$selectAttributes = array('data-crm-custom' => $dataCrmCustomVal, 'class' => 'crm-select2');
if (strpos($field->html_type, 'Multi') === 0) {
$selectAttributes['multiple'] = 'multiple';
}
}
// Add popup link for editing options. Normally this is handled by CRM_Core_Form->addSelect
if (in_array($field->html_type, array('Select', 'Multi-Select')) && !$search && CRM_Core_Permission::check('administer CiviCRM')) {
$selectAttributes += array('data-api-entity' => 'contact', 'data-api-field' => 'custom_' . $field->id, 'data-option-group-url' => 'civicrm/admin/options/' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $field->option_group_id));
}
if (!isset($label)) {
$label = $field->label;
}
/**
* at some point in time we might want to split the below into small functions
**/
switch ($field->html_type) {
case 'Text':
if ($field->is_search_range && $search) {
$qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
$qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
} else {
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, $useRequired && !$search);
}
break;
case 'TextArea':
$attributes = $dataCrmCustomAttr;
if ($field->note_rows) {
$attributes .= 'rows=' . $field->note_rows;
} else {
$attributes .= 'rows=4';
}
if ($field->note_columns) {
$attributes .= ' cols=' . $field->note_columns;
} else {
$attributes .= ' cols=60';
}
if ($field->text_length) {
$attributes .= ' maxlength=' . $field->text_length;
}
$element =& $qf->add(strtolower($field->html_type), $elementName, $label, $attributes, $useRequired && !$search);
break;
case 'Select Date':
if ($field->is_search_range && $search) {
$qf->addDate($elementName . '_from', $label . ' - ' . ts('From'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
$qf->addDate($elementName . '_to', ts('To'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
} else {
$required = $useRequired && !$search;
$qf->addDate($elementName, $label, $required, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
}
break;
case 'Radio':
$choice = array();
if ($field->data_type != 'Boolean') {
$customOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
foreach ($customOption as $v => $l) {
$choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $field->attributes);
}
$group = $qf->addGroup($choice, $elementName, $label);
} else {
$choice[] = $qf->createElement('radio', NULL, '', ts('Yes'), '1', $field->attributes);
$choice[] = $qf->createElement('radio', NULL, '', ts('No'), '0', $field->attributes);
$group = $qf->addGroup($choice, $elementName, $label);
}
if ($useRequired && !$search) {
$qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
} else {
$group->setAttribute('unselectable', TRUE);
}
break;
//.........这里部分代码省略.........
示例8: autocomplete
/**
* Function to fetch the values
*/
static function autocomplete()
{
$fieldID = CRM_Utils_Type::escape($_GET['cfid'], 'Integer');
$optionGroupID = CRM_Utils_Type::escape($_GET['ogid'], 'Integer');
$label = CRM_Utils_Type::escape($_GET['s'], 'String');
$selectOption = CRM_Core_BAO_CustomOption::valuesByID($fieldID, $optionGroupID);
$results = array();
foreach ($selectOption as $id => $value) {
if (strtolower($label) == strtolower(substr($value, 0, strlen($label)))) {
$results[$id] = $value;
}
}
CRM_Core_Page_AJAX::autocompleteResults($results);
}
示例9: _civicrm_api_get_custom_fields
/**
* Return an array of fields for a given entity - this is the same as the BAO function but
* fields are prefixed with 'custom_' to represent api params
*/
function _civicrm_api_get_custom_fields($entity, &$params)
{
$customfields = array();
$entity = _civicrm_api_get_camel_name($entity);
if (strtolower($entity) == 'contact') {
// Use sub-type if available, otherwise stick with 'Contact'
$entity = CRM_Utils_Array::value('contact_type', $params);
}
$retrieveOnlyParent = FALSE;
// we could / should probably test for other subtypes here - e.g. activity_type_id
if ($entity == 'Contact') {
empty($params['contact_sub_type']);
}
$customfields = CRM_Core_BAO_CustomField::getFields($entity, FALSE, FALSE, CRM_Utils_Array::value('contact_sub_type', $params, FALSE), NULL, $retrieveOnlyParent, FALSE, FALSE);
// find out if we have any requests to resolve options
$getoptions = CRM_Utils_Array::value('get_options', CRM_Utils_Array::value('options', $params));
if (!is_array($getoptions)) {
$getoptions = array($getoptions);
}
foreach ($customfields as $key => $value) {
// Regular fields have a 'name' property
$value['name'] = 'custom_' . $key;
$value['type'] = _getStandardTypeFromCustomDataType($value['data_type']);
$customfields['custom_' . $key] = $value;
if (in_array('custom_' . $key, $getoptions)) {
$customfields['custom_' . $key]['options'] = CRM_Core_BAO_CustomOption::valuesByID($key);
}
unset($customfields[$key]);
}
return $customfields;
}