本文整理汇总了PHP中CRM_Contact_BAO_Contact_Utils类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Utils类的具体用法?PHP CRM_Contact_BAO_Contact_Utils怎么用?PHP CRM_Contact_BAO_Contact_Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Contact_BAO_Contact_Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the page.
*
* This method is called after the page is created.
*/
public function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
$address = array();
if ($addressId > 0) {
$locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
$entityBlock = array('id' => $addressId);
$address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
if (!empty($address)) {
foreach ($address as $key => &$value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
}
// we just need current address block
$currentAddressBlock['address'][$locBlockNo] = array_pop($address);
if (!empty($currentAddressBlock['address'][$locBlockNo])) {
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
foreach ($currentAddressBlock['address'] as $key => $addressValue) {
if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
$idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
$idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
}
// add custom data of type address
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $idValue);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
$this->assign("dnc_viewCustomData", NULL);
$this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
$this->assign('sharedAddresses', $sharedAddresses);
}
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contactId;
$contact->find(TRUE);
$privacy = array();
foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
if (isset($contact->{$name})) {
$privacy[$name] = $contact->{$name};
}
}
$this->assign('contactId', $contactId);
$this->assign('locationIndex', $locBlockNo);
$this->assign('addressId', $addressId);
$this->assign('privacy', $privacy);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例2: run
/**
* Run the page.
*
* This method is called after the page is created.
*
* @return void
* @access public
*
*/
function run()
{
// get the emails for this contact
$contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
$addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
$address = array();
if ($addressId > 0) {
$locationTypes = CRM_Core_PseudoConstant::locationDisplayName();
$entityBlock = array('id' => $addressId);
$address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
if (!empty($address)) {
foreach ($address as $key => &$value) {
$value['location_type'] = $locationTypes[$value['location_type_id']];
}
}
}
// we just need current address block
$currentAddressBlock['address'][$locBlockNo] = array_pop($address);
if (!empty($currentAddressBlock['address'][$locBlockNo])) {
// get contact name of shared contact names
$sharedAddresses = array();
$shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
foreach ($currentAddressBlock['address'] as $key => $addressValue) {
if (CRM_Utils_Array::value('master_id', $addressValue) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
$sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
}
}
// add custom data of type address
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $currentAddressBlock['address'][$locBlockNo]['id']);
// we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
$currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
$this->assign("dnc_viewCustomData", NULL);
$this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
$this->assign('sharedAddresses', $sharedAddresses);
}
$this->assign('contactId', $contactId);
$this->assign('locationIndex', $locBlockNo);
$this->assign('addressId', $addressId);
$appendBlockIndex = CRM_Core_BAO_Address::getAddressCount($contactId);
// check if we are adding new address, then only append add link
if ($appendBlockIndex == $locBlockNo) {
if ($appendBlockIndex) {
$appendBlockIndex++;
}
} else {
$appendBlockIndex = 0;
}
$this->assign('appendBlockIndex', $appendBlockIndex);
// check logged in user permission
CRM_Contact_Page_View::checkUserPermission($this, $contactId);
// finally call parent
parent::run();
}
示例3: preProcess
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess()
{
// initialize the task and row fields
parent::preProcess();
//get the contact read only fields to display.
$readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_memberIds, 'CiviMember', $returnProperties);
$this->assign('contactDetails', $contactDetails);
$this->assign('readOnlyFields', $readOnlyFields);
}
示例4: preProcess
/**
* Set variables up before form is built.
*/
public function preProcess()
{
$this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->_crid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
// Are we cancelling a recurring contribution that is linked to an auto-renew membership?
if ($this->_subscriptionDetails->membership_id) {
$this->_mid = $this->_subscriptionDetails->membership_id;
}
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
}
if ($this->_mid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'info');
$this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_mid, 'membership', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_mid, 'membership');
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
$membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_mid, 'membership_type_id');
$this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes));
$this->_mode = 'auto_renew';
}
if (!$this->_crid && !$this->_coid && !$this->_mid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to cancel subscription.'));
}
$this->_selfService = TRUE;
}
if (!$this->_paymentProcessor['object']->isSupported('updateSubscriptionBillingInfo')) {
CRM_Core_Error::fatal(ts("%1 processor doesn't support updating subscription billing details.", array(1 => $this->_paymentProcessor['object']->_processorName)));
}
$this->assign('paymentProcessor', $this->_paymentProcessor);
$this->assignBillingType();
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
$this->assign('amount', $this->_subscriptionDetails->amount);
$this->assign('installments', $this->_subscriptionDetails->installments);
$this->assign('mode', $this->_mode);
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
}
示例5: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
/*
* initialize the task and row fields
*/
parent::preProcess();
//get the contact read only fields to display.
require_once 'CRM/Core/BAO/Preferences.php';
$readOnlyFields = array_merge(array('sort_name' => ts('Name')), CRM_Core_BAO_Preferences::valueOptions('contact_autocomplete_options', true, null, false, 'name', true));
//get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_contributionIds, 'CiviContribute', $returnProperties);
$this->assign('contactDetails', $contactDetails);
$this->assign('readOnlyFields', $readOnlyFields);
}
示例6: preProcess
public function preProcess()
{
$this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
if ($this->_crid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
}
$this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
if ($this->_coid) {
$this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
$this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
$this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
$this->_crid = $this->_subscriptionDetails->recur_id;
} elseif ($this->_crid) {
$this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_crid, 'id', 'contribution_recur_id');
}
if (!$this->_crid || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
CRM_Core_Error::fatal('Required information missing.');
}
if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
}
if (!CRM_Core_Permission::check('edit contributions')) {
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
}
$this->_selfService = TRUE;
}
$this->assign('self_service', $this->_selfService);
if (!$this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
$userAlert = ts('Updates made using this form will change the recurring contribution information stored in your CiviCRM database, but will NOT be sent to the payment processor. You must enter the same changes using the payment processor web site.');
CRM_Core_Session::setStatus($userAlert, ts('Warning'), 'alert');
}
$this->assign('isChangeSupported', $this->_paymentProcessorObj->isSupported('changeSubscriptionAmount'));
$this->assign('paymentProcessor', $this->_paymentProcessor);
$this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
$this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
if ($this->_subscriptionDetails->contact_id) {
list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
}
CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
// handle context redirection
CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
}
示例7: testProfileChecksum
public function testProfileChecksum()
{
$this->webtestLogin('admin');
// Profile fields.
$fields = array('first_name' => array('type' => 'Individual', 'label' => 'First Name', 'default_value' => substr(sha1(rand()), 0, 7), 'update_value' => substr(sha1(rand()), 0, 7), 'element_name' => 'first_name'), 'last_name' => array('type' => 'Individual', 'label' => 'Last Name', 'default_value' => substr(sha1(rand()), 0, 7), 'update_value' => substr(sha1(rand()), 0, 7), 'element_name' => 'last_name'), 'email' => array('type' => 'Contact', 'label' => 'Email', 'location' => 0, 'default_value' => substr(sha1(rand()), 0, 5) . '@example.com', 'update_value' => substr(sha1(rand()), 0, 7) . '@example.com', 'element_name' => 'email-Primary'), 'city' => array('type' => 'Contact', 'label' => 'City', 'location' => 0, 'default_value' => substr(sha1(rand()), 0, 7), 'update_value' => substr(sha1(rand()), 0, 7), 'element_name' => 'city-Primary'), 'country' => array('type' => 'Contact', 'label' => 'Country', 'location' => 0, 'default_value' => '1228', 'update_value' => '1228', 'update_value_label' => 'UNITED STATES', 'element_name' => 'country-Primary', 'html_type' => 'select'), 'state_province' => array('type' => 'Contact', 'label' => 'State', 'location' => 0, 'default_value' => '1004', 'update_value' => '1031', 'update_value_label' => 'NY', 'element_name' => 'state_province-Primary', 'html_type' => 'select'));
// Create a contact.
$this->webtestAddContact($fields['first_name']['default_value'], $fields['last_name']['default_value'], $fields['email']['default_value']);
// Get contact id from url.
$contactId = $this->urlArg('cid');
// Create profile for contact
$profileName = "Profile_" . substr(sha1(rand()), 0, 7);
$profileId = $this->_testCreateContactProfile($fields, $profileName);
// Check for profile create/edit permissions.
$permission = array('edit-1-profile-edit', 'edit-1-profile-create', 'edit-1-access-all-custom-data', 'edit-1-edit-all-contacts');
$this->changePermissions($permission);
// Get checksum of the newly created contact.
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId);
// logout.
$this->webtestLogout();
// Go to edit profile page of the created contact.
$this->openCiviPage("profile/edit", "id={$contactId}&gid={$profileId}&reset=1&cs={$cs}", NULL);
$this->waitForTextPresent($profileName);
// Check all profile fields, update their values.
foreach ($fields as $field) {
$this->assertTrue($this->isElementPresent($field['element_name']), "Missing Field: {$field['label']}.");
if (isset($field['html_type']) && $field['html_type'] == 'select') {
$this->waitForElementPresent($field['element_name']);
$this->select($field['element_name'], "value={$field['update_value']}");
} else {
$this->type($field['element_name'], $field['update_value']);
}
}
// Save profile.
$this->click("_qf_Edit_next");
$this->waitForPageToLoad(2 * $this->getTimeoutMsec());
// Check profile view page.
$this->waitForTextPresent($profileName);
// Check updated values of all fields.
$checkFieldValues = array();
foreach ($fields as $field) {
$checkFieldValues[] = isset($field['update_value_label']) ? $field['update_value_label'] : $field['update_value'];
}
$this->assertStringsPresent($checkFieldValues);
}
示例8: preProcess
/**
* Build all the data structures needed to build the form.
*
* @return void
*/
public function preProcess()
{
// initialize the task and row fields
parent::preProcess();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
$validate = FALSE;
//validations
if (count($this->_contactIds) > $this->_maxContacts) {
CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Batch Update is %1. You have selected %2. Please select fewer contacts from your search results and try again.", array(1 => $this->_maxContacts, 2 => count($this->_contactIds))), ts('Maximum Exceeded'), 'error');
$validate = TRUE;
}
if (CRM_Contact_BAO_Contact_Utils::checkContactType($this->_contactIds)) {
CRM_Core_Session::setStatus(ts("Batch update requires that all selected contacts be the same basic type (e.g. all Individuals OR all Organizations...). Please modify your selection and try again."), ts('Contact Type Mismatch'), 'error');
$validate = TRUE;
}
// than redirect
if ($validate) {
CRM_Utils_System::redirect($this->_userContext);
}
}
示例9: preProcess
/**
* Build all the data structures needed to build the form.
*/
public function preProcess()
{
// Initialize the task and row fields.
parent::preProcess();
// Get the contact read only fields to display.
$readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')), CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE));
// Get the read only field data.
$returnProperties = array_fill_keys(array_keys($readOnlyFields), 1);
$contactDetails = CRM_Contact_BAO_Contact_Utils::contactDetails($this->_activityHolderIds, 'Activity', $returnProperties);
$readOnlyFields['assignee_display_name'] = ts('Assigned to');
if (!empty($contactDetails)) {
foreach ($contactDetails as $key => $value) {
$assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
foreach ($assignee as $keys => $values) {
$assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values);
}
$contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
}
}
$this->assign('contactDetails', $contactDetails);
$this->assign('readOnlyFields', $readOnlyFields);
}
示例10: preProcess
/**
* build all the data structures needed to build the form
*
* @return void
* @access public
*/
function preProcess()
{
/*
* initialize the task and row fields
*/
parent::preProcess();
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();
$validate = FALSE;
//validations
if (count($this->_contactIds) > $this->_maxContacts) {
CRM_Core_Session::setStatus("The maximum number of contacts you can select for Batch Update is {$this->_maxContacts}. You have selected " . count($this->_contactIds) . ". Please select fewer contacts from your search results and try again.");
$validate = TRUE;
}
if (CRM_Contact_BAO_Contact_Utils::checkContactType($this->_contactIds)) {
CRM_Core_Session::setStatus("Batch update requires that all selected contacts be the same type (e.g. all Individuals OR all Organizations...). Please modify your selected contacts and try again.");
$validate = TRUE;
}
// than redirect
if ($validate) {
CRM_Utils_System::redirect($this->_userContext);
}
}
示例11: sendTransitionParticipantMail
/**
* Send mail and create activity
* when participant status changed.
*
* @param int $participantId
* Participant id.
* @param array $participantValues
* Participant detail values. status id for participants.
* @param array $eventDetails
* Required event details.
* @param array $contactDetails
* Required contact details.
* @param array $domainValues
* Required domain values.
* @param string $mailType
* (eg 'approval', 'confirm', 'expired' ).
*
* @return bool
*/
public static function sendTransitionParticipantMail($participantId, $participantValues, $eventDetails, $contactDetails, &$domainValues, $mailType)
{
//send emails.
$mailSent = FALSE;
//don't send confirmation mail to additional
//since only primary able to confirm registration.
if (!empty($participantValues['registered_by_id']) && $mailType == 'Confirm') {
return $mailSent;
}
$toEmail = CRM_Utils_Array::value('email', $contactDetails);
if ($toEmail) {
$contactId = $participantValues['contact_id'];
$participantName = $contactDetails['display_name'];
//calculate the checksum value.
$checksumValue = NULL;
if ($mailType == 'Confirm' && !$participantValues['registered_by_id']) {
$checksumLife = 'inf';
$endDate = CRM_Utils_Array::value('end_date', $eventDetails);
if ($endDate) {
$checksumLife = (CRM_Utils_Date::unixTime($endDate) - time()) / (60 * 60);
}
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId, NULL, $checksumLife);
}
//take a receipt from as event else domain.
$receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>';
if (!empty($eventDetails['confirm_from_name']) && !empty($eventDetails['confirm_from_email'])) {
$receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>';
}
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'participant_' . strtolower($mailType), 'contactId' => $contactId, 'tplParams' => array('contact' => $contactDetails, 'domain' => $domainValues, 'participant' => $participantValues, 'event' => $eventDetails, 'paidEvent' => CRM_Utils_Array::value('is_monetary', $eventDetails), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $eventDetails), 'isAdditional' => $participantValues['registered_by_id'], 'isExpired' => $mailType == 'Expired', 'isConfirm' => $mailType == 'Confirm', 'checksumValue' => $checksumValue), 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails)));
// 3. create activity record.
if ($mailSent) {
$now = date('YmdHis');
$activityType = 'Event Registration';
$activityParams = array('subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $participantId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($now), 'due_date_time' => CRM_Utils_Date::isoToMysql($participantValues['register_date']), 'is_test' => $participantValues['is_test'], 'status_id' => 2);
if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) {
CRM_Core_Error::fatal('Failed creating Activity for expiration mail');
}
}
}
return $mailSent;
}
示例12: array
/**
* Returns all the rows in the given offset and rowCount.
*
* @param string $action
* The action being performed.
* @param int $offset
* The row number to start from.
* @param int $rowCount
* The number of rows to return.
* @param string $sort
* The sql string that describes the sort order.
* @param string $output
* What should the result set include (web/email/csv).
*
* @return array
* rows in the given offset and rowCount
*/
public function &getRows($action, $offset, $rowCount, $sort, $output = NULL)
{
$result = $this->_query->searchQuery($offset, $rowCount, $sort, FALSE, FALSE, FALSE, FALSE, FALSE, $this->_eventClause);
// process the result of the query
$rows = array();
//lets handle view, edit and delete separately. CRM-4418
$permissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit event participants')) {
$permissions[] = CRM_Core_Permission::EDIT;
}
if (CRM_Core_Permission::check('delete in CiviEvent')) {
$permissions[] = CRM_Core_Permission::DELETE;
}
$mask = CRM_Core_Action::mask($permissions);
$statusTypes = CRM_Event_PseudoConstant::participantStatus();
$statusClasses = CRM_Event_PseudoConstant::participantStatusClass();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
//get all campaigns.
$allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
while ($result->fetch()) {
$row = array();
// the columns we are interested in
foreach (self::$_properties as $property) {
if (isset($result->{$property})) {
$row[$property] = $result->{$property};
}
}
//carry campaign on selectors.
$row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns);
$row['campaign_id'] = $result->participant_campaign_id;
// gross hack to show extra information for pending status
$statusClass = NULL;
if (isset($row['participant_status_id']) && ($statusId = array_search($row['participant_status_id'], $statusTypes))) {
$statusClass = $statusClasses[$statusId];
}
$row['showConfirmUrl'] = $statusClass == 'Pending' ? TRUE : FALSE;
if (!empty($row['participant_is_test'])) {
$row['participant_status'] .= ' (' . ts('test') . ')';
}
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->participant_id;
$links = self::links($this->_key, $this->_context, $this->_compContext);
if ($statusTypes[$row['participant_status_id']] == 'Partially paid') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment'));
}
if ($statusTypes[$row['participant_status_id']] == 'Pending refund') {
$links[CRM_Core_Action::ADD] = array('name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund'));
}
$row['action'] = CRM_Core_Action::formLink($links, $mask, array('id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context), ts('more'), FALSE, 'participant.selector.row', 'Participant', $result->participant_id);
$row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id);
$row['paid'] = CRM_Event_BAO_Event::isMonetary($row['event_id']);
if (!empty($row['participant_fee_level'])) {
CRM_Event_BAO_Participant::fixEventLevel($row['participant_fee_level']);
}
if (CRM_Event_BAO_Event::usesPriceSet($row['event_id'])) {
// add line item details if applicable
$lineItems[$row['participant_id']] = CRM_Price_BAO_LineItem::getLineItems($row['participant_id']);
}
if (!empty($row['participant_role_id'])) {
$viewRoles = array();
foreach (explode($sep, $row['participant_role_id']) as $k => $v) {
$viewRoles[] = $participantRoles[$v];
}
$row['participant_role_id'] = implode(', ', $viewRoles);
}
$rows[] = $row;
}
CRM_Core_Selector_Controller::$_template->assign_by_ref('lineItems', $lineItems);
return $rows;
}
示例13: checkDuplicateContacts
/**
* Function to that checks for duplicate contacts
*
* @param array $fields fields array which are submitted
* @param array $error error message array
* @param int $contactID contact id
* @param string $contactType contact type
*/
static function checkDuplicateContacts(&$fields, &$errors, $contactID, $contactType)
{
// if this is a forced save, ignore find duplicate rule
if (!CRM_Utils_Array::value('_qf_Contact_upload_duplicate', $fields)) {
require_once 'CRM/Dedupe/Finder.php';
$dedupeParams = CRM_Dedupe_Finder::formatParams($fields, $contactType);
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $contactType, 'Fuzzy', array($contactID));
if ($ids) {
$viewUrls = array();
$editUrls = array();
require_once 'CRM/Contact/BAO/Contact/Utils.php';
list($viewUrls, $editUrls, $mergeUrl) = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, true, true, $contactID);
$viewUrl = implode(', ', $viewUrls);
$editUrl = implode(', ', $editUrls);
$errors['_qf_default'] = ts('One matching contact was found.', array('count' => count($editUrls), 'plural' => '%count matching contacts were found.'));
$errors['_qf_default'] .= '<br />';
$errors['_qf_default'] .= ts('If you need to verify if this is the same contact, click here - %1 - to VIEW the existing contact in a new tab.', array(1 => $viewUrl, 'count' => count($viewUrls), 'plural' => 'If you need to verify whether one of these is the same contact, click here - %1 - to VIEW the existing contact in a new tab.'));
$errors['_qf_default'] .= '<br />';
$errors['_qf_default'] .= ts('If you know the record you are creating is a duplicate, click here - %1 - to EDIT the original record instead.', array(1 => $editUrl));
$errors['_qf_default'] .= '<br />';
//allow to merge with matching contact, CRM-3160
if (!empty($mergeUrl)) {
$errors['_qf_default'] .= ts('If you know the record you are editing is a duplicate, click here - %1 - to MERGE with the existing record instead.', array(1 => $mergeUrl));
$errors['_qf_default'] .= '<br />';
}
$errors['_qf_default'] .= ts('If you are sure this is NOT a duplicate, click the "Save Matching Contact" button (this button is located at the bottom of the Contact Details section below).');
// let smarty know that there are duplicates
$template =& CRM_Core_Smarty::singleton();
$template->assign('isDuplicate', 1);
} else {
if (CRM_Utils_Array::value('_qf_Contact_refresh_dedupe', $fields)) {
// add a session message for no matching contacts
CRM_Core_Session::setStatus('No matching contact found.');
}
}
}
}
示例14: setDb
/**
* Update the DB record for this setting.
*
* @param string $name
* The simple name of the setting.
* @param mixed $value
* The new value of the setting.
*/
protected function setDb($name, $value)
{
if (\CRM_Core_BAO_Setting::isUpgradeFromPreFourOneAlpha1()) {
// civicrm_setting table is not going to be present.
return;
}
$fields = array();
$fieldsToSet = \CRM_Core_BAO_Setting::validateSettingsInput(array($name => $value), $fields);
//We haven't traditionally validated inputs to setItem, so this breaks things.
//foreach ($fieldsToSet as $settingField => &$settingValue) {
// self::validateSetting($settingValue, $fields['values'][$settingField]);
//}
$metadata = $fields['values'][$name];
$dao = new \CRM_Core_DAO_Setting();
$dao->name = $name;
$dao->domain_id = $this->domainId;
if ($this->contactId) {
$dao->contact_id = $this->contactId;
$dao->is_domain = 0;
} else {
$dao->is_domain = 1;
}
$dao->find(TRUE);
if (isset($metadata['on_change'])) {
foreach ($metadata['on_change'] as $callback) {
call_user_func(\Civi\Core\Resolver::singleton()->get($callback), unserialize($dao->value), $value, $metadata, $this->domainId);
}
}
if (\CRM_Utils_System::isNull($value)) {
$dao->value = 'null';
} else {
$dao->value = serialize($value);
}
$dao->created_date = \CRM_Utils_Time::getTime('Ymdhis');
$session = \CRM_Core_Session::singleton();
if (\CRM_Contact_BAO_Contact_Utils::isContactId($session->get('userID'))) {
$dao->created_id = $session->get('userID');
}
$dao->save();
$dao->free();
}
示例15: authenticatePledgeUser
/**
* Function to authenticate pledge user during online payment.
*
* @access public
*
* @return None
*/
public function authenticatePledgeUser()
{
//get the userChecksum and contact id
$userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this);
$contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
//get pledge status and contact id
$pledgeValues = array();
$pledgeParams = array('id' => $this->_values['pledge_id']);
$returnProperties = array('contact_id', 'status_id');
CRM_Core_DAO::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties);
//get all status
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$validStatus = array(array_search('Pending', $allStatus), array_search('In Progress', $allStatus), array_search('Overdue', $allStatus));
$validUser = FALSE;
if ($this->_userID && $this->_userID == $pledgeValues['contact_id']) {
//check for authenticated user.
$validUser = TRUE;
} elseif ($userChecksum && $pledgeValues['contact_id']) {
//check for anonymous user.
$validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($pledgeValues['contact_id'], $userChecksum);
//make sure cid is same as pledge contact id
if ($validUser && $pledgeValues['contact_id'] != $contactID) {
$validUser = FALSE;
}
}
if (!$validUser) {
CRM_Core_Error::fatal(ts("Oops. It looks like you have an incorrect or incomplete link (URL). Please make sure you've copied the entire link, and try again. Contact the site administrator if this error persists."));
}
//check for valid pledge status.
if (!in_array($pledgeValues['status_id'], $validStatus)) {
CRM_Core_Error::fatal(ts('Oops. You cannot make a payment for this pledge - pledge status is %1.', array(1 => CRM_Utils_Array::value($pledgeValues['status_id'], $allStatus))));
}
}