This module is the result of the conversation in http://www.ubercart.org/forum/support/9952/need_remove_role_purchase.

Use case

  • We have a product Silver associated with a Silver role and a product Gold associated with a Gold role. We also have other roles in our site independent of memberships.
  • A user buys a Silver Membership.
  • A few days later, before the actual expiration of the Silver Membership, the user decides to buy the Gold Membership.
  • By default, the user will have both Silver and Gold roles.
  • UC Clear Roles is responsible for fixing exactly this by removing the Silver role. Ubercart does the rest.

Notice:
In the example above, the user loses all days he would normally be allowed to remain as Silver and immediately changes to Gold as a new membership and not as a renewal..
In case a Gold user buys another Gold membership product before the actual expiration of the first package, this module does nothing and expiration time gets appended(and not resetted).

This module also respects other roles that may exist in your system but are independent of memberships(ex. admin, article-writer, editor). For choosing which roles are memberships and which are not, an administration page exists for the administrator to choose.

UC Clear Roles works with Conditional Actions and not with Rules. Therefore, it is only applicable to Ubercart 2.x and Drupal 6.x. There is no plan right now to make a port to D7.

Reviewed the following projects:
Taxonomy Term Google Maps: http://drupal.org/node/1799766#comment-6542330
HTTP proxy: http://drupal.org/node/1797090#comment-6542120
User Request Name: http://drupal.org/node/1784544#comment-6542238
Advanced Forum Basic Subscription: http://drupal.org/node/1466090#comment-6547012
GC-Code: http://drupal.org/node/1532408#comment-6546828
Deep Survery: http://drupal.org/node/1236914#comment-6546924

CommentFileSizeAuthor
#12 drupalcs-result.txt2.78 KBklausi

Comments

ccardea’s picture

Status: Needs review » Needs work

Please provide a link to your sandbox project.

vensires’s picture

Link is:http://drupal.org/sandbox/vensires/1219984. "UC Clear Roles" in my first post is actually a link to my sandbox project.

vensires’s picture

Status: Needs work » Needs review
ccardea’s picture

Status: Needs review » Needs work

The only thing in the repository is the .info file, which has only the name of your project. You need to push your code to the repository. Also it looks like you need to identify yourself to git. The author of your initial commit is unknown

vensires’s picture

Thank you ccardea! Now it's all done. Check it out!

vensires’s picture

Status: Needs work » Needs review
davisben’s picture

Status: Needs review » Needs work

Hi vensires,
You should run your module through Coder with the minor setting selected. This will help you fix some problems that I noticed. After doing that, set this back to Needs Review, and I'll go through and do a more thorough review.

nyleve101’s picture

Hi,

this seems great, is it still in development?

Hope you're well,

Evelyn

vensires’s picture

Hi Evelyn!
Actually, even if it's not entitled by Drupal a full project, it is actually ready and you can download it from http://drupal.org/sandbox/vensires/1219984. As for further development, besides the coder module suggestions that I have not yet implemented, I do not think I have anything else to do. If you want anything more though, please file a feature request in the project issue queue and let's discuss it there.

nyleve101’s picture

Vensires,

thanks for getting back to me. I'll check it out right away. Thanks for your hard work!

Evelyn

vensires’s picture

Status: Needs work » Needs review

Module code is now fixed with coding standards. So 10oclock (or anyone else) if you might test it please :D

klausi’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: security
StatusFileSize
new2.78 KB

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

manual review:

  • uc_clear_roles.info: Remove "; $".
  • "return array(uc_clear_roles_ADMIN);": permissions string should be enclosed in quotes ''. Same in hook_menu().
  • "'#options' => user_roles()," you need to sanitize the role names before outputting them to avoid XSS attacks.
  • uc_clear_roles_admin_form(): you should use system_settings_form().
  • uc_clear_roles_action_order_delete(): for building the query you should use db_placeholders(), see also http://drupal.org/writing-secure-code . And do not use sprintf(), the DB API will handle the replacements for you.
misc’s picture

@vensires has been contacted to ask if the application is abandoned.

After ten weeks with a status of needs work: the applicant may be contacted by a reviewer to determine whether the application was indeed abandoned. The action taken by the reviewer should be documented in the project application issue.

http://drupal.org/node/894256

vensires’s picture

Sorry for the huge delay. The application isn't abandoned. But due to heavy work, it has been left a little behind and it will have to wait a little while longer.

vensires’s picture

I think I have done all the needed changes to the code. Could you please check it once again?

klausi’s picture

You need to set the status to "needs review" if you want to get a review.

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

vensires’s picture

Status: Needs work » Needs review

You are quite right klausi. I will do my best when I go home.

caiovlp’s picture

Status: Needs review » Needs work

Please document the requirements and dependencies on your project page. I had to read the .info file to see what it needs to work.
t() shouldn't be used in the hook_menu titles.
Also found a few coding standard issues. Please use the following tool to validate your project: http://ventral.org/pareview

vensires’s picture

Status: Needs work » Needs review

It took some time but I think that finally everything is the way it should be. Could you please check once again?

vensires’s picture

klausi’s picture

Issue tags: +PAreview: security

Please don't remove the security tag, we keep that for statistical purposes and to show examples of security problems.

vensires’s picture

I'm sorry klausi. Removed by accident!

klausi’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

Thanks for your reviews, just make sure that you pick the oldest applications first. When finishing your review comment also set the issue status either to "needs work" (you found some problems with the project) or "reviewed & tested by the community" (you found no major flaws).

Please add all your reviews to the issue summary as indicated in #1410826: [META] Review bonus.

manual review:

  1. "variable_get('uc_clear_roles_roles'...": if you define your own variables you should remove them on module uninstallation (hook_uninstall()).
  2. why did you remove comments in the code? Please add them back. The coding standards only say that inline comments should be on there own line and that longer function descriptions should have their own paragraph in the doc block. Removing comments really hurts my feelings :-(

But otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

vensires’s picture

Thank you for your kind comments and advices klausi! Since it hurt you, I restored the comments in the code, in their own line of course :-)
I also created a .install file to variable_del() the variable I used in the module.
Also, thanks to you and your idea of "adding the comments back", I found out that the module assumed (in most cases correctly but...) that each product is associated with one and only role and fixed it to work with multiple roles per product.

PAReview.sh keeps returning 0 errors and 0 warning, so the process can keep going. Thank you for voting +1 RTBC for me!

vensires’s picture

Issue summary: View changes

Added the projects I have reviewed.

vensires’s picture

Issue tags: +PAreview: review bonus

Latest reviews (added to summary too):
Advanced Forum Basic Subscription: http://drupal.org/node/1466090#comment-6547012
GC-Code: http://drupal.org/node/1532408#comment-6546828
Deep Survery: http://drupal.org/node/1236914#comment-6546924

patrickd’s picture

Assigned: Unassigned » patrickd
patrickd’s picture

Status: Reviewed & tested by the community » Fixed

.install

7 /**
   8  * Implements hook_install().
   9  */
  10 function uc_clear_roles_install() {
  11 }

Don't implement hooks that do nothing.

Thanks for your contribution!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

vensires’s picture

Thank you very much all of you for your patience, your comments, your suggestions and everything! I'll try to remember all these things while programming and giving back to the community! I hope we will each other around Drupal.org :-)

PatrickD thanks for giving the final blow for this project to become full. :)
Klausi, I also have a thanks for you and I end this little speech with you since you were the guide here for me in this vast Drupalopoly!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added latest reviews of other projects.