本文整理汇总了PHP中CRM_Contact_BAO_Contact_Utils::generateChecksum方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact_Utils::generateChecksum方法的具体用法?PHP CRM_Contact_BAO_Contact_Utils::generateChecksum怎么用?PHP CRM_Contact_BAO_Contact_Utils::generateChecksum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact_Utils
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact_Utils::generateChecksum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: getContactTokenReplacement
/**
* @param $token
* @param $contact
* @param bool $html
* @param bool $returnBlankToken
* @param bool $escapeSmarty
*
* @return bool|mixed|null|string
*/
public static function getContactTokenReplacement($token, &$contact, $html = FALSE, $returnBlankToken = FALSE, $escapeSmarty = FALSE)
{
if (self::$_tokens['contact'] == NULL) {
/* This should come from UF */
self::$_tokens['contact'] = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields('All')), array('checksum', 'contact_id'));
}
// Construct value from $token and $contact
$value = NULL;
$noReplace = FALSE;
// Support legacy tokens
$token = CRM_Utils_Array::value($token, self::legacyContactTokens(), $token);
// check if the token we were passed is valid
// we have to do this because this function is
// called only when we find a token in the string
if (!in_array($token, self::$_tokens['contact'])) {
$noReplace = TRUE;
} elseif ($token == 'checksum') {
$hash = CRM_Utils_Array::value('hash', $contact);
$contactID = CRM_Utils_Array::retrieveValueRecursive($contact, 'contact_id');
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, NULL, $hash);
$value = "cs={$cs}";
} else {
$value = CRM_Utils_Array::retrieveValueRecursive($contact, $token);
// FIXME: for some pseudoconstants we get array ( 0 => id, 1 => label )
if (is_array($value)) {
$value = $value[1];
} elseif ($value && is_numeric($value)) {
$allFields = CRM_Contact_BAO_Contact::exportableFields('All');
if (!empty($allFields[$token]['pseudoconstant'])) {
$value = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', $token, $value);
}
}
}
if (!$html) {
$value = str_replace('&', '&', $value);
}
// if null then return actual token
if ($returnBlankToken && !$value) {
$noReplace = TRUE;
}
if ($noReplace) {
$value = "{contact.{$token}}";
}
if ($escapeSmarty && !($returnBlankToken && $noReplace)) {
// $returnBlankToken means the caller wants to do further attempts at
// processing unreplaced tokens -- so don't escape them yet in this case.
$value = self::tokenEscapeSmarty($value);
}
return $value;
}
示例4: subscriptionURL
/**
* Get the subscription URL.
*
* @param int $entityID
* @param null $entity
* @param string $action
*
* @return string
*/
public function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel')
{
$url = parent::subscriptionURL($entityID, $entity, $action);
if (!isset($url)) {
return NULL;
}
if (stristr($url, '&cs=')) {
return $url;
}
$user_id = CRM_Core_Session::singleton()->get('userID');
$contact_id = $this->getContactID($entity, $entityID);
if ($contact_id && $user_id != $contact_id) {
return $url . '&cs=' . CRM_Contact_BAO_Contact_Utils::generateChecksum($contact_id, NULL, 'inf');
}
return $url;
}
示例5: updatePledgeStatus
public static function updatePledgeStatus($params)
{
$returnMessages = array();
$sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE);
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//unset statues that we never use for pledges
foreach (array('Completed', 'Cancelled', 'Failed') as $statusKey) {
if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
unset($allStatus[$key]);
}
}
$statusIds = implode(',', array_keys($allStatus));
$updateCnt = 0;
$query = "\nSELECT pledge.contact_id as contact_id,\n pledge.id as pledge_id,\n pledge.amount as amount,\n payment.scheduled_date as scheduled_date,\n pledge.create_date as create_date,\n payment.id as payment_id,\n pledge.currency as currency,\n pledge.contribution_page_id as contribution_page_id,\n payment.reminder_count as reminder_count,\n pledge.max_reminders as max_reminders,\n payment.reminder_date as reminder_date,\n pledge.initial_reminder_day as initial_reminder_day,\n pledge.additional_reminder_day as additional_reminder_day,\n pledge.status_id as pledge_status,\n payment.status_id as payment_status,\n pledge.is_test as is_test,\n pledge.campaign_id as campaign_id,\n SUM(payment.scheduled_amount) as amount_due,\n ( SELECT sum(civicrm_pledge_payment.actual_amount)\n FROM civicrm_pledge_payment\n WHERE civicrm_pledge_payment.status_id = 1\n AND civicrm_pledge_payment.pledge_id = pledge.id\n ) as amount_paid\n FROM civicrm_pledge pledge, civicrm_pledge_payment payment\n WHERE pledge.id = payment.pledge_id\n AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )\n GROUP By payment.id\n ";
$dao = CRM_Core_DAO::executeQuery($query);
$now = date('Ymd');
$pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
while ($dao->fetch()) {
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
$pledgeDetails[$dao->payment_id] = array('scheduled_date' => $dao->scheduled_date, 'amount_due' => $dao->amount_due, 'amount' => $dao->amount, 'amount_paid' => $dao->amount_paid, 'create_date' => $dao->create_date, 'contact_id' => $dao->contact_id, 'pledge_id' => $dao->pledge_id, 'checksumValue' => $checksumValue, 'contribution_page_id' => $dao->contribution_page_id, 'reminder_count' => $dao->reminder_count, 'max_reminders' => $dao->max_reminders, 'reminder_date' => $dao->reminder_date, 'initial_reminder_day' => $dao->initial_reminder_day, 'additional_reminder_day' => $dao->additional_reminder_day, 'pledge_status' => $dao->pledge_status, 'payment_status' => $dao->payment_status, 'is_test' => $dao->is_test, 'currency' => $dao->currency, 'campaign_id' => $dao->campaign_id);
$contactIds[$dao->contact_id] = $dao->contact_id;
$pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'), $now) && $dao->payment_status != array_search('Overdue', $allStatus)) {
$pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
}
}
// process the updating script...
foreach ($pledgePayments as $pledgeId => $paymentIds) {
// 1. update the pledge /pledge payment status. returns new status when an update happens
$returnMessages[] = "Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
$newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds, array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE);
if ($newStatus != $pledgeStatus[$pledgeId]) {
$returnMessages[] = "- status updated to: {$allStatus[$newStatus]}";
$updateCnt += 1;
}
}
if ($sendReminders) {
// retrieve domain tokens
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
//get the domain email address, since we don't carry w/ object.
$domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
$domainValues['email'] = $domainValue[1];
// retrieve contact tokens
// this function does NOT return Deceased contacts since we don't want to send them email
list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, $tokens, 'CRM_UpdatePledgeRecord');
// assign domain values to template
$template = CRM_Core_Smarty::singleton();
$template->assign('domain', $domainValues);
//set receipt from
$receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
foreach ($pledgeDetails as $paymentId => $details) {
if (array_key_exists($details['contact_id'], $contactDetails)) {
$contactId = $details['contact_id'];
$pledgerName = $contactDetails[$contactId]['display_name'];
} else {
continue;
}
if (empty($details['reminder_date'])) {
$nextReminderDate = new DateTime($details['scheduled_date']);
$nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
} else {
$nextReminderDate = new DateTime($details['reminder_date']);
$nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
}
if ($details['reminder_count'] < $details['max_reminders'] && $nextReminderDate <= $now) {
$toEmail = $doNotEmail = $onHold = NULL;
if (!empty($contactDetails[$contactId]['email'])) {
$toEmail = $contactDetails[$contactId]['email'];
}
if (!empty($contactDetails[$contactId]['do_not_email'])) {
$doNotEmail = $contactDetails[$contactId]['do_not_email'];
}
if (!empty($contactDetails[$contactId]['on_hold'])) {
$onHold = $contactDetails[$contactId]['on_hold'];
}
// 2. send acknowledgement mail
if ($toEmail && !($doNotEmail || $onHold)) {
//assign value to template
$template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
$template->assign('contact', $contactDetails[$contactId]);
$template->assign('next_payment', $details['scheduled_date']);
$template->assign('amount_due', $details['amount_due']);
$template->assign('checksumValue', $details['checksumValue']);
$template->assign('contribution_page_id', $details['contribution_page_id']);
$template->assign('pledge_id', $details['pledge_id']);
$template->assign('scheduled_payment_date', $details['scheduled_date']);
$template->assign('amount', $details['amount']);
$template->assign('create_date', $details['create_date']);
$template->assign('currency', $details['currency']);
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_reminder', 'contactId' => $contactId, 'from' => $receiptFrom, 'toName' => $pledgerName, 'toEmail' => $toEmail));
// 3. update pledge payment details
if ($mailSent) {
CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
//.........这里部分代码省略.........
示例6: create
/**
* Construct a new mailing object, along with job and mailing_group
* objects, from the form values of the create mailing wizard.
*
* This function is a bit evil. It not only merges $params and saves
* the mailing -- it also schedules the mailing and chooses the recipients.
* Since it merges $params, it's also the only place to correctly trigger
* multi-field validation. It should be broken up.
*
* In the mean time, use-cases which break under the weight of this
* evil may find reprieve in these extra evil params:
*
* - _skip_evil_bao_auto_recipients_: bool
* - _skip_evil_bao_auto_schedule_: bool
* - _evil_bao_validator_: string|callable
*
* </twowrongsmakesaright>
*
* @params array $params
* Form values.
*
* @param array $params
* @param array $ids
*
* @return object
* $mailing The new mailing object
* @throws \Exception
*/
public static function create(&$params, $ids = array())
{
// WTH $ids
if (empty($ids) && isset($params['id'])) {
$ids['mailing_id'] = $ids['id'] = $params['id'];
}
// CRM-12430
// Do the below only for an insert
// for an update, we should not set the defaults
if (!isset($ids['id']) && !isset($ids['mailing_id'])) {
// Retrieve domain email and name for default sender
$domain = civicrm_api('Domain', 'getsingle', array('version' => 3, 'current_domain' => 1, 'sequential' => 1));
if (isset($domain['from_email'])) {
$domain_email = $domain['from_email'];
$domain_name = $domain['from_name'];
} else {
$domain_email = 'info@EXAMPLE.ORG';
$domain_name = 'EXAMPLE.ORG';
}
if (!isset($params['created_id'])) {
$session =& CRM_Core_Session::singleton();
$params['created_id'] = $session->get('userID');
}
$defaults = array('override_verp' => TRUE, 'forward_replies' => FALSE, 'open_tracking' => TRUE, 'url_tracking' => TRUE, 'visibility' => 'Public Pages', 'replyto_email' => $domain_email, 'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''), 'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''), 'from_email' => $domain_email, 'from_name' => $domain_name, 'msg_template_id' => NULL, 'created_id' => $params['created_id'], 'approver_id' => NULL, 'auto_responder' => 0, 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL);
// Get the default from email address, if not provided.
if (empty($defaults['from_email'])) {
$defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
foreach ($defaultAddress as $id => $value) {
if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
$defaults['from_email'] = $match[2];
$defaults['from_name'] = $match[1];
}
}
}
$params = array_merge($defaults, $params);
}
/**
* Could check and warn for the following cases:
*
* - groups OR mailings should be populated.
* - body html OR body text should be populated.
*/
$transaction = new CRM_Core_Transaction();
$mailing = self::add($params, $ids);
if (is_a($mailing, 'CRM_Core_Error')) {
$transaction->rollback();
return $mailing;
}
// update mailings with hash values
CRM_Contact_BAO_Contact_Utils::generateChecksum($mailing->id, NULL, NULL, NULL, 'mailing', 16);
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
/* Create the mailing group record */
$mg = new CRM_Mailing_DAO_MailingGroup();
$groupTypes = array('include' => 'Include', 'exclude' => 'Exclude', 'base' => 'Base');
foreach (array('groups', 'mailings') as $entity) {
foreach (array('include', 'exclude', 'base') as $type) {
if (isset($params[$entity][$type])) {
self::replaceGroups($mailing->id, $groupTypes[$type], $entity, $params[$entity][$type]);
}
}
}
if (!empty($params['search_id']) && !empty($params['group_id'])) {
$mg->reset();
$mg->mailing_id = $mailing->id;
$mg->entity_table = $groupTableName;
$mg->entity_id = $params['group_id'];
$mg->search_id = $params['search_id'];
$mg->search_args = $params['search_args'];
$mg->group_type = 'Include';
$mg->save();
}
//.........这里部分代码省略.........
示例7: subscriptionURL
/**
* Get url for users to manage this recurring contribution for this processor.
*
* @param int $entityID
* @param null $entity
* @param string $action
*
* @return string
*/
public function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel')
{
// Set URL
switch ($action) {
case 'cancel':
$url = 'civicrm/contribute/unsubscribe';
break;
case 'billing':
//in notify mode don't return the update billing url
if (!$this->isSupported('updateSubscriptionBillingInfo')) {
return NULL;
}
$url = 'civicrm/contribute/updatebilling';
break;
case 'update':
$url = 'civicrm/contribute/updaterecur';
break;
}
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
$contactID = 0;
$checksumValue = '';
$entityArg = '';
// Find related Contact
if ($entityID) {
switch ($entity) {
case 'membership':
$contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
$entityArg = 'mid';
break;
case 'contribution':
$contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id");
$entityArg = 'coid';
break;
case 'recur':
$sql = "\n SELECT con.contact_id\n FROM civicrm_contribution_recur rec\nINNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )\n WHERE rec.id = %1\n GROUP BY rec.id";
$contactID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($entityID, 'Integer')));
$entityArg = 'crid';
break;
}
}
// Add entity arguments
if ($entityArg != '') {
// Add checksum argument
if ($contactID != 0 && $userId != $contactID) {
$checksumValue = '&cs=' . CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
}
return CRM_Utils_System::url($url, "reset=1&{$entityArg}={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
}
// Else login URL
if ($this->isSupported('accountLoginURL')) {
return $this->accountLoginURL();
}
// Else default
return isset($this->_paymentProcessor['url_recur']) ? $this->_paymentProcessor['url_recur'] : '';
}
示例8: postProcess
/**
* Process the user submitted custom data values.
*
*
* @return void
*/
public function postProcess()
{
parent::postProcess();
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'display_name');
$sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'sort_name');
$this->ajaxResponse['label'] = $sortName;
// When saving (not deleting) and not in an ajax popup
if (empty($_POST[$this->_deleteButtonName]) && $this->_context != 'dialog') {
CRM_Core_Session::setStatus(ts('Your information has been saved.'), ts('Thank you.'), 'success');
}
$session = CRM_Core_Session::singleton();
// only replace user context if we do not have a postURL
if (!$this->_postURL) {
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
$urlParams = "reset=1&id={$this->_id}&gid={$gidString}";
if ($this->_isContactActivityProfile && $this->_activityId) {
$urlParams .= "&aid={$this->_activityId}";
}
// Get checksum if present
if ($this->get('cs')) {
$urlParams .= "&cs=" . $this->get('cs');
} elseif (!CRM_Contact_BAO_Contact_Permission::allow($this->_id)) {
$urlParams .= "&cs=" . CRM_Contact_BAO_Contact_Utils::generateChecksum($this->_id);
}
$url = CRM_Utils_System::url('civicrm/profile/view', $urlParams);
} else {
// Replace tokens from post URL
$contactParams = array('contact_id' => $this->_id, 'version' => 3);
$contact = civicrm_api('contact', 'get', $contactParams);
$contact = reset($contact['values']);
$dummyMail = new CRM_Mailing_BAO_Mailing();
$dummyMail->body_text = $this->_postURL;
$tokens = $dummyMail->getTokens();
$url = CRM_Utils_Token::replaceContactTokens($this->_postURL, $contact, FALSE, CRM_Utils_Array::value('text', $tokens));
}
$session->replaceUserContext($url);
}
示例9: getContactTokenReplacement
public function getContactTokenReplacement($token, &$contact, $html = false, $returnBlankToken = false)
{
if (self::$_tokens['contact'] == null) {
/* This should come from UF */
self::$_tokens['contact'] = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields('All')), array('checksum', 'contact_id'));
}
/* Construct value from $token and $contact */
$value = null;
// check if the token we were passed is valid
// we have to do this because this function is
// called only when we find a token in the string
if (!in_array($token, self::$_tokens['contact'])) {
$value = "{contact.{$token}}";
} else {
if ($token == 'checksum') {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contact['contact_id']);
$value = "cs={$cs}";
} else {
$value = CRM_Utils_Array::retrieveValueRecursive($contact, $token);
}
}
if (!$html) {
$value = str_replace('&', '&', $value);
}
// if null then return actual token
if ($returnBlankToken && !$value) {
$value = "{contact.{$token}}";
}
return $value;
}
示例10: subscriptionURL
function subscriptionURL($entityID = NULL, $entity = NULL, $action = 'cancel')
{
if ($action == 'cancel') {
$url = 'civicrm/contribute/unsubscribe';
} elseif ($action == 'billing') {
//in notify mode don't return the update billing url
if ($this->_paymentProcessor['billing_mode'] == self::BILLING_MODE_NOTIFY) {
return NULL;
}
$url = 'civicrm/contribute/updatebilling';
} elseif ($action == 'update') {
$url = 'civicrm/contribute/updaterecur';
}
$session = CRM_Core_Session::singleton();
$userId = $session->get('userID');
$checksumValue = "";
if ($entityID && $entity == 'membership') {
if (!$userId) {
$contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
$checksumValue = "&cs={$checksumValue}";
}
return CRM_Utils_System::url($url, "reset=1&mid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
}
if ($entityID && $entity == 'contribution') {
if (!$userId) {
$contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id");
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
$checksumValue = "&cs={$checksumValue}";
}
return CRM_Utils_System::url($url, "reset=1&coid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
}
if ($entityID && $entity == 'recur') {
if (!$userId) {
$sql = "\n SELECT con.contact_id\n FROM civicrm_contribution_recur rec\nINNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )\n WHERE rec.id = %1\n GROUP BY rec.id";
$contactID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($entityID, 'Integer')));
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
$checksumValue = "&cs={$checksumValue}";
}
return CRM_Utils_System::url($url, "reset=1&crid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
}
if ($this->isSupported('accountLoginURL')) {
return $this->accountLoginURL();
}
return $this->_paymentProcessor['url_recur'];
}
示例11: postProcess
/**
* Process the user submitted custom data values.
*
* @access public
*
* @return void
*/
public function postProcess()
{
parent::postProcess();
// this is special case when we create contact using Dialog box
if ($this->_context == 'dialog') {
$displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'display_name');
$sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'sort_name');
$returnArray = array('contactID' => $this->_id, 'displayName' => $displayName, 'sortName' => $sortName, 'newContactSuccess' => TRUE);
echo json_encode($returnArray);
CRM_Utils_System::civiExit();
}
//for delete record handling
if (!CRM_Utils_Array::value($this->_deleteButtonName, $_POST)) {
CRM_Core_Session::setStatus(ts('Your information has been saved.'), ts('Thank you.'), 'success');
}
$session = CRM_Core_Session::singleton();
// only replace user context if we do not have a postURL
if (!$this->_postURL) {
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
$urlParams = "reset=1&id={$this->_id}&gid={$gidString}";
if ($this->_isContactActivityProfile && $this->_activityId) {
$urlParams .= "&aid={$this->_activityId}";
}
// Get checksum if present
if ($this->get('cs')) {
$urlParams .= "&cs=" . $this->get('cs');
} elseif (!CRM_Contact_BAO_Contact_Permission::allow($this->_id)) {
$urlParams .= "&cs=" . CRM_Contact_BAO_Contact_Utils::generateChecksum($this->_id);
}
$url = CRM_Utils_System::url('civicrm/profile/view', $urlParams);
} else {
// Replace tokens from post URL
$contactParams = array('contact_id' => $this->_id, 'version' => 3);
$contact = civicrm_api('contact', 'get', $contactParams);
$contact = reset($contact['values']);
$dummyMail = new CRM_Mailing_BAO_Mailing();
$dummyMail->body_text = $this->_postURL;
$tokens = $dummyMail->getTokens();
$url = CRM_Utils_Token::replaceContactTokens($this->_postURL, $contact, FALSE, CRM_Utils_Array::value('text', $tokens));
}
$session->replaceUserContext($url);
}
示例12: testAllowSelfService
/**
* CRM-16761: Self service view, update and cancel for CiviEvent
*/
public function testAllowSelfService()
{
$this->webtestLogin('admin');
// Create Individual
$contact1 = substr(sha1(rand()), 0, 7);
$this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
// Add event
$this->openCiviPage("event/add", "reset=1&action=add");
$eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
$eventDescription = "Here is a description for this conference.";
$registerIntro = "Fill in all the fields below and click Continue.";
$multipleRegistrations = TRUE;
$allowSelfService = TRUE;
$this->_testAddEventInfo($eventTitle, $eventDescription);
$streetAddress = "100 Main Street";
$this->_testAddLocation($streetAddress);
$this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
$this->_testAddOnlineRegistration($registerIntro, FALSE, $allowSelfService);
// Register participant
$id = $this->urlArg('id');
$this->openCiviPage("event/register", "reset=1&id={$id}&action=preview", '_qf_Register_upload-bottom');
$this->waitForElementPresent("xpath=//div[@id='crm-event-register-different']/a");
$this->click("xpath=//div[@id='crm-event-register-different']/a");
$this->waitForAjaxcontent();
$this->select2("select_contact_id", "{$contact1}");
// Fill card details
$this->select("credit_card_type", "value=Visa");
$this->type("credit_card_number", "4111111111111111");
$this->type("cvv2", "000");
$this->select("credit_card_exp_date[M]", "value=1");
$this->select("credit_card_exp_date[Y]", "value=2020");
// Add billing Address
$this->webtestAddBillingDetails($contact1, NULL, 'Anderson');
$this->click("_qf_Register_upload-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->waitForElementPresent("_qf_Confirm_next-top");
$this->click("_qf_Confirm_next-top");
// Find Participant.
$this->openCiviPage("event/search", "reset=1");
$this->waitForElementPresent("_qf_Search_refresh");
$this->type('sort_name', "Anderson, {$contact1}");
$this->click("_qf_Search_refresh");
$this->waitForElementPresent("xpath=//div[@id='participantSearch']");
// Get the id of primary participant
$primaryParticipantId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Anderson, {$contact1}']/../../td[11]/span/a[1][text()='View']@href"));
// Get the contact id of primary participant
$primaryParticipantContactid = $this->urlArg('cid', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Anderson, {$contact1}']/../../td[11]/span/a[1][text()='View']@href"));
// Generate checksum for primary participant
$checkSum = CRM_Contact_BAO_Contact_Utils::generateChecksum($primaryParticipantContactid);
$this->open($this->sboxPath . "admin/people/permissions/roles");
$permissions = array("edit-1-access-civicrm", "edit-1-access-civievent", "edit-1-edit-all-events");
$this->webtestLogout();
// Transfer event registration.
$this->openCiviPage("event/selfsvcupdate", "reset=1&pid={$primaryParticipantId}&cs={$checkSum}");
$this->waitForElementPresent("xpath=//table[@class='crm-selfsvcupdate-form-details']");
$this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[1]", preg_quote("Anderson, {$contact1}"));
$this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[2]", preg_quote("{$eventTitle}"));
$this->select("action", "value=1");
$this->click("_qf_SelfSvcUpdate_submit-bottom");
$this->waitForElementPresent("_qf_SelfSvcTransfer_submit-bottom");
$newParticipantFirstName = substr(sha1(rand()), 0, 5);
$newParticipantLastName = "Smith";
$newParticipantEmail = "{$newParticipantFirstName}@example.com";
$this->type('email', $newParticipantEmail);
$this->type('last_name', $newParticipantLastName);
$this->type('first_name', $newParticipantFirstName);
$this->click("_qf_SelfSvcTransfer_submit-bottom");
// Cancel event registration.
$this->webtestLogin('admin');
$this->openCiviPage("event/search", "reset=1");
$this->type('sort_name', "Smith, {$newParticipantFirstName}");
$this->click("_qf_Search_refresh");
$this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, {$newParticipantFirstName}']/../../td[11]/span/a[1][text()='View']");
// Get the id of new participant
$newParticipantId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, {$newParticipantFirstName}']/../../td[11]/span/a[1][text()='View']@href"));
// Get the contact id of new participant
$newParticipantContactId = $this->urlArg('cid', $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody/tr/td[3]/a[text()='Smith, {$newParticipantFirstName}']/../../td[11]/span/a[1][text()='View']@href"));
// Generate checksum for new participant
$newParticipantcheckSum = CRM_Contact_BAO_Contact_Utils::generateChecksum($newParticipantContactId);
$this->webtestLogout();
$this->openCiviPage("event/selfsvcupdate", "reset=1&pid={$newParticipantId}&cs={$newParticipantcheckSum}");
$this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[1]", preg_quote("Smith, {$newParticipantFirstName}"));
$this->verifyText("xpath=//table[@class='crm-selfsvcupdate-form-details']/tbody/tr/td[2]", preg_quote("{$eventTitle}"));
$this->select("action", "value=2");
$this->click("_qf_SelfSvcUpdate_submit-bottom");
// Check the status of participant
$this->webtestLogin('admin');
$this->openCiviPage("event/search", "reset=1");
$this->waitForElementPresent('_qf_Search_refresh');
$this->select2("event_id", $eventTitle);
$this->click("xpath=//div[@id='searchForm']/table/tbody/tr[9]/td[1]/label[text()='No']");
$this->click("_qf_Search_refresh");
$this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody");
$this->assertElementContainsText("xpath=//div[@id='participantSearch']/table/tbody/tr[@id='rowid{$primaryParticipantId}']/td[9]", "Transferred");
$this->assertElementContainsText("xpath=//div[@id='participantSearch']/table/tbody/tr[@id='rowid{$newParticipantId}']/td[9]", "Cancelled");
}
示例13: civiqrcode_civicrm_tokenValues
function civiqrcode_civicrm_tokenValues(&$values, $cids, $job = null, $tokens = array(), $context = null)
{
if (array_key_exists('contact', $tokens)) {
$config = CRM_Core_Config::singleton();
$imageUploadDir = $config->imageUploadDir;
$extensionDir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$qrlibFile = $extensionDir . '/lib/phpqrcode/phpqrcode.php';
$tableName = QRCODE_SETTING_DB_TABLENAME;
$qrToken = QRCODE_SETTING_DB_COLUMN_QRCODE_TOKEN;
$qrTarget = QRCODE_SETTING_DB_COLUMN_QRCODE_TARGET;
$argExt = QRCODE_SETTING_DB_COLUMN_QRCODE_ARG_EXT;
$argCs = QRCODE_SETTING_DB_COLUMN_QRCODE_ARG_CS;
$getAllQrCodeTokenDAO = CRM_Core_DAO::executeQuery("SELECT * FROM {$tableName}");
foreach ($cids as $id) {
while ($getAllQrCodeTokenDAO->fetch()) {
$filename = $getAllQrCodeTokenDAO->{$qrToken} . '_' . $id . date('dmy') . '.png';
$pngAbsoluteFilePath = $imageUploadDir . $filename;
//delete if the filename exists
if (file_exists($pngAbsoluteFilePath)) {
unlink($pngAbsoluteFilePath);
}
$urlParams = array();
$urlParams['cid'] = $id;
$urlParams['reset'] = 1;
if ($getAllQrCodeTokenDAO->{$argExt}) {
$urlParams['mid'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $id, 'external_identifier', 'id');
}
if ($getAllQrCodeTokenDAO->{$argCs}) {
$urlParams['cs'] = CRM_Contact_BAO_Contact_Utils::generateChecksum($id);
}
$url = CRM_Utils_System::url($getAllQrCodeTokenDAO->{$qrTarget}, $urlParams, TRUE);
require_once $qrlibFile;
QRcode::png($url, $pngAbsoluteFilePath, 'L', 4, 2);
$values[$id]['civiqrcode.' . $getAllQrCodeTokenDAO->{$qrToken}] = realpath($pngAbsoluteFilePath);
}
//end while
}
//end foreach
}
//end if
}
示例14: getContactTokenReplacement
public static function getContactTokenReplacement($token, &$contact, $html = FALSE, $returnBlankToken = FALSE, $escapeSmarty = FALSE)
{
if (self::$_tokens['contact'] == NULL) {
/* This should come from UF */
self::$_tokens['contact'] = array_merge(array_keys(CRM_Contact_BAO_Contact::exportableFields('All')), array('checksum', 'contact_id'));
}
/* Construct value from $token and $contact */
$value = NULL;
// check if the token we were passed is valid
// we have to do this because this function is
// called only when we find a token in the string
if (!in_array($token, self::$_tokens['contact'])) {
$value = "{contact.{$token}}";
} elseif ($token == 'checksum') {
$hash = CRM_Utils_Array::value('hash', $contact);
$contactID = CRM_Utils_Array::retrieveValueRecursive($contact, 'contact_id');
$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, NULL, $hash);
$value = "cs={$cs}";
} else {
$value = CRM_Utils_Array::retrieveValueRecursive($contact, $token);
}
if (!$html) {
$value = str_replace('&', '&', $value);
}
// if null then return actual token
if ($returnBlankToken && !$value) {
$value = "{contact.{$token}}";
}
if ($escapeSmarty) {
$value = self::tokenEscapeSmarty($value);
}
return $value;
}
示例15: cancelSubscriptionURL
function cancelSubscriptionURL($entityID = null, $entity = null)
{
if ($entityID && $entity == 'membership') {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
$contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, null, 'inf');
return CRM_Utils_System::url('civicrm/contribute/unsubscribe', "reset=1&mid={$entityID}&cs={$checksumValue}", true, null, false, false);
}
return $this->_mode == 'test' ? 'https://test.authorize.net' : 'https://authorize.net';
}