Project:Drupal.org CVS applications
Component:Miscellaneous
Category:task
Priority:normal
Assigned:kiamlaluno
Status:closed (fixed)
Issue tags:module review

Issue Summary

CVS edit link for sajt

I like to make a name day module. (http://en.wikipedia.org/wiki/Name_day)

Comments

#1

Status:postponed (maintainer needs more info)» needs review

I like a CVS account for this module. And some review of my code :)

Thanks!

AttachmentSize
nameday.tgz 11.17 KB

#2

Status:needs review» needs work

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.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module/theme; for modules it should include also a comparison with the existing solutions, while for themes a screenshot is also required.

#3

What I must to do? Waiting?

#4

See comment #2.

#5

The nameday module creates a block with the current (in this time only Hungarian) name-day(s) and holiday if it exists. You can easily add your country's name-days and holidays.

#6

Status:needs work» needs review

#7

What I must to make? Is somthing wrong?

#8

I putted the code to the github: http://github.com/sajt/nameday I do not really understand why I can not get CVS access.

#9

From http://drupal.org/cvs-application/requirements, "...You must provide a motivation message, which should be a few paragraphs instead of only a few sentences. It should include details about your contribution, its features, how it compares to already existing solutions, links to screenshots or a demo, etc...."

#10

A lot of portal site like to show the actual name day, in some country (you can see a list in the Wikipedia). There was a lot of solution for it, but no drupal modules. (I did not find).

This module is very easy of use. Install it as usual and select the block from the admin/build/block list. The name day is depend on the current language (and naturally on the current date) and now only hungarian name days is working.

I welcome the new languages files for other countries. The file description is in the datas/README.txt. This file is included when You install the module.

#11

Whats news?

#12

I think my project a little bit better than this: http://drupal.org/project/chuck

#13

Status:needs review» needs work

I've done a visual review of the code.

It looks pretty good overall -- clearly good attention to detail and use of Drupal's APIs and conventions. Its purpose is quite esoteric, but that's fine :)

A few things that need work though:

- Quite a big architectural problem this one: you populate your database table from the included data file in hook_install. How is a user of the module going to get updated data from later versions of the module, or from their own data file? You need to think about a more flexible way of doing this. I suggest you look at how Ubercart handles country information files: there's a UI for adding a custom one, or for reading in data from one that's in the module's own data folder. It looks like you have the same requirements.

- variable_set("show_date", TRUE); -- namespace your variables.

- also, there's no point in setting a variable in your hook_install. Instead, take the value TRUE as your default!

- $lang = $GLOBALS["language"]->language; -- I'm not sure of this, but should you just say 'global $language'?

- $date = getdate(); -- you might want to account for the user's timezone?

- echo format_date(time(), "small"); -- the standard in TPL files is print, not echo.

- also, it's a nice touch to indent the code in TPL, ie indent this line because it's inside an if block. It makes the logic of your TPL much clearer to follow, as at the moment it's hard to see where the ifs end and what gets printed unconditionally.

- <?php if ($date):?> -- think the convention is a space before the closing angle bracket -- check what core does.

- finally, a minor point: no blank line between function doc blocks and the function declaration. But bonus points for putting these in! :)

I'm not sure whether to set this to 'needs work' or RTBC. The architectural problem I mentioned is a big task and needs addressing, but on the other hand the best course might be to grant CVS access so the module author can make a dev release and potentially get the attention of other interested developers to help with this. I'll leave this decision to one of the admins :)

#14

  • 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. <?php
    function nameday_install() {
     
    drupal_install_schema("nameday");
     
    variable_set("show_date", TRUE);
     
    $dir = drupal_get_path("module", "nameday") . "/datas/";
      if (
    $dh = opendir($dir)) {
        while ((
    $file = readdir($dh)) !== FALSE) {
         
    $pathinfo = (pathinfo($file));
          if (
    $pathinfo["extension"] == "namedays") {
           
    $lang = $pathinfo["filename"];
           
    $langfile = file($dir . $file);
            foreach (
    $langfile as $row) {
             
    $currentrow = split(";", $row);
              if (
    count($currentrow) == 3) {
               
    $currentrow[3] = "";
              }
             
    db_query("INSERT INTO  {nameday} (month, day, language, name, holiday) VALUES (%d, %d, '%s', '%s', '%s')", $currentrow[0], $currentrow[1], $lang, $currentrow[2], $currentrow[3]);
            }
          }
        }
       
    closedir($dh);
      }
    }
    ?>

    Why isn't the code using file_scan_dir()?

  2. License files cannot be committed in Drupal.org repository. Projects committed in Drupal.org repository have the same license used by Drupal.
  3. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how Drupal variables, global variables, constants, and functions defined from the module should be named.
  4. <?php
       
    case 'list':
         
    $blocks[0]['info'] = "Name day";
          return
    $blocks;
    ?>

    Strings used in the user interface should be translated.

#15

Thank you for the nice reviews. In last time I rewritten the full module, for example I putted the token support. I make some changes and I am considering your suggestions. When I finished it, I will put the new module.

Thanks.

#16

I finished the changes. Only Joachim's UI suggestion is missing for the data-table manipulation, I must to think about the correct interface.

I hope every other errors is fixed. I added a little token support, what is pre-alpha and maybe very useless.

AttachmentSize
nameday-6.x-1.1-alpha1.tar_.gz 6.16 KB

#17

Status:needs work» needs review

Change status

#18

anybody?

#19

Teszt

#20

Status:needs review» needs work

A few minor points for consistency within Drupal:

- the 'datas' directory should be 'data'. ('data' is already a plural...)
- the standard filename for admin pages is MODULE.admin.inc rather than nameday.settings.inc.

The more complex logic in your TPL should really be moved up to a preprocessor function:

- print format_date(time(), variable_get('nameday_date_format', 'small'), variable_get('nameday_date_format_custom', ''));

This should be just a print $nameday_date; do the formatting work in the preprocessor.

- if ($nameday['holiday'] != '' && variable_get('nameday_show_holiday', TRUE))

This should be just if ($holiday):

> I must to think about the correct interface.

What I'd suggest is something like a list of the language files the system has found, along with operations depending on whether the system also has data for that language in the DB:

language status operations
- English new [load data button]
- French loaded [refresh data button]

Good idea adding token support btw! :)

#21

Status:needs work» needs review

Thanks for the fast answer. I made the suggested changes, except the last one. I will make it, when I get an other name-day file than Hungarian :)

AttachmentSize
nameday-6.x-1.1-alpha2.tar_.gz 6.26 KB

#22

Assigned to:Anonymous» kiamlaluno
Status:needs review» fixed

#23

Status:fixed» closed (fixed)

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