I did a quick code review. All of these are (extremely) MINOR points. Fix them as you please.

  1. Try not to use tabs. We use 2 spaces.
  2. I'd avoid using "simplenews" in output shown to the user/admin. For example, I'd rename the permission administer simplenews to administer newsletter.
  3. Also in URLs, I'd use 'newsletter' and not 'simplenews'. It makes them easier to remember/guess.
  4. I'd consider to rename the list types-tab to newsletters. Using the term list types makes sense if you are a developer but is less intuitive for regular users. (You have multiple newsletters, and each newsletter has multiple newsletter issues (or issues for short.)
  5. We use '-' (dash) in CSS class/ID names, not '_' (underscore).
  6. $sn_form .= strlen($email) <= 30 ? $email : substr($email, 0, 29).'...'; will fail when multi-byte UTF-8 characters are present. Remember we are always dealing with UTF-8 strings, not ASCII strings. Use truncate_utf8($mail, 29, FASLE, TRUE);. It's a Drupal function that lives in common.inc.
  7. In core we write 'E-mail', not 'Email'.
  8. $sn_form = form($sn_form, $method = 'post', ''); looks like a copy-past error. Probably should be $sn_form = form($sn_form).
  9. We usually don't glue words together in the URL scheme: newsletterconfirm/remove/$subscription-id would be something like newsletter/confirm-remove/$subscription-id or newsletter/remove/$subscription-id.
  10. $message = t('Newsletter "%title" could not be sent to %email.', array('%title'=>check_plain($node->title), '%email'=>$mail->mail)); watchdog('simplenews', $message, WATCHDOG_ERROR);
    For consitency, use theme('placeholder', $foo) with watchdog() and drupal_set_message(). This ensures that messages are themed properly. theme('placeholder') calls check_plain() for you, and makes sure messages are themed properly/consistently.
  11. t('Newsletter subscription status confirmation notice for').' '.variable_get('simplenews_from_name', $name_default).' '.t('newsletter.'); is not easy to translate. Better to use a variable %newsletter-name so you don't have to break up the sentence. That gets you translation bonus points.
  12. drupal_set_message(t('No addresses were added.'),'status'); You can omit the 'status'. It's the default value.
  13. In CVS HEAD there is some timer functionality you can use to replace sn_time(). See timer_start(), timer_read() and timer_start().
  14. Substitute $GLOBALS['HTTP_SERVER_VARS']['HTTP_REFERER'] with referer_uri().
CommentFileSizeAuthor
#1 simplenews.patch50.13 KBnathanwastaken

Comments

nathanwastaken’s picture

Assigned: Unassigned » nathanwastaken
StatusFileSize
new50.13 KB

I'm not the greatest coder, but I will work my way through these points, so that DriesK can get to work on more urgent issues.

This patch deals with point number 1. It is a VERY MINOR issue, but it will make it more useable for other developers who are interested in this modules development.

No more tabs in this code.

I am sorry I am going to get this done, patch by patch (and point by point), but I don't have the time (or the patience) to do them all in one hit. Just apply them in order, and there should be no problems.

nathanwastaken’s picture

Some work has come up, I will work on this, but... It may take a little longer. I will 'un-assign' myself.

nathanwastaken’s picture

Assigned: nathanwastaken » Unassigned

and I forgot to...

DriesK’s picture

Assigned: Unassigned » DriesK

Nathan, thanks for the effort anyway. I'm going to change simplenews.module in the next few weeks to enable subscription to multiple terms as discussed earlier (I'll try to do so during my holidays). This probably means that a lot of code has to change anyway, so when I encounter any of Dries' issues, I'll address them right away. If any of them remain, you can tune in again as you like. I'm leaving for France on Friday, and I don't think I'm going to have much of an internet connection, so you can expect to hear from me again in about two weeks.

As for the tabs: it's a funny thing. I always type 2 spaces, but apparently my editor automatically changes double spaces into tabs. I never realised that, but now I disabled this "feature" :-).

DriesK’s picture

Status: Active » Fixed
osherl’s picture

Anonymous’s picture

DriesK’s picture

Status: Fixed » Closed (fixed)

Closed because the automatic close feature in project module is broken, and the issue list is becoming cluttered.