本文整理汇总了PHP中CRM_Contact_BAO_Contact::processImageParams方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::processImageParams方法的具体用法?PHP CRM_Contact_BAO_Contact::processImageParams怎么用?PHP CRM_Contact_BAO_Contact::processImageParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::processImageParams方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processFormSubmission
/**
* Post form submission handling.
*
* This is also called from the test suite.
*
* @param int $contactID
*
* @return array
*/
protected function processFormSubmission($contactID)
{
$isPayLater = $this->_params['is_pay_later'];
if (!isset($this->_params['payment_processor_id'])) {
// If there is no processor we are using the pay-later manual pseudo-processor.
// (note it might make sense to make this a row in the processor table in the db).
$this->_params['payment_processor_id'] = 0;
}
if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) {
$this->_params['is_pay_later'] = $isPayLater = TRUE;
}
// add a description field at the very beginning
$this->_params['description'] = ts('Online Contribution') . ': ' . ($this->_pcpInfo['title'] ? $this->_pcpInfo['title'] : $this->_values['title']);
$this->_params['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values);
// fix currency ID
$this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
//carry payment processor id.
if (CRM_Utils_Array::value('id', $this->_paymentProcessor)) {
$this->_params['payment_processor_id'] = $this->_paymentProcessor['id'];
}
$premiumParams = $membershipParams = $params = $this->_params;
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$fields = array('email-Primary' => 1);
// get the add to groups
$addToGroups = array();
// now set the values for the billing location.
foreach ($this->_fields as $name => $value) {
$fields[$name] = 1;
// get the add to groups for uf fields
if (!empty($value['add_to_group_id'])) {
$addToGroups[$value['add_to_group_id']] = $value['add_to_group_id'];
}
}
$fields = $this->formatParamsForPaymentProcessor($fields);
// billing email address
$fields["email-{$this->_bltID}"] = 1;
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
// process on-behalf-of functionality.
if (!empty($this->_values['onbehalf_profile_id'])) {
$behalfOrganization = array();
$orgFields = array('organization_name', 'organization_id', 'org_option');
foreach ($orgFields as $fld) {
if (array_key_exists($fld, $params)) {
$behalfOrganization[$fld] = $params[$fld];
unset($params[$fld]);
}
}
if (is_array($params['onbehalf']) && !empty($params['onbehalf'])) {
foreach ($params['onbehalf'] as $fld => $values) {
if (strstr($fld, 'custom_')) {
$behalfOrganization[$fld] = $values;
} elseif (!strstr($fld, '-')) {
if (in_array($fld, array('contribution_campaign_id', 'member_campaign_id'))) {
$fld = 'campaign_id';
} else {
$behalfOrganization[$fld] = $values;
}
$this->_params[$fld] = $values;
}
}
}
if (array_key_exists('onbehalf_location', $params) && is_array($params['onbehalf_location'])) {
foreach ($params['onbehalf_location'] as $block => $vals) {
//fix for custom data (of type checkbox, multi-select)
if (substr($block, 0, 7) == 'custom_') {
continue;
}
// fix the index of block elements
if (is_array($vals)) {
foreach ($vals as $key => $val) {
//dont adjust the index of address block as
//it's index is WRT to location type
$newKey = $block == 'address' ? $key : ++$key;
$behalfOrganization[$block][$newKey] = $val;
}
}
}
unset($params['onbehalf_location']);
}
if (!empty($params['onbehalf[image_URL]'])) {
$behalfOrganization['image_URL'] = $params['onbehalf[image_URL]'];
}
}
// check for profile double opt-in and get groups to be subscribed
$subscribeGroupIds = CRM_Core_BAO_UFGroup::getDoubleOptInGroupIds($params, $contactID);
// since we are directly adding contact to group lets unset it from mailing
if (!empty($addToGroups)) {
//.........这里部分代码省略.........
示例2: 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;
//.........这里部分代码省略.........
示例3: postProcess
/**
* Process the user submitted custom data values.
*
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//if the delete record button is clicked
if ($this->_deleteButtonName) {
if (!empty($_POST[$this->_deleteButtonName]) && $this->_recordId) {
$filterParams['id'] = $this->_customGroupId;
$returnProperties = array('is_multiple', 'table_name');
CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties);
if (!empty($returnValues['is_multiple'])) {
if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) {
$sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2";
$sqlParams = array(1 => array($this->_recordId, 'Integer'), 2 => array($this->_id, 'Integer'));
CRM_Core_DAO::executeQuery($sql, $sqlParams);
CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success');
}
}
return;
}
}
CRM_Utils_Hook::processProfile($this->_ufGroup['name']);
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
$details = array();
if ($this->_id) {
$contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
$details = $contactDetails[0][$this->_id];
}
if (!(!empty($details['addressee_id']) || !empty($details['email_greeting_id']) || CRM_Utils_Array::value('postal_greeting_id', $details))) {
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
//Though Profile type is contact we need
//Individual/Household/Organization for setting Greetings.
if ($profileType == 'Contact') {
$profileType = 'Individual';
//if we editing Household/Organization.
if ($this->_id) {
$profileType = CRM_Contact_BAO_Contact::getContactType($this->_id);
}
}
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
foreach ($greetingTypes as $key => $value) {
if (!array_key_exists($key, $params)) {
$params[$key] = CRM_Contact_BAO_Contact_Utils::defaultGreeting($profileType, $key);
}
}
}
$transaction = new CRM_Core_Transaction();
//used to send subscribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$result = NULL;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
//array of group id, subscribed by contact
$contactGroup = array();
if (!empty($params['group']) && CRM_Core_BAO_UFGroup::isProfileDoubleOptin()) {
$groupSubscribed = array();
if (!empty($result['email'])) {
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
//.........这里部分代码省略.........
示例4: processOnBehalfOrganization
/**
* Function to add on behalf of organization and it's location
*
* @param $behalfOrganization array array of organization info
* @param $contactID int individual contact id. One
* who is doing the process of signup / contribution.
*
* @param $values array form values array
* @param $params
* @param null $fields
*
* @return void
* @access public
*/
static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL)
{
$isCurrentEmployer = FALSE;
$orgID = NULL;
if (!empty($behalfOrganization['organization_id']) && !empty($behalfOrganization['org_option'])) {
$orgID = $behalfOrganization['organization_id'];
unset($behalfOrganization['organization_id']);
$isCurrentEmployer = TRUE;
}
// formalities for creating / editing organization.
$behalfOrganization['contact_type'] = 'Organization';
// get the relationship type id
$relType = new CRM_Contact_DAO_RelationshipType();
$relType->name_a_b = 'Employee of';
$relType->find(TRUE);
$relTypeId = $relType->id;
// keep relationship params ready
$relParams['relationship_type_id'] = $relTypeId . '_a_b';
$relParams['is_permission_a_b'] = 1;
$relParams['is_active'] = 1;
if (!$orgID) {
// check if matching organization contact exists
$dedupeParams = CRM_Dedupe_Finder::formatParams($behalfOrganization, 'Organization');
$dedupeParams['check_permission'] = FALSE;
$dupeIDs = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Organization', 'Unsupervised');
// CRM-6243 says to pick the first org even if more than one match
if (count($dupeIDs) >= 1) {
$behalfOrganization['contact_id'] = $dupeIDs[0];
// don't allow name edit
unset($behalfOrganization['organization_name']);
}
} else {
// if found permissioned related organization, allow location edit
$behalfOrganization['contact_id'] = $orgID;
// don't allow name edit
unset($behalfOrganization['organization_name']);
}
// handling for image url
if (!empty($behalfOrganization['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($behalfOrganization);
}
// create organization, add location
$orgID = CRM_Contact_BAO_Contact::createProfileContact($behalfOrganization, $fields, $orgID, NULL, NULL, 'Organization');
// create relationship
$relParams['contact_check'][$orgID] = 1;
$cid = array('contact' => $contactID);
CRM_Contact_BAO_Relationship::create($relParams, $cid);
// if multiple match - send a duplicate alert
if ($dupeIDs && count($dupeIDs) > 1) {
$values['onbehalf_dupe_alert'] = 1;
// required for IPN
$params['onbehalf_dupe_alert'] = 1;
}
// make sure organization-contact-id is considered for recording
// contribution/membership etc..
if ($contactID != $orgID) {
// take a note of contact-id, so we can send the
// receipt to individual contact as well.
// required for mailing/template display ..etc
$values['related_contact'] = $contactID;
// required for IPN
$params['related_contact'] = $contactID;
//make this employee of relationship as current
//employer / employee relationship, CRM-3532
if ($isCurrentEmployer && $orgID != CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id')) {
$isCurrentEmployer = FALSE;
}
if (!$isCurrentEmployer && $orgID) {
//build current employer params
$currentEmpParams[$contactID] = $orgID;
CRM_Contact_BAO_Contact_Utils::setCurrentEmployer($currentEmpParams);
}
// contribution / signup will be done using this
// organization id.
$contactID = $orgID;
}
}
示例5: postProcess
/**
* Process the form submission.
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//set as Primary participant
$params['is_primary'] = 1;
if ($this->_values['event']['is_pay_later'] && (!array_key_exists('hidden_processor', $params) || $params['payment_processor_id'] == 0)) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
$this->set('is_pay_later', $params['is_pay_later']);
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
if (!$this->_allowConfirmation) {
// check if the participant is already registered
if (!$this->_skipDupeRegistrationCheck) {
$params['contact_id'] = self::checkRegistration($params, $this, FALSE, TRUE, TRUE);
}
}
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
//carry campaign to partcipants.
if (array_key_exists('participant_campaign_id', $params)) {
$params['campaign_id'] = $params['participant_campaign_id'];
} else {
$params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
}
//hack to allow group to register w/ waiting
$primaryParticipantCount = self::getParticipantCount($this, $params);
$totalParticipants = $primaryParticipantCount;
if (!empty($params['additional_participants'])) {
$totalParticipants += $params['additional_participants'];
}
if (!$this->_allowConfirmation && !empty($params['bypass_payment']) && is_numeric($this->_availableRegistrations) && $totalParticipants > $this->_availableRegistrations) {
$this->_allowWaitlist = TRUE;
$this->set('allowWaitlist', TRUE);
}
//carry participant id if pre-registered.
if ($this->_allowConfirmation && $this->_participantId) {
$params['participant_id'] = $this->_participantId;
}
$params['defaultRole'] = 1;
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
if (array_key_exists('participant_role_id', $params)) {
$params['defaultRole'] = 0;
}
if (empty($params['participant_role_id']) && $this->_values['event']['default_role_id']) {
$params['participant_role_id'] = $this->_values['event']['default_role_id'];
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
$params['amount_level'] = $this->getAmountLevel($params, $discountId);
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
if (!empty($params['amount'])) {
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
if ($params['tax_amount']) {
$this->set('tax_amount', $params['tax_amount']);
}
$submittedLineItems = $this->get('lineItem');
if (!empty($submittedLineItems) && is_array($submittedLineItems)) {
$submittedLineItems[0] = $lineItem;
} else {
$submittedLineItems = array($lineItem);
}
$this->set('lineItem', $submittedLineItems);
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if ($this->_paymentProcessor) {
$payment = $this->_paymentProcessor['object'];
//.........这里部分代码省略.........
示例6: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
//set as Primary participant
$params['is_primary'] = 1;
if ($this->_values['event']['is_pay_later'] && !array_key_exists('hidden_processor', $params)) {
$params['is_pay_later'] = 1;
} else {
$params['is_pay_later'] = 0;
}
$this->set('is_pay_later', $params['is_pay_later']);
// assign pay later stuff
$this->_params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, FALSE);
$this->assign('is_pay_later', $params['is_pay_later']);
if ($params['is_pay_later']) {
$this->assign('pay_later_text', $this->_values['event']['pay_later_text']);
$this->assign('pay_later_receipt', $this->_values['event']['pay_later_receipt']);
}
if (!$this->_allowConfirmation) {
// check if the participant is already registered
if (!$this->_skipDupeRegistrationCheck) {
$params['contact_id'] = self::checkRegistration($params, $this, FALSE, TRUE, TRUE);
}
}
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
//carry campaign to partcipants.
if (array_key_exists('participant_campaign_id', $params)) {
$params['campaign_id'] = $params['participant_campaign_id'];
} else {
$params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']);
}
//hack to allow group to register w/ waiting
$primaryParticipantCount = self::getParticipantCount($this, $params);
$totalParticipants = $primaryParticipantCount;
if (CRM_Utils_Array::value('additional_participants', $params)) {
$totalParticipants += $params['additional_participants'];
}
if (!$this->_allowConfirmation && CRM_Utils_Array::value('bypass_payment', $params) && is_numeric($this->_availableRegistrations) && $totalParticipants > $this->_availableRegistrations) {
$this->_allowWaitlist = TRUE;
$this->set('allowWaitlist', TRUE);
}
//carry participant id if pre-registered.
if ($this->_allowConfirmation && $this->_participantId) {
$params['participant_id'] = $this->_participantId;
}
$params['defaultRole'] = 1;
if (array_key_exists('participant_role', $params)) {
$params['participant_role_id'] = $params['participant_role'];
}
if (array_key_exists('participant_role_id', $params)) {
$params['defaultRole'] = 0;
}
if (!CRM_Utils_Array::value('participant_role_id', $params) && $this->_values['event']['default_role_id']) {
$params['participant_role_id'] = $this->_values['event']['default_role_id'];
}
$config = CRM_Core_Config::singleton();
$params['currencyID'] = $config->defaultCurrency;
if ($this->_values['event']['is_monetary']) {
// we first reset the confirm page so it accepts new values
$this->controller->resetPage('Confirm');
//added for discount
$discountId = CRM_Core_BAO_Discount::findSet($this->_eventId, 'civicrm_event');
if (!empty($this->_values['discount'][$discountId])) {
$params['discount_id'] = $discountId;
$params['amount_level'] = $this->_values['discount'][$discountId][$params['amount']]['label'];
$params['amount'] = $this->_values['discount'][$discountId][$params['amount']]['value'];
} elseif (empty($params['priceSetId'])) {
if (!empty($params['amount'])) {
$params['amount_level'] = $this->_values['fee'][$params['amount']]['label'];
$params['amount'] = $this->_values['fee'][$params['amount']]['value'];
} else {
$params['amount_level'] = $params['amount'] = '';
}
} else {
$lineItem = array();
CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem);
$this->set('lineItem', array($lineItem));
$this->set('lineItemParticipantsCount', array($primaryParticipantCount));
}
$this->set('amount', $params['amount']);
$this->set('amount_level', $params['amount_level']);
// generate and set an invoiceID for this transaction
$invoiceID = md5(uniqid(rand(), TRUE));
$this->set('invoiceID', $invoiceID);
if (is_array($this->_paymentProcessor)) {
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
}
// default mode is direct
$this->set('contributeMode', 'direct');
if (isset($params["state_province_id-{$this->_bltID}"]) && $params["state_province_id-{$this->_bltID}"]) {
//.........这里部分代码省略.........
示例7: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
$contactID = $this->_userID;
// add a description field at the very beginning
$this->_params['description'] = ts('Online Contribution') . ': ' . ($this->_pcpInfo['title'] ? $this->_pcpInfo['title'] : $this->_values['title']);
// also add accounting code
$this->_params['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values);
// fix currency ID
$this->_params['currencyID'] = $config->defaultCurrency;
$premiumParams = $membershipParams = $tempParams = $params = $this->_params;
//carry payment processor id.
if ($paymentProcessorId = CRM_Utils_Array::value('id', $this->_paymentProcessor)) {
$this->_params['payment_processor_id'] = $paymentProcessorId;
foreach (array('premiumParams', 'membershipParams', 'tempParams', 'params') as $p) {
${$p}['payment_processor_id'] = $paymentProcessorId;
}
}
$now = date('YmdHis');
$fields = array();
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
// set email for primary location.
$fields['email-Primary'] = 1;
// don't create primary email address, just add it to billing location
//$params["email-Primary"] = $params["email-{$this->_bltID}"];
// get the add to groups
$addToGroups = array();
// now set the values for the billing location.
foreach ($this->_fields as $name => $value) {
$fields[$name] = 1;
// get the add to groups for uf fields
if (CRM_Utils_Array::value('add_to_group_id', $value)) {
$addToGroups[$value['add_to_group_id']] = $value['add_to_group_id'];
}
}
if (!array_key_exists('first_name', $fields)) {
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
}
// billing email address
$fields["email-{$this->_bltID}"] = 1;
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
if ($params['is_pay_later']) {
$billingFields = array('billing_first_name', 'billing_middle_name', 'billing_last_name', "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
foreach ($billingFields as $value) {
unset($params[$value]);
unset($fields[$value]);
}
}
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
// process on-behalf-of functionality.
if (CRM_Utils_Array::value('hidden_onbehalf_profile', $this->_params)) {
$behalfOrganization = array();
$orgFields = array('organization_name', 'organization_id', 'org_option');
foreach ($orgFields as $fld) {
if (array_key_exists($fld, $params)) {
$behalfOrganization[$fld] = $params[$fld];
unset($params[$fld]);
}
}
if (is_array($params['onbehalf']) && !empty($params['onbehalf'])) {
foreach ($params['onbehalf'] as $fld => $values) {
if (strstr($fld, 'custom_')) {
$behalfOrganization[$fld] = $values;
} elseif (!strstr($fld, '-')) {
if (in_array($fld, array('contribution_campaign_id', 'member_campaign_id'))) {
$fld = 'campaign_id';
} else {
$behalfOrganization[$fld] = $values;
}
$this->_params[$fld] = $values;
}
}
}
if (array_key_exists('onbehalf_location', $params) && is_array($params['onbehalf_location'])) {
foreach ($params['onbehalf_location'] as $block => $vals) {
//fix for custom data (of type checkbox, multi-select)
if (substr($block, 0, 7) == 'custom_') {
continue;
}
// fix the index of block elements
if (is_array($vals)) {
foreach ($vals as $key => $val) {
//.........这里部分代码省略.........
示例8: processFormSubmission
/**
* Post form submission handling.
*
* This is also called from the test suite.
*
* @param int $contactID
*
* @return array
*/
protected function processFormSubmission($contactID)
{
$isPayLater = $this->_params['is_pay_later'];
if (isset($this->_params['payment_processor_id']) && $this->_params['payment_processor_id'] == 0) {
$this->_params['is_pay_later'] = $isPayLater = TRUE;
}
// add a description field at the very beginning
$this->_params['description'] = ts('Online Contribution') . ': ' . ($this->_pcpInfo['title'] ? $this->_pcpInfo['title'] : $this->_values['title']);
$this->_params['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values);
// fix currency ID
$this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency;
//carry payment processor id.
if (CRM_Utils_Array::value('id', $this->_paymentProcessor)) {
$this->_params['payment_processor_id'] = $this->_paymentProcessor['id'];
}
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$premiumParams = $membershipParams = $params = $this->_params;
$fields = array('email-Primary' => 1);
// get the add to groups
$addToGroups = array();
// now set the values for the billing location.
foreach ($this->_fields as $name => $value) {
$fields[$name] = 1;
// get the add to groups for uf fields
if (!empty($value['add_to_group_id'])) {
$addToGroups[$value['add_to_group_id']] = $value['add_to_group_id'];
}
}
if (!array_key_exists('first_name', $fields)) {
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = TRUE;
}
}
}
// billing email address
$fields["email-{$this->_bltID}"] = 1;
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
if ($isPayLater && !$this->_isBillingAddressRequiredForPayLater) {
$billingFields = array('billing_first_name', 'billing_middle_name', 'billing_last_name', "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
foreach ($billingFields as $value) {
unset($params[$value]);
unset($fields[$value]);
}
}
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
// process on-behalf-of functionality.
if (!empty($this->_params['hidden_onbehalf_profile'])) {
$behalfOrganization = array();
$orgFields = array('organization_name', 'organization_id', 'org_option');
foreach ($orgFields as $fld) {
if (array_key_exists($fld, $params)) {
$behalfOrganization[$fld] = $params[$fld];
unset($params[$fld]);
}
}
if (is_array($params['onbehalf']) && !empty($params['onbehalf'])) {
foreach ($params['onbehalf'] as $fld => $values) {
if (strstr($fld, 'custom_')) {
$behalfOrganization[$fld] = $values;
} elseif (!strstr($fld, '-')) {
if (in_array($fld, array('contribution_campaign_id', 'member_campaign_id'))) {
$fld = 'campaign_id';
} else {
$behalfOrganization[$fld] = $values;
}
$this->_params[$fld] = $values;
}
}
}
if (array_key_exists('onbehalf_location', $params) && is_array($params['onbehalf_location'])) {
foreach ($params['onbehalf_location'] as $block => $vals) {
//fix for custom data (of type checkbox, multi-select)
if (substr($block, 0, 7) == 'custom_') {
continue;
}
// fix the index of block elements
if (is_array($vals)) {
foreach ($vals as $key => $val) {
//dont adjust the index of address block as
//it's index is WRT to location type
$newKey = $block == 'address' ? $key : ++$key;
$behalfOrganization[$block][$newKey] = $val;
//.........这里部分代码省略.........
示例9: postProcess
/**
* Process the user submitted custom data values.
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
$greetingTypes = array('addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id');
if ($this->_id) {
$contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes);
$details = $contactDetails[0][$this->_id];
}
if (!(CRM_Utils_Array::value('addressee_id', $details) || CRM_Utils_Array::value('email_greeting_id', $details) || CRM_Utils_Array::value('postal_greeting_id', $details))) {
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
//Though Profile type is contact we need
//Individual/Household/Organization for setting Greetings.
if ($profileType == 'Contact') {
$profileType = 'Individual';
//if we editing Household/Organization.
if ($this->_id) {
$profileType = CRM_Contact_BAO_Contact::getContactType($this->_id);
}
}
if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
$profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
}
$contactTypeFilters = array(1 => 'Individual', 2 => 'Household', 3 => 'Organization');
$filter = CRM_Utils_Array::key($profileType, $contactTypeFilters);
if ($filter) {
foreach ($greetingTypes as $key => $value) {
if (!array_key_exists($key, $params)) {
$defaultGreetingTypeId = CRM_Core_OptionGroup::values($key, null, null, null, "AND is_default =1\n AND (filter = \n {$filter} OR \n filter = 0 )", 'value');
$params[$key] = key($defaultGreetingTypeId);
}
}
}
if ($profileType == 'Organization') {
unset($params['email_greeting'], $params['postal_greeting']);
}
}
if ($this->_mode == self::MODE_REGISTER) {
require_once 'CRM/Core/BAO/Address.php';
CRM_Core_BAO_Address::setOverwrite(false);
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
//used to send subcribe mail to the group which user want.
//if the profile double option in is enabled
$mailingType = array();
$config = CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $params)) {
$result = null;
foreach ($params as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$result['email'] = $values;
}
}
$groupSubscribed = array();
if (CRM_Utils_Array::value('email', $result)) {
require_once 'CRM/Contact/DAO/Group.php';
//array of group id, subscribed by contact
$contactGroup = array();
if ($this->_id) {
$contactGroups = new CRM_Contact_DAO_GroupContact();
$contactGroups->contact_id = $this->_id;
$contactGroups->status = 'Added';
$contactGroups->find();
$contactGroup = array();
while ($contactGroups->fetch()) {
$contactGroup[] = $contactGroups->group_id;
$groupSubscribed[$contactGroups->group_id] = 1;
}
}
foreach ($params['group'] as $key => $val) {
if (!$val) {
unset($params['group'][$key]);
continue;
}
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $key, 'group_type', 'id');
$groupType = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($groupTypes, 1, -1));
//filter group of mailing type and unset it from params
if (in_array(2, $groupType)) {
//if group is already subscribed , ignore it
$groupExist = CRM_Utils_Array::key($key, $contactGroup);
if (!isset($groupExist)) {
$mailingType[] = $key;
unset($params['group'][$key]);
}
}
}
}
}
if (CRM_Utils_Array::value('add_to_group', $params)) {
$addToGroupId = $params['add_to_group'];
// since we are directly adding contact to group lets unset it from mailing
//.........这里部分代码省略.........
示例10: postProcess
/**
* Process the form
*
* @return void
* @access public
*/
public function postProcess()
{
$config = CRM_Core_Config::singleton();
require_once 'CRM/Contact/BAO/Contact.php';
$contactID = $this->_userID;
// add a description field at the very beginning
$this->_params['description'] = ts('Online Contribution') . ': ' . ($this->_pcpInfo['title'] ? $this->_pcpInfo['title'] : $this->_values['title']);
// also add accounting code
$this->_params['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values);
// fix currency ID
$this->_params['currencyID'] = $config->defaultCurrency;
$premiumParams = $membershipParams = $tempParams = $params = $this->_params;
//carry payment processor id.
if ($paymentProcessorId = CRM_Utils_Array::value('id', $this->_paymentProcessor)) {
$this->_params['payment_processor_id'] = $paymentProcessorId;
foreach (array('premiumParams', 'membershipParams', 'tempParams', 'params') as $p) {
${$p}['payment_processor_id'] = $paymentProcessorId;
}
}
$now = date('YmdHis');
$fields = array();
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
// set email for primary location.
$fields['email-Primary'] = 1;
// don't create primary email address, just add it to billing location
//$params["email-Primary"] = $params["email-{$this->_bltID}"];
// get the add to groups
$addToGroups = array();
// now set the values for the billing location.
foreach ($this->_fields as $name => $value) {
$fields[$name] = 1;
// get the add to groups for uf fields
if (CRM_Utils_Array::value('add_to_group_id', $value)) {
$addToGroups[$value['add_to_group_id']] = $value['add_to_group_id'];
}
}
if (!array_key_exists('first_name', $fields)) {
$nameFields = array('first_name', 'middle_name', 'last_name');
foreach ($nameFields as $name) {
$fields[$name] = 1;
if (array_key_exists("billing_{$name}", $params)) {
$params[$name] = $params["billing_{$name}"];
$params['preserveDBName'] = true;
}
}
}
// billing email address
$fields["email-{$this->_bltID}"] = 1;
//unset the billing parameters if it is pay later mode
//to avoid creation of billing location
if ($params['is_pay_later']) {
$billingFields = array('billing_first_name', 'billing_middle_name', 'billing_last_name', "billing_street_address-{$this->_bltID}", "billing_city-{$this->_bltID}", "billing_state_province-{$this->_bltID}", "billing_state_province_id-{$this->_bltID}", "billing_postal_code-{$this->_bltID}", "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}");
foreach ($billingFields as $value) {
unset($params[$value]);
unset($fields[$value]);
}
}
// if onbehalf-of-organization contribution, take out
// organization params in a separate variable, to make sure
// normal behavior is continued. And use that variable to
// process on-behalf-of functionality.
if (CRM_Utils_Array::value('is_for_organization', $this->_values)) {
$behalfOrganization = array();
foreach (array('organization_name', 'organization_id', 'org_option') as $fld) {
if (array_key_exists($fld, $params)) {
$behalfOrganization[$fld] = $params[$fld];
unset($params[$fld]);
}
}
if (array_key_exists('onbehalf_location', $params) && is_array($params['onbehalf_location'])) {
foreach ($params['onbehalf_location'] as $block => $vals) {
$behalfOrganization[$block] = $vals;
}
unset($params['onbehalf_location']);
}
}
// check for profile double opt-in and get groups to be subscribed
require_once 'CRM/Core/BAO/UFGroup.php';
$subscribeGroupIds = CRM_Core_BAO_UFGroup::getDoubleOptInGroupIds($params, $contactID);
// since we are directly adding contact to group lets unset it from mailing
if (!empty($addToGroups)) {
foreach ($addToGroups as $groupId) {
if (isset($subscribeGroupIds[$groupId])) {
unset($subscribeGroupIds[$groupId]);
}
}
}
foreach ($addToGroups as $k) {
if (array_key_exists($k, $subscribeGroupIds)) {
unset($addToGroups[$k]);
}
}
//.........这里部分代码省略.........
示例11: postProcess
/**
* Form submission of new/edit contact is processed.
*
* @access public
* @return None
*/
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);
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
if (is_numeric(CRM_Utils_Array::value('current_employer_id', $params)) && CRM_Utils_Array::value('current_employer', $params)) {
$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 ($this->_contactSubType && !CRM_Utils_Array::value('contact_sub_type', $params)) {
$params['contact_sub_type'] = $this->_contactSubType;
}
if ($this->_contactId) {
$params['contact_id'] = $this->_contactId;
}
//make deceased date null when is_deceased = false
if ($this->_contactType == 'Individual' && CRM_Utils_Array::value('Demographics', $this->_editOptions) && !CRM_Utils_Array::value('is_deceased', $params)) {
$params['is_deceased'] = false;
$params['deceased_date'] = null;
}
// process membership status for deceased contact
$deceasedParams = array('contact_id' => $params['contact_id'], 'is_deceased' => $params['is_deceased'], 'deceased_date' => $params['deceased_date']);
$updateMembershipMsg = $this->updateMembershipStatus($deceasedParams);
// action is taken depending upon the mode
require_once 'CRM/Utils/Hook.php';
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);
}
require_once 'CRM/Core/BAO/CustomField.php';
$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, $customFields, $this->_contactId, $customFieldExtends, true);
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.
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if (!array_key_exists('TagsAndGroups', $this->_editOptions)) {
unset($params['group']);
}
if (CRM_Utils_Array::value('contact_id', $params) && $this->_action & CRM_Core_Action::UPDATE) {
// figure out which all groups are intended to be removed
if (!empty($params['group'])) {
$contactGroupList =& CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], 'Added');
if (is_array($contactGroupList)) {
foreach ($contactGroupList as $key) {
if ($params['group'][$key['group_id']] != 1) {
$params['group'][$key['group_id']] = -1;
}
}
}
}
}
// parse street address, CRM-5450
$parseStatusMsg = null;
if ($this->_parseStreetAddress) {
$parseResult = $this->parseAddress($params);
$parseStatusMsg = $this->parseAddressStatusMsg($parseResult);
}
// Allow un-setting of location info, CRM-5969
$params['updateBlankLocInfo'] = true;
require_once 'CRM/Contact/BAO/Contact.php';
$contact =& CRM_Contact_BAO_Contact::create($params, true, false, true);
// set the contact ID
$this->_contactId = $contact->id;
if (array_key_exists('TagsAndGroups', $this->_editOptions)) {
//add contact to tags
require_once 'CRM/Core/BAO/EntityTag.php';
CRM_Core_BAO_EntityTag::create($params['tag'], 'civicrm_contact', $params['contact_id']);
//save free tags
if (isset($params['taglist']) && !empty($params['taglist'])) {
require_once 'CRM/Core/Form/Tag.php';
CRM_Core_Form_Tag::postProcess($params['taglist'], $params['contact_id'], 'civicrm_contact', $this);
}
}
//.........这里部分代码省略.........