本文整理汇总了PHP中CRM_Core_BAO_CustomField类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField类的具体用法?PHP CRM_Core_BAO_CustomField怎么用?PHP CRM_Core_BAO_CustomField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_CustomField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set the default form values
*
* @access protected
*
* @return array the default array reference
*/
function setDefaultValues()
{
$defaults = array();
$stateCountryMap = array();
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
}
//CRM-5403
if (substr($name, 0, 14) === 'state_province' || substr($name, 0, 7) === 'country' || substr($name, 0, 6) === 'county') {
list($fieldName, $index) = CRM_Utils_System::explode('-', $name, 2);
if (!array_key_exists($index, $stateCountryMap)) {
$stateCountryMap[$index] = array();
}
$stateCountryMap[$index][$fieldName] = $name;
}
}
// also take care of state country widget
if (!empty($stateCountryMap)) {
CRM_Core_BAO_Address::addStateCountryMap($stateCountryMap, $defaults);
}
//set default for country.
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
// now fix all state country selectors
CRM_Core_BAO_Address::fixAllStateSelects($this, $defaults);
return $defaults;
}
开发者ID:hguru,项目名称:224Civi,代码行数:34,代码来源:AbstractPreview.php
示例2: buildWhereClause
/**
* @inheritDoc
*/
protected function buildWhereClause()
{
foreach ($this->where as $key => $value) {
$table_name = NULL;
$column_name = NULL;
$field = $this->getField($key);
if (in_array($key, $this->entityFieldNames)) {
$table_name = self::MAIN_TABLE_ALIAS;
$column_name = $key;
} elseif (($cf_id = \CRM_Core_BAO_CustomField::getKeyID($key)) != FALSE) {
//list($table_name, $column_name) = $this->addCustomField($this->apiFieldSpec['custom_' . $cf_id], 'INNER');
} elseif (strpos($key, '.')) {
$fkInfo = $this->addFkField($key, 'INNER');
if ($fkInfo) {
list($table_name, $column_name) = $fkInfo;
$this->validateNestedInput($key, $value);
}
}
if (!$table_name || !$column_name || is_null($value)) {
throw new \API_Exception("Invalid field '{$key}' in where clause.");
}
if (!is_array($value)) {
$this->query->where(array("`{$table_name}`.`{$column_name}` = @value"), array("@value" => $value));
} elseif (count($value) !== 1) {
throw new \API_Exception("Invalid value in where clause for field '{$key}'");
} else {
$clause = \CRM_Core_DAO::createSQLFilter("`{$table_name}`.`{$column_name}`", $value);
if ($clause === NULL) {
throw new \API_Exception("Invalid value in where clause for field '{$key}'");
}
$this->query->where($clause);
}
}
}
开发者ID:civicrm,项目名称:api4,代码行数:37,代码来源:Api4SelectQuery.php
示例3: checkIsMultiRecord
/**
* Function the check whether the field belongs.
* to multi-record custom set
*/
public function checkIsMultiRecord()
{
$customId = $_GET['customId'];
$isMultiple = CRM_Core_BAO_CustomField::isMultiRecordField($customId);
$isMultiple = array('is_multi' => $isMultiple);
CRM_Utils_JSON::output($isMultiple);
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:11,代码来源:AJAX.php
示例4: setUp
function setUp()
{
parent::setUp();
// Create Group For Individual Contact Type
$groupIndividual = array('title' => 'TestGroup For Indivi' . substr(sha1(rand()), 0, 5), 'extends' => array('Individual'), 'style' => 'Inline', 'is_active' => 1);
$this->CustomGroupIndividual = $this->customGroupCreate($groupIndividual);
$this->IndividualField = $this->customFieldCreate(array('custom_group_id' => $this->CustomGroupIndividual['id']));
// Create Group For Individual-Student Contact Sub Type
$groupIndiStudent = array('title' => 'Student Test' . substr(sha1(rand()), 0, 5), 'extends' => array('Individual', array('Student')), 'style' => 'Inline', 'is_active' => 1);
$this->CustomGroupIndiStudent = $this->customGroupCreate($groupIndiStudent);
$this->IndiStudentField = $this->customFieldCreate(array('custom_group_id' => $this->CustomGroupIndiStudent['id']));
$params = array('first_name' => 'Mathev', 'last_name' => 'Adison', 'contact_type' => 'Individual');
$this->individual = $this->individualCreate($params);
$params = array('first_name' => 'Steve', 'last_name' => 'Tosun', 'contact_type' => 'Individual', 'contact_sub_type' => 'Student');
$this->individualStudent = $this->individualCreate($params);
$params = array('first_name' => 'Mark', 'last_name' => 'Dawson', 'contact_type' => 'Individual', 'contact_sub_type' => 'Parent');
$this->individualParent = $this->individualCreate($params);
$params = array('organization_name' => 'Wellspring', 'contact_type' => 'Organization');
$this->organization = $this->organizationCreate($params);
$params = array('organization_name' => 'SubUrban', 'contact_type' => 'Organization', 'contact_sub_type' => 'Sponsor');
$this->organizationSponsor = $this->organizationCreate($params);
//refresh php cached variables
CRM_Core_PseudoConstant::flush();
CRM_Core_BAO_CustomField::getTableColumnGroup($this->IndividualField['id'], True);
CRM_Core_BAO_CustomField::getTableColumnGroup($this->IndiStudentField['id'], True);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:26,代码来源:CustomValueContactTypeTest.php
示例5: setDefaultValues
function setDefaultValues()
{
// check if the user is registered and we have a contact ID
$session =& CRM_Core_Session::singleton();
$contactID = $session->get('userID');
if ($contactID) {
$options = array();
$fields = array();
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
$fields['state_province'] = $fields['country'] = $fields['email'] = 1;
$contact =& CRM_Contact_BAO_Contact::contactDetails($contactID, $options, $fields);
foreach ($fields as $name => $dontCare) {
if ($contact->{$name}) {
if (substr($name, 0, 7) == 'custom_') {
$id = substr($name, 7);
$this->_defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact->{$name}, $id, $options);
} else {
$this->_defaults[$name] = $contact->{$name};
}
}
}
}
// hack to simplify credit card entry for testing
/**
$this->_defaults['credit_card_type'] = 'Visa';
$this->_defaults['credit_card_number'] = '4807731747657838';
$this->_defaults['cvv2'] = '000';
$this->_defaults['credit_card_exp_date'] = array( 'Y' => '2008', 'M' => '01' );
**/
return $this->_defaults;
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:33,代码来源:Main.php
示例6: checkIsMultiRecord
/**
* Function the check whether the field belongs
* to multi-record custom set
*/
function checkIsMultiRecord()
{
$customId = $_GET['customId'];
$isMultiple = CRM_Core_BAO_CustomField::isMultiRecordField($customId);
$isMultiple = array('is_multi' => $isMultiple);
echo json_encode($isMultiple);
CRM_Utils_System::civiExit();
}
开发者ID:hguru,项目名称:224Civi,代码行数:12,代码来源:AJAX.php
示例7: postProcess
/**
* Process the form when submitted.
*
* @return void
*/
public function postProcess()
{
$field = new CRM_Core_DAO_CustomField();
$field->id = $this->_id;
$field->find(TRUE);
CRM_Core_BAO_CustomField::deleteField($field);
// also delete any profiles associted with this custom field
CRM_Core_Session::setStatus(ts('The custom field \'%1\' has been deleted.', array(1 => $field->label)), '', 'success');
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:14,代码来源:DeleteField.php
示例8: testDeleteCustomfield
function testDeleteCustomfield()
{
$customGroup = Custom::createGroup(array(), 'Individual');
$fields = array('groupId' => $customGroup->id, 'dataType' => 'Memo', 'htmlType' => 'TextArea');
$customField = Custom::createField(array(), $fields);
CRM_Core_BAO_CustomField::deleteField($customField);
$this->assertDBNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for deleted Custom Field.');
Custom::deleteGroup($customGroup);
}
开发者ID:ksecor,项目名称:civicrm,代码行数:9,代码来源:CustomFieldTest.php
示例9: setDefaultValues
/**
* Set the default form values.
*
*
* @return array
* the default array reference
*/
public function setDefaultValues()
{
$defaults = array();
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
}
}
//set default for country.
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
return $defaults;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:19,代码来源:AbstractPreview.php
示例10: 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);
}
开发者ID:sdekok,项目名称:civicrm-core,代码行数:50,代码来源:CustomValueTableSetGetTest.php
示例11: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
$this->_title = ts('Update multiple contacts') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
$suppressFields = TRUE;
unset($this->_fields[$name]);
}
}
//FIX ME: phone ext field is added at the end and it gets removed because of below code
//$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Contact(s)'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_contactIds);
// if below fields are missing we should not reset sort name / display name
// CRM-6794
$preserveDefaultsArray = array('first_name', 'last_name', 'middle_name', 'organization_name', 'prefix_id', 'suffix_id', 'household_name');
foreach ($this->_contactIds as $contactId) {
$profileFields = $this->_fields;
CRM_Core_BAO_Address::checkContactSharedAddressFields($profileFields, $contactId);
foreach ($profileFields as $name => $field) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
if (in_array($field['name'], $preserveDefaultsArray)) {
$this->_preserveDefault = FALSE;
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
$buttonName = $this->controller->getButtonName('submit');
if ($suppressFields && $buttonName != '_qf_BatchUpdateProfile_next') {
CRM_Core_Session::setStatus(ts("File or Autocomplete-Select type field(s) in the selected profile are not supported for Update multiple contacts."), ts('Some Fields Excluded'), 'info');
}
$this->addDefaultButtons(ts('Update Contacts'));
$this->addFormRule(array('CRM_Contact_Form_Task_Batch', 'formRule'));
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:49,代码来源:Batch.php
示例12: civicrm_api3_pcpteams_create
/**
* File for the CiviCRM APIv3 group functions
*
* @package CiviCRM_APIv3
* @subpackage API_pcpteams
* @copyright CiviCRM LLC (c) 2004-2014
*/
function civicrm_api3_pcpteams_create($params)
{
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
// $params['pcp_title'] = $pcp['title'];
// $params['pcp_contact_id'] = $pcp['contact_id'];
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
// 1 -> waiting review
// 2 -> active / approved (default for now)
$params['status_id'] = CRM_Utils_Array::value('status_id', $params, 2);
// active by default for now
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 1);
$pcp = CRM_Pcpteams_BAO_PCP::create($params, FALSE);
//Custom Set
$customFields = CRM_Core_BAO_CustomField::getFields('PCP', FALSE, FALSE, NULL, NULL, TRUE);
$isCustomValueSet = FALSE;
foreach ($customFields as $fieldID => $fieldValue) {
list($tableName, $columnName, $cgId) = CRM_Core_BAO_CustomField::getTableColumnGroup($fieldID);
if (!empty($params[$columnName]) || !empty($params["custom_{$fieldID}"])) {
$isCustomValueSet = TRUE;
//FIXME: to find out the custom value exists, set -1 as default now
$params["custom_{$fieldID}_-1"] = !empty($params[$columnName]) ? $params[$columnName] : $params["custom_{$fieldID}"];
}
}
if ($isCustomValueSet) {
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $pcp->id, 'PCP');
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pcp', $pcp->id);
}
//end custom set
$values = array();
@_civicrm_api3_object_to_array_unique_fields($pcp, $values[$pcp->id]);
return civicrm_api3_create_success($values, $params, 'Pcpteams', 'create');
}
开发者ID:eruraindil,项目名称:uk.co.vedaconsulting.pcpteams,代码行数:52,代码来源:Pcpteams.php
示例13: registerInterview
static function registerInterview()
{
$fields = array('result', 'voter_id', 'survey_id', 'activity_id', 'surveyTitle', 'interviewer_id', 'activity_type_id');
$params = array();
foreach ($fields as $fld) {
$params[$fld] = CRM_Utils_Array::value($fld, $_POST);
}
$params['details'] = CRM_Utils_Array::value('note', $_POST);
$voterId = $params['voter_id'];
$activityId = $params['activity_id'];
$customKey = "field_{$voterId}_custom";
foreach ($_POST as $key => $value) {
if (strpos($key, $customKey) !== FALSE) {
$customFieldKey = str_replace(str_replace(substr($customKey, -6), '', $customKey), '', $key);
$params[$customFieldKey] = $value;
}
}
if (isset($_POST['field']) && !empty($_POST['field'][$voterId]) && is_array($_POST['field'][$voterId])) {
foreach ($_POST['field'][$voterId] as $fieldKey => $value) {
$params[$fieldKey] = $value;
}
}
//lets pickup contat related fields.
foreach ($_POST as $key => $value) {
if (strpos($key, "field_{$voterId}_") !== FALSE && strpos($key, "field_{$voterId}_custom") === FALSE) {
$key = substr($key, strlen("field_{$voterId}_"));
$params[$key] = $value;
}
}
$result = array('status' => 'fail', 'voter_id' => $voterId, 'activity_id' => $params['interviewer_id']);
//time to validate custom data.
$errors = CRM_Core_BAO_CustomField::validateCustomData($params);
if (is_array($errors) && !empty($errors)) {
$result['errors'] = $errors;
echo json_encode($result);
CRM_Utils_System::civiExit();
}
//process the response/interview data.
$activityId = CRM_Campaign_Form_Task_Interview::registerInterview($params);
if ($activityId) {
$result['status'] = 'success';
}
echo json_encode($result);
CRM_Utils_System::civiExit();
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:45,代码来源:AJAX.php
示例14: 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.');
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:22,代码来源:ContributionTest.php
示例15: registerInterview
static function registerInterview()
{
$fields = array('result', 'voter_id', 'ufGroupId', 'activity_id', 'surveyTitle', 'interviewer_id', 'activity_type_id');
$params = array();
foreach ($fields as $fld) {
$params[$fld] = CRM_Utils_Array::value($fld, $_POST);
}
$params['details'] = CRM_Utils_Array::value('note', $_POST);
$voterId = $params['voter_id'];
$activityId = $params['activity_id'];
$customKey = "field_{$voterId}_custom";
foreach ($_POST as $key => $value) {
if (strpos($key, $customKey) !== false) {
$customFieldKey = str_replace(str_replace(substr($customKey, -6), '', $customKey), '', $key);
$params[$customFieldKey] = $value;
}
}
if (isset($_POST['field']) && CRM_Utils_Array::value($voterId, $_POST['field']) && is_array($_POST['field'][$voterId])) {
foreach ($_POST['field'][$voterId] as $fieldKey => $value) {
$params[$fieldKey] = $value;
}
}
require_once "CRM/Utils/JSON.php";
$result = array('status' => 'fail', 'voter_id' => $voterId, 'activity_id' => $params['interviewer_id']);
//time to validate custom data.
require_once 'CRM/Core/BAO/CustomField.php';
$errors = CRM_Core_BAO_CustomField::validateCustomData($params);
if (is_array($errors) && !empty($errors)) {
$result['errors'] = $errors;
echo json_encode($result);
CRM_Utils_System::civiExit();
}
//process the response/interview data.
require_once 'CRM/Campaign/Form/Task/Interview.php';
$activityId = CRM_Campaign_Form_Task_Interview::registerInterview($params);
if ($activityId) {
$result['status'] = 'success';
}
require_once "CRM/Utils/JSON.php";
echo json_encode($result);
CRM_Utils_System::civiExit();
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:42,代码来源:AJAX.php
示例16: setDefaultValues
function setDefaultValues()
{
if (!$this->_donorID) {
return;
}
foreach ($this->_fields as $name => $dontcare) {
$fields[$name] = 1;
}
require_once "CRM/Core/BAO/UFGroup.php";
CRM_Core_BAO_UFGroup::setProfileDefaults($this->_donorID, $fields, $this->_defaults);
//set custom field defaults
require_once "CRM/Core/BAO/CustomField.php";
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
if (!isset($this->_defaults[$name])) {
CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $this->_defaults, NULL, CRM_Profile_Form::MODE_REGISTER);
}
}
}
return $this->_defaults;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:21,代码来源:ItemAccount.php
示例17: addColumns
function addColumns()
{
// add all the fields for chosen groups
$this->_tables = $this->_options = array();
foreach ($this->_groupTree as $groupID => $group) {
if (!CRM_Utils_Array::value($groupID, $this->_customGroupIDs)) {
continue;
}
// now handle all the fields
foreach ($group['fields'] as $fieldID => $field) {
$this->_columns[$field['label']] = "custom_{$field['id']}";
if (!array_key_exists($group['table_name'], $this->_tables)) {
$this->_tables[$group['table_name']] = array();
}
$this->_tables[$group['table_name']][$field['id']] = $field['column_name'];
// also build the option array
$this->_options[$field['id']] = array();
CRM_Core_BAO_CustomField::buildOption($field, $this->_options[$field['id']]);
}
}
}
开发者ID:hguru,项目名称:224Civi,代码行数:21,代码来源:MultipleValues.php
示例18: hrui_civicrm_buildForm
function hrui_civicrm_buildForm($formName, &$form)
{
CRM_Core_Resources::singleton()->addStyleFile('org.civicrm.hrui', 'css/hrui.css')->addScriptFile('org.civicrm.hrui', 'js/hrui.js');
if ($form instanceof CRM_Contact_Form_Contact) {
CRM_Core_Resources::singleton()->addSetting(array('formName' => 'contactForm'));
//HR-358 - Set default values
//set default value to phone location and type
$locationId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', 'Main', 'id', 'name');
$result = civicrm_api3('LocationType', 'create', array('id' => $locationId, 'is_default' => 1, 'is_active' => 1));
if ($form->elementExists('phone[2][phone_type_id]') && $form->elementExists('phone[2][phone_type_id]')) {
$phoneType = $form->getElement('phone[2][phone_type_id]');
$phoneValue = CRM_Core_OptionGroup::values('phone_type');
$phoneKey = CRM_Utils_Array::key('Mobile', $phoneValue);
$phoneType->setSelected($phoneKey);
$phoneLocation = $form->getElement('phone[2][location_type_id]');
$phoneLocation->setSelected($locationId);
}
}
$ogID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'type_20130502144049', 'id', 'name');
//HR-355 -- Add Government ID
if ($formName == 'CRM_Contact_Form_Contact' && $ogID && $form->_contactType == 'Individual') {
//add government fields
$contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $form);
$templatePath = CRM_Extension_System::singleton()->getMapper()->keyToBasePath('org.civicrm.hrui') . '/templates';
$form->add('text', 'GovernmentId', ts('Government ID'));
$form->addElement('select', "govTypeOptions", '', CRM_Core_BAO_OptionValue::getOptionValuesAssocArray($ogID));
CRM_Core_Region::instance('page-body')->add(array('template' => "{$templatePath}/CRM/HRUI/Form/contactField.tpl"));
$action = CRM_Utils_Request::retrieve('action', 'String', $form);
$govVal = CRM_HRIdent_Page_HRIdent::retreiveContactFieldValue($contactID);
//set default to government type option
$default = array();
$default['govTypeOptions'] = CRM_Core_BAO_CustomField::getOptionGroupDefault($ogID, 'select');
if ($action == CRM_Core_Action::UPDATE && !empty($govVal)) {
//set key for updating specific record of contact id in custom value table
$default['govTypeOptions'] = CRM_Utils_Array::value('type', $govVal);
$default['GovernmentId'] = CRM_Utils_Array::value('typeNumber', $govVal);
}
$form->setDefaults($default);
}
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:40,代码来源:hrui.php
示例19: postProcess
/**
* Form submission of new/edit contact is processed.
*/
public function postProcess()
{
// check if dedupe button, if so return.
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->_dedupeButtonName) {
return;
}
//get the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$group = CRM_Utils_Array::value('group', $params);
if (!empty($group) && is_array($group)) {
unset($params['group']);
foreach ($group as $key => $value) {
$params['group'][$value] = 1;
}
}
CRM_Contact_BAO_Contact_Optimizer::edit($params, $this->_preEditValues);
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
if (is_numeric(CRM_Utils_Array::value('current_employer_id', $params)) && !empty($params['current_employer'])) {
$params['current_employer'] = $params['current_employer_id'];
}
// don't carry current_employer_id field,
// since we don't want to directly update DAO object without
// handling related business logic ( eg related membership )
if (isset($params['current_employer_id'])) {
unset($params['current_employer_id']);
}
$params['contact_type'] = $this->_contactType;
if (empty($params['contact_sub_type']) && $this->_isContactSubType) {
$params['contact_sub_type'] = array($this->_contactSubType);
}
if ($this->_contactId) {
$params['contact_id'] = $this->_contactId;
}
//make deceased date null when is_deceased = false
if ($this->_contactType == 'Individual' && !empty($this->_editOptions['Demographics']) && empty($params['is_deceased'])) {
$params['is_deceased'] = FALSE;
$params['deceased_date'] = NULL;
}
if (isset($params['contact_id'])) {
// process membership status for deceased contact
$deceasedParams = array('contact_id' => CRM_Utils_Array::value('contact_id', $params), 'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE), 'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL));
$updateMembershipMsg = $this->updateMembershipStatus($deceasedParams);
}
// action is taken depending upon the mode
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
}
$customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, TRUE);
//CRM-5143
//if subtype is set, send subtype as extend to validate subtype customfield
$customFieldExtends = CRM_Utils_Array::value('contact_sub_type', $params) ? $params['contact_sub_type'] : $params['contact_type'];
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_contactId, $customFieldExtends, TRUE);
if ($this->_contactId && !empty($this->_oldSubtypes)) {
CRM_Contact_BAO_ContactType::deleteCustomSetForSubtypeMigration($this->_contactId, $params['contact_type'], $this->_oldSubtypes, $params['contact_sub_type']);
}
if (array_key_exists('CommunicationPreferences', $this->_editOptions)) {
// this is a chekbox, so mark false if we dont get a POST value
$params['is_opt_out'] = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
}
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if (!array_key_exists('TagsAndGroups', $this->_editOptions) && !empty($params['group'])) {
unset($params['group']);
}
if (!empty($params['contact_id']) && $this->_action & CRM_Core_Action::UPDATE && !empty($params['group'])) {
// figure out which all groups are intended to be removed
$contactGroupList = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], 'Added');
if (is_array($contactGroupList)) {
foreach ($contactGroupList as $key) {
if ((!array_key_exists($key['group_id'], $params['group']) || $params['group'][$key['group_id']] != 1) && empty($key['is_hidden'])) {
$params['group'][$key['group_id']] = -1;
}
}
}
}
// parse street address, CRM-5450
$parseStatusMsg = NULL;
if ($this->_parseStreetAddress) {
$parseResult = self::parseAddress($params);
$parseStatusMsg = self::parseAddressStatusMsg($parseResult);
}
// Allow un-setting of location info, CRM-5969
$params['updateBlankLocInfo'] = TRUE;
$contact = CRM_Contact_BAO_Contact::create($params, TRUE, FALSE, TRUE);
// status message
if ($this->_contactId) {
$message = ts('%1 has been updated.', array(1 => $contact->display_name));
} else {
$message = ts('%1 has been created.', array(1 => $contact->display_name));
}
// set the contact ID
$this->_contactId = $contact->id;
//.........这里部分代码省略.........
开发者ID:nganivet,项目名称:civicrm-core,代码行数:101,代码来源:Contact.php
示例20: run
//.........这里部分代码省略.........
}
/* trim whitespace around the values */
$empty = TRUE;
foreach ($values as $k => $v) {
$values[$k] = trim($v, " \t\r\n");
}
if (CRM_Utils_System::isNull($values)) {
continue;
}
$this->_totalCount++;
if ($mode == self::MODE_MAPFIELD) {
$returnCode = $this->mapField($values);
} elseif ($mode == self::MODE_PREVIEW) {
$returnCode = $this->preview($values);
} elseif ($mode == self::MODE_SUMMARY) {
$returnCode = $this->summary($values);
} elseif ($mode == self::MODE_IMPORT) {
$returnCode = $this->import($onDuplicate, $values);
} else {
$returnCode = self::ERROR;
}
// note that a line could be valid but still produce a warning
if ($returnCode & self::VALID) {
$this->_validCount++;
if ($mode == self::MODE_MAPFIELD) {
$this->_rows[] = $values;
$this->_activeFieldCount = max($this->_activeFieldCount, count($values));
}
}
if ($returnCode & self::WARNING) {
$this->_warningCount++;
if ($this->_warningCount < $this->_maxWarningCount) {
$this->_warningCount[] = $line;
}
}
if ($returnCode & self::ERROR) {
$this->_invalidRowCount++;
if ($this->_invalidRowCount < $this->_maxErrorCount) {
$recordNumber = $this->_lineCount;
array_unshift($values, $recordNumber);
$this->_errors[] = $values;
}
}
if ($returnCode & self::CONFLICT) {
$this->_conflictCount++;
$recordNumber = $this->_lineCount;
array_unshift($values, $recordNumber);
$this->_conflicts[] = $values;
}
if ($returnCode & self::DUPLICATE) {
if ($returnCode & self::MULTIPLE_DUPE) {
/* TODO: multi-dupes should be counted apart from singles
* on non-skip action */
}
$this->_duplicateCount++;
$recordNumber = $this->_lineCount;
array_unshift($values, $recordNumber);
$this->_duplicates[] = $values;
if ($onDuplicate != self::DUPLICATE_SKIP) {
$this->_validCount++;
}
}
// we give the derived class a way of aborting the process
// note that the return code could be multiple code or'ed together
if ($returnCode & self::STOP) {
break;
}
// if we are done processing the maxNumber of lines, break
if ($this->_maxLinesToProcess > 0 && $this->_validCount >= $this->_maxLinesToProcess) {
break;
}
}
fclose($fd);
if ($mode == self::MODE_PREVIEW || $mode == self::MODE_IMPORT) {
$customHeaders = $mapper;
$customfields = CRM_Core_BAO_CustomField::getFields('Membership');
foreach ($customHeaders as $key => $value) {
if ($id = CRM_Core_BAO_CustomField::getKeyID($value)) {
$customHeaders[$key] = $customfields[$id][0];
}
}
if ($this->_invalidRowCount) {
// removed view url for invlaid contacts
$headers = array_merge(array(ts('Line Number'), ts('Reason')), $customHeaders);
$this->_errorFileName = self::errorFileName(self::ERROR);
self::exportCSV($this->
|
请发表评论