本文整理汇总了PHP中CRM_Utils_Array::crmArrayMerge方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::crmArrayMerge方法的具体用法?PHP CRM_Utils_Array::crmArrayMerge怎么用?PHP CRM_Utils_Array::crmArrayMerge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Array
的用法示例。
在下文中一共展示了CRM_Utils_Array::crmArrayMerge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preProcess
/**
* Function to set variables up before form is built
*
* @return void
* @access public
*/
public function preProcess()
{
require_once 'CRM/Event/BAO/Participant.php';
$values = $ids = array();
$params = array('id' => $this->get('id'));
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
CRM_Event_BAO_Participant::resolveDefaults($values[$params['id']]);
if (CRM_Utils_Array::value('fee_level', $values[$params['id']])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$params['id']]['fee_level']);
}
if ($values[$params['id']]['is_test']) {
$values[$params['id']]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($values[$params['id']]['id'], 'civicrm_participant');
$values[$params['id']]['note'] = array_values($noteValue);
require_once 'CRM/Price/BAO/LineItem.php';
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($params['id']);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$params['id']]['lineItem'][] = $lineItem;
}
$values[$params['id']]['totalAmount'] = $values[$params['id']]['fee_amount'];
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id'], null, $values[$params['id']]['role_id'], $roleCustomDataTypeID);
$eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id'], null, $values[$params['id']]['event_id'], $eventNameCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $params['id']));
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
$this->assign($values[$params['id']]);
// add viewed participant to recent items list
require_once 'CRM/Utils/Recent.php';
require_once 'CRM/Contact/BAO/Contact.php';
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$params['id']]['id']}&cid={$values[$params['id']]['contact_id']}");
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$params['id']]['event_id'], 'title');
$title = CRM_Contact_BAO_Contact::displayName($values[$params['id']]['contact_id']) . ' (' . $participantRoles[$values[$params['id']]['role_id']] . ' - ' . $eventTitle . ')';
// add the recently created Activity
CRM_Utils_Recent::add($title, $url, $values[$params['id']]['id'], 'Participant', $values[$params['id']]['contact_id'], null);
}
示例2: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
public function postProcess($params = null)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted sucessfully."));
return;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
//set activity type id
if (!CRM_Utils_Array::value('activity_type_id', $params)) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', false, false, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', false, false, null, null, true));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// assigning formated value to related variable
if (CRM_Utils_Array::value('target_contact_id', $params)) {
$params['target_contact_id'] = explode(',', $params['target_contact_id']);
} else {
$params['target_contact_id'] = array();
}
if (CRM_Utils_Array::value('assignee_contact_id', $params)) {
$params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']);
} else {
$params['assignee_contact_id'] = array();
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
} else {
$params['source_contact_id'] = $this->_submitValues['source_contact_qid'];
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
// format target params
if (!$this->_single) {
$params['target_contact_id'] = $this->_contactIds;
}
$activityAssigned = array();
// format assignee params
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) {
//skip those assignee contacts which are already assigned
//while sending a copy.CRM-4509.
$activityAssigned = array_flip($params['assignee_contact_id']);
if ($this->_activityId) {
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($this->_activityId);
$activityAssigned = array_diff_key($activityAssigned, $assigneeContacts);
}
}
// call begin post process. Idea is to let injecting file do
// any processing before the activity is added/updated.
$this->beginPostProcess($params);
$activity = CRM_Activity_BAO_Activity::create($params);
// call end post process. Idea is to let injecting file do any
// processing needed, after the activity has been added/updated.
$this->endPostProcess($params, $activity);
// create follow up activity if needed
$followupStatus = '';
if (CRM_Utils_Array::value('followup_activity_type_id', $params)) {
$followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($activity->id, $params);
$followupStatus = "A followup activity has been scheduled.";
}
// send copy to assignee contacts.CRM-4509
$mailStatus = '';
$config =& CRM_Core_Config::singleton();
if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id']) && $config->activityAssigneeNotification) {
$mailToContacts = array();
$assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activity->id, true, false);
//build an associative array with unique email addresses.
foreach ($activityAssigned as $id => $dnc) {
if (isset($id) && array_key_exists($id, $assigneeContacts)) {
$mailToContacts[$assigneeContacts[$id]['email']] = $assigneeContacts[$id];
}
}
if (!CRM_Utils_array::crmIsEmptyArray($mailToContacts)) {
//include attachments while sendig a copy of activity.
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
require_once "CRM/Case/BAO/Case.php";
$result = CRM_Case_BAO_Case::sendActivityCopy(null, $activity->id, $mailToContacts, $attachments, null);
$mailStatus .= ts("A copy of the activity has also been sent to assignee contacts(s).");
}
}
// set status message
//.........这里部分代码省略.........
示例3: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = $ids = array();
$participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
$params = array('id' => $participantID);
CRM_Event_BAO_Participant::getValues($params, $values, $ids);
if (empty($values)) {
CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
}
CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
if (!empty($values[$participantID]['fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
}
$this->assign('contactId', $contactID);
$this->assign('participantId', $participantID);
$paymentId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $participantID, 'id', 'participant_id');
$this->assign('hasPayment', $paymentId);
if ($parentParticipantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'registered_by_id')) {
$parentHasPayment = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $parentParticipantId, 'id', 'participant_id');
$this->assign('parentHasPayment', $parentHasPayment);
}
$statusId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'status_id', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
$status = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantStatusType', $statusId, 'name', 'id');
if ($status == 'Transferred') {
$transferId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $participantID, 'transferred_to_contact_id', 'id');
$pid = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_Participant', $transferId, 'id', 'contact_id');
$transferName = current(CRM_Contact_BAO_Contact::getContactDetails($transferId));
$this->assign('pid', $pid);
$this->assign('transferId', $transferId);
$this->assign('transferName', $transferName);
}
$participantStatuses = CRM_Event_PseudoConstant::participantStatus();
if ($values[$participantID]['is_test']) {
$values[$participantID]['status'] .= ' (test) ';
}
// Get Note
$noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
$values[$participantID]['note'] = array_values($noteValue);
// Get Line Items
$lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
if (!CRM_Utils_System::isNull($lineItem)) {
$values[$participantID]['lineItem'][] = $lineItem;
}
$values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]);
// Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859)
if (!empty($values[$participantID]['participant_registered_by_id'])) {
$values[$participantID]['registered_by_contact_id'] = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $values[$participantID]['participant_registered_by_id'], 'contact_id', 'id');
$values[$participantID]['registered_by_display_name'] = CRM_Contact_BAO_Contact::displayName($values[$participantID]['registered_by_contact_id']);
}
// Check if this is a primaryParticipant (registered for others) and retrieve additional participants if true (CRM-4859)
if (CRM_Event_BAO_Participant::isPrimaryParticipant($participantID)) {
$values[$participantID]['additionalParticipants'] = CRM_Event_BAO_Participant::getAdditionalParticipants($participantID);
}
// get the option value for custom data type
$roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
$eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
$eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
$allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']);
$groupTree = array();
$finalTree = array();
foreach ($allRoleIDs as $k => $v) {
$roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $v, $roleCustomDataTypeID);
$eventGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
$eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
$eventTypeGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, NULL, $eventTypeID, $eventTypeCustomDataTypeID);
$groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
$groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
foreach ($groupTree as $treeId => $trees) {
$finalTree[$treeId] = $trees;
}
}
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $finalTree, FALSE, NULL, NULL, NULL, $participantID);
$eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
//CRM-7150, show event name on participant view even if the event is disabled
if (empty($values[$participantID]['event'])) {
$values[$participantID]['event'] = $eventTitle;
}
//do check for campaigns
if ($campaignId = CRM_Utils_Array::value('campaign_id', $values[$participantID])) {
$campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($campaignId);
$values[$participantID]['campaign'] = $campaigns[$campaignId];
}
$this->assign($values[$participantID]);
// add viewed participant to recent items list
$url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
$recentOther = array();
if (CRM_Core_Permission::check('edit event participants')) {
$recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=delete&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
}
//.........这里部分代码省略.........
示例4: postProcess
//.........这里部分代码省略.........
$this->_params['participant_source'] = $params['source'];
}
$this->_params['description'] = $this->_params['participant_source'];
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode);
$now = date('YmdHis');
$fields = array();
// set email for primary location.
$fields['email-Primary'] = 1;
$params['email-Primary'] = $params["email-{$this->_bltID}"] = $this->_contributorEmail;
$params['register_date'] = $now;
// now set the values for the billing location.
foreach ($this->_fields as $name => $dontCare) {
$fields[$name] = 1;
}
// also add location name to the array
$params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params);
$params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]);
$fields["address_name-{$this->_bltID}"] = 1;
$fields["email-{$this->_bltID}"] = 1;
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'contact_type');
$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;
}
}
$contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_contactId, NULL, NULL, $ctype);
}
if (!empty($this->_params['participant_role_id'])) {
$customFieldsRole = array();
foreach ($this->_params['participant_role_id'] as $roleKey) {
$customFieldsRole = CRM_Utils_Array::crmArrayMerge(CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $roleKey, $this->_roleCustomDataTypeID), $customFieldsRole);
}
$customFieldsEvent = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, CRM_Utils_Array::value('event_id', $params), $this->_eventNameCustomDataTypeID);
$customFieldsEventType = CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $this->_eventTypeId, $this->_eventTypeCustomDataTypeID);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsRole, CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, NULL, NULL, TRUE));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEvent, $customFields);
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsEventType, $customFields);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_id, 'Participant');
}
//do cleanup line items if participant edit the Event Fee.
if (($this->_lineItem || !isset($params['proceSetId'])) && !$this->_paymentId && $this->_id) {
CRM_Price_BAO_LineItem::deleteLineItems($this->_id, 'civicrm_participant');
}
if ($this->_mode) {
// add all the additional payment params we need
$this->_params["state_province-{$this->_bltID}"] = $this->_params["billing_state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvinceAbbreviation($this->_params["billing_state_province_id-{$this->_bltID}"]);
$this->_params["country-{$this->_bltID}"] = $this->_params["billing_country-{$this->_bltID}"] = CRM_Core_PseudoConstant::countryIsoCode($this->_params["billing_country_id-{$this->_bltID}"]);
$this->_params['year'] = CRM_Core_Payment_Form::getCreditCardExpirationYear($this->_params);
$this->_params['month'] = CRM_Core_Payment_Form::getCreditCardExpirationMonth($this->_params);
$this->_params['ip_address'] = CRM_Utils_System::ipAddress();
$this->_params['amount'] = $params['fee_amount'];
$this->_params['amount_level'] = $params['amount_level'];
$this->_params['currencyID'] = $config->defaultCurrency;
$this->_params['invoiceID'] = md5(uniqid(rand(), TRUE));
// at this point we've created a contact and stored its address etc
// all the payment processors expect the name and address to be in the
// so we copy stuff over to first_name etc.
$paymentParams = $this->_params;
if (!empty($this->_params['send_receipt'])) {
$paymentParams['email'] = $this->_contributorEmail;
}
// The only reason for merging in the 'contact_id' rather than ensuring it is set
// is that this patch is being done around the time of the stable release
示例5: postProcess
/**
* Process the form submission.
*
*
* @param array $params
* @return array|null
*/
public function postProcess($params = NULL)
{
if ($this->_action & CRM_Core_Action::DELETE) {
$deleteParams = array('id' => $this->_activityId);
$moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
// delete tags for the entity
$tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
CRM_Core_BAO_EntityTag::del($tagParams);
CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."), ts('Record Deleted'), 'success');
return NULL;
}
// store the submitted values in an array
if (!$params) {
$params = $this->controller->exportValues($this->_name);
}
// Set activity type id.
if (empty($params['activity_type_id'])) {
$params['activity_type_id'] = $this->_activityTypeId;
}
if (!empty($params['hidden_custom']) && !isset($params['custom'])) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_activityId, 'Activity');
}
// store the date with proper format
$params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
// format params as arrays
foreach (array('target', 'assignee', 'followup_assignee') as $name) {
if (!empty($params["{$name}_contact_id"])) {
$params["{$name}_contact_id"] = explode(',', $params["{$name}_contact_id"]);
} else {
$params["{$name}_contact_id"] = array();
}
}
// get ids for associated contacts
if (!$params['source_contact_id']) {
$params['source_contact_id'] = $this->_currentUserId;
}
if (isset($this->_activityId)) {
$params['id'] = $this->_activityId;
}
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
$activity = array();
if (!empty($params['is_multi_activity']) && !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])) {
$targetContacts = $params['target_contact_id'];
foreach ($targetContacts as $targetContactId) {
$params['target_contact_id'] = array($targetContactId);
// save activity
$activity[] = $this->processActivity($params);
}
} else {
// save activity
$activity = $this->processActivity($params);
}
$activityIds = empty($this->_activityIds) ? array($this->_activityId) : $this->_activityIds;
foreach ($activityIds as $activityId) {
// set params for repeat configuration in create mode
$params['entity_id'] = $activityId;
$params['entity_table'] = 'civicrm_activity';
if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
if ($checkParentExistsForThisId) {
$params['parent_entity_id'] = $checkParentExistsForThisId;
$scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']);
} else {
$params['parent_entity_id'] = $params['entity_id'];
$scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']);
}
if (property_exists($scheduleReminderDetails, 'id')) {
$params['schedule_reminder_id'] = $scheduleReminderDetails->id;
}
}
$params['dateColumns'] = array('activity_date_time');
// Set default repetition start if it was not provided.
if (empty($params['repetition_start_date'])) {
$params['repetition_start_date'] = $params['activity_date_time'];
}
// unset activity id
unset($params['id']);
$linkedEntities = array(array('table' => 'civicrm_activity_contact', 'findCriteria' => array('activity_id' => $activityId), 'linkedColumns' => array('activity_id'), 'isRecurringEntityRecord' => FALSE));
CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities);
}
return array('activity' => $activity);
}
示例6: whereClause
/**
* Given a list of conditions in params generate the required
* where clause
*
* @return void
* @access public
*/
function whereClause()
{
$this->_where[0] = array();
$this->_qill[0] = array();
$config = CRM_Core_Config::singleton();
$this->includeContactIds();
if (!empty($this->_params)) {
$activity = FALSE;
foreach (array_keys($this->_params) as $id) {
if (!CRM_Utils_Array::value(0, $this->_params[$id])) {
continue;
}
// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
if ($this->_params[$id][1] == 'IS NULL' || $this->_params[$id][1] == 'IS NOT NULL') {
$this->_where[0][] = "contact_a.id {$this->_params[$id][1]}";
} else {
$this->_where[0][] = "contact_a.id {$this->_params[$id][1]} {$this->_params[$id][2]}";
}
} else {
$this->whereClauseSingle($this->_params[$id]);
}
if (substr($this->_params[$id][0], 0, 9) == 'activity_') {
$activity = TRUE;
}
}
CRM_Core_Component::alterQuery($this, 'where');
}
if ($this->_customQuery) {
// Added following if condition to avoid the wrong value diplay for 'myaccount' / any UF info.
// Hope it wont affect the other part of civicrm.. if it does please remove it.
if (!empty($this->_customQuery->_where)) {
$this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
}
$this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
}
$clauses = array();
$andClauses = array();
$validClauses = 0;
if (!empty($this->_where)) {
foreach ($this->_where as $grouping => $values) {
if ($grouping > 0 && !empty($values)) {
$clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
$validClauses++;
}
}
if (!empty($this->_where[0])) {
$andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
}
if (!empty($clauses)) {
$andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
}
if ($validClauses > 1) {
$this->_useDistinct = TRUE;
}
}
return implode(' AND ', $andClauses);
}
示例7: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$tx = new CRM_Core_Transaction();
// check if dedupe button, if so return.
$buttonName = $this->controller->getButtonName();
if (isset($this->_dedupeButtonName) && $buttonName == $this->_dedupeButtonName) {
return;
}
if ($this->_action & CRM_Core_Action::DELETE) {
$statusMsg = NULL;
$caseDelete = CRM_Case_BAO_Case::deleteCase($this->_caseId, TRUE);
if ($caseDelete) {
$statusMsg = ts('The selected case has been moved to the Trash. You can view and / or restore deleted cases by checking the "Deleted Cases" option under Find Cases.<br />');
}
CRM_Core_Session::setStatus($statusMsg);
return;
}
if ($this->_action & CRM_Core_Action::RENEW) {
$statusMsg = NULL;
$caseRestore = CRM_Case_BAO_Case::restoreCase($this->_caseId);
if ($caseRestore) {
$statusMsg = ts('The selected case has been restored.<br />');
}
CRM_Core_Session::setStatus($statusMsg);
return;
}
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$params['now'] = date("Ymd");
// 1. call begin post process
if ($this->_activityTypeFile) {
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::beginPostProcess( \$this, \$params );");
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = array();
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, NULL, 'Case');
}
// 2. create/edit case
if (CRM_Utils_Array::value('case_type_id', $params)) {
$caseType = CRM_Case_PseudoConstant::caseType('name');
$params['case_type'] = $caseType[$params['case_type_id']];
$params['subject'] = $params['activity_subject'];
$params['case_type_id'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['case_type_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
}
$caseObj = CRM_Case_BAO_Case::create($params);
$params['case_id'] = $caseObj->id;
// unset any ids, custom data
unset($params['id'], $params['custom']);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
$tagParams = array();
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_case', $caseObj->id);
//save free tags
if (isset($params['case_taglist']) && !empty($params['case_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['case_taglist'], $caseObj->id, 'civicrm_case', $this);
}
// user context
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseObj->id}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
// 3. format activity custom data
if (CRM_Utils_Array::value('hidden_custom', $params)) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// 4. call end post process
if ($this->_activityTypeFile) {
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::endPostProcess( \$this, \$params );");
}
// 5. auto populate activites
// 6. set status
CRM_Core_Session::setStatus("{$params['statusMsg']}");
}
示例8: printPDF
//.........这里部分代码省略.........
$locationDefaults = CRM_Core_BAO_Location::getValues($locParams);
if (isset($locationDefaults['address'][1]['state_province_id'])) {
$stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']);
} else {
$stateProvinceAbbreviationDomain = '';
}
if (isset($locationDefaults['address'][1]['country_id'])) {
$countryDomain = CRM_Core_PseudoConstant::country($locationDefaults['address'][1]['country_id']);
} else {
$countryDomain = '';
}
// parameters to be assign for template
$tplParams = array('title' => $title, 'component' => $input['component'], 'id' => $contribution->id, 'source' => $source, 'invoice_id' => $invoiceId, 'resourceBase' => $config->userFrameworkResourceURL, 'defaultCurrency' => $config->defaultCurrency, 'amount' => $contribution->total_amount, 'amountDue' => $amountDue, 'invoice_date' => $invoiceDate, 'dueDate' => $dueDate, 'notes' => CRM_Utils_Array::value('notes', $prefixValue), 'display_name' => $contribution->_relatedObjects['contact']->display_name, 'lineItem' => $lineItem, 'dataArray' => $dataArray, 'refundedStatusId' => $refundedStatusId, 'contribution_status_id' => $contribution->contribution_status_id, 'subTotal' => $subTotal, 'street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'stateProvinceAbbreviation' => $stateProvinceAbbreviation, 'postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value($contribution->contact_id, $billingAddress)), 'is_pay_later' => $contribution->is_pay_later, 'organization_name' => $contribution->_relatedObjects['contact']->organization_name, 'domain_organization' => $domain->name, 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value('1', $locationDefaults['address'])), 'domain_state' => $stateProvinceAbbreviationDomain, 'domain_country' => $countryDomain, 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])), 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])));
if (isset($creditNoteId)) {
$tplParams['creditnote_id'] = $creditNoteId;
}
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_invoice_receipt', 'contactId' => $contribution->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'Invoice.pdf');
$session = CRM_Core_Session::singleton();
$contactID = $session->get('userID');
//CRM-16319 - we dont store in userID in case the user is doing multiple
//transactions etc
if (empty($contactID)) {
$contactID = $session->get('transaction.userID');
}
$contactEmails = CRM_Core_BAO_Email::allEmails($contactID);
$emails = array();
$fromDisplayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
foreach ($contactEmails as $emailId => $item) {
$email = $item['email'];
if ($email) {
$emails[$emailId] = '"' . $fromDisplayName . '" <' . $email . '> ';
}
}
$fromEmail = CRM_Utils_Array::crmArrayMerge($emails, CRM_Core_OptionGroup::values('from_email_address'));
// from email address
if (isset($params['from_email_address'])) {
$fromEmailAddress = CRM_Utils_Array::value($params['from_email_address'], $fromEmail);
}
// condition to check for download PDF Invoice or email Invoice
if ($invoiceElements['createPdf']) {
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
if (isset($params['forPage'])) {
return $html;
} else {
$mail = array('subject' => $subject, 'body' => $message, 'html' => $html);
if ($mail['html']) {
$messageInvoice[] = $mail['html'];
} else {
$messageInvoice[] = nl2br($mail['body']);
}
}
} elseif ($contribution->_component == 'contribute') {
$email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
$sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment']));
$sendTemplateParams['from'] = $fromEmailAddress;
$sendTemplateParams['toEmail'] = $email;
$sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values);
$sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values);
list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
// functions call for adding activity with attachment
$fileName = self::putFile($html);
self::addActivities($subject, $contribution->contact_id, $fileName, $params);
} elseif ($contribution->_component == 'event') {
$email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id);
$sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment']));
$sendTemplateParams['from'] = $fromEmailAddress;
示例9: getActivities
/**
* @param bool $printReport
*
* @return array
*/
public function getActivities($printReport = FALSE)
{
$retval = array();
/*
* Loop through the activities in the file and add them to the appropriate region array.
*/
$doc = new DOMDocument();
if ($doc->loadXML($this->xmlString)) {
$regionList = $this->auditConfig->getRegions();
$ifBlanks = $this->auditConfig->getIfBlanks();
$includeAll = $doc->getElementsByTagName("IncludeActivities")->item(0)->nodeValue;
$includeAll = $includeAll == 'All';
$activityindex = 0;
$activityList = $doc->getElementsByTagName("Activity");
$caseActivities = array();
$activityStatusType = array();
foreach ($activityList as $activity) {
$retval[$activityindex] = array();
$ifBlankReplacements = array();
$completed = FALSE;
$sortValues = array('1970-01-01');
$category = '';
$fieldindex = 1;
$fields = $activity->getElementsByTagName("Field");
foreach ($fields as $field) {
$datatype_elements = $field->getElementsByTagName("Type");
$datatype = $datatype_elements->item(0)->nodeValue;
$label_elements = $field->getElementsByTagName("Label");
$label = $label_elements->item(0)->nodeValue;
$value_elements = $field->getElementsByTagName("Value");
$value = $value_elements->item(0)->nodeValue;
$category_elements = $field->getElementsByTagName("Category");
if (!empty($category_elements->length)) {
$category = $category_elements->item(0)->nodeValue;
}
// Based on the config file, does this field's label and value indicate a completed activity?
if ($label == $this->auditConfig->getCompletionLabel() && $value == $this->auditConfig->getCompletionValue()) {
$completed = TRUE;
}
// Based on the config file, does this field's label match the one to use for sorting activities?
if (in_array($label, $this->auditConfig->getSortByLabels())) {
$sortValues[$label] = $value;
}
foreach ($regionList as $region) {
// Based on the config file, is this field a potential replacement for another?
if (!empty($ifBlanks[$region])) {
if (in_array($label, $ifBlanks[$region])) {
$ifBlankReplacements[$label] = $value;
}
}
if ($this->auditConfig->includeInRegion($label, $region)) {
$retval[$activityindex][$region][$fieldindex] = array();
$retval[$activityindex][$region][$fieldindex]['label'] = $label;
$retval[$activityindex][$region][$fieldindex]['datatype'] = $datatype;
$retval[$activityindex][$region][$fieldindex]['value'] = $value;
if ($datatype == 'Date') {
$retval[$activityindex][$region][$fieldindex]['includeTime'] = $this->auditConfig->includeTime($label, $region);
}
//CRM-4570
if ($printReport) {
if (!in_array($label, array('Activity Type', 'Status'))) {
$caseActivities[$activityindex][$fieldindex] = array();
$caseActivities[$activityindex][$fieldindex]['label'] = $label;
$caseActivities[$activityindex][$fieldindex]['datatype'] = $datatype;
$caseActivities[$activityindex][$fieldindex]['value'] = $value;
} else {
$activityStatusType[$activityindex][$fieldindex] = array();
$activityStatusType[$activityindex][$fieldindex]['label'] = $label;
$activityStatusType[$activityindex][$fieldindex]['datatype'] = $datatype;
$activityStatusType[$activityindex][$fieldindex]['value'] = $value;
}
}
}
}
$fieldindex++;
}
if ($printReport) {
$caseActivities[$activityindex] = CRM_Utils_Array::crmArrayMerge($activityStatusType[$activityindex], $caseActivities[$activityindex]);
$caseActivities[$activityindex]['sortValues'] = $sortValues;
}
if ($includeAll || !$completed) {
$retval[$activityindex]['completed'] = $completed;
$retval[$activityindex]['category'] = $category;
$retval[$activityindex]['sortValues'] = $sortValues;
// Now sort the fields based on the order in the config file.
foreach ($regionList as $region) {
$this->auditConfig->sort($retval[$activityindex][$region], $region);
}
$retval[$activityindex]['editurl'] = $activity->getElementsByTagName("EditURL")->item(0)->nodeValue;
// If there are any fields with ifBlank specified, replace their values.
// We need to do this as a second pass because if we do it while looping through fields we might not have come across the field we need yet.
foreach ($regionList as $region) {
foreach ($retval[$activityindex][$region] as &$v) {
$vlabel = $v['label'];
if (trim($v['value']) == '' && !empty($ifBlanks[$region][$vlabel])) {
//.........这里部分代码省略.........
示例10: processMembership
/**
* Process membership records.
*
* @param array $params
* Associated array of submitted values.
*
*
* @return bool
*/
private function processMembership(&$params)
{
$dateTypes = array('join_date' => 'joinDate', 'membership_start_date' => 'startDate', 'membership_end_date' => 'endDate');
$dates = array('join_date', 'start_date', 'end_date', 'reminder_date');
// get the price set associated with offline membership
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_membership_type_amount', 'id', 'name');
$this->_priceSet = $priceSets = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId));
if (isset($params['field'])) {
$customFields = array();
foreach ($params['field'] as $key => $value) {
// if contact is not selected we should skip the row
if (empty($params['primary_contact_id'][$key])) {
continue;
}
$value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']);
// update contact information
$this->updateContactInfo($value);
$membershipTypeId = $value['membership_type_id'] = $value['membership_type'][1];
foreach ($dateTypes as $dateField => $dateVariable) {
${$dateVariable} = CRM_Utils_Date::processDate($value[$dateField]);
$fDate[$dateField] = CRM_Utils_Array::value($dateField, $value);
}
$calcDates = array();
$calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId, $joinDate, $startDate, $endDate);
foreach ($calcDates as $memType => $calcDate) {
foreach ($dates as $d) {
//first give priority to form values then calDates.
$date = CRM_Utils_Array::value($d, $value);
if (!$date) {
$date = CRM_Utils_Array::value($d, $calcDate);
}
$value[$d] = CRM_Utils_Date::processDate($date);
}
}
if (!empty($value['send_receipt'])) {
$value['receipt_date'] = date('Y-m-d His');
}
if (!empty($value['membership_source'])) {
$value['source'] = $value['membership_source'];
}
unset($value['membership_source']);
//Get the membership status
if (!empty($value['membership_status'])) {
$value['status_id'] = $value['membership_status'];
unset($value['membership_status']);
}
if (empty($customFields)) {
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $membershipTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
}
//check for custom data
$value['custom'] = CRM_Core_BAO_CustomField::postProcess($params['field'][$key], $key, 'Membership', $membershipTypeId);
if (!empty($value['financial_type'])) {
$value['financial_type_id'] = $value['financial_type'];
}
if (!empty($value['payment_instrument'])) {
$value['payment_instrument_id'] = $value['payment_instrument'];
}
// handle soft credit
if (!empty($params['soft_credit_contact_id'][$key]) && !empty($params['soft_credit_amount'][$key])) {
$value['soft_credit'][$key]['contact_id'] = $params['soft_credit_contact_id'][$key];
$value['soft_credit'][$key]['amount'] = CRM_Utils_Rule::cleanMoney($params['soft_credit_amount'][$key]);
//CRM-15350: if soft-credit-type profile field is disabled or removed then
//we choose Gift as default value as per Gift Membership rule
if (!empty($params['soft_credit_type'][$key])) {
$value['soft_credit'][$key]['soft_credit_type_id'] = $params['soft_credit_type'][$key];
} else {
$value['soft_credit'][$key]['soft_credit_type_id'] = CRM_Core_OptionGroup::getValue('soft_credit_type', 'Gift', 'name');
}
}
if (!empty($value['receive_date'])) {
$value['receive_date'] = CRM_Utils_Date::processDate($value['receive_date'], $value['receive_date_time'], TRUE);
}
$params['actualBatchTotal'] += $value['total_amount'];
unset($value['financial_type']);
unset($value['payment_instrument']);
$value['batch_id'] = $this->_batchId;
$value['skipRecentView'] = TRUE;
// make entry in line item for contribution
$editedFieldParams = array('price_set_id' => $priceSetId, 'name' => $value['membership_type'][0]);
$editedResults = array();
CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
if (!empty($editedResults)) {
unset($this->_priceSet['fields']);
$this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
unset($this->_priceSet['fields'][$editedResults['id']]['options']);
$fid = $editedResults['id'];
$editedFieldParams = array('price_field_id' => $editedResults['id'], 'membership_type_id' => $value['membership_type_id']);
$editedResults = array();
CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
//.........这里部分代码省略.........
示例11: postProcess
//.........这里部分代码省略.........
$paymentParams['email'] = $this->_contributorEmail;
}
$paymentParams['contactID'] = $this->_contributorContactID;
CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $paymentParams, TRUE);
$payment = CRM_Core_Payment::singleton($this->_mode, $this->_paymentProcessor, $this);
if (!empty($paymentParams['auto_renew'])) {
$contributionRecurParams = $this->processRecurringContribution($paymentParams);
$this->_params['contributionRecurID'] = $contributionRecurParams['contributionRecurID'];
$paymentParams = array_merge($paymentParams, $contributionRecurParams);
}
$result = $payment->doDirectPayment($paymentParams);
if (is_a($result, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($result);
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"));
}
if ($result) {
$this->_params = array_merge($this->_params, $result);
}
$formValues['contribution_status_id'] = 1;
$formValues['invoice_id'] = $this->_params['invoiceID'];
$formValues['trxn_id'] = $result['trxn_id'];
$formValues['payment_instrument_id'] = 1;
$formValues['is_test'] = $this->_mode == 'live' ? 0 : 1;
$this->set('params', $this->_params);
$this->assign('trxn_id', $result['trxn_id']);
}
$renewalDate = NULL;
if ($formValues['renewal_date']) {
$this->set('renewalDate', CRM_Utils_Date::processDate($formValues['renewal_date']));
}
$this->_membershipId = $this->_id;
// membership type custom data
$customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, $formValues['membership_type_id'][1]);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, NULL, NULL, TRUE));
$customFieldsFormatted = CRM_Core_BAO_CustomField::postProcess($formValues, $customFields, $this->_id, 'Membership');
// check for test membership.
$isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test');
// chk for renewal for multiple terms CRM-8750
$numRenewTerms = 1;
if (is_numeric(CRM_Utils_Array::value('num_terms', $formValues))) {
$numRenewTerms = $formValues['num_terms'];
}
//if contribution status is pending then set pay later
if ($formValues['contribution_status_id'] == array_search('Pending', CRM_Contribute_PseudoConstant::contributionStatus())) {
$this->_params['is_pay_later'] = 1;
}
$renewMembership = CRM_Member_BAO_Membership::renewMembershipFormWrapper($this->_contactID, $formValues['membership_type_id'][1], $isTestMembership, $this, NULL, NULL, $customFieldsFormatted, $numRenewTerms, $this->_membershipId);
$endDate = CRM_Utils_Date::processDate($renewMembership->end_date);
// Retrieve the name and email of the current user - this will be the FROM for the receipt email
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
$memType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $renewMembership->membership_type_id, 'name');
if (!empty($formValues['record_contribution']) || $this->_mode) {
// set the source
$formValues['contribution_source'] = "{$memType} Membership: Offline membership renewal (by {$userName})";
//create line items
$lineItem = array();
$priceSetId = NULL;
CRM_Member_BAO_Membership::createLineItems($this, $formValues['membership_type_id'], $priceSetId);
CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$priceSetId]);
//CRM-11529 for quick config backoffice transactions
//when financial_type_id is passed in form, update the
//line items with the financial type selected in form
if ($submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues)) {
foreach ($lineItem[$priceSetId] as &$li) {
示例12: whereClause
/**
* Given a list of conditions in params generate the required.
* where clause
*
* @return string
*/
public function whereClause()
{
$this->_where[0] = array();
$this->_qill[0] = array();
$this->includeRelationshipIds();
if (!empty($this->_params)) {
foreach (array_keys($this->_params) as $id) {
if (empty($this->_params[$id][0])) {
continue;
}
// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'relationship_id') {
$this->_where[0][] = self::buildClause("relationship.id", $this->_params[$id][1], $this->_params[$id][2]);
} else {
$this->whereClauseSingle($this->_params[$id]);
}
}
}
if ($this->_customQuery) {
if (!empty($this->_customQuery->_where)) {
$this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
}
$this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
}
$clauses = array();
$andClauses = array();
$validClauses = 0;
if (!empty($this->_where)) {
foreach ($this->_where as $grouping => $values) {
if ($grouping > 0 && !empty($values)) {
$clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
$validClauses++;
}
}
if (!empty($this->_where[0])) {
$andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
}
if (!empty($clauses)) {
$andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
}
if ($validClauses > 1) {
$this->_useDistinct = TRUE;
}
}
return implode(' AND ', $andClauses);
}
示例13: whereClause
/**
* Given a list of conditions in params generate the required where clause.
*
* @param string $apiEntity
*
* @return string
*/
public function whereClause($apiEntity = NULL)
{
$this->_where[0] = array();
$this->_qill[0] = array();
$this->includeContactIds();
if (!empty($this->_params)) {
foreach (array_keys($this->_params) as $id) {
if (empty($this->_params[$id][0])) {
continue;
}
// check for both id and contact_id
if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
$this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
} else {
$this->whereClauseSingle($this->_params[$id], $apiEntity);
}
}
CRM_Core_Component::alterQuery($this, 'where');
CRM_Contact_BAO_Query_Hook::singleton()->alterSearchQuery($this, 'where');
}
if ($this->_customQuery) {
// Added following if condition to avoid the wrong value display for 'my account' / any UF info.
// Hope it wont affect the other part of civicrm.. if it does please remove it.
if (!empty($this->_customQuery->_where)) {
$this->_where = CRM_Utils_Array::crmArrayMerge($this->_where, $this->_customQuery->_where);
}
$this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill);
}
$clauses = array();
$andClauses = array();
$validClauses = 0;
if (!empty($this->_where)) {
foreach ($this->_where as $grouping => $values) {
if ($grouping > 0 && !empty($values)) {
$clauses[$grouping] = ' ( ' . implode(" {$this->_operator} ", $values) . ' ) ';
$validClauses++;
}
}
if (!empty($this->_where[0])) {
$andClauses[] = ' ( ' . implode(" {$this->_operator} ", $this->_where[0]) . ' ) ';
}
if (!empty($clauses)) {
$andClauses[] = ' ( ' . implode(' OR ', $clauses) . ' ) ';
}
if ($validClauses > 1) {
$this->_useDistinct = TRUE;
}
}
return implode(' AND ', $andClauses);
}
示例14: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
$checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active');
foreach ($checkBoxes as $key) {
if (!isset($params[$key])) {
$params[$key] = 0;
}
}
$session = CRM_Core_Session::singleton();
$contactID = isset($this->_contactID) ? $this->_contactID : $session->get('userID');
if (!$contactID) {
$contactID = $this->get('contactID');
}
$params['title'] = $params['pcp_title'];
$params['intro_text'] = $params['pcp_intro_text'];
$params['contact_id'] = $contactID;
$params['page_id'] = $this->get('component_page_id') ? $this->get('component_page_id') : $this->_contriPageId;
$params['page_type'] = $this->_component;
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
$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']);
$approval_needed = $pcpBlock->is_approval_needed;
$approvalMessage = NULL;
if ($this->get('action') & CRM_Core_Action::ADD) {
$params['status_id'] = $approval_needed ? 1 : 2;
$approvalMessage = $approval_needed ? ts('but requires administrator review before you can begin promoting your campaign. You will receive an email confirmation shortly which includes a link to return to this page.') : ts('and is ready to use.');
}
$params['id'] = $this->_pageId;
$pcp = CRM_PCP_BAO_PCP::add($params, FALSE);
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_pcp', $pcp->id);
//MV: update Custom Values
if (!empty($params['hidden_custom']) && CRM_Core_Permission::check('administer CiviCRM')) {
$customFields = CRM_Core_BAO_CustomField::getFields('PCP');
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('PCP'));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $pcpBlock->entity_id, 'PCP');
//API to Update Custom Values;
$customApiParams = array('version' => 3, 'entity_id' => $params['id']);
foreach ($params['custom'] as $elementId => $elementValues) {
$elementValue = array_values($elementValues);
$customApiParams['custom_' . $elementId] = $elementValue[0]['value'];
if ($elementValue['id']) {
$customApiParams['id'] = $elementValue[0]['id'];
}
}
$temp = civicrm_api3('CustomValue', 'create', $customApiParams);
}
//END
$pageStatus = isset($this->_pageId) ? ts('updated') : ts('created');
$statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id');
//send notification of PCP create/update.
$pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id);
$notifyParams = array();
$notifyStatus = "";
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email'));
if ($emails = $pcpBlock->notify_email) {
$this->assign('pcpTitle', $pcp->title);
if ($this->_pageId) {
$this->assign('mode', 'Update');
} else {
$this->assign('mode', 'Add');
}
$pcpStatus = CRM_Core_OptionGroup::getLabel('pcp_status', $statusId);
$this->assign('pcpStatus', $pcpStatus);
$this->assign('pcpId', $pcp->id);
$supporterUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$pcp->contact_id}", TRUE, NULL, FALSE, FALSE);
$this->assign('supporterUrl', $supporterUrl);
$supporterName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $pcp->contact_id, 'display_name');
$this->assign('supporterName', $supporterName);
if ($this->_component == 'contribute') {
$pageUrl = CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $pcpBlock->entity_id, 'title');
} elseif ($this->_component == 'event') {
$pageUrl = CRM_Utils_System::url('civicrm/event', "reset=1&id={$pcpBlock->entity_id}", TRUE, NULL, FALSE, TRUE);
$contribPageTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpBlock->entity_id, 'title');
}
$this->assign('contribPageUrl', $pageUrl);
$this->assign('contribPageTitle', $contribPageTitle);
$managePCPUrl = CRM_Utils_System::url('civicrm/admin/pcp', "reset=1", TRUE, NULL, FALSE, FALSE);
$this->assign('managePCPUrl', $managePCPUrl);
//.........这里部分代码省略.........
示例15: postProcess
/**
* Function to process the form
*
* @access public
*
* @return void
*/
public function postProcess()
{
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Grant_BAO_Grant::del($this->_id);
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$ids['grant_id'] = $this->_id;
}
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
if (empty($params['grant_report_received'])) {
$params['grant_report_received'] = "null";
}
// set the contact, when contact is selected
if ($this->_context == 'standalone') {
$this->_contactID = $params['contact_id'];
}
$params['contact_id'] = $this->_contactID;
$ids['note'] = array();
if ($this->_noteId) {
$ids['note']['id'] = $this->_noteId;
}
// build custom data getFields array
$customFieldsGrantType = CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, CRM_Utils_Array::value('grant_type_id', $params));
$customFields = CRM_Utils_Array::crmArrayMerge($customFieldsGrantType, CRM_Core_BAO_CustomField::getFields('Grant', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_id, 'Grant');
// add attachments as needed
CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_grant', $this->_id);
$grant = CRM_Grant_BAO_Grant::create($params, $ids);
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();
if ($this->_context == 'standalone') {
if ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/add', 'reset=1&action=add&context=standalone'));
} else {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactID}&selectedChild=grant"));
}
} elseif ($buttonName == $this->getButtonName('upload', 'new')) {
$session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/grant', "reset=1&action=add&context=grant&cid={$this->_contactID}"));
}
}