本文整理汇总了PHP中CRM_Core_BAO_CustomField::retrieve方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::retrieve方法的具体用法?PHP CRM_Core_BAO_CustomField::retrieve怎么用?PHP CRM_Core_BAO_CustomField::retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::retrieve方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* set up variables to build the form
*
* @param null
*
* @return void
* @acess protected
*/
function preProcess()
{
$this->_id = $this->get('id');
$defaults = array();
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $defaults);
$this->_title = CRM_Utils_Array::value('label', $defaults);
CRM_Utils_System::setTitle(ts('Delete %1', array(1 => $this->_title)));
}
示例2: preProcess
/**
* set up variables to build the form
*
* @param null
* @return void
* @acess protected
*/
function preProcess()
{
$this->_id = $this->get('id');
$defaults = array();
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $defaults);
$this->_title = $defaults['label'];
$this->assign('title', $this->_title);
CRM_Utils_System::setTitle(ts('Confirm Custom Field Delete'));
}
示例3: preProcess
/**
* set up variables to build the form
*
* @return void
* @acess protected
*/
function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$this->_values = array();
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
$this->_htmlTypeTransitions = self::fieldTypeTransitions(CRM_Utils_Array::value('data_type', $this->_values), CRM_Utils_Array::value('html_type', $this->_values));
if (empty($this->_values) || empty($this->_htmlTypeTransitions)) {
CRM_Core_Error::fatal(ts("Invalid custom field or can't change input type of this custom field."));
}
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field/update', "action=update&reset=1&gid={$this->_values['custom_group_id']}&id={$this->_id}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
CRM_Utils_System::setTitle(ts('Change Field Type: %1', array(1 => $this->_values['label'])));
}
示例4: testSetGetValuesYesNoRadio
/**
* Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio
*/
public function testSetGetValuesYesNoRadio()
{
$params = array();
$contactID = Contact::createIndividual();
//create Custom Group
$customGroup = Custom::createGroup($params, 'Individual', TRUE);
//create Custom Field of type YesNo(Boolean) Radio
$fields = array('groupId' => $customGroup->id, 'dataType' => 'Boolean', 'htmlType' => 'Radio');
$customField = Custom::createField($params, $fields);
// Retrieve the field ID for sample custom field 'test_Boolean'
$params = array('label' => 'test_Boolean');
$field = array();
//get field Id
CRM_Core_BAO_CustomField::retrieve($params, $field);
$fieldID = $field['id'];
// valid boolean value '1' for Boolean Radio
$yesNo = '1';
$params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo);
$result = CRM_Core_BAO_CustomValueTable::setValues($params);
$this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
// Check that the YesNo radio value is stored
$values = array();
$params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
$this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the boolean value is stored for contact ' . $contactID);
// Now set YesNo radio to an invalid boolean value and try to reset
$badYesNo = '20';
$params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo);
$errorScope = CRM_Core_TemporaryErrorScope::useException();
$message = NULL;
try {
$result = CRM_Core_BAO_CustomValueTable::setValues($params);
} catch (Exception $e) {
$message = $e->getMessage();
}
$errorScope = NULL;
// Check that an exception has been thrown
$this->assertNotNull($message, 'Verify than an exception is thrown when bad boolean is passed');
$params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID);
// Cleanup
Custom::deleteField($customField);
Custom::deleteGroup($customGroup);
Contact::delete($contactID);
}
示例5: preProcess
/**
* Function to set variables up before form is built
*
* @param null
*
* @return void
* @access public
*/
public function preProcess()
{
if (!self::$_dataTypeKeys) {
self::$_dataTypeKeys = array_keys(CRM_Core_BAO_CustomField::dataType());
self::$_dataTypeValues = array_values(CRM_Core_BAO_CustomField::dataType());
}
if (!self::$_dataToHTML) {
self::$_dataToHTML = CRM_Core_BAO_CustomField::dataToHtml();
}
//custom group id
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
CRM_Core_Error::fatal("You cannot add or edit fields in a reserved custom field-set.");
}
if ($this->_gid) {
$url = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_gid}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
}
//custom field id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
//get the values form db if update.
$this->_values = array();
if ($this->_id) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
// note_length is an alias for the text_length field
$this->_values['note_length'] = CRM_Utils_Array::value('text_length', $this->_values);
}
if (self::$_dataToLabels == NULL) {
self::$_dataToLabels = array(array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), 'Multi-Select' => ts('Multi-Select'), 'AdvMulti-Select' => ts('Advanced Multi-Select'), 'Autocomplete-Select' => ts('Autocomplete Select')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('TextArea' => ts('TextArea'), 'RichTextEditor' => 'RichTextEditor'), array('Date' => ts('Select Date')), array('Radio' => ts('Radio')), array('StateProvince' => ts('Select State/Province'), 'Multi-Select' => ts('Multi-Select State/Province')), array('Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country ')), array('File' => ts('Select File')), array('Link' => ts('Link')), array('ContactReference' => ts('Autocomplete Select')));
}
}
示例6: buildRecipientContacts
//.........这里部分代码省略.........
$contactField = 'e.contact_id';
$table = 'civicrm_membership e';
// build where clause
if ($status == 2) {
//auto-renew memberships
$where[] = "e.contribution_recur_id IS NOT NULL ";
} elseif ($status == 1) {
$where[] = "e.contribution_recur_id IS NULL ";
}
// build where clause
if (!empty($value)) {
$where[] = "e.membership_type_id IN ({$value})";
} else {
$where[] = "e.membership_type_id IS NULL";
}
$where[] = "( e.is_override IS NULL OR e.is_override = 0 )";
$dateField = str_replace('membership_', 'e.', $actionSchedule->start_action_date);
$notINClause = self::permissionedRelationships($contactField);
$membershipStatus = CRM_Member_PseudoConstant::membershipStatus(NULL, "(is_current_member = 1 OR name = 'Expired')", 'id');
$mStatus = implode(',', $membershipStatus);
$where[] = "e.status_id IN ({$mStatus})";
}
if ($mapping->entity == 'civicrm_contact') {
if ($value == 'birth_date') {
$dateDBField = 'birth_date';
$table = 'civicrm_contact e';
$contactField = 'e.id';
$where[] = 'e.is_deleted = 0';
$where[] = 'e.is_deceased = 0';
} else {
//custom field
$customFieldParams = array('id' => substr($value, 7));
$customGroup = $customField = array();
CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
$dateDBField = $customField['column_name'];
$customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
$from = $table = "{$customGroup['table_name']} e";
$contactField = 'e.entity_id';
$where[] = '1';
// possible to have no "where" in this case
}
$status_ = explode(',', $status);
if (in_array(2, $status_)) {
// anniversary mode:
$dateField = 'DATE_ADD(e.' . $dateDBField . ', INTERVAL ROUND(DATEDIFF(DATE(' . $now . '), e.' . $dateDBField . ') / 365) YEAR)';
$anniversary = true;
} else {
// regular mode:
$dateField = 'e.' . $dateDBField;
}
// TODO get this working
// TODO: Make sure everything's provided for repetition, etc.
}
// CRM-13577 Introduce Smart Groups Handling
if ($actionSchedule->group_id) {
// Need to check if its a smart group or not
// Then decide which table to join onto the query
$group = CRM_Contact_DAO_Group::getTableName();
// Get the group information
$sql = "\nSELECT {$group}.id, {$group}.cache_date, {$group}.saved_search_id, {$group}.children\nFROM {$group}\nWHERE {$group}.id = {$actionSchedule->group_id}\n";
$groupDAO = CRM_Core_DAO::executeQuery($sql);
$isSmartGroup = FALSE;
if ($groupDAO->fetch() && !empty($groupDAO->saved_search_id)) {
// Check that the group is in place in the cache and up to date
CRM_Contact_BAO_GroupContactCache::check($actionSchedule->group_id);
示例7: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = array();
$fieldDefaults = array();
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomOption::retrieve($params, $defaults);
$paramsField = array('id' => $this->_fid);
CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
if ($fieldDefaults['html_type'] == 'CheckBox' || $fieldDefaults['html_type'] == 'Multi-Select' || $fieldDefaults['html_type'] == 'AdvMulti-Select') {
$defaultCheckValues = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($fieldDefaults['default_value'], 1, -1));
if (in_array($defaults['value'], $defaultCheckValues)) {
$defaults['default_value'] = 1;
}
} else {
if (CRM_Utils_Array::value('default_value', $fieldDefaults) == CRM_Utils_Array::value('value', $defaults)) {
$defaults['default_value'] = 1;
}
}
} else {
$defaults['is_active'] = 1;
}
require_once 'CRM/Core/DAO.php';
if ($this->_action & CRM_Core_Action::ADD) {
$fieldValues = array('option_group_id' => $this->_optionGroupID);
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
}
return $defaults;
}
示例8: preProcess
/**
* Function to set variables up before form is built
*
* @param null
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Core/BAO/CustomField.php';
if (!self::$_dataTypeKeys) {
self::$_dataTypeKeys = array_keys(CRM_Core_BAO_CustomField::dataType());
self::$_dataTypeValues = array_values(CRM_Core_BAO_CustomField::dataType());
}
//custom group id
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
//custom field id
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
//get the values form db if update.
$this->_values = array();
if ($this->_id) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $this->_values);
}
if (self::$_dataToLabels == null) {
self::$_dataToLabels = array(array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), 'Multi-Select' => ts('Multi-Select'), 'AdvMulti-Select' => ts('Advanced Multi-Select'), 'Autocomplete-Select' => ts('Autocomplete Select')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio')), array('TextArea' => ts('TextArea'), 'RichTextEditor' => 'RichTextEditor'), array('Date' => ts('Select Date')), array('Radio' => ts('Radio')), array('StateProvince' => ts('Select State/Province'), 'Multi-Select' => ts('Multi-Select State/Province')), array('Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country ')), array('File' => ts('Select File')), array('Link' => ts('Link')), array('ContactReference' => ts('Autocomplete Select')));
}
}
示例9: createQuery
/**
* Generate a query to locate recipients who match the given
* schedule.
*
* @param \CRM_Core_DAO_ActionSchedule $schedule
* The schedule as configured by the administrator.
* @param string $phase
* See, e.g., RecipientBuilder::PHASE_RELATION_FIRST.
* @param array $defaultParams
*
* @return \CRM_Utils_SQL_Select
* @throws \CRM_Core_Exception
* @see RecipientBuilder
*/
public function createQuery($schedule, $phase, $defaultParams)
{
$selectedValues = (array) \CRM_Utils_Array::explodePadded($schedule->entity_value);
$selectedStatuses = (array) \CRM_Utils_Array::explodePadded($schedule->entity_status);
// FIXME: This assumes that $values only has one field, but UI shows multiselect.
// Properly supporting multiselect would require total rewrite of this function.
if (count($selectedValues) != 1 || !isset($selectedValues[0])) {
throw new \CRM_Core_Exception("Error: Scheduled reminders may only have one contact field.");
} elseif (in_array($selectedValues[0], $this->contactDateFields)) {
$dateDBField = $selectedValues[0];
$query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);
$query->param(array('casAddlCheckFrom' => 'civicrm_contact e', 'casContactIdField' => 'e.id', 'casEntityIdField' => 'e.id', 'casContactTableAlias' => 'e'));
$query->where('e.is_deleted = 0 AND e.is_deceased = 0');
} else {
//custom field
$customFieldParams = array('id' => substr($selectedValues[0], 7));
$customGroup = $customField = array();
\CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField);
$dateDBField = $customField['column_name'];
$customGroupParams = array('id' => $customField['custom_group_id'], $customGroup);
\CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup);
$query = \CRM_Utils_SQL_Select::from("{$customGroup['table_name']} e")->param($defaultParams);
$query->param(array('casAddlCheckFrom' => "{$customGroup['table_name']} e", 'casContactIdField' => 'e.entity_id', 'casEntityIdField' => 'e.id', 'casContactTableAlias' => NULL));
$query->where('1');
// possible to have no "where" in this case
}
$query['casDateField'] = 'e.' . $dateDBField;
if (in_array(2, $selectedStatuses)) {
$query['casAnniversaryMode'] = 1;
$query['casDateField'] = 'DATE_ADD(' . $query['casDateField'] . ', INTERVAL ROUND(DATEDIFF(DATE(' . $query['casNow'] . '), ' . $query['casDateField'] . ') / 365) YEAR)';
}
return $query;
}
示例10: getVacancyIDByCase
/**
* This function is to get Vacancy ID from Application ID
*
* @param int $caseID - Case ID of type Application
*
* @return int
* @access public
*/
public static function getVacancyIDByCase($caseID)
{
$vacancyID = NULL;
$applCaseID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_CustomField', 'custom_group_id', 'application_case');
$cgID = array('custom_group_id' => $applCaseID);
CRM_Core_BAO_CustomField::retrieve($cgID, $cfID);
$params = array("entityID" => $caseID, "custom_{$cfID['id']}" => 1);
$result = CRM_Core_BAO_CustomValueTable::getValues($params);
if (array_key_exists("custom_{$cfID['id']}", $result)) {
$vacancyID = $result["custom_{$cfID['id']}"];
}
return $vacancyID;
}
示例11: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = array();
$fieldDefaults = array();
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_CustomOption::retrieve($params, $defaults);
//$this->_fid = $defaults['custom_field_id'];
$this->_fid = $defaults['entity_id'];
$paramsField = array('id' => $this->_fid);
CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
if ($fieldDefaults['html_type'] == 'CheckBox' || $fieldDefaults['html_type'] == 'Multi-Select') {
$defaultCheckValues = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $fieldDefaults['default_value']);
if (in_array($defaults['value'], $defaultCheckValues)) {
$defaults['default_value'] = 1;
}
} else {
if ($fieldDefaults['default_value'] == $defaults['value']) {
$defaults['default_value'] = 1;
}
}
} else {
$defaults['is_active'] = 1;
}
require_once 'CRM/Core/DAO.php';
if ($this->_action & CRM_CORE_ACTION_ADD) {
$cf =& new CRM_Core_DAO();
$sql = "SELECT max(weight) as weight\n FROM civicrm_custom_option\n WHERE entity_table='civicrm_custom_field' AND entity_id=" . $this->_fid . "\n ORDER BY weight";
$cf->query($sql);
while ($cf->fetch()) {
$defaults['weight'] = $cf->weight + 1;
}
if (empty($defaults['weight'])) {
$defaults['weight'] = 1;
}
}
return $defaults;
}
示例12: setDefaultValues
/**
* This function sets the default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
* @param null
*
* @return array array of default values
* @access public
*/
function setDefaultValues()
{
$defaults = array();
// is it an edit operation ?
if (isset($this->_id)) {
$params = array('id' => $this->_id);
$this->assign('id', $this->_id);
CRM_Core_BAO_CustomField::retrieve($params, $defaults);
$this->_gid = $defaults['custom_group_id'];
if ($defaults['data_type'] == 'StateProvince') {
$daoState =& new CRM_Core_DAO_StateProvince();
$stateId = $defaults['default_value'];
$daoState->id = $stateId;
if ($daoState->find(true)) {
$defaults['default_value'] = $daoState->name;
}
} else {
if ($defaults['data_type'] == 'Country') {
$daoCountry =& new CRM_Core_DAO_Country();
$countryId = $defaults['default_value'];
$daoCountry->id = $countryId;
if ($daoCountry->find(true)) {
$defaults['default_value'] = $daoCountry->name;
}
}
}
if (CRM_Utils_Array::value('data_type', $defaults)) {
$defaults['data_type'] = array('0' => array_search($defaults['data_type'], $GLOBALS['_CRM_CUSTOM_FORM_FIELD']['_dataTypeKeys']), '1' => $defaults['html_type']);
}
$date_parts = explode(CRM_CORE_BAO_CUSTOMOPTION_VALUE_SEPERATOR, $defaults['date_parts']);
$temp_date_parts = array();
if (is_array($date_parts)) {
foreach ($date_parts as $v) {
$temp_date_parts[$v] = 1;
}
$defaults['date_parts'] = $temp_date_parts;
}
} else {
$defaults['is_active'] = 1;
for ($i = 1; $i <= CRM_CUSTOM_FORM_FIELD_NUM_OPTION; $i++) {
$defaults['option_status[' . $i . ']'] = 1;
$defaults['option_weight[' . $i . ']'] = $i;
}
}
if ($this->_action & CRM_CORE_ACTION_ADD) {
$cf =& new CRM_Core_DAO();
$sql = "SELECT weight FROM civicrm_custom_field WHERE custom_group_id = " . $this->_gid . " ORDER BY weight DESC LIMIT 0, 1";
$cf->query($sql);
while ($cf->fetch()) {
$defaults['weight'] = $cf->weight + 1;
}
if (empty($defaults['weight'])) {
$defaults['weight'] = 1;
}
$defaults['date_parts'] = array('d' => 1, 'M' => 1, 'Y' => 1);
$defaults['note_columns'] = 60;
$defaults['note_rows'] = 4;
}
return $defaults;
}
示例13: testSetGetValuesYesNoRadio
function testSetGetValuesYesNoRadio()
{
$params = array();
$contactID = Contact::createIndividual();
//create Custom Group
$customGroup = Custom::createGroup($params, 'Individual', true);
//create Custom Field of type YesNo(Boolean) Radio
$fields = array('groupId' => $customGroup->id, 'dataType' => 'Boolean', 'htmlType' => 'Radio');
$customField = Custom::createField($params, $fields);
// Retrieve the field ID for sample custom field 'test_Boolean'
$params = array('label' => 'test_Boolean');
$field = array();
//get field Id
require_once 'CRM/Core/BAO/CustomField.php';
CRM_Core_BAO_CustomField::retrieve($params, $field);
$fieldID = $field['id'];
// valid boolean value '1' for Boolean Radio
$yesNo = '1';
$params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo);
require_once 'CRM/Core/BAO/CustomValueTable.php';
$result = CRM_Core_BAO_CustomValueTable::setValues($params);
$this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
// Check that the YesNo radio value is stored
$values = array();
$params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
$this->assertEquals($values['custom_1_1'], $yesNo, 'Verify that the date value is stored for contact ' . $contactID);
// Now set YesNo radio to an invalid boolean value and try to reset
$badYesNo = '20';
$params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo);
require_once 'CRM/Core/BAO/CustomValueTable.php';
$result = CRM_Core_BAO_CustomValueTable::setValues($params);
// Check that the error flag is set AND that custom date value has not been modified
$this->assertEquals($result['is_error'], $yesNo, 'Verify that is_error = 1 when bad boolen value is passed.');
$params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals($values['custom_1_1'], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID);
// Cleanup
Custom::deleteField($customField);
Custom::deleteGroup($customGroup);
Contact::delete($contactID);
}