CVS edit link for jm.federico

Well, it's been almost 2 years since I became a hard-core Drupal developer, and since then I just fell in love with it. Have been 2 great years where I had the chance to really learn how things are.

I started developing custom modules for clients 6 months ago and now I already have 2 which I would love to share with the community.

On of them being an add-on module for ubercart, a favorite order module. It basically lets any user of a site with ubercart save an order for quick use. It integrates smoothly with Ubercart and Drupal and my clients already love it. I've seen some requests out there for something like this so here I have it.

There is an alpha version in http://eqx-biz2.dns2au.com/~freshasf/drupal/
If you create an account log in and add product to the cart you can see what the idea is. And if you go to your account settings you should see a tab for favourite order.

The other module is in development and is an access control module for stores that sell articles where they need to give access to the snippet to non subscribers and an option to buy the article, but also give full access to users that have the appropriate permission. It kind of works on www.intermedium.com.au but that is the first version that I developed, I kept working on it and I hope I can make it available to everyone out there. It integrates with ubercart (again).

Check these links. They both are the same content type but one has restricted access. The other one is free to read by anyone.

http://www.intermedium.com.au/content/ict-expertise-under-represented-ap...
http://www.intermedium.com.au/content/free-article-education-receives-24...

I've already submitted some patches to other modules, and of you check you'll see the difference between my first posts and the last ones. I've improved a lot!

That and the fact that I just love Drupal and want to do all I can to make sure that we keep growing as a community and make of this the best CMS out there!

Also, right now I live in Australia, but in 6 month will be moving back to Colombia, where I am from, and I plan to really introduce Drupal there.

Hope you all have a nice day.

Federico

Comments

jm.federico’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new4.79 KB

Attaching Ubercart Favorite Order module

Not attaching the security access one because the code is a mess and somebody would cry if it is seen.

Cheers

avpaderno’s picture

Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

dman’s picture

Status: Needs review » Needs work

This is indeed a requested module, and I'm not aware of any duplication.
The code looks really tidy, and the docblocks are all accurate.

Mostly good use of t() and other Drupal API.
I'm not in favor of using serialized blobs in the database to store your array data, but that's your choice.
Curious indenting on some nested arrays, but I don't think it's wrong.

1

Unfortunately coder.module does not agree with all of the code style. :-(
It's all REALLY boring and trivial whitespace niggles, but try running coder.module over it to get in the habit.
Coder.module report below.

2

  $result = mysql_query("SELECT * FROM uc_favor
   WHERE uid='$user_id'") or die(mysql_error());  
  $result = mysql_fetch_array($result);

No. Must use Drupal DB API

3

function uc_favor_menu(){
  $items['user/%/favorite_order'] = array(
    'title' => 'Favorite Order',
    'page callback' => 'uc_favor_show_favorite_order',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

Visually, this looks like a privacy breach? Anyone can see what any other user has favorited?

4

What's happening with the "e-" here looks like it needs documentation. Sure looks weird on review. Also it would appear the message is not always correct?

/**
 * Process Favorite function form
 */
function uc_favor_load_fav_order_submit($form, &$form_state) {
  $clear = '';
  // Check if we want to clear cart's content
  if($form_state['clicked_button']['#post']['clear']){
    $clear = 'e-';
  }
  drupal_set_message(t('Your favorite order has been added to the cart'));
  // redirect using Ubercart CART LINK
  $form_state['redirect'] = 'cart/add/'.$clear.$form_state['values']['link'];
}

... I've not yet tried the module, just scanned the code visually for inconsistencies.

coder.module:

uc_favor.module

Line 23: Control statements should have one space between the control keyword and opening parenthesis
  if(user_is_logged_in()){
Line 23: use a space between the closing parenthesis and the open bracket
  if(user_is_logged_in()){
Line 39: use a space between the closing parenthesis and the open bracket
function uc_favor_save_order($form, &$form_state){
Line 51: Control statements should have one space between the control keyword and opening parenthesis
  foreach($form_state['values']['items'] as $product){
Line 51: use a space between the closing parenthesis and the open bracket
  foreach($form_state['values']['items'] as $product){
Line 53: Control statements should have one space between the control keyword and opening parenthesis
    if($product['remove']!=1 && $product['qty']!=0){
Line 53: use a space between the closing parenthesis and the open bracket
    if($product['remove']!=1 && $product['qty']!=0){
Line 57: Control statements should have one space between the control keyword and opening parenthesis
      if($first>1){
Line 57: use a space between the closing parenthesis and the open bracket
      if($first>1){
Line 61: string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
      $order_link .= 'p'.$product['nid'].'_q'.$product['qty'];
Line 72: Control statements should have one space between the control keyword and opening parenthesis
  if($first){
Line 72: use a space between the closing parenthesis and the open bracket
  if($first){
Line 76: else statements should begin on a new line
  }else{
Line 77: table names should be enclosed in {curly_brackets}
    mysql_query("DELETE FROM uc_favor WHERE uid='$user->uid'") 
Line 79: missing space after comma
    drupal_set_message(t('You have no favorite order.'),'notice');
Line 92: use a space between the closing parenthesis and the open bracket
function uc_favor_menu(){
Line 103: use a space between the closing parenthesis and the open bracket
function uc_favor_show_favorite_order($user_id = NULL){
Line 105: table names should be enclosed in {curly_brackets}
  $result = mysql_query("SELECT * FROM uc_favor
Line 109: Control statements should have one space between the control keyword and opening parenthesis
  if($result){
Line 109: use a space between the closing parenthesis and the open bracket
  if($result){
Line 123: Control statements should have one space between the control keyword and opening parenthesis
    foreach($products as $product){
Line 123: use a space between the closing parenthesis and the open bracket
    foreach($products as $product){
Line 126: missing space after comma
                                      array('data' => $node->title,'class' => 'desc'),
Line 127: missing space after comma
                                      array('data' => $product['qty'],'class' => 'qty'),
Line 128: missing space after comma
                                      array('data' => uc_currency_format($node->sell_price),'class' => 'price'),
Line 129: missing space after comma
                                      array('data' => uc_currency_format($node->sell_price*$product['qty']),'class' => 'price'),
Line 140: Arrays should be formatted with a space separating each element and assignment operator
                                          'data'=>'<strong>'.t('subtotal').'</strong> '.uc_currency_format($subtotal),
Line 140: string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
                                          'data'=>'<strong>'.t('subtotal').'</strong> '.uc_currency_format($subtotal),
Line 141: Arrays should be formatted with a space separating each element and assignment operator
                                          'colspan'=>4,
Line 142: Arrays should be formatted with a space separating each element and assignment operator
                                          'class'=>'subtotal',
Line 149: missing space after comma
    $content .= theme_table($header,$rows,array('id' => 'uc_favor-favorite-order'));
Line 155: else statements should begin on a new line
  }else{
Line 190: Control statements should have one space between the control keyword and opening parenthesis
  if($form_state['clicked_button']['#post']['clear']){
Line 190: use a space between the closing parenthesis and the open bracket
  if($form_state['clicked_button']['#post']['clear']){
Line 195: string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
  $form_state['redirect'] = 'cart/add/'.$clear.$form_state['values']['link'];

sites/all/modules/contributions/uc_favor/uc_favor.install
uc_favor.install

Line -1: Include the CVS keyword $Id$ in each file. This should be in the format // $Id$ or // $Id$ (Drupal Docs)
Line 15: use a space between the closing parenthesis and the open bracket
function faf_fav_or_install(){
Line 23: use a space between the closing parenthesis and the open bracket
function faf_fav_or_uninstall(){
Line 31: use a space between the closing parenthesis and the open bracket
function faf_fav_or_schema(){
jm.federico’s picture

Status: Needs review » Needs work
StatusFileSize
new5.34 KB

Hello! I'm Back

Right, so I did some changes!

I agree with the serialize thing. It will eventually be a separate table. But for now will leave as is. Part of the todo list.

Using Drupal db API now.

I have no idea how I didn't see the access check.

If you installed the previous code, uninstall, delete files and enable new module. No update option yet and I changed the name.

Also, there were inconsistencies between .install and .module with some names. This is because "faf_fav_or" was the name of the module when first started for a client (faf being the initials of the client). Now it is all uc_favorder

Demo version here:
http://122.252.1.190/~freshasf/drupal

There are no links to the cart :( remember to use
http://122.252.1.190/~freshasf/drupal/cart

Federico

jm.federico’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs work » Needs review

string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms

The coding standards report to add a space before, and after the concatenation operator, as for other operators.

dman’s picture

Yeah, looks like I need to update the install of coder.module on my testbed - if it's been updated to that change.

jm.federico’s picture

coder initially reported

string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms

But will change anyway to include spaces before and after the operator, regardless of what is being concatenated.

Yes, it changed. It just works like a new module because I changed the name and the database schema. This would be the final name, so from now on should include updates if database changes.

Should I submit again with spaces for the concatenation operators?

jm.federico’s picture

StatusFileSize
new5.01 KB

Attached new files.
Removed code that was left form previous version where I had an extra Database field where I was storing a string to be used as a Ubercart CART LINK.

That was the initial module. Changed it now to use Ubercart functions and be able to control the redirect at the end of the submission (redirect with ubercart CART LINK was not working).

Right now there is no redirect. but in the future the idea is to have a block with the load favourite order link/button, and the redirect could be set using the admin section (which also is a TODO).

Well, the todo list is endless. But I hope you get the idea, this is the simplest version of the module. From now on is all about making it more powerful!

jm.federico’s picture

Hello guys, just checking if you've had the time to check the module.

I'm very keen on keep working on it, and off course keep learning as I go. Comments, critiques and suggestions are more than welcome!

Cheers

jm.federico’s picture

StatusFileSize
new3.6 KB

Hello

Adding another really simple module that I have, I know one exists already for this, but I felt it was to complex to what it needs to do. I already contacted the developer and gave him my code for him to decide if he wants to merge both options.

It lets a user limit the taxonomy tags to a single value or a single numeric value

Attaching here for you to check

avpaderno’s picture

@jm.federico: We just review a module / theme per applicant.

jm.federico’s picture

@kiamlaluno, didn't know, :P

Cheers

jm.federico’s picture

If I have made improvements to the one you are reviewing, should I upload them?

tr’s picture

Seems like there's a lot of overlap between this and uc_reorder http://drupal.org/project/uc_reorder ? uc_reorder adds a button to the customer's order history so the customer can quickly replicate a previous order. The button adds the contents of the previous order to the cart, which allows the customer to modify the order (add items/delete items/change attributes) or just go straight to checkout. uc_reorder has been on drupal.org for more than a year (and on ubercart.org for another year prior to that), and is being actively maintained.

jm.federico’s picture

StatusFileSize
new5.23 KB

It certainly seems like there is some overlapping. They are two different approaches though. uc_reorder is definitely handy [installed and in use ;)] but I still think a favourite order is needed. Even if you can reorder a previous order, the process a user has to go through to reorder their favourite articles is longer than it should be.

I'm attaching an update to the favourite order module. You'll see that I put a block that will give the user instant access to the orders content and a one-click solution to order it.

This module is still not compatible with attributes, that is in the TODO list too.

Cheers

avpaderno’s picture

CVS requirements report that the proposed module must not duplicate the work done from existing project, which doesn't only mean duplicated code.

jm.federico’s picture

Hi I undrestand there sholud be no 2 modules doing the same thing. And I think we have 2 different modules here.

I'll give you one example. Lets say you do your groceries online, and you have some basic products you always get, but every week you also get whatever is in special, or whatever you feel like ordering different to last time. You can't really use uc_reorder because you would have to:

  1. Go to previous orders page
  2. load last order
  3. Go to shopping cart
  4. Remove products you do not want (las week special for example)
  5. Add extra products (if any)
  6. Checkout

While with favourite order:

  1. Load favorite order
  2. Add extra products (if any)
  3. Checkout

Another example: If you are a new customer and you haven't ordered anything yet, you can't really re-order. With favourite order you can save it for future use if you want.

I guess my point is that even when they look like they do the same thing, the don't. Put yourself in the final user position. Would you find the "favorite order" option to be the same as "re order from last orders". I don't. I think thet both have their use, but are two different things.

Let me know what you think.

Federico

jm.federico’s picture

Hello, me here again. I'm just wondering if there are some news.

:( I really want to put this up there and give back to others what others have given me.

Cheers ;)

dave reid’s picture

Issue tags: +Ubercart

Tagging all CVS applications with ubercart-related code.

avpaderno’s picture

Status: Needs review » Needs work
  • This is a partial review.
  • The points reported in this review are not in order of importance / relevance.
  • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
  • Not all the reported points are application blockers; some of the points I report are simple suggestions to who applies for a CVS account. For a list of what is considered a blocker for the application approval, see CVS applications review, what to expect. Keep in mind the list is still under construction, and can be changed to adapt it to what has been found out during code review, or to make the list clearer to who applies for a CVS account.
  1. The version line needs to be removed from the .info file.
  2. Hook implementation comments should be like the following one:
    /**
     * Implements hook_menu().
     */
    
  3. Menu descriptions and titles, as well as schema descriptions, are not passed to t().
  4.   if ($uid == $user->uid || user_access('administer users')) {
        return TRUE;
      }
      else {
        return FALSE;
      }
    
    
        return ($uid == $user->uid || user_access('administer users'));
    
jm.federico’s picture

Status: Needs work » Needs review
StatusFileSize
new5.55 KB

@kiamlaluno
Thanks for your comments

Uploading improved version.

  • Correct use of uc_price()
  • Descriptions, and titles not passed to t()
  • Avoid unnecessary db queries
  • Saves more info about the order. Needed to integrate with uc_attribute (not tested, probably not working)
  • Some typos

NOTE: This version stores data differently, there is no upgrade path. If you have an older one running, make sure you un-install and re-install.

Cheers

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Needs review » Fixed

Thank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, 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.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)
Issue tags: -Ubercart, -Module review

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

avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes