本文整理汇总了PHP中CRM_Core_Form::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::getName方法的具体用法?PHP CRM_Core_Form::getName怎么用?PHP CRM_Core_Form::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcessMembers
/**
* Process the form after the input has been submitted and validated.
* @todo this is horrible copy & paste code because there is so much risk of breakage
* in fixing the existing pdfLetter classes to be suitably generic
*
* @param CRM_Core_Form $form
* @param $membershipIDs
* @param $skipOnHold
* @param $skipDeceased
* @param $contactIDs
*/
public static function postProcessMembers(&$form, $membershipIDs, $skipOnHold, $skipDeceased, $contactIDs)
{
$formValues = $form->controller->exportValues($form->getName());
list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues);
$html = self::generateHTML($membershipIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $html_message, $categories);
self::createActivities($form, $html_message, $contactIDs);
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues);
$form->postProcessHook();
CRM_Utils_System::civiExit(1);
}
示例2: buildPremium
/**
* Build the form object for Premium Information.
*
* Called from the CRM_Contribute_Form_Contribute function and seemingly nowhere else.
*
* Probably this should be on the form that uses it since it is not used on multiple forms.
*
* Putting it on this class doesn't seem to reduce complexity.
*
* @param CRM_Core_Form $form
*/
public static function buildPremium(&$form)
{
//premium section
$form->add('hidden', 'hidden_Premium', 1);
$sel1 = $sel2 = array();
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
$dao->find();
$min_amount = array();
$sel1[0] = ts('-select product-');
while ($dao->fetch()) {
$sel1[$dao->id] = $dao->name . " ( " . $dao->sku . " )";
$min_amount[$dao->id] = $dao->min_contribution;
$options = explode(',', $dao->options);
foreach ($options as $k => $v) {
$options[$k] = trim($v);
}
if ($options[0] != '') {
$sel2[$dao->id] = $options;
}
$form->assign('premiums', TRUE);
}
$form->_options = $sel2;
$form->assign('mincontribution', $min_amount);
$sel =& $form->addElement('hierselect', "product_name", ts('Premium'), 'onclick="showMinContrib();"');
$js = "<script type='text/javascript'>\n";
$formName = 'document.forms.' . $form->getName();
for ($k = 1; $k < 2; $k++) {
if (!isset($defaults['product_name'][$k]) || !$defaults['product_name'][$k]) {
$js .= "{$formName}['product_name[{$k}]'].style.display = 'none';\n";
}
}
$sel->setOptions(array($sel1, $sel2));
$js .= "</script>\n";
$form->assign('initHideBoxes', $js);
$form->addDate('fulfilled_date', ts('Fulfilled'), FALSE, array('formatType' => 'activityDate'));
$form->addElement('text', 'min_amount', ts('Minimum Contribution Amount'));
}
示例3: postProcess
/**
* Process the form after the input has been submitted and validated.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function postProcess(&$form)
{
// check and ensure that
$thisValues = $form->controller->exportValues($form->getName());
$fromSmsProviderId = $thisValues['sms_provider_id'];
// process message template
if (!empty($thisValues['saveTemplate']) || !empty($thisValues['updateTemplate'])) {
$messageTemplate = array('msg_text' => $thisValues['sms_text_message'], 'is_active' => TRUE);
if (!empty($thisValues['saveTemplate'])) {
$messageTemplate['msg_title'] = $thisValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
if (!empty($thisValues['template']) && !empty($thisValues['updateTemplate'])) {
$messageTemplate['id'] = $thisValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
}
// format contact details array to handle multiple sms from same contact
$formattedContactDetails = array();
$tempPhones = array();
foreach ($form->_contactIds as $key => $contactId) {
$phone = $form->_toContactPhone[$key];
if ($phone) {
$phoneKey = "{$contactId}::{$phone}";
if (!in_array($phoneKey, $tempPhones)) {
$tempPhones[] = $phoneKey;
if (!empty($form->_contactDetails[$contactId])) {
$formattedContactDetails[] = $form->_contactDetails[$contactId];
}
}
}
}
// $smsParams carries all the arguments provided on form (or via hooks), to the provider->send() method
// this gives flexibity to the users / implementors to add their own args via hooks specific to their sms providers
$smsParams = $thisValues;
unset($smsParams['sms_text_message']);
$smsParams['provider_id'] = $fromSmsProviderId;
$contactIds = array_keys($form->_contactDetails);
$allContactIds = array_keys($form->_allContactDetails);
list($sent, $activityId, $countSuccess) = CRM_Activity_BAO_Activity::sendSMS($formattedContactDetails, $thisValues, $smsParams, $contactIds);
if ($countSuccess > 0) {
CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $countSuccess)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $countSuccess)), 'success');
}
if (is_array($sent)) {
// At least one PEAR_Error object was generated.
// Display the error messages to the user.
$status = '<ul>';
foreach ($sent as $errMsg) {
$status .= '<li>' . $errMsg . '</li>';
}
$status .= '</ul>';
CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($sent), 'plural' => '%count Messages Not Sent')), 'info');
} else {
//Display the name and number of contacts for those sms is not sent.
$smsNotSent = array_diff_assoc($allContactIds, $contactIds);
if (!empty($smsNotSent)) {
$not_sent = array();
foreach ($smsNotSent as $index => $contactId) {
$displayName = $form->_allContactDetails[$contactId]['display_name'];
$phone = $form->_allContactDetails[$contactId]['phone'];
$contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactId}");
$not_sent[] = "<a href='{$contactViewUrl}' title='{$phone}'>{$displayName}</a>";
}
$status = '(' . ts('because no phone number on file or communication preferences specify DO NOT SMS or Contact is deceased');
if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') {
$status .= ' ' . ts("or the contact is not part of the activity '%1'", array(1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT));
}
$status .= ')<ul><li>' . implode('</li><li>', $not_sent) . '</li></ul>';
CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array('count' => count($smsNotSent), 'plural' => '%count Messages Not Sent')), 'info');
}
}
}
示例4: buildQuickForm
/**
* Build the form object.
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildQuickForm(&$form)
{
if ($form->_eventId) {
$form->_isPaidEvent = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_eventId, 'is_monetary');
if ($form->_isPaidEvent) {
$form->addElement('hidden', 'hidden_feeblock', 1);
}
// make sure this is for backoffice registration.
if ($form->getName() == 'Participant') {
$eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId);
$form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg'));
}
}
if ($form->_pId) {
if (CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $form->_pId, 'contribution_id', 'participant_id')) {
$form->_online = TRUE;
}
}
if ($form->_isPaidEvent) {
$params = array('id' => $form->_eventId);
CRM_Event_BAO_Event::retrieve($params, $event);
//retrieve custom information
$form->_values = array();
CRM_Event_Form_Registration::initEventFee($form, $event['id']);
CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId);
$lineItem = array();
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$totalTaxAmount = 0;
if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) {
$lineItem[] = $form->_values['line_items'];
foreach ($form->_values['line_items'] as $key => $value) {
$totalTaxAmount = $value['tax_amount'] + $totalTaxAmount;
}
}
if ($invoicing) {
$form->assign('totalTaxAmount', $totalTaxAmount);
}
$form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
$discounts = array();
if (!empty($form->_values['discount'])) {
foreach ($form->_values['discount'] as $key => $value) {
$value = current($value);
$discounts[$key] = $value['name'];
}
$element = $form->add('select', 'discount_id', ts('Discount Set'), array(0 => ts('- select -')) + $discounts, FALSE, array('class' => "crm-select2"));
if ($form->_online) {
$element->freeze();
}
}
if ($form->_mode) {
CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE);
} elseif (!$form->_mode) {
$form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"));
$form->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType());
$form->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDate'));
$form->add('select', 'payment_instrument_id', ts('Paid By'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"));
// don't show transaction id in batch update mode
$path = CRM_Utils_System::currentPath();
$form->assign('showTransactionId', FALSE);
if ($path != 'civicrm/contact/search/basic') {
$form->add('text', 'trxn_id', ts('Transaction ID'));
$form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'));
$form->assign('showTransactionId', TRUE);
}
$status = CRM_Contribute_PseudoConstant::contributionStatus();
// CRM-14417 suppressing contribution statuses that are NOT relevant to new participant registrations
$statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
foreach (array('Cancelled', 'Failed', 'In Progress', 'Overdue', 'Refunded', 'Pending refund') as $suppress) {
unset($status[CRM_Utils_Array::key($suppress, $statusName)]);
}
$form->add('select', 'contribution_status_id', ts('Payment Status'), $status);
$form->add('text', 'check_number', ts('Check Number'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'check_number'));
$form->add('text', 'total_amount', ts('Amount'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution', 'total_amount'));
}
} else {
$form->add('text', 'amount', ts('Event Fee(s)'));
}
$form->assign('onlinePendingContributionId', $form->get('onlinePendingContributionId'));
$form->assign('paid', $form->_isPaidEvent);
$form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"));
$form->add('select', 'from_email_address', ts('Receipt From'), $form->_fromEmails['from_email_id']);
$form->add('textarea', 'receipt_text', ts('Confirmation Message'));
// Retrieve the name and email of the contact - form will be the TO for receipt email ( only if context is not standalone)
if ($form->_context != 'standalone') {
if ($form->_contactId) {
list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($form->_contactId);
$form->assign('email', $form->_contributorEmail);
} else {
//show email block for batch update for event
$form->assign('batchEmail', TRUE);
}
}
//.........这里部分代码省略.........
示例5: postProcess
/**
* Process the form after the input has been submitted and validated.
*
* @param CRM_Core_Form $form
*/
public static function postProcess(&$form)
{
if (count($form->_contactIds) > self::MAX_EMAILS_KILL_SWITCH) {
CRM_Core_Error::fatal(ts('Please do not use this task to send a lot of emails (greater than %1). We recommend using CiviMail instead.', array(1 => self::MAX_EMAILS_KILL_SWITCH)));
}
// check and ensure that
$formValues = $form->controller->exportValues($form->getName());
$fromEmail = $formValues['fromEmailAddress'];
$from = CRM_Utils_Array::value($fromEmail, $form->_emails);
$subject = $formValues['subject'];
// CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields
$elements = array('cc_id', 'bcc_id');
$additionalDetails = NULL;
$ccValues = $bccValues = array();
foreach ($elements as $element) {
if (!empty($formValues[$element])) {
$allEmails = explode(',', $formValues[$element]);
foreach ($allEmails as $value) {
list($contactId, $email) = explode('::', $value);
$contactURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$contactId}", TRUE);
switch ($element) {
case 'cc_id':
$ccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$ccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
case 'bcc_id':
$bccValues['email'][] = '"' . $form->_contactDetails[$contactId]['sort_name'] . '" <' . $email . '>';
$bccValues['details'][] = "<a href='{$contactURL}'>" . $form->_contactDetails[$contactId]['display_name'] . "</a>";
break;
}
}
}
}
$cc = $bcc = '';
if (!empty($ccValues)) {
$cc = implode(',', $ccValues['email']);
$additionalDetails .= "\ncc : " . implode(", ", $ccValues['details']);
}
if (!empty($bccValues)) {
$bcc = implode(',', $bccValues['email']);
$additionalDetails .= "\nbcc : " . implode(", ", $bccValues['details']);
}
// CRM-5916: prepend case id hash to CiviCase-originating emails’ subjects
if (isset($form->_caseId) && is_numeric($form->_caseId)) {
$hash = substr(sha1(CIVICRM_SITE_KEY . $form->_caseId), 0, 7);
$subject = "[case #{$hash}] {$subject}";
}
// process message template
if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
$messageTemplate = array('msg_text' => $formValues['text_message'], 'msg_html' => $formValues['html_message'], 'msg_subject' => $formValues['subject'], 'is_active' => TRUE);
if (!empty($formValues['saveTemplate'])) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
if (!empty($formValues['template']) && !empty($formValues['updateTemplate'])) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplate::add($messageTemplate);
}
}
$attachments = array();
CRM_Core_BAO_File::formatAttachment($formValues, $attachments, NULL, NULL);
// format contact details array to handle multiple emails from same contact
$formattedContactDetails = array();
$tempEmails = array();
foreach ($form->_contactIds as $key => $contactId) {
// if we dont have details on this contactID, we should ignore
// potentially this is due to the contact not wanting to receive email
if (!isset($form->_contactDetails[$contactId])) {
continue;
}
$email = $form->_toContactEmails[$key];
// prevent duplicate emails if same email address is selected CRM-4067
// we should allow same emails for different contacts
$emailKey = "{$contactId}::{$email}";
if (!in_array($emailKey, $tempEmails)) {
$tempEmails[] = $emailKey;
$details = $form->_contactDetails[$contactId];
$details['email'] = $email;
unset($details['email_id']);
$formattedContactDetails[] = $details;
}
}
// send the mail
list($sent, $activityId) = CRM_Activity_BAO_Activity::sendEmail($formattedContactDetails, $subject, $formValues['text_message'], $formValues['html_message'], NULL, NULL, $from, $attachments, $cc, $bcc, array_keys($form->_toContactDetails), $additionalDetails);
$followupStatus = '';
if ($sent) {
$followupActivity = NULL;
if (!empty($formValues['followup_activity_type_id'])) {
$params['followup_activity_type_id'] = $formValues['followup_activity_type_id'];
$params['followup_activity_subject'] = $formValues['followup_activity_subject'];
$params['followup_date'] = $formValues['followup_date'];
$params['followup_date_time'] = $formValues['followup_date_time'];
$params['target_contact_id'] = $form->_contactIds;
$params['followup_assignee_contact_id'] = explode(',', $formValues['followup_assignee_contact_id']);
//.........这里部分代码省略.........
示例6: createActivities
/**
* @param CRM_Core_Form $form
* @param $html_message
* @param $contactIds
*
* @throws CRM_Core_Exception
*/
public static function createActivities($form, $html_message, $contactIds)
{
//Added for CRM-12682: Add activity subject and campaign fields
$formValues = $form->controller->exportValues($form->getName());
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('subject' => $formValues['subject'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $formValues), 'source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if (!empty($form->_activityId)) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
if (!empty($form->_caseId)) {
$caseActivityParams = array('activity_id' => $activity->id, 'case_id' => $form->_caseId);
CRM_Case_BAO_Case::processCaseActivity($caseActivityParams);
}
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
//@todo why are we using $form->_contactIds here & contactIds above - need comment
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'contact_id' => $contactId, 'record_type_id' => $targetID);
CRM_Activity_BAO_ActivityContact::create($activityTargetParams);
}
}