本文整理汇总了PHP中CRM_Utils_System::setUFMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::setUFMessage方法的具体用法?PHP CRM_Utils_System::setUFMessage怎么用?PHP CRM_Utils_System::setUFMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::setUFMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* This function takes care of all the things common to all pages.
*
* This typically involves assigning the appropriate smarty variables :)
*/
public function run()
{
$transaction = new CRM_Core_Transaction();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
}
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$event_in_cart = $cart->add_event($this->_id);
$url = CRM_Utils_System::url('civicrm/event/view_cart');
CRM_Utils_System::setUFMessage(ts("<b>%1</b> has been added to your cart. <a href='%2'>View your cart.</a>", array(1 => $event_in_cart->event->title, 2 => $url)));
$transaction->commit();
return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']);
}
示例2: run
function run()
{
// Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
CRM_Utils_System::setTitle(ts('Prinsclear'));
$this->assign('startTime', date('Y-m-d H:i:s'));
try {
$conv = new CRM_Prinsimport_Pages_Importhandling();
foreach ($GLOBALS['CONVERSIE'] as $def) {
$conv->clearTable($def);
}
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Utils_System::setUFMessage('API error: ' . $error);
}
// Example: Assign a variable for use in a template
$this->assign('currentTime', date('Y-m-d H:i:s'));
$this->assign('homeCiviUrl', CRM_Utils_System::url('civicrm', null, true));
parent::run();
}
示例3: run
function run()
{
// Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
CRM_Utils_System::setTitle(ts('Prinsread'));
$this->assign('startTime', date('Y-m-d H:i:s'));
$this->assign('message', 'starting');
// message to produce on the page
try {
$conv = new CRM_Prinsimport_Pages_Importhandling();
//$con = $conv->dbConnect();
//CRM_Core_Error::Debug('CONNECTION', $con);
//exit();
// open files
//CRM_Core_Error::Debug('GLOBALS', dirname(__FILE__));
//exit();
//dpm($GLOBALS['CONVERSIE']);
foreach ($GLOBALS['CONVERSIE'] as $def) {
//CRM_Core_Error::Debug($def);
//exit();
// create tables (if not available)
$this->assign('message', 'create table ' . key($GLOBALS['CONVERSIE']));
$conv->createTable($def);
$conv->importFile($def);
}
// read lines
// insert into table
// close files
// report "done"
$this->assign('message', 'ready');
// Example: Assign a variable for use in a template
$this->assign('currentTime', date('Y-m-d H:i:s'));
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Utils_System::setUFMessage('API error: ' . $error);
$this->assign('message', $this->message . ': ' . $error);
}
// Example: Assign a variable for use in a template
$this->assign('currentTime', date('Y-m-d H:i:s'));
$this->assign('homeCiviUrl', CRM_Utils_System::url('civicrm', null, true));
parent::run();
}
示例4: preProcess
function preProcess()
{
$params = array();
$defaults = array();
$ids = array();
$session =& CRM_Core_Session::singleton();
$uid = $session->get('userID');
if (!$uid) {
require_once 'CRM/Utils/System.php';
CRM_Utils_System::setUFMessage(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
CRM_Core_Error::statusBounce(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
}
$this->assign('contactId', $uid);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'view');
$this->assign('action', $this->_action);
// a user can always view their own activity history
// if they have access CiviCRM permission
$this->_permission = CRM_Core_Permission::VIEW;
// make the permission edit if the user has edit permission on the contact
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if (CRM_Contact_BAO_Contact_Permission::allow($uid, CRM_Core_Permission::EDIT)) {
$this->_permission = CRM_Core_Permission::EDIT;
}
$displayName = $this->get('displayName');
list($displayName, $contactImage, $contactType) = CRM_Contact_BAO_Contact::getDisplayAndImage($uid, true);
$this->set('displayName', $displayName);
$this->set('contactImage', $contactImage);
CRM_Utils_System::setTitle($contactImage . ' ' . $displayName, $displayName);
CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $uid), $uid, $contactType, $uid, $displayName);
// call hook to get html from other modules
require_once 'CRM/Utils/Hook.php';
$contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
// ignored but needed to prevent warnings
$html = CRM_Utils_Hook::dashboard($uid, $contentPlacement);
if (is_array($html)) {
$this->assign_by_ref('hookContent', $html);
$this->assign('hookContentPlacement', $contentPlacement);
}
}
示例5: commonSubscribe
/**
* Send subscribe mail.
*
* @param array $groups
* The list of group ids for subscribe.
* @param array $params
* The list of email.
* @param int $contactId
* Currently used during event registration/contribution.
* Specifically to avoid linking group to wrong duplicate contact
* during event registration.
* @param string $context
*
* @return void
*/
public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $context = NULL)
{
$contactGroups = CRM_Mailing_Event_BAO_Subscribe::getContactGroups($params['email'], $contactId);
$group = array();
$success = NULL;
foreach ($groups as $groupID) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $groupID, 'title');
if (array_key_exists($groupID, $contactGroups) && $contactGroups[$groupID]['status'] != 'Removed') {
$group[$groupID]['title'] = $contactGroups[$groupID]['title'];
$group[$groupID]['status'] = $contactGroups[$groupID]['status'];
$status = ts('You are already subscribed in %1, your subscription is %2.', array(1 => $group[$groupID]['title'], 2 => ts($group[$groupID]['status'])));
CRM_Utils_System::setUFMessage($status);
continue;
}
$se = self::subscribe($groupID, $params['email'], $contactId, $context);
if ($se !== NULL) {
$success = TRUE;
$groupAdded[] = $title;
// Ask the contact for confirmation
$se->send_confirm_request($params['email']);
} else {
$success = FALSE;
$groupFailed[] = $title;
}
}
if ($success) {
$groupTitle = implode(', ', $groupAdded);
CRM_Utils_System::setUFMessage(ts('Your subscription request has been submitted for %1. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder.', array(1 => $groupTitle)));
} elseif ($success === FALSE) {
$groupTitle = implode(',', $groupFailed);
CRM_Utils_System::setUFMessage(ts('We had a problem processing your subscription request for %1. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator.', array(1 => $groupTitle)));
}
}
示例6: validate
/**
* Intercept QF validation and do our own redirection.
*
* We use this to send control back to the user for a user formatted page
* This allows the user to maintain the same state and display the error messages
* in their own theme along with any modifications
*
* This is a first version and will be tweaked over a period of time
*
*
* @return bool
* true if no error found
*/
public function validate()
{
$errors = parent::validate();
if (!$errors && !empty($_POST['errorURL'])) {
$message = NULL;
foreach ($this->_errors as $name => $mess) {
$message .= $mess;
$message .= '<p>';
}
CRM_Utils_System::setUFMessage($message);
$message = urlencode($message);
$errorURL = $_POST['errorURL'];
if (strpos($errorURL, '?') !== FALSE) {
$errorURL .= '&';
} else {
$errorURL .= '?';
}
$errorURL .= "gid={$this->_gid}&msg={$message}";
CRM_Utils_System::redirect($errorURL);
}
return $errors;
}
示例7: postProcess
/**
* called after the user submits the form.
*
*
* @return void
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->exportValues();
if ($this->_selfService && $this->_donorEmail) {
// for self service force notify
$params['is_notify'] = 1;
}
// if this is an update of an existing recurring contribution, pass the ID
$params['id'] = $this->_subscriptionDetails->recur_id;
$message = '';
$params['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
$updateSubscription = TRUE;
if ($this->_paymentProcessorObj->isSupported('changeSubscriptionAmount')) {
$updateSubscription = $this->_paymentProcessorObj->changeSubscriptionAmount($message, $params);
}
if (is_a($updateSubscription, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($updateSubscription);
$status = ts('Could not update the Recurring contribution details');
$msgTitle = ts('Update Error');
$msgType = 'error';
} elseif ($updateSubscription) {
// save the changes
$result = CRM_Contribute_BAO_ContributionRecur::add($params);
$status = ts('Recurring contribution has been updated to: %1, every %2 %3(s) for %4 installments.', array(1 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency), 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit, 4 => $params['installments']));
$msgTitle = ts('Update Success');
$msgType = 'success';
$contactID = $this->_subscriptionDetails->contact_id;
if ($this->_subscriptionDetails->amount != $params['amount']) {
$message .= "<br /> " . ts("Recurring contribution amount has been updated from %1 to %2 for this subscription.", array(1 => CRM_Utils_Money::format($this->_subscriptionDetails->amount, $this->_subscriptionDetails->currency), 2 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency))) . ' ';
}
if ($this->_subscriptionDetails->installments != $params['installments']) {
$message .= "<br /> " . ts("Recurring contribution installments have been updated from %1 to %2 for this subscription.", array(1 => $this->_subscriptionDetails->installments, 2 => $params['installments'])) . ' ';
}
$activityParams = array('source_contact_id' => $contactID, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Update Recurring Contribution', 'name'), 'subject' => ts('Recurring Contribution Updated'), 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
$session = CRM_Core_Session::singleton();
$cid = $session->get('userID');
if ($cid) {
$activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
$activityParams['source_contact_id'] = $cid;
}
CRM_Activity_BAO_Activity::create($activityParams);
if (!empty($params['is_notify'])) {
// send notification
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
} else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
}
list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
$tplParams = array('recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => CRM_Utils_Money::format($params['amount']), 'installments' => $params['installments']);
$tplParams['contact'] = array('display_name' => $donorDisplayName);
$tplParams['receipt_from_email'] = $receiptFrom;
$sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_recurring_edit', 'contactId' => $contactID, 'tplParams' => $tplParams, 'isTest' => $this->_subscriptionDetails->is_test, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail);
list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID && $status) {
CRM_Core_Session::setStatus($status, $msgTitle, $msgType);
} elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
}
// keep result as 1, since we not displaying anything on the redirected page anyway
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=update&result=1"));
}
}
示例8: run
/**
* Run the page.
*
* This method is called after the page is created. It checks for the
* type of action and executes that action.
* Finally it calls the parent's run method.
*
* @return void
*/
public function run()
{
//get the event id.
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
$config = CRM_Core_Config::singleton();
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'view event info')) {
CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event'));
return CRM_Utils_System::permissionDenied();
}
$action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'register');
$this->assign('context', $context);
// Sometimes we want to suppress the Event Full msg
$noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
// set breadcrumb to append to 2nd layer pages
$breadCrumbPath = CRM_Utils_System::url('civicrm/event/info', "id={$this->_id}&reset=1");
//retrieve event information
$params = array('id' => $this->_id);
CRM_Event_BAO_Event::retrieve($params, $values['event']);
if (!$values['event']['is_active']) {
// form is inactive, die a fatal death
CRM_Utils_System::setUFMessage(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
return CRM_Utils_System::permissionDenied();
}
if (!empty($values['event']['is_template'])) {
// form is an Event Template
CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
}
// Add Event Type to $values in case folks want to display it
$values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType());
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.
if ($this->_id && !empty($values['event']['is_monetary'])) {
//CRM-6907
$config = CRM_Core_Config::singleton();
$config->defaultCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency);
//CRM-10434
$discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
if ($discountId) {
$priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'price_set_id');
} else {
$priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_id);
}
// get price set options, - CRM-5209
if ($priceSetId) {
$setDetails = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, TRUE);
$priceSetFields = $setDetails[$priceSetId]['fields'];
if (is_array($priceSetFields)) {
$fieldCnt = 1;
$visibility = CRM_Core_PseudoConstant::visibility('name');
// CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
$adminFieldVisible = FALSE;
if (CRM_Core_Permission::check('administer CiviCRM')) {
$adminFieldVisible = TRUE;
}
foreach ($priceSetFields as $fid => $fieldValues) {
if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == FALSE) {
continue;
}
if (count($fieldValues['options']) > 1) {
$values['feeBlock']['value'][$fieldCnt] = '';
$values['feeBlock']['label'][$fieldCnt] = $fieldValues['label'];
$values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label';
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
$fieldCnt++;
$labelClass = 'price_set_option-label';
} else {
$labelClass = 'price_set_field-label';
}
// show tax rate with amount
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
foreach ($fieldValues['options'] as $optionId => $optionVal) {
$values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
if ($invoicing && isset($optionVal['tax_amount'])) {
$values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
$values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount'];
} else {
$values['feeBlock']['value'][$fieldCnt] = $optionVal['amount'];
}
$values['feeBlock']['label'][$fieldCnt] = $optionVal['label'];
$values['feeBlock']['lClass'][$fieldCnt] = $labelClass;
$fieldCnt++;
}
}
}
// Tell tpl we have price set fee data and whether it's a quick_config price set
$this->assign('isPriceSet', 1);
//.........这里部分代码省略.........
示例9: commonSubscribe
/**
* Function to send subscribe mail
* @params array $groups the list of group ids for subscribe
* @params array $params the list of email
* @params int $contactId Currently used during event registration/contribution.
* Specifically to avoid linking group to wrong duplicate contact
* during event registration.
* @public
* @return void
*/
function commonSubscribe(&$groups, &$params, $contactId = null)
{
$success = true;
foreach ($groups as $groupID) {
$se = self::subscribe($groupID, $params['email'], $contactId);
if ($se !== null) {
/* Ask the contact for confirmation */
$se->send_confirm_request($params['email']);
} else {
$success = false;
}
}
if ($success) {
CRM_Utils_System::setUFMessage(ts("Your subscription request has been submitted. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder."));
} else {
CRM_Utils_System::setUFMessage(ts("We had a problem processing your subscription request. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator"));
}
}
示例10: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
function buildQuickForm()
{
if ($this->_mode != CRM_PROFILE_FORM_MODE_REGISTER) {
//check for mix profile (eg: individual + other contact type)
require_once "CRM/Core/BAO/UFField.php";
if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
CRM_Utils_System::setUFMessage(ts("This Profile includes fields for contact types other than 'Individuals' and can not be used to create/update contacts."));
$config =& CRM_Core_Config::singleton();
CRM_Utils_System::redirect($config->userFrameworkBaseURL);
}
}
$this->assign('mode', $this->_mode);
$this->assign('action', $this->_action);
$this->assign('fields', $this->_fields);
$this->assign('fieldset', $this->_fieldset);
/* if ($this->_mode & self::MODE_EDIT) {
$group =& new CRM_Core_DAO_UFGroup();
$group->id = $this->_gid;
if ($group->find(true)) {
$this->assign('help_pre', $group->help_pre);
$this->assign('help_post', $group->help_post);
}
}*/
// do we need inactive options ?
if ($this->_action & CRM_CORE_ACTION_VIEW) {
$inactiveNeeded = true;
} else {
$inactiveNeeded = false;
}
// should we restrict what we display
$admin = true;
if ($this->_mode == CRM_PROFILE_FORM_MODE_EDIT) {
$admin = false;
$session =& CRM_Core_Session::singleton();
// show all fields that are visibile: if we are a admin or the same user or in registration mode
if (CRM_Utils_System::checkPermission('administer users') || $this->_id == $session->get('userID')) {
$admin = true;
}
}
require_once "CRM/Contribute/PseudoConstant.php";
// add the form elements
foreach ($this->_fields as $name => $field) {
// make sure that there is enough permission to expose this field
if (!$admin && $field['visibility'] == 'User and User Admin Only') {
unset($this->_fields[$name]);
continue;
}
// since the CMS manages the email field, suppress the email display if in
// register mode which occur within the CMS form
if ($this->_mode == CRM_PROFILE_FORM_MODE_REGISTER && substr($name, 0, 5) == 'email') {
unset($this->_fields[$name]);
continue;
}
$required = $this->_mode == CRM_PROFILE_FORM_MODE_SEARCH ? false : $field['is_required'];
//if ( $field['name'] === 'state_province' ) {
if (substr($field['name'], 0, 14) === 'state_province') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince(), $required);
} else {
if (substr($field['name'], 0, 7) === 'country') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(), $required);
} else {
if ($field['name'] === 'birth_date') {
$this->add('date', $field['name'], $field['title'], CRM_Core_SelectValues::date('birth'), $required);
} else {
if ($field['name'] === 'gender') {
$genderOptions = array();
$gender = CRM_Core_PseudoConstant::gender();
foreach ($gender as $key => $var) {
$genderOptions[$key] = HTML_QuickForm::createElement('radio', null, ts('Gender'), $var, $key);
}
$this->addGroup($genderOptions, $field['name'], $field['title']);
if ($required) {
$this->addRule($field['name'], ts('%1 is a required field.', array(1 => $field['title'])), 'required');
}
} else {
if ($field['name'] === 'individual_prefix') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualPrefix(), $required);
} else {
if ($field['name'] === 'individual_suffix') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_PseudoConstant::individualSuffix(), $required);
} else {
if ($field['name'] === 'preferred_communication_method') {
$this->add('select', $name, $field['title'], array('' => ts('- select -')) + CRM_Core_SelectValues::pcm());
} else {
if ($field['name'] === 'preferred_mail_format') {
$this->add('select', $name, $field['title'], CRM_Core_SelectValues::pmf());
} else {
if (substr($field['name'], 0, 3) === 'is_' or substr($field['name'], 0, 7) === 'do_not_') {
$this->add('checkbox', $name, $field['title'], $field['attributes'], $required);
} else {
if ($field['name'] === 'group') {
require_once 'CRM/Contact/Form/GroupTag.php';
CRM_Contact_Form_GroupTag::buildGroupTagBlock($this, $this->_id, CRM_CONTACT_FORM_GROUPTAG_GROUP, true, $required, $field['title'], null);
} else {
//.........这里部分代码省略.........
示例11: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$status = $message = NULL;
$cancelSubscription = TRUE;
$params = $this->controller->exportValues($this->_name);
if ($this->_selfService) {
// for self service force sending-request & notify
if ($this->_paymentProcessorObj->isSupported('cancelSubscription')) {
$params['send_cancel_request'] = 1;
}
if ($this->_donorEmail) {
$params['is_notify'] = 1;
}
}
if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
$cancelParams = array('subscriptionId' => $this->_subscriptionDetails->subscription_id);
$cancelSubscription = $this->_paymentProcessorObj->cancelSubscription($message, $cancelParams);
}
if (is_a($cancelSubscription, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($cancelSubscription);
} elseif ($cancelSubscription) {
$activityParams = array('subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), 'details' => $message);
$cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($this->_subscriptionDetails->recur_id, CRM_Core_DAO::$_nullObject, $activityParams);
if ($cancelStatus) {
$tplParams = array();
if ($this->_mid) {
$inputParams = array('id' => $this->_mid);
CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
$tplParams = $tplParams[$this->_mid];
$tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', array(1 => $tplParams['membershipType']));
$msgTitle = 'Membership Renewal Cancelled';
$msgType = 'info';
} else {
$tplParams['recur_frequency_interval'] = $this->_subscriptionDetails->frequency_interval;
$tplParams['recur_frequency_unit'] = $this->_subscriptionDetails->frequency_unit;
$tplParams['amount'] = $this->_subscriptionDetails->amount;
$tplParams['contact'] = array('display_name' => $this->_donorDisplayName);
$status = ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
$msgTitle = 'Contribution Cancelled';
$msgType = 'success';
}
if (CRM_Utils_Array::value('is_notify', $params) == 1) {
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
} else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
}
// send notification
$sendTemplateParams = array('groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $this->_donorDisplayName, 'toEmail' => $this->_donorEmail);
list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
}
} else {
$msgType = 'error';
$msgTitle = ts('Error');
if ($params['send_cancel_request'] == 1) {
$status = ts('Recurring contribution was cancelled successfully by the processor, but could not be marked as cancelled in the database.');
} else {
$status = ts('Recurring contribution could not be cancelled in the database.');
}
}
} else {
$status = ts('The recurring contribution could not be cancelled.');
$msgTitle = 'Error Cancelling Contribution';
$msgType = 'error';
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID && $status) {
$session->setStatus($status, $msgTitle, $msgType);
} elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
}
// keep result as 1, since we not displaying anything on the redirected page anyway
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=cancel&result=1"));
}
}
示例12: processLine
/**
* Transforms a single line from a conversion file to an sql statement, based on the details in its definition array
*/
private function processLine($specs, $line)
{
$values = explode(',', $line);
$sqlcolnames = '';
$sqlcolvalues = '';
for ($i = 0; $i < count($values); $i++) {
try {
$sqlcol = '';
$colval = $this->decodeValue($values[$i]);
$colname = $specs['COLS'][$i]['NAME'];
$coltype = $specs['COLS'][$i]['TYPE'];
$colsize = $specs['COLS'][$i]['SIZE'];
switch ($coltype) {
case 'varchar':
if (isset($colsize)) {
$colval = substr($colval, 0, $colsize);
}
break;
case 'text':
// ignore $colsize;
// ignore $colsize;
case 'date':
// ignore $colsize; date is already formatted 'yyyy-mm-dd'
break;
case 'int':
// ignore $colsize
// ?: $colval = intval($colval);
// min/max
break;
case 'double':
// ignore $colsize
// ?: rounding to decimals
// min/max
break;
default:
// do not add field to sql statement
// report undefined data type
$colval = NULL;
}
if (isset($colval)) {
if (strlen($sqlcolnames) > 0) {
$sqlcolnames .= ', ';
$sqlcolvalues .= ', ';
}
if (strpos($colval, '\\') > -1) {
//CRM_Core_Error::Debug('VALUE ALERT', $colval);
//CRM_Core_Error::Debug('POS', strpos($colval, '\\'));
$colval = str_ireplace('\\', '\\\\', $colval);
}
if (strpos($colval, chr(39)) > -1) {
//CRM_Core_Error::Debug('VALUE ALERT', $colval);
//CRM_Core_Error::Debug('POS', strpos($colval, chr(39)));
$colval = str_ireplace(chr(39), '\\' . chr(39), $colval);
}
if (strpos($colval, chr(34)) > -1) {
//CRM_Core_Error::Debug('VALUE ALERT', $colval);
//CRM_Core_Error::Debug('POS', strpos($colval, chr(34)));
$colval = str_ireplace(chr(34), '\\' . chr(34), $colval);
}
$sqlcolnames .= '`' . $colname . '`';
$sqlcolvalues .= '\'' . $colval . '\'';
}
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Utils_System::setUFMessage('API error: ' . $error . '(col=' . $i . ')');
}
}
return 'INSERT INTO `' . $specs['TBL'] . '` (' . $sqlcolnames . ') VALUES (' . $sqlcolvalues . ')';
}
示例13: postProcess
/**
* Form submission of new/edit contact is processed.
*
* @access public
* @return None
*/
public function postProcess()
{
$queue_id = $this->get('queue_id');
$job_id = $this->get('job_id');
$hash = $this->get('hash');
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$params['body_text'] = $formValues['forward_comment'];
$html_comment = $formValues['html_comment'];
$params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment));
$emails = array();
for ($i = 0; $i < 5; $i++) {
$email = $this->controller->exportValue($this->_name, "email_{$i}");
if (!empty($email)) {
$emails[] = $email;
}
}
$forwarded = null;
foreach ($emails as $email) {
$result = crm_mailer_event_forward($job_id, $queue_id, $hash, $email, $this->_fromEmail, $params);
if ($result) {
$forwarded++;
}
}
$status = ts('Mailing is not forwarded to the given email address.', array('count' => count($emails), 'plural' => 'Mailing is not forwarded to the given email addresses.'));
if ($forwarded) {
$status = ts('Mailing is forwarded successfully to %count email address.', array('count' => $forwarded, 'plural' => 'Mailing is forwarded successfully to %count email addresses.'));
}
require_once 'CRM/Utils/System.php';
CRM_Utils_System::setUFMessage($status);
// always redirect to front page of url
$session =& CRM_Core_Session::singleton();
$config =& CRM_Core_Config::singleton();
$session->pushUserContext($config->userFrameworkBaseURL);
}
示例14: postProcess
/**
* Form submission of new/edit contact is processed.
*/
public function postProcess()
{
$queue_id = $this->get('queue_id');
$job_id = $this->get('job_id');
$hash = $this->get('hash');
$timeStamp = date('YmdHis');
$formValues = $this->controller->exportValues($this->_name);
$params = array();
$params['body_text'] = $formValues['forward_comment'];
$html_comment = $formValues['html_comment'];
$params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment));
$emails = array();
for ($i = 0; $i < 5; $i++) {
$email = $this->controller->exportValue($this->_name, "email_{$i}");
if (!empty($email)) {
$emails[] = $email;
}
}
$forwarded = NULL;
foreach ($emails as $email) {
$params = array('version' => 3, 'job_id' => $job_id, 'event_queue_id' => $queue_id, 'hash' => $hash, 'email' => $email, 'time_stamp' => $timeStamp, 'fromEmail' => $this->_fromEmail, 'params' => $params);
$result = civicrm_api('Mailing', 'event_forward', $params);
if (!civicrm_error($result)) {
$forwarded++;
}
}
$status = ts('Mailing is not forwarded to the given email address.', array('count' => count($emails), 'plural' => 'Mailing is not forwarded to the given email addresses.'));
if ($forwarded) {
$status = ts('Mailing is forwarded successfully to %count email address.', array('count' => $forwarded, 'plural' => 'Mailing is forwarded successfully to %count email addresses.'));
}
CRM_Utils_System::setUFMessage($status);
// always redirect to front page of url
$session = CRM_Core_Session::singleton();
$config = CRM_Core_Config::singleton();
$session->pushUserContext($config->userFrameworkBaseURL);
}
示例15: postProcess
//.........这里部分代码省略.........
$processorParams['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
$processorParams['amount'] = $this->_subscriptionDetails->amount;
$updateSubscription = $this->_paymentProcessorObj->updateSubscriptionBillingInfo($message, $processorParams);
if (is_a($updateSubscription, 'CRM_Core_Error')) {
CRM_Core_Error::displaySessionError($updateSubscription);
} elseif ($updateSubscription) {
$ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_subscriptionDetails->contact_id, 'contact_type');
$contact =& CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_subscriptionDetails->contact_id, NULL, NULL, $ctype);
// build tpl params
if ($this->_subscriptionDetails->membership_id) {
$inputParams = array('id' => $this->_subscriptionDetails->membership_id);
CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
$tplParams = $tplParams[$this->_subscriptionDetails->membership_id];
$tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
$tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
$status = ts('Billing details for your automatically renewed %1 membership have been updated.', array(1 => $tplParams['membershipType']));
$msgTitle = ts('Details Updated');
$msgType = 'success';
} else {
$status = ts('Billing details for the recurring contribution of %1, every %2 %3 have been updated.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
$msgTitle = ts('Details Updated');
$msgType = 'success';
$tplParams = array('recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => $this->_subscriptionDetails->amount);
}
// format new address for display
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
$addressParts[$part] = CRM_Utils_Array::value($part, $processorParams);
}
$tplParams['address'] = CRM_Utils_Address::format($addressParts);
// format old address to store in activity details
$this->_defaults["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvince($this->_defaults["state_province-{$this->_bltID}"], FALSE);
$this->_defaults["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::country($this->_defaults["country-{$this->_bltID}"], FALSE);
$addressParts = array("street_address", "city", "postal_code", "state_province", "country");
foreach ($addressParts as $part) {
$key = "{$part}-{$this->_bltID}";
$addressParts[$part] = CRM_Utils_Array::value($key, $this->_defaults);
}
$this->_defaults['address'] = CRM_Utils_Address::format($addressParts);
// format new billing name
$name = $processorParams['first_name'];
if (!empty($processorParams['middle_name'])) {
$name .= " {$processorParams['middle_name']}";
}
$name .= ' ' . $processorParams['last_name'];
$name = trim($name);
$tplParams['billingName'] = $name;
// format old billing name
$name = $this->_defaults['first_name'];
if (!empty($this->_defaults['middle_name'])) {
$name .= " {$this->_defaults['middle_name']}";
}
$name .= ' ' . $this->_defaults['last_name'];
$name = trim($name);
$this->_defaults['billingName'] = $name;
$message .= "\n<br/><br/>New Billing Name and Address\n<br/>==============================\n<br/>{$tplParams['billingName']}\n<br/>{$tplParams['address']}\n\n<br/><br/>Previous Billing Name and Address\n<br/>==================================\n<br/>{$this->_defaults['billingName']}\n<br/>{$this->_defaults['address']}";
$activityParams = array('source_contact_id' => $this->_subscriptionDetails->contact_id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Update Recurring Contribution Billing Details', 'name'), 'subject' => ts('Recurring Contribution Billing Details Updated'), 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
$session = CRM_Core_Session::singleton();
$cid = $session->get('userID');
if ($cid) {
$activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
$activityParams['source_contact_id'] = $cid;
}
CRM_Activity_BAO_Activity::create($activityParams);
// send notification
if ($this->_subscriptionDetails->contribution_page_id) {
CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
$receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
} else {
$domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
$receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
}
list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
$tplParams['contact'] = array('display_name' => $donorDisplayName);
$date = CRM_Utils_Date::format($processorParams['credit_card_exp_date']);
$tplParams['credit_card_exp_date'] = CRM_Utils_Date::mysqlToIso($date);
$tplParams['credit_card_number'] = CRM_Utils_System::mungeCreditCard($processorParams['credit_card_number']);
$tplParams['credit_card_type'] = $processorParams['credit_card_type'];
$sendTemplateParams = array('groupName' => $this->_subscriptionDetails->membership_id ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_subscriptionDetails->membership_id ? 'membership_autorenew_billing' : 'contribution_recurring_billing', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'isTest' => $this->_subscriptionDetails->is_test, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail);
list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
} else {
$status = ts('There was some problem updating the billing details.');
$msgTitle = ts('Update Error');
$msgType = 'error';
}
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
if ($userID && $status) {
$session->setStatus($status, $msgTitle, $msgType);
} elseif (!$userID) {
if ($status) {
CRM_Utils_System::setUFMessage($status);
}
$result = (int) ($updateSubscription && isset($ctype));
if (isset($tplParams)) {
$session->set('resultParams', $tplParams);
}
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=billing&result={$result}"));
}
}