本文整理汇总了PHP中CRM_Core_DAO_OptionValue::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_OptionValue::find方法的具体用法?PHP CRM_Core_DAO_OptionValue::find怎么用?PHP CRM_Core_DAO_OptionValue::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_OptionValue
的用法示例。
在下文中一共展示了CRM_Core_DAO_OptionValue::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _civicrm_api3_pcpteams_getCustomData
function _civicrm_api3_pcpteams_getCustomData(&$params)
{
$result = array();
foreach ($params as $pcpId => $pcpValues) {
foreach ($pcpValues as $fieldName => $values) {
$explodeFieldName = explode('_', $fieldName);
if ($explodeFieldName[0] == 'custom') {
$column_name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $explodeFieldName[1], 'column_name');
$params[$pcpId][$column_name] = $values;
if ($column_name == 'team_pcp_id') {
$params[$pcpId]['team_pcp_name'] = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $values, 'title');
} elseif (isset($explodeFieldName[2]) && $explodeFieldName[2] == 'id') {
$column_name = str_replace('id', 'name', $column_name);
$params[$pcpId][$column_name] = $pcpValues['custom_' . $explodeFieldName[1]];
} else {
$column_name .= '_label';
$ogId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $explodeFieldName[1], 'option_group_id');
$ovDao = new CRM_Core_DAO_OptionValue();
$ovDao->option_group_id = $ogId;
$ovDao->value = $values;
$ovDao->find(TRUE);
$params[$pcpId][$column_name] = $ovDao->label;
}
}
}
}
}
示例2: getOptionValuesArray
/**
* Get the values of all option values given an option group ID. Store in system cache
* Does not take any filtering arguments. The object is to avoid hitting the DB and retrieve
* from memory
*
* @param int $optionGroupID
* The option group for which we want the values from.
*
* @return array
* an array of array of values for this option group
*/
public static function getOptionValuesArray($optionGroupID)
{
// check if we can get the field values from the system cache
$cacheKey = "CRM_Core_BAO_OptionValue_OptionGroupID_{$optionGroupID}";
$cache = CRM_Utils_Cache::singleton();
$optionValues = $cache->get($cacheKey);
if (empty($optionValues)) {
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $optionGroupID;
$dao->orderBy('weight ASC, label ASC');
$dao->find();
$optionValues = array();
while ($dao->fetch()) {
$optionValues[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $optionValues[$dao->id]);
}
$cache->set($cacheKey, $optionValues);
}
return $optionValues;
}
示例3: updateCustomValues
static function updateCustomValues($params)
{
$optionDAO = new CRM_Core_DAO_OptionValue();
$optionDAO->id = $params['optionId'];
$optionDAO->find(TRUE);
$oldValue = $optionDAO->value;
// get the table, column, html_type and data type for this field
$query = "\nSELECT g.table_name as tableName ,\n f.column_name as columnName,\n f.data_type as dataType,\n f.html_type as htmlType\nFROM civicrm_custom_group g,\n civicrm_custom_field f\nWHERE f.custom_group_id = g.id\n AND f.id = %1";
$queryParams = array(1 => array($params['fieldId'], 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
if ($dao->fetch()) {
if ($dao->dataType == 'Money') {
$params['value'] = CRM_Utils_Rule::cleanMoney($params['value']);
}
switch ($dao->htmlType) {
case 'Autocomplete-Select':
case 'Select':
case 'Radio':
$query = "\nUPDATE {$dao->tableName}\nSET {$dao->columnName} = %1\nWHERE id = %2";
if ($dao->dataType == 'Auto-complete') {
$dataType = "String";
} else {
$dataType = $dao->dataType;
}
$queryParams = array(1 => array($params['value'], $dataType), 2 => array($params['optionId'], 'Integer'));
break;
case 'AdvMulti-Select':
case 'Multi-Select':
case 'CheckBox':
$oldString = CRM_Core_DAO::VALUE_SEPARATOR . $oldValue . CRM_Core_DAO::VALUE_SEPARATOR;
$newString = CRM_Core_DAO::VALUE_SEPARATOR . $params['value'] . CRM_Core_DAO::VALUE_SEPARATOR;
$query = "\nUPDATE {$dao->tableName}\nSET {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )";
$queryParams = array(1 => array($oldString, 'String'), 2 => array($newString, 'String'));
break;
default:
CRM_Core_Error::fatal();
}
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
}
}
示例4: del
/**
* Delete a PDF Page Format.
*
* @param int $id
* ID of the PDF Page Format to be deleted.
*
*/
public static function del($id)
{
if ($id) {
$dao = new CRM_Core_DAO_OptionValue();
$dao->id = $id;
if ($dao->find(TRUE)) {
if ($dao->option_group_id == self::_getGid()) {
$filter = array('option_group_id' => self::_getGid());
CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter);
$dao->delete();
return;
}
}
}
CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
}
示例5: updateValue
/**
* When changing the value of an option this is called to update all corresponding custom data
*
* @param int $optionId
* @param string $newValue
*/
public static function updateValue($optionId, $newValue)
{
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionId;
$optionValue->find(TRUE);
$oldValue = $optionValue->value;
if ($oldValue == $newValue) {
return;
}
$customField = new CRM_Core_DAO_CustomField();
$customField->option_group_id = $optionValue->option_group_id;
$customField->find();
while ($customField->fetch()) {
$customGroup = new CRM_Core_DAO_CustomGroup();
$customGroup->id = $customField->custom_group_id;
$customGroup->find(TRUE);
if (CRM_Core_BAO_CustomField::isSerialized($customField)) {
$params = array(1 => array(CRM_Utils_Array::implodePadded($oldValue), 'String'), 2 => array(CRM_Utils_Array::implodePadded($newValue), 'String'), 3 => array('%' . CRM_Utils_Array::implodePadded($oldValue) . '%', 'String'));
} else {
$params = array(1 => array($oldValue, 'String'), 2 => array($newValue, 'String'), 3 => array($oldValue, 'String'));
}
$sql = "UPDATE `{$customGroup->table_name}` SET `{$customField->column_name}` = REPLACE(`{$customField->column_name}`, %1, %2) WHERE `{$customField->column_name}` LIKE %3";
$customGroup->free();
CRM_Core_DAO::executeQuery($sql, $params);
}
$customField->free();
}
示例6: int
function upgrade_3_3_beta1($rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// CRM-6902
// Add column price_field_value_id in civicrm_line_item.
// Do not drop option_group_id column now since we need it to
// update line items.
$updateLineItem1 = "ALTER TABLE civicrm_line_item ADD COLUMN price_field_value_id int(10) unsigned default NULL;";
CRM_Core_DAO::executeQuery($updateLineItem1);
$priceFieldDAO = new CRM_Price_DAO_Field();
$priceFieldDAO->find();
$ids = array();
while ($priceFieldDAO->fetch()) {
$opGroupDAO = new CRM_Core_DAO_OptionGroup();
$opGroupDAO->name = 'civicrm_price_field.amount.' . $priceFieldDAO->id;
if (!$opGroupDAO->find(TRUE)) {
$opGroupDAO->free();
continue;
}
$opValueDAO = new CRM_Core_DAO_OptionValue();
$opValueDAO->option_group_id = $opGroupDAO->id;
$opValueDAO->find();
while ($opValueDAO->fetch()) {
// FIX ME: not migrating description(?), there will
// be a field description for each option.
$fieldValue = array('price_field_id' => $priceFieldDAO->id, 'label' => $opValueDAO->label, 'name' => CRM_Utils_String::munge($opValueDAO->label, '_', 64), 'amount' => $opValueDAO->name, 'weight' => $opValueDAO->weight, 'is_default' => $opValueDAO->is_default, 'is_active' => $opValueDAO->is_active);
if ($priceFieldDAO->count) {
// Migrate Participant Counts on option level.
// count of each option will be the same
// as earlier field count.
$fieldValue['count'] = $priceFieldDAO->count;
}
$fieldValueDAO = CRM_Price_BAO_FieldValue::add($fieldValue, $ids);
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
$lineItemDAO->unit_price = $opValueDAO->name;
$labelFound = $priceFound = FALSE;
// check with label and amount
if (!$lineItemDAO->find(TRUE)) {
$lineItemDAO->free();
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
// check with label only
if ($lineItemDAO->find(TRUE)) {
$labelFound = TRUE;
}
} else {
$labelFound = TRUE;
$priceFound = TRUE;
}
$lineItemDAO->free();
// update civicrm_line_item for price_field_value_id.
// Used query to avoid line by line update.
if ($labelFound || $priceFound) {
$lineItemParams = array(1 => array($fieldValueDAO->id, 'Integer'), 2 => array($opValueDAO->label, 'String'));
$updateLineItems = "UPDATE civicrm_line_item SET price_field_value_id = %1 WHERE label = %2";
if ($priceFound) {
$lineItemParams[3] = array($opValueDAO->name, 'Float');
$updateLineItems .= " AND unit_price = %3";
}
CRM_Core_DAO::executeQuery($updateLineItems, $lineItemParams);
}
}
$opGroupDAO->delete();
$opValueDAO->free();
$opGroupDAO->free();
}
$priceFieldDAO->free();
// Now drop option_group_id column from civicrm_line_item
$updateLineItem2 = "ALTER TABLE civicrm_line_item DROP option_group_id,\n ADD CONSTRAINT `FK_civicrm_price_field_value_id` FOREIGN KEY (price_field_value_id) REFERENCES civicrm_price_field_value(id) ON DELETE SET NULL;";
CRM_Core_DAO::executeQuery($updateLineItem2, array(), TRUE, NULL, FALSE, FALSE);
$updatePriceField = "ALTER TABLE civicrm_price_field DROP count";
CRM_Core_DAO::executeQuery($updatePriceField, array(), TRUE, NULL, FALSE, FALSE);
// as the table 'civicrm_price_field' is localised and column 'count' is dropped
// after the views are rebuild, we need to rebuild views to avoid invalid refrence of table.
if ($upgrade->multilingual) {
CRM_Core_I18n_Schema::rebuildMultilingualSchema($upgrade->locales, $rev);
}
}
示例7: getRows
/**
* Return option-values of a particular group
*
* @param array $groupParams
* Array containing group fields whose option-values is to retrieved.
* @param array $links
* Has links like edit, delete, disable ..etc.
* @param string $orderBy
* For orderBy clause.
*
* @return array
* Array of option-values
*
*/
public static function getRows($groupParams, $links, $orderBy = 'weight')
{
$optionValue = array();
$optionGroupID = NULL;
if (!isset($groupParams['id']) || !$groupParams['id']) {
if ($groupParams['name']) {
$config = CRM_Core_Config::singleton();
$optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $dnc);
$optionGroupID = $optionGroup->id;
}
} else {
$optionGroupID = $groupParams['id'];
}
$groupName = CRM_Utils_Array::value('name', $groupParams);
if (!$groupName && $optionGroupID) {
$groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupID, 'name', 'id');
}
$dao = new CRM_Core_DAO_OptionValue();
if ($optionGroupID) {
$dao->option_group_id = $optionGroupID;
if (in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups)) {
$dao->domain_id = CRM_Core_Config::domainID();
}
$dao->orderBy($orderBy);
$dao->find();
}
if ($groupName == 'case_type') {
$caseTypeIds = CRM_Case_BAO_Case::getUsedCaseType();
} elseif ($groupName == 'case_status') {
$caseStatusIds = CRM_Case_BAO_Case::getUsedCaseStatuses();
}
$componentNames = CRM_Core_Component::getNames();
$visibilityLabels = CRM_Core_PseudoConstant::visibility();
while ($dao->fetch()) {
$optionValue[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]);
// form all action links
$action = array_sum(array_keys($links));
// update enable/disable links depending on if it is is_reserved or is_active
if ($dao->is_reserved) {
$action = CRM_Core_Action::UPDATE;
} else {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($groupName == 'case_type' && in_array($dao->value, $caseTypeIds) || $groupName == 'case_status' && in_array($dao->value, $caseStatusIds)) {
$action -= CRM_Core_Action::DELETE;
}
}
$optionValue[$dao->id]['label'] = htmlspecialchars($optionValue[$dao->id]['label']);
$optionValue[$dao->id]['order'] = $optionValue[$dao->id]['weight'];
$optionValue[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'gid' => $optionGroupID, 'value' => $dao->value), ts('more'), FALSE, 'optionValue.row.actions', 'optionValue', $dao->id);
if (!empty($optionValue[$dao->id]['component_id'])) {
$optionValue[$dao->id]['component_name'] = $componentNames[$optionValue[$dao->id]['component_id']];
} else {
$optionValue[$dao->id]['component_name'] = 'Contact';
}
if (!empty($optionValue[$dao->id]['visibility_id'])) {
$optionValue[$dao->id]['visibility_label'] = $visibilityLabels[$optionValue[$dao->id]['visibility_id']];
}
}
return $optionValue;
}
示例8: browse
/**
* Browse all options value.
*
*
* @return void
* @access public
* @static
*/
function browse()
{
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $this->_gid;
if (in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups)) {
$dao->domain_id = CRM_Core_Config::domainID();
}
if ($this->_gName == 'encounter_medium') {
$mediumIds = CRM_Case_BAO_Case::getUsedEncounterMediums();
} elseif ($this->_gName == 'case_status') {
$caseStatusIds = CRM_Case_BAO_Case::getUsedCaseStatuses();
} elseif ($this->_gName == 'case_type') {
$caseTypeIds = CRM_Case_BAO_Case::getUsedCaseType();
}
$dao->orderBy('name');
$dao->find();
$optionValue = array();
while ($dao->fetch()) {
$optionValue[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->links()));
if ($dao->is_default) {
$optionValue[$dao->id]['default_value'] = '[x]';
}
//do not show default option for email/postal greeting and addressee, CRM-4575
if (!in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee'))) {
$this->assign('showIsDefault', TRUE);
}
// update enable/disable links depending on if it is is_reserved or is_active
if ($dao->is_reserved) {
$action = CRM_Core_Action::UPDATE;
} else {
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($this->_gName == 'encounter_medium' && in_array($dao->value, $mediumIds) || $this->_gName == 'case_status' && in_array($dao->value, $caseStatusIds) || $this->_gName == 'case_type' && in_array($dao->value, $caseTypeIds)) {
$action -= CRM_Core_Action::DELETE;
}
}
$optionValue[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id, 'gid' => $this->_gid));
}
$this->assign('rows', $optionValue);
}
示例9: formRule
static function formRule($fields, $files, $self)
{
$errors = array();
$dupeClass = FALSE;
$reportUrl = new CRM_Core_DAO_OptionValue();
$reportUrl->option_group_id = $self->_opID;
$reportUrl->value = $fields['value'];
if ($reportUrl->find(TRUE) && $self->_id != $reportUrl->id) {
$errors['value'] = ts('Url already exists in Database.');
if ($reportUrl->name == $fields['name']) {
$dupeClass = TRUE;
}
}
if (!$dupeClass) {
$reportClass = new CRM_Core_DAO_OptionValue();
$reportClass->option_group_id = $self->_opID;
$reportClass->name = $fields['name'];
if ($reportClass->find(TRUE) && $self->_id != $reportClass->id) {
$dupeClass = TRUE;
}
}
if ($dupeClass) {
$errors['name'] = ts('Class already exists in Database.');
}
return $errors;
}
示例10: getGrantStatuses
static function getGrantStatuses()
{
$og = CRM_Grant_BAO_Grant::getGrantStatusOptGroup();
require_once 'CRM/Core/BAO/OptionValue.php';
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $og->id;
$dao->find();
$statuses = array();
while ($dao->fetch()) {
$statuses[$dao->id] = $dao->label;
}
return $statuses;
}
示例11: removeLegacyRegisteredReport
/** Remove all the report that registerd on GiftAid 1.0beta and 2.0beta
**/
static function removeLegacyRegisteredReport()
{
$reportClass = new CRM_Core_DAO_OptionValue();
$reportClass->option_group_id = self::getReportTemplateGroupId();
$reportClass->name = 'GiftAid_Report_Form_Contribute_GiftAid';
if ($reportClass->find(TRUE)) {
$reportClass->delete();
}
}
示例12: updateOptionWeights
/**
* updates options values weights.
*
* @param int $opGroupIde option group id.
* @param array $opWeights options value , weight pair
*
* @return void
* @access public
* @static
*/
static function updateOptionWeights($opGroupId, $opWeights)
{
if (!is_array($opWeights) || empty($opWeights)) {
return;
}
foreach ($opWeights as $opValue => $opWeight) {
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->option_group_id = $opGroupId;
$optionValue->value = $opValue;
if ($optionValue->find(true)) {
$optionValue->weight = $opWeight;
$optionValue->save();
}
$optionValue->free();
}
}