CVS edit link for wdki

I have created a module providing extra settings for uc cart (ordering cart columns, overriding cart columns titles, addind a unit price collumn, replace checkboxes cart remove items system by text or image). I want to publish it on drupal.org and i will maintain it.
Best regards

Comments

raphael apard’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new25.46 KB

Asking for create my own project : Module "UC Cart extra settings"

------------
Description
------------

This module provides extra settings for UC Cart.
- Alter cart columns order
- Overwrite cart columns titles
- Add "Unit price" column
- Replace items remove checkboxes by text or image
- Freeze cart items quantity inputs text
- Hide update cart button

------------
Requirements
------------

- Drupal 6
- UC Cart

------------
Installation
------------

- Copy uc_cart_extra into your drupal modules directory

- Enable the module on the Modules admin page:
Administer > Site building > Modules

- Go to UC cart settings page to alter default settings
Administer > Store administration > Configuration > Cart settings

Best regards,
Raphael

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.

raphael apard’s picture

StatusFileSize
new25.51 KB

Hello and thanks too.
I made some corrections about a multilangual variable and add some check_plain(), so i post the new version.
Sorry for this duplicate upload but i can't edit the first one.

I have a question for volunteers :
I use a reverse function of t() because of cart column default titles which are defined as t('Some text') before i get them.
May i use i18n multilingual variables for those values to avoid that ? But i saw that Order workflow do not use them so i'm not sure ?

This will be probably more easy to understand reading code.
Regards

Raphael

raphael apard’s picture

StatusFileSize
new24.72 KB

Hello,

I update my module. Now it use i18n multilingual variables for cart column titles, and i remove the reverse t() function.
Regards

Raphael

raphael apard’s picture

StatusFileSize
new44.66 KB

A screenshot of what does this module

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Module looks pretty good on a read of the code.

Some minor points could do with addressing:

- DEFINE('CART_REMOVE_IMG', base_path() . drupal_get_path('module', 'uc_cart_extra') . '/delete-icon.gif');

You're only using this twice, and in the same function too. You don't need this as a constant.

- uc_cart_extra_init

Do you really need to run this on every single page load? I am not entirely sure what it does, but could it be run more selectively?

- it's good practice when you define variables to delete them all in your module's hook_uninstall().

- code formatting points to bear in mind: space after foreach and switch; space after comma in function calls; space before opening a block brace; space after semicolon in C-style foreach; space either side of comparison operators. Hence this:

        for($i=0;$i<count(uc_cart_get_contents());$i++){

should be:

        for ($i = 0; $i < count(uc_cart_get_contents()); $i++) {

- keywords like TRUE, FALSE, and NULL should be in capitals.

I'm going to recommend this for a CVS account, as I see good attention to detail in general (bonus points for doxygen headers on all functions!) and I'm confident the module author will address the above points before making a release :)

avpaderno’s picture

Status: Reviewed & tested by the community » Needs work
  • The points reported in this review are not in order or 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. function uc_cart_extra_init() {
      global $conf;
      $table = uc_cart_view_table(null);
      $columns = $table["#columns"];
      
      foreach($columns as $column_id => $column) {
        $conf['i18n_variables'][] = 'uc_cart_columns_' . $column_id . '_title';
      }
      $conf['i18n_variables'][] = 'uc_cart_columns_unit_price_title';
      $conf['i18n_variables'][] = 'uc_cart_columns_replacing_text';
    }
    
    

    hook_init() is executed for not cached pages; depending from the module, that can create problems.

  2.           $pattern = '<img src="' . CART_REMOVE_IMG . '" alt="' . t('Delete') . '" />';
    
    

    There is a Drupal theme function to use in this case.

  3. The module doesn't implement hook_uninstall().
  4. The archive contains backup files that need to be removed.
raphael apard’s picture

Status: Needs work » Active

Hi,

Thanks to joachim & kiamlaluno for your replies.
I fixed issue from joachim message, but i don't know what to use :

1. for

<?php
function uc_cart_extra_init() {
  global $conf;
  $table = uc_cart_view_table(null);
  $columns = $table["#columns"];
  
  foreach($columns as $column_id => $column) {
    $conf['i18n_variables'][] = 'uc_cart_columns_' . $column_id . '_title';
  }
  $conf['i18n_variables'][] = 'uc_cart_columns_unit_price_title';
  $conf['i18n_variables'][] = 'uc_cart_columns_replacing_text';
}
?>

Do I have to use an implementation of hook_boot() ?
I need to set these i18n variables.

2. And for :

<?php
          $pattern = '<img src="' . CART_REMOVE_IMG . '" alt="' . t('Delete') . '" />';
?>

I use a themable function as :

<?php
          function theme_uc_cart_extra_icon() {
                    return '<img src="' . base_path() . drupal_get_path('module', 'uc_cart_extra') . '/delete-icon.gif' . '" alt="' . t('Delete') . '" />'
          }
?>

Is that correct ?

Thank you for your time
Regards

Raphael

joachim’s picture

Status: Active » Needs work

uc_cart_extra_init() -- my point about this was do you actually need to do all this on *every single loaded page of the site*? It seems to me you probably don't. Thus hook_boot() would be just as bad!

Also -- though these are moot --
- global $conf; -- namespace globals! don't assume your module will be the only one to want to call a global variable $conf ;)
- $table = uc_cart_view_table(null); -- NULL, not null.

$pattern = 'Only local images are allowed.

raphael apard’s picture

Status: Needs work » Active

Thanks for helping me. I fix all issues except the big for i18n_variables.
I don't see antoher way to define them, ubercart module use hook_init(), and i find this :
http://drupal.org/node/313272#comment-2786004.
Maybe i will have to remove i18n_variables and use regular variables or somebody knows a way to do this.

raphael apard’s picture

Status: Active » Needs review
StatusFileSize
new9.48 KB

Hy,
Here a new version of my module.
I'm using regular vars, translated as usual with t() function.
Hope everything is fine now.
Regards

Raphael

tr’s picture

Status: Needs review » Needs work

I'm a little disturbed that you would go off and spend time writing your own module and trying to get a CVS account instead of helping out and contributing to issues like #529110: Users misunderstand "Remove” checkbox on cart page and #930770: Display unit price in cart, which are addressing the functionality you are "adding" with your module. Drupal and Ubercart are community projects, which means they rely on the community to participate and make these improvements happen. Maybe you are unaware of these efforts in the Ubercart issue queue, in which case I would suggest that CVS privileges be withheld so that you don't inadvertently keep on creating more modules that duplicate or invalidate what's going on in the community.

raphael apard’s picture

Status: Needs work » Active

I understand you but i'm thinking that write again some diff file is not the best way to contributing to ubercat project. Writing this module will give an alternative to customize easily ubercat cart table.
Are you sure that diff file is a good way for this ?

joachim’s picture

> some diff file is not the best way to contributing to ubercat project

Actually, patches are the main way of contributing to module development.

I don't know enough about this proposed module, or those UC issues to comment on the specifics, but submitting patches to modules is (nearly) ALWAYS better than writing a new module to hack it.

avpaderno’s picture

Status: Active » Needs review

I agree with joachim; to contribute to the development of an existing module is generally preferable to creating a new module that duplicates the functionality of the first module.

raphael apard’s picture

Status: Needs review » Closed (duplicate)

You ve got right, i was thinking patches (on basic drupal user view) like something getting drupal hard to update.
I did'nt realize that patches could be included on main projects.
I just checked link #529110: Users misunderstand "Remove” checkbox on cart page, the last patch is a better than mine (i use javascript).
So it's ok for this part. I will see if i can be useful on the other one.
Sorry for spent time and for my english

avpaderno’s picture

Status: Closed (duplicate) » Closed (won't fix)
avpaderno’s picture

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