Status:
Answered
This patch (below) fixes the following bugs in ms_membership-5.x-5.8. I am aware this is not the latest version of the module;
- Add plan form validation incorrectly fails under certain criteria (According to 5.9's release notes, it seems this was also fixed there)
- Success message when added a new plan is missing the new plan's name
- 'PayPal History' tab is displayed to anonymous users
The following recommendations are made with @todo annotations in the patch;
- Merge the form/validate/submit functions for the add_plan and edit_plan forms into one set of form/validate/submit functions for both forms. This would mean that bug #1 above would have been found and fixed a lot sooner — and probably not released, because there would be better code-reuse.
- Convert the paypal API form to use the Form API (or perhaps a theme function). This would allow a developer to make various fields customizable by the end user. E.g.
http://www.realitysandwich.com/esm/join-evolver-social-movement-esm
Further, I recommend you use Drupal's code syntax standards and use the coder module to learn them and fix code style.
These changes are recommended because the modules do not, generally, adhere to Drupal coding standards, despite MoneyScript.net's claims to "follow Drupal Best Practices".
- Only in moneyscripts: .svn
- Only in moneyscripts: moneyscripts.patch
- Only in moneyscripts/ms_charts: .svn
- Only in moneyscripts/ms_charts/includes: .svn
- Only in moneyscripts/ms_charts/js: .svn
- Only in moneyscripts/ms_helper: .svn
- Only in moneyscripts/ms_membership: .svn
- Only in moneyscripts/ms_membership/includes: .svn
- Only in moneyscripts/ms_membership/js: .svn
- diff -rup orig/moneyscripts/ms_membership/ms_membership.module moneyscripts/ms_membership/ms_membership.module
- --- orig/moneyscripts/ms_membership/ms_membership.module 2010-02-20 20:13:49 -0800
- +++ moneyscripts/ms_membership/ms_membership.module 2010-04-05 20:01:58 -0700
- @@ -2014,6 +2014,7 @@ function ms_membership_process_ipn($type
- // ======================================
- // FORMS
- +// @todo: Merge the form/validate/submit functions for the add_plan and edit_plan forms into one set of form/validate/submit functions for both forms.
- // ======================================
- function ms_membership_add_plan_form() {
- @@ -2991,7 +2992,7 @@ $v = $form_values;
- }
- // Validate Number of Payments
- - if (($v['srt'] < 1) && $v['src']) {
- + if (($v['srt'] < 0 || $v['srt'] == 1) && $v['src']) {
- form_set_error('srt', t('You must enter more than 1 payment if you are using Recurring Subscription'));
- }
- // Validate Number of Payments
- @@ -3046,7 +3047,7 @@ function ms_membership_edit_plan_form_su
- $v['exp_rid'], $v['mpid']
- );
- }
- Only in moneyscripts/ms_paypal_api: .svn
- Only in moneyscripts/ms_paypal_api/includes: .svn
- diff -rup orig/moneyscripts/ms_paypal_api/includes/ms_paypal_api_class.php moneyscripts/ms_paypal_api/includes/ms_paypal_api_class.php
- --- orig/moneyscripts/ms_paypal_api/includes/ms_paypal_api_class.php 2010-01-01 14:14:26 -0800
- +++ moneyscripts/ms_paypal_api/includes/ms_paypal_api_class.php 2010-04-05 20:05:56 -0700
- @@ -18,6 +18,7 @@ class ms_paypal_api_class {
- }
- function submit() {
- + // @todo: To adhere with Drupal conventions, convert this to use the Form API or a theme function.
- $form = "<form id='paypalPaymentForm' method='post' name='paypal_form' action='". $this->ipnLink ."'>";
- foreach ($this->values as $name => $value) {
- $form .= "<input type='hidden' name='$name' value='$value' />";
- diff -rup orig/moneyscripts/ms_paypal_api/ms_paypal_api.module moneyscripts/ms_paypal_api/ms_paypal_api.module
- --- orig/moneyscripts/ms_paypal_api/ms_paypal_api.module 2010-01-22 07:21:57 -0800
- +++ moneyscripts/ms_paypal_api/ms_paypal_api.module 2010-04-05 20:03:03 -0700
- @@ -39,6 +39,8 @@ function ms_paypal_api_access_pages_test
- * Implementation of hook_menu
- */
- function ms_paypal_api_menu($may_cache) {
- + global $user;
- +
- if (!$may_cache) {
- @@ -71,15 +73,19 @@ function ms_paypal_api_menu($may_cache)
- - );
- - 'path' => 'user/'. $uid .'/paypal-history',
- - 'title' => 'PayPal History',
- - 'callback' => 'ms_paypal_api_history',
- - 'access' => ms_paypal_api_access_test($uid),
- );
- +
- + // Don't show this tab to anonymous users.
- + if ($uid > 0) {
- + 'path' => 'user/'. $uid .'/paypal-history',
- + 'title' => 'PayPal History',
- + 'callback' => 'ms_paypal_api_history',
- + 'access' => ms_paypal_api_access_test($uid),
- + );
- + }
- }
- return $items;








Bevan,
First, thanks for your patch and the suggestions, they are much appreciated. I have already fixed most of the things you mentioned in Membership Suite 6.0, and I will be adding the other things in before release.
One thing though, I cannot use the Forms API with the payment gateway 'submit' forms because they submit their values to other sites and domains, and the Forms API wasn't built to handle that. I suppose I could build the form and then submit the values of it manually, but I think it would be more intuitive to just expose a hook for other modules to alter the values before they are sent off. With the new system, this will be possible as well.
I run my modules through Coder to clean things up every so often, but sometimes some badly formatted code gets into a release. I actually just got done running Membership Suite 6.0 through coder last night, so I can assure you that I do regularly use that great tool :)
Again, thanks for your help and contribution!
Sincerely,
Leighton Whiting