From: Kurund Jalmi Date: Mon, 27 Jul 2015 06:45:26 +0000 (+0530) Subject: Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-07-27-10-02-15 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=86d6da5b052426f6cae65e67e772aba37aff5c6e;p=civicrm-core.git Merge remote-tracking branch 'upstream/4.6' into 4.6-master-2015-07-27-10-02-15 Conflicts: CRM/Contribute/Form/Contribution.php CRM/Core/Payment.php CRM/Core/Payment/IATS.php CRM/Core/Payment/PayPalImpl.php --- 86d6da5b052426f6cae65e67e772aba37aff5c6e diff --cc CRM/Core/Payment.php index 7420fe4f6a,5dd8ced50a..fe7f9797c5 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@@ -202,47 -191,22 +202,63 @@@ abstract class CRM_Core_Payment return FALSE; } + /** + * Does this processor support pre-approval. + * + * This would generally look like a redirect to enter credentials which can then be used in a later payment call. + * + * Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the + * contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the + * 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do. + * + * @return bool + */ + protected function supportsPreApproval() { + return FALSE; + } + + /** + * Can recurring contributions be set against pledges. + * + * In practice all processors that use the baseIPN function to finish transactions or + * call the completetransaction api support this by looking up previous contributions in the + * series and, if there is a prior contribution against a pledge, and the pledge is not complete, + * adding the new payment to the pledge. + * + * However, only enabling for processors it has been tested against. + * + * @return bool + */ + protected function supportsRecurContributionsForPledges() { + return FALSE; + } + + /** + * Function to action pre-approval if supported + * + * @param array $params + * Parameters from the form + * + * This function returns an array which should contain + * - pre_approval_parameters (this will be stored on the calling form & available later) + * - redirect_url (if set the browser will be redirected to this. + */ + public function doPreApproval(&$params) {} + + /** + * Get any details that may be available to the payment processor due to an approval process having happened. + * + * In some cases the browser is redirected to enter details on a processor site. Some details may be available as a + * result. + * + * @param array $storedDetails + * + * @return array + */ + public function getPreApprovalDetails($storedDetails) { + return array(); + } + /** * Default payment instrument validation. * diff --cc CRM/Core/Payment/PayPalImpl.php index 1bacf20c24,28ba5849bd..68a4b168d2 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@@ -76,69 -85,22 +76,85 @@@ class CRM_Core_Payment_PayPalImpl exten return FALSE; } + /** + * Does this processor support pre-approval. + * + * This would generally look like a redirect to enter credentials which can then be used in a later payment call. + * + * Currently Paypal express supports this, with a redirect to paypal after the 'Main' form is submitted in the + * contribution page. This token can then be processed at the confirm phase. Although this flow 'looks' like the + * 'notify' flow a key difference is that in the notify flow they don't have to return but in this flow they do. + * + * @return bool + */ + protected function supportsPreApproval() { + if ($this->_processorName == ts('PayPal Express')) { + return TRUE; + } + return FALSE; + } + + /** + * Opportunity for the payment processor to override the entire form build. + * + * @param CRM_Core_Form $form + * + * @return bool + * Should form building stop at this point? + */ + public function buildForm(&$form) { + if ($this->_processorName == 'PayPal Express' || $this->_processorName == 'PayPal Pro') { + $this->addPaypalExpressCode($form); + if ($this->_processorName == 'PayPal Express') { + CRM_Core_Region::instance('billing-block-post')->add(array( + 'template' => 'CRM/Financial/Form/PaypalExpress.tpl', + 'name' => 'paypal_express', + )); + } + if ($this->_processorName == 'PayPal Pro') { + CRM_Core_Region::instance('billing-block-pre')->add(array( + 'template' => 'CRM/Financial/Form/PaypalPro.tpl', + )); + } + } + return FALSE; + } + + /** + * Billing mode button is basically synonymous with paypal express - this is probably a good example of 'odds & sods' code we + * need to find a way for the payment processor to assign. A tricky aspect is that the payment processor may need to set the order + * + * @param $form + */ + protected function addPaypalExpressCode(&$form) { + if (empty($form->isBackOffice)) { + $form->_expressButtonName = $form->getButtonName('upload', 'express'); + $form->assign('expressButtonName', $form->_expressButtonName); + $form->add( + 'image', + $form->_expressButtonName, + $this->_paymentProcessor['url_button'], + array('class' => 'crm-form-submit') + ); + } + } + + /** + * Can recurring contributions be set against pledges. + * + * In practice all processors that use the baseIPN function to finish transactions or + * call the completetransaction api support this by looking up previous contributions in the + * series and, if there is a prior contribution against a pledge, and the pledge is not complete, + * adding the new payment to the pledge. + * + * However, only enabling for processors it has been tested against. + * + * @return bool + */ + protected function supportsRecurContributionsForPledges() { + return TRUE; + } + /** * Express checkout code. Check PayPal documentation for more information * diff --cc CRM/Financial/BAO/PaymentProcessor.php index 83550bdb59,4bbc650c21..6e1b723ee1 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@@ -268,17 -302,18 +268,18 @@@ class CRM_Financial_BAO_PaymentProcesso * @return array */ public static function getAllPaymentProcessors($mode, $reset = FALSE) { - /* - * $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all'); - * if (!$reset) { - * $processors = CRM_Utils_Cache::singleton()->get($cacheKey); - * if (!empty($processors)) { - * return $processors; - * } - * } - */ + + $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all'); + if (!$reset) { + $processors = CRM_Utils_Cache::singleton()->get($cacheKey); + if (!empty($processors)) { + return $processors; + } + } + $retrievalParameters = array( 'is_active' => TRUE, + 'domain_id' => CRM_Core_Config::domainID(), 'options' => array('sort' => 'is_default DESC, name'), 'api.payment_processor_type.getsingle' => 1, ); diff --cc CRM/Price/BAO/PriceSet.php index 4827833009,794c0a591b..92453318cf --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@@ -1412,6 -1397,46 +1412,54 @@@ LEFT JOIN civicrm_price_field pf ON p LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id LEFT JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_id WHERE ps.id = %1 + "; + + $params = array(1 => array($id, 'Integer')); + $dao = CRM_Core_DAO::executeQuery($query, $params); + - $autoRenew = array(); - //FIXME: do a comprehensive check of whether - //2 membership types can be selected - //instead of comparing all of them ++ $membershipTypes = array( ++ 'all' => array(), ++ 'autorenew' => array(), ++ 'autorenew_required' => array(), ++ 'autorenew_optional' => array(), ++ ); + while ($dao->fetch()) { - //temp fix for #CRM-10370 - //if its NULL consider it '0' i.e. 'No auto-renew option' - $daoAutoRenew = $dao->auto_renew; - if ($daoAutoRenew === NULL) { - $daoAutoRenew = 0; ++ if (empty($dao->membership_type_id)) { ++ continue; + } - if (!empty($autoRenew) && !in_array($daoAutoRenew, $autoRenew)) { - return TRUE; ++ $membershipTypes['all'][] = $dao->membership_type_id; ++ if (!empty($dao->auto_renew)) { ++ $membershipTypes['autorenew'][] = $dao->membership_type_id; ++ if ($dao->auto_renew == 2) { ++ $membershipTypes['autorenew_required'][] = $dao->membership_type_id; ++ } ++ else { ++ $membershipTypes['autorenew_optional'][] = $dao->membership_type_id; ++ } ++ } ++ else { ++ $membershipTypes['non_renew'][] = $dao->membership_type_id; + } - $autoRenew[] = $daoAutoRenew; + } - return FALSE; ++ return $membershipTypes; + } + + /** + * Get an array of the membership types in a price set. + * + * @param int $id + * + * @return array( + * Membership types in the price set + */ + public static function getMembershipTypesFromPriceSet($id) { + $query + = "SELECT pfv.id, pfv.price_field_id, pfv.name, pfv.membership_type_id, pf.html_type, mt.auto_renew + FROM civicrm_price_field_value pfv + LEFT JOIN civicrm_price_field pf ON pf.id = pfv.price_field_id + LEFT JOIN civicrm_price_set ps ON ps.id = pf.price_set_id + LEFT JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_id + WHERE ps.id = %1 "; $params = array(1 => array($id, 'Integer')); diff --cc templates/CRM/Case/Form/Activity.tpl index 8e7b997f15,5e2b943e88..95dc28bf74 --- a/templates/CRM/Case/Form/Activity.tpl +++ b/templates/CRM/Case/Form/Activity.tpl @@@ -59,9 -62,10 +59,9 @@@ || $activityTypeFile EQ 'ChangeCaseStartDate'} {include file="CRM/Case/Form/Activity/$activityTypeFile.tpl"} - {ts}Notes{/ts} + {ts}Details{/ts} - {* If using plain textarea, assign class=huge to make input large enough. *} - {if $defaultWysiwygEditor eq 0}{$form.details.html|crmAddClass:huge}{else}{$form.details.html}{/if} + {$form.details.html} {* Added Activity Details accordion tab *}