本文整理汇总了PHP中CRM_Core_BAO_CustomValueTable::getValues方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomValueTable::getValues方法的具体用法?PHP CRM_Core_BAO_CustomValueTable::getValues怎么用?PHP CRM_Core_BAO_CustomValueTable::getValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomValueTable
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomValueTable::getValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFieldValue
/**
* Returns the value of the field for the condition
* For example: I want to check if age > 50, this function would return the 50
*
* @param object CRM_Civirules_TriggerData_TriggerData $triggerData
* @return
* @access protected
* @abstract
*/
protected function getFieldValue(CRM_Civirules_TriggerData_TriggerData $triggerData)
{
$entity = $this->conditionParams['entity'];
$field = $this->conditionParams['field'];
$data = $triggerData->getEntityData($entity);
if (isset($data[$field])) {
return $this->normalizeValue($data[$field]);
}
if (strpos($field, 'custom_') === 0) {
$custom_field_id = str_replace("custom_", "", $field);
try {
$params['entityID'] = $data['id'];
$params[$field] = 1;
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
if (!empty($values[$field])) {
return $this->normalizeValue($values[$field]);
} elseif (!empty($values['error_message'])) {
$custom_values = $triggerData->getCustomFieldValues($custom_field_id);
if (!empty($custom_values)) {
return $this->normalizeValue(reset($custom_values));
}
}
} catch (Exception $e) {
//do nothing
}
}
return null;
}
示例2: testCustomGroupMultipleOldFormat
public function testCustomGroupMultipleOldFormat()
{
$contactID = $this->individualCreate();
$customGroup = $this->customGroupCreate(array('is_multiple' => 1));
$fields = array('custom_group_id' => $customGroup['id'], 'dataType' => 'String', 'htmlType' => 'Text');
$customField = $this->customFieldCreate($fields);
$params = array('entityID' => $contactID, "custom_{$customField['id']}" => 'First String');
CRM_Core_BAO_CustomValueTable::setValues($params);
$newParams = array('entityID' => $contactID, "custom_{$customField['id']}" => 1);
$result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
$this->assertEquals($params["custom_{$customField['id']}"], $result["custom_{$customField['id']}_1"]);
$this->assertEquals($params['entityID'], $result['entityID']);
$this->customFieldDelete($customField['id']);
$this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
示例3: testCustomGroupMultipleOldFormate
public function testCustomGroupMultipleOldFormate()
{
$params = array();
$contactID = Contact::createIndividual();
$customGroup = Custom::createGroup($params, 'Individual', TRUE);
$fields = array('groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text');
$customField = Custom::createField($params, $fields);
$params = array('entityID' => $contactID, "custom_{$customField->id}" => 'First String');
$error = CRM_Core_BAO_CustomValueTable::setValues($params);
$newParams = array('entityID' => $contactID, "custom_{$customField->id}" => 1);
$result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
$this->assertEquals($params["custom_{$customField->id}"], $result["custom_{$customField->id}_1"]);
$this->assertEquals($params['entityID'], $result['entityID']);
Custom::deleteField($customField);
Custom::deleteGroup($customGroup);
Contact::delete($contactID);
}
示例4: testCreateWithCustomData
/**
* Create() method with custom data.
*/
public function testCreateWithCustomData()
{
$contactId = $this->individualCreate();
//create custom data
$customGroup = $this->customGroupCreate(array('extends' => 'Contribution'));
$customGroupID = $customGroup['id'];
$customGroup = $customGroup['values'][$customGroupID];
$fields = array('label' => 'testFld', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroupID);
$customField = CRM_Core_BAO_CustomField::create($fields);
$params = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => NULL, 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww322323', 'invoice_id' => '22ed39c9e9ee6ef6031621ce0eafe6da70', 'thankyou_date' => '20080522');
$params['custom'] = array($customField->id => array(-1 => array('value' => 'Test custom value', 'type' => 'String', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroupID, 'table_name' => $customGroup['table_name'], 'column_name' => $customField->column_name, 'file_id' => NULL)));
$contribution = CRM_Contribute_BAO_Contribution::create($params);
// Check that the custom field value is saved
$customValueParams = array('entityID' => $contribution->id, 'custom_' . $customField->id => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($customValueParams);
$this->assertEquals('Test custom value', $values['custom_' . $customField->id], 'Check the custom field value');
$this->assertEquals($params['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
$this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id for Conribution.');
}
示例5: getFieldValue
/**
* Returns the value of the field for the condition
* For example: I want to check if age > 50, this function would return the 50
*
* @param object CRM_Civirules_TriggerData_TriggerData $triggerData
* @return
* @access protected
* @abstract
*/
protected function getFieldValue(CRM_Civirules_TriggerData_TriggerData $triggerData)
{
$entity = $this->conditionParams['entity'];
$field = $this->conditionParams['field'];
$data = $triggerData->getEntityData($entity);
if (isset($data[$field])) {
return $this->normalizeValue($data[$field]);
}
if ($this->isRelativeDate($field)) {
$relativeDate = $this->parseRelativeDate($field);
$field = $relativeDate['field'];
$interval = $relativeDate['interval'];
if (isset($data[$field])) {
$date = new DateTime($data[$field]);
$today = new DateTime("now");
$diff = $date->diff($today);
return $this->normalizeValue($diff->format('%' . $interval));
}
}
if (strpos($field, 'custom_') === 0) {
$custom_field_id = str_replace("custom_", "", $field);
try {
$params['entityID'] = $data['id'];
$params[$field] = 1;
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$value = null;
if (!empty($values[$field])) {
$value = $this->normalizeValue($values[$field]);
} elseif (!empty($values['error_message'])) {
$value = $triggerData->getCustomFieldValue($custom_field_id);
}
if ($value !== null) {
$value = $this->convertMultiselectCustomfieldToArray($custom_field_id, $value);
return $this->normalizeValue($value);
}
} catch (Exception $e) {
//do nothing
}
}
return null;
}
示例6: testSetGetValuesYesNoRadio
/**
* Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio
*/
public function testSetGetValuesYesNoRadio()
{
$contactID = $this->individualCreate();
$customGroup = $this->customGroupCreate(array('is_multiple' => 1));
//create Custom Field of type YesNo(Boolean) Radio
$fields = array('custom_group_id' => $customGroup['id'], 'data_type' => 'Boolean', 'html_type' => 'Radio', 'default_value' => '');
$customField = $this->customFieldCreate($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 = $customField['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
$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);
CRM_Core_TemporaryErrorScope::useException();
$message = NULL;
try {
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
$this->customFieldDelete($customField['id']);
$this->customGroupDelete($customGroup['id']);
$this->contactDelete($contactID);
}
示例7: civicrm_api3_custom_value_get
/**
* Use this API to get existing custom values for an entity.
*
* @param array $params
* Array specifying the entity_id.
* Optionally include entity_type param, i.e. 'entity_type' => 'Activity'
* If no entity_type is supplied, it will be determined based on the fields you request.
* If no entity_type is supplied and no fields are specified, 'Contact' will be assumed.
* Optionally include the desired custom data to be fetched (or else all custom data for this entity will be returned)
* Example: 'entity_id' => 123, 'return.custom_6' => 1, 'return.custom_33' => 1
* If you do not know the ID, you may use group name : field name, for example 'return.foo_stuff:my_field' => 1
*
* @throws API_Exception
* @return array
*/
function civicrm_api3_custom_value_get($params)
{
$getParams = array('entityID' => $params['entity_id'], 'entityType' => CRM_Utils_Array::value('entity_table', $params, ''));
if (strstr($getParams['entityType'], 'civicrm_')) {
$getParams['entityType'] = ucfirst(substr($getParams['entityType'], 8));
}
unset($params['entity_id'], $params['entity_table']);
foreach ($params as $id => $param) {
if ($param && substr($id, 0, 6) == 'return') {
$id = substr($id, 7);
list($c, $i) = CRM_Utils_System::explode('_', $id, 2);
if ($c == 'custom' && is_numeric($i)) {
$names['custom_' . $i] = 'custom_' . $i;
$id = $i;
} else {
// Lookup names if ID was not supplied
list($group, $field) = CRM_Utils_System::explode(':', $id, 2);
$id = CRM_Core_BAO_CustomField::getCustomFieldID($field, $group);
if (!$id) {
continue;
}
$names['custom_' . $id] = 'custom_' . $i;
}
$getParams['custom_' . $id] = 1;
}
}
$result = CRM_Core_BAO_CustomValueTable::getValues($getParams);
if ($result['is_error']) {
if ($result['error_message'] == "No values found for the specified entity ID and custom field(s).") {
$values = array();
return civicrm_api3_create_success($values, $params, 'CustomValue');
} else {
throw new API_Exception($result['error_message']);
}
} else {
$entity_id = $result['entityID'];
unset($result['is_error'], $result['entityID']);
// Convert multi-value strings to arrays
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
foreach ($result as $id => $value) {
if (strpos($value, $sp) !== FALSE) {
$value = explode($sp, trim($value, $sp));
}
$idArray = explode('_', $id);
if ($idArray[0] != 'custom') {
continue;
}
$fieldNumber = $idArray[1];
$customFieldInfo = CRM_Core_BAO_CustomField::getNameFromID($fieldNumber);
$info = array_pop($customFieldInfo);
// id is the index for returned results
if (empty($idArray[2])) {
$n = 0;
$id = $fieldNumber;
} else {
$n = $idArray[2];
$id = $fieldNumber . "." . $idArray[2];
}
if (!empty($params['format.field_names'])) {
$id = $info['field_name'];
} else {
$id = $fieldNumber;
}
$values[$id]['entity_id'] = $getParams['entityID'];
if (!empty($getParams['entityType'])) {
$values[$id]['entity_table'] = $getParams['entityType'];
}
//set 'latest' -useful for multi fields but set for single for consistency
$values[$id]['latest'] = $value;
$values[$id]['id'] = $id;
$values[$id][$n] = $value;
}
return civicrm_api3_create_success($values, $params, 'CustomValue');
}
}
示例8: moveAllBelongings
//.........这里部分代码省略.........
continue;
}
foreach ($group['fields'] as $fid => $field) {
$cFields[$fid]['attributes'] = $field;
}
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
if (empty($cFields[$fid])) {
continue;
}
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
$submitted[$key] = CRM_Core_BAO_CustomField::getDisplayValue($value, $fid, $cFields);
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select Country':
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
// get the existing custom values from db.
$customParams = array('entityID' => $mainId, $key => TRUE);
$customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
if (!empty($customfieldValues[$key])) {
$existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
if (is_array($existingValue) && !empty($existingValue)) {
$mergeValue = $submmtedCustomValue = array();
if ($value) {
$submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
}
//hack to remove null and duplicate values from array.
foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) {
if ($v != '' && !in_array($v, $mergeValue)) {
$mergeValue[] = $v;
}
}
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
if (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select'))) {
$submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $mergeValue) . CRM_Core_DAO::VALUE_SEPARATOR;
} else {
$submitted[$key] = $mergeValue;
}
}
} elseif (in_array($htmlType, array('Multi-Select Country', 'Multi-Select State/Province'))) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
//hack to remove null values from array.
$mergeValue = array();
foreach ($mergeValueArray as $k => $v) {
if ($v != '') {
$mergeValue[] = $v;
}
}
示例9: 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;
}
示例10: postProcess
//.........这里部分代码省略.........
foreach ($cgTree as $key => $group) {
if (!isset($group['fields'])) {
continue;
}
foreach ($group['fields'] as $fid => $field) {
$cFields[$fid]['attributes'] = $field;
}
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
$submitted[$key] = CRM_Core_BAO_CustomField::getDisplayValue($value, $fid, $cFields);
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select Country':
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
// get the existing custom values from db.
require_once 'CRM/Core/BAO/CustomValueTable.php';
$customParams = array('entityID' => $this->_cid, $key => true);
$customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
if (CRM_Utils_array::value($key, $customfieldValues)) {
$existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
if (is_array($existingValue) && !empty($existingValue)) {
$mergeValue = $submmtedCustomValue = array();
if ($value) {
$submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
}
//hack to remove null and duplicate values from array.
foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) {
if ($v != '' && !in_array($v, $mergeValue)) {
$mergeValue[] = $v;
}
}
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPERATOR
if (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select'))) {
$submitted[$key] = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $mergeValue) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
} else {
$submitted[$key] = $mergeValue;
}
}
} else {
if (in_array($htmlType, array('Multi-Select Country', 'Multi-Select State/Province'))) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
//hack to remove null values from array.
$mergeValue = array();
foreach ($mergeValueArray as $k => $v) {
if ($v != '') {
$mergeValue[] = $v;
}
示例11: exportComponents
//.........这里部分代码省略.........
require_once 'api/v2/Relationship.php';
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Core/BAO/CustomValueTable.php';
require_once 'CRM/Core/BAO/CustomQuery.php';
$params['relationship_type_id'] = $contactRelationshipTypes[$field];
$contact_id['contact_id'] = $dao->contact_id;
//Get relationships
$val = civicrm_contact_relationship_get($contact_id, null, $params);
if (is_array($val['result'])) {
asort($val['result']);
}
$is_valid = null;
$data = null;
if ($val['result']) {
foreach ($val['result'] as $k => $v) {
//consider only active relationships
if ($v['is_active'] && $v['rtype'] == $direction) {
$cID['contact_id'] = $v['cid'];
if ($cID) {
//Get Contact Details
$data = CRM_Contact_BAO_Contact::retrieve($cID, $defaults);
}
$is_valid = true;
break;
}
}
}
$relCustomIDs = array();
foreach ($value as $relationkey => $relationvalue) {
if ($val['result'] && ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationkey))) {
foreach ($val['result'] as $k1 => $v1) {
$contID = $v1['cid'];
$param1 = array('entityID' => $contID, $relationkey => 1);
$getcustomValue = CRM_Core_BAO_CustomValueTable::getValues($param1);
$custom_ID = CRM_Core_BAO_CustomField::getKeyID($relationkey);
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($relationkey)) {
if (empty($query->_options)) {
$relCustomIDs[$cfID] = array();
$relQuery = new CRM_Core_BAO_CustomQuery($relCustomIDs);
$relQuery->query();
$relOptions = $relQuery->_options;
} else {
$relOptions = $query->_options;
}
$custom_data = CRM_Core_BAO_CustomField::getDisplayValue($getcustomValue[$relationkey], $cfID, $relOptions);
} else {
$custom_data = '';
}
}
}
//Get all relationships type custom fields
list($id, $atype, $btype) = explode('_', $field);
$relCustomData = CRM_Core_BAO_CustomField::getFields('Relationship', null, null, $id, null, null);
$tmpArray = array_keys($relCustomData);
$customIDs = array();
foreach ($tmpArray as $customID) {
$customIDs[$customID] = array();
}
require_once 'CRM/Core/BAO/CustomQuery.php';
$customQuery = new CRM_Core_BAO_CustomQuery($customIDs);
$customQuery->query();
$options = $customQuery->_options;
foreach ($relCustomData as $id => $customdatavalue) {
if (in_array($relationkey, $customdatavalue)) {
$customkey = "custom_{$id}";
if ($val['result']) {
示例12: moveAllBelongings
//.........这里部分代码省略.........
}
if (!isset($submitted)) {
$submitted = array();
}
foreach ($submitted as $key => $value) {
if (substr($key, 0, 7) == 'custom_') {
$fid = (int) substr($key, 7);
if (empty($cFields[$fid])) {
continue;
}
$htmlType = $cFields[$fid]['attributes']['html_type'];
switch ($htmlType) {
case 'File':
$customFiles[] = $fid;
unset($submitted["custom_{$fid}"]);
break;
case 'Select Country':
case 'Select State/Province':
$submitted[$key] = CRM_Core_BAO_CustomField::displayValue($value, $fid);
break;
case 'Select Date':
if ($cFields[$fid]['attributes']['is_view']) {
$submitted[$key] = date('YmdHis', strtotime($submitted[$key]));
}
break;
case 'CheckBox':
case 'AdvMulti-Select':
case 'Multi-Select':
case 'Multi-Select Country':
case 'Multi-Select State/Province':
// Merge values from both contacts for multivalue fields, CRM-4385
// get the existing custom values from db.
$customParams = array('entityID' => $mainId, $key => TRUE);
$customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
if (!empty($customfieldValues[$key])) {
$existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
if (is_array($existingValue) && !empty($existingValue)) {
$mergeValue = $submmtedCustomValue = array();
if ($value == 'null') {
// CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it.
$submitted[$key] = $value;
} else {
if ($value) {
$submmtedCustomValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
}
//hack to remove null and duplicate values from array.
foreach (array_merge($submmtedCustomValue, $existingValue) as $k => $v) {
if ($v != '' && !in_array($v, $mergeValue)) {
$mergeValue[] = $v;
}
}
//keep state and country as array format.
//for checkbox and m-select format w/ VALUE_SEPARATOR
if (in_array($htmlType, array('CheckBox', 'Multi-Select', 'AdvMulti-Select'))) {
$submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $mergeValue) . CRM_Core_DAO::VALUE_SEPARATOR;
} else {
$submitted[$key] = $mergeValue;
}
}
}
} elseif (in_array($htmlType, array('Multi-Select Country', 'Multi-Select State/Province'))) {
//we require submitted values should be in array format
if ($value) {
$mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
//hack to remove null values from array.
$mergeValue = array();
示例13: testDeleteContact
/**
* test case for deleteContact( )
*/
function testDeleteContact()
{
$contactParams = $this->contactParams();
//create contact
require_once 'CRM/Contact/BAO/Contact.php';
$contact = CRM_Contact_BAO_Contact::create($contactParams);
$contactId = $contact->id;
//delete contact.
CRM_Contact_BAO_Contact::deleteContact($contactId);
//Now check DB for location elements.
//Now check DB for Address
$this->assertDBNull('CRM_Core_DAO_Address', CRM_Utils_Array::value('street_address', $contactParams['address'][1]), 'id', 'street_address', 'Database check, Address deleted successfully.');
//Now check DB for Email
$this->assertDBNull('CRM_Core_DAO_Email', CRM_Utils_Array::value('email', $contactParams['email'][1]), 'id', 'email', 'Database check, Email deleted successfully.');
//Now check DB for Phone
$this->assertDBNull('CRM_Core_DAO_Phone', CRM_Utils_Array::value('phone', $contactParams['phone'][1]), 'id', 'phone', 'Database check, Phone deleted successfully.');
//Now check DB for Mobile
$this->assertDBNull('CRM_Core_DAO_Phone', CRM_Utils_Array::value('phone', $contactParams['phone'][2]), 'id', 'phone', 'Database check, Mobile deleted successfully.');
//Now check DB for IM
$this->assertDBNull('CRM_Core_DAO_IM', CRM_Utils_Array::value('name', $contactParams['im'][1]), 'id', 'name', 'Database check, IM deleted successfully.');
//Now check DB for openId
$this->assertDBNull('CRM_Core_DAO_OpenID', CRM_Utils_Array::value('openid', $contactParams['openid'][1]), 'id', 'name', 'Database check, openId deleted successfully.');
require_once 'CRM/Core/BAO/CustomValueTable.php';
// Check that the custom field value is no longer present
$params = array('entityID' => $contactId, 'custom_' . $fieldID => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals(CRM_Utils_Array::value("custom_{$fieldID}", $values), '', 'Verify that the data value is empty for contact ' . $contactId);
$this->assertEquals($values['is_error'], 1, 'Verify that is_error = 0 (success).');
//Now check DB for contact.
$this->assertDBNull('CRM_Contact_DAO_Contact', $contactParams['last_name'] . ', ' . $contactParams['first_name'], 'id', 'sort_name', 'Database check, contact deleted successfully.');
}
示例14: hrrecruitment_civicrm_buildForm
//.........这里部分代码省略.........
if ($vacancyID && $aType) {
$administerper = CRM_HRRecruitment_BAO_HRVacancyPermission::checkVacancyPermission($vacancyID, array("administer Vacancy", "administer CiviCRM", "manage Applicants"));
$evaluateper = CRM_HRRecruitment_BAO_HRVacancyPermission::checkVacancyPermission($vacancyID, array("administer Vacancy", "administer CiviCRM", "evaluate Applicants"));
if ($aType != $evalID && !$administerper || $aType == $evalID && !$evaluateper) {
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm'));
CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to perform this action.'));
return;
}
}
/* TO set vacancy stages as case status for 'Change Case Status' activity */
if ($aType == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Case Status')) {
$allcase = TRUE;
foreach ($caseId as $key => $val) {
$caseType = CRM_Case_BAO_Case::getCaseType($val, 'id');
if ($caseType != $appValue) {
$allcase = FALSE;
}
}
if ($allcase) {
$form->removeElement('case_status_id');
$form->_caseStatus = CRM_Case_PseudoConstant::caseStatus('label', TRUE, 'AND filter = 1', TRUE);
$form->add('select', 'case_status_id', ts('Case Status'), $form->_caseStatus, TRUE);
if ($caseStatusId = CRM_Utils_Request::retrieve('case_status_id', 'Positive', $form)) {
$form->freeze('case_status_id');
$form->setDefaults(array('case_status_id' => $caseStatusId));
}
}
}
/* build the evaluation profile on the evaluation activity */
//check for evaluation activity type
if ($aType == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation')) {
//rename label and status name for Activity Status
$activityStatus = $form->getElement('status_id');
$activityStatus->_options = array();
$scheduleStatus = CRM_Core_OptionGroup::getValue('activity_status', 'Scheduled');
$completeStatus = CRM_Core_OptionGroup::getValue('activity_status', 'Completed');
$activityStatus->addOption('Scheduled', $scheduleStatus);
$activityStatus->addOption('Complete Evaluation', $completeStatus);
$activityStatus->_label = 'Evaluation Status';
//retriev Case ID, Activity ID, Contact ID
$caseID = CRM_Utils_Request::retrieve('caseid', 'Positive', $form);
$activityID = CRM_Utils_Request::retrieve('id', 'Positive', $form);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $form);
//get Evaluation profile ID
$dao = new CRM_Core_DAO_UFJoin();
$dao->module = 'Vacancy';
$dao->entity_id = CRM_HRRecruitment_BAO_HRVacancy::getVacancyIDByCase($caseID);
$dao->module_data = 'evaluation_profile';
$dao->find(TRUE);
$profileID = $dao->uf_group_id;
$profileFields = CRM_Core_BAO_UFGroup::getFields($profileID);
$form->assign('fields', $profileFields);
CRM_Core_BAO_UFGroup::setProfileDefaults($contactID, $profileFields, $def);
$form->setDefaults($def);
//auto populate assignee contact name with vacancy related permission
if ($form->_action & CRM_Core_Action::ADD) {
$evaluateContactID = CRM_HRRecruitment_BAO_HRVacancyPermission::getPermissionContact($vacancyID, 'evaluate Applicants');
$defaults['assignee_contact_id'] = $evaluateContactID;
$form->setDefaults($defaults);
}
//build evaluaiton profile fields
foreach ($profileFields as $profileFieldKey => $profileFieldVal) {
CRM_Core_BAO_UFGroup::buildProfile($form, $profileFieldVal, CRM_Profile_Form::MODE_EDIT, $contactID, TRUE, FALSE, NULL);
$form->_fields[$profileFieldKey] = $profileFields[$profileFieldKey];
$params[$profileFieldKey] = $profileFieldVal;
}
if (!empty($activityID)) {
$params['entityID'] = $activityID;
$form->addElement('hidden', 'evaluationProfile', $profileID);
$defVal = CRM_Core_BAO_CustomValueTable::getValues($params);
$form->setDefaults($defVal);
}
CRM_Core_Region::instance('case-activity-form')->add(array('template' => 'CRM/UF/Form/Block.tpl'));
}
//HR-373 -- set Completed status for Comment activity by default
if ($aType == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Comment')) {
$defaults['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed');
$form->setDefaults($defaults);
}
}
/* HR-401 Changes to Edit Evaluation and Application popups */
if ($formName == 'CRM_Custom_Form_Field' || $formName == 'CRM_HRRecruitment_Form_HRVacancy') {
$uncolapseAppl = $uncolapseEval = array();
$applicationCG = civicrm_api3('CustomGroup', 'get', array('extends' => "Case", 'extends_entity_column_value' => $appValue, 'name' => 'Application'));
foreach ($applicationCG['values'] as $k => $v) {
$uncolapseAppl[] = $v['id'];
}
$evalCG = civicrm_api3('CustomGroup', 'get', array('extends' => "Activity", 'extends_entity_column_value' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Evaluation')));
foreach ($evalCG['values'] as $k => $v) {
$uncolapseEval[$k] = $v['id'];
}
CRM_Core_Resources::singleton()->addSetting(array('profileSelectorSet' => array('application' => $uncolapseAppl, 'evaluation' => $uncolapseEval)));
$gID = CRM_Utils_Array::value('gid', $_GET);
/* HR-401 set default for 'Is field searchable' */
if (!empty($gID) && (in_array($gID, $uncolapseEval) || in_array($gID, $uncolapseAppl)) && $formName == 'CRM_Custom_Form_Field') {
$default['is_searchable'] = 1;
$form->setDefaults($default);
}
}
}
示例15: testDeleteContact
/**
* Test case for deleteContact( ).
*/
public function testDeleteContact()
{
$contactParams = $this->contactParams();
$customGroup = $this->customGroupCreate();
$fields = array('label' => 'testFld', 'data_type' => 'String', 'html_type' => 'Text', 'custom_group_id' => $customGroup['id']);
$customField = CRM_Core_BAO_CustomField::create($fields);
$contactParams['custom'] = array($customField->id => array(-1 => array('value' => 'Test custom value', 'type' => 'String', 'custom_field_id' => $customField->id, 'custom_group_id' => $customGroup['id'], 'table_name' => $customGroup['values'][$customGroup['id']]['table_name'], 'column_name' => $customField->column_name, 'file_id' => NULL)));
//create contact
$contact = CRM_Contact_BAO_Contact::create($contactParams);
$contactId = $contact->id;
//delete contact permanently.
CRM_Contact_BAO_Contact::deleteContact($contactId, FALSE, TRUE);
//Now check DB for location elements.
//Now check DB for Address
$this->assertDBNull('CRM_Core_DAO_Address', $contactId, 'id', 'street_address', 'Database check, Address deleted successfully.');
//Now check DB for Email
$this->assertDBNull('CRM_Core_DAO_Email', $contactId, 'id', 'email', 'Database check, Email deleted successfully.');
//Now check DB for Phone
$this->assertDBNull('CRM_Core_DAO_Phone', $contactId, 'id', 'phone', 'Database check, Phone deleted successfully.');
//Now check DB for Mobile
$this->assertDBNull('CRM_Core_DAO_Phone', $contactId, 'id', 'phone', 'Database check, Mobile deleted successfully.');
//Now check DB for IM
$this->assertDBNull('CRM_Core_DAO_IM', $contactId, 'id', 'name', 'Database check, IM deleted successfully.');
//Now check DB for openId
$this->assertDBNull('CRM_Core_DAO_OpenID', $contactId, 'id', 'openid', 'Database check, openId deleted successfully.');
// Check that the custom field value is no longer present
$params = array('entityID' => $contactId, 'custom_' . $customField->id => 1);
$values = CRM_Core_BAO_CustomValueTable::getValues($params);
$this->assertEquals(CRM_Utils_Array::value("custom_" . $customField->id, $values), '', 'Verify that the data value is empty for contact ' . $contactId);
$this->assertEquals($values['is_error'], 1, 'Verify that is_error = 0 (success).');
//Now check DB for contact.
$this->assertDBNull('CRM_Contact_DAO_Contact', $contactId, 'id', 'sort_name', 'Database check, contact deleted successfully.');
$this->quickCleanup(array('civicrm_contact', 'civicrm_note'));
$this->customGroupDelete($customGroup['id']);
}