CVS edit link for slashrsm

Recently I developed a moule that allows site owner to send sequenced newsletters. For example:
- user registers into the site/subscribes to newsletter
- there are N newsletters that new users get every day, N days after registration
- so new user will keep recieveing newsletters for N days
- first letter is always the same, no matter when user actually registers, same for second, third, ..., Nth
- when user has recieved all sequenced emails, stops getting them

Dependency for this module is Simplenews and Date API. It was developed for one of my clients, and it is already used in production. Anyway, to make it more usable in different situations I must do some more work on it, but I would like to get some feedback from the community while doing that. I hope I will get that if I publish it as a project on Drupal.org.

Current code is at Github:
git://github.com/slashrsm/sequenced_newsletter.git

Demo installation:
http://sequenced_newsletter.janezek.org
admin user: admin
pass: sequencednewsletter

Look for "Sequenced newsletter" admin page and "List of sent letters" page.

JAnez
janez@janezek.org

Comments

slashrsm’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.59 KB

Uploaded code.

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 the code, pointing out what it needs to be changed.

slashrsm’s picture

OK. Will wait for review. THX for all.

Scyther’s picture

Status: Needs review » Needs work

1.

function sequenced_newsletter_menu() {

  $items = array();

  $items['admin/settings/sequenced_newsletter'] = array(
    'title' => t('Sequenced newsletter'),
    'description' => t('Configuration'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('sequenced_newsletter_admin'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  $items['sequenced_newsletter/list'] = array(
    'title' => t('List of sent letters'),
    'description' => t('List of sent letters'),
    'page callback' => '_sequenced_newsletter_list_letters',
    'access arguments' => array('view sent letters list'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}

Don't use t() on title and description.
Default type is MENU_NORMAL_ITEM so you don't actually need do write it.

2.

$lett_array = Array();

// should be

$lett_array = array();

Can be found at more places.

3. Please remove all the "debug" comments. eg. // print_r($subs_array);

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new2.59 KB

Fixed that.

Just a question.... Since we do not use t() in title and desc... It is translated automatically?

avpaderno’s picture

Menu titles and descriptions are passed to t() from Drupal core code.
This is similar to what done from watchdog(); the second argument is not a translated string, but a string that watchdog() will pass to t().

slashrsm’s picture

THX for the explanation.

Scyther’s picture

Status: Needs review » Needs work

Small details:

1. array with a small "a".

// sequenced_newsletter.module:41
$types = Array( 


2. The do it ;)

// sequenced_newsletter.module:11
$output = '<p>TODO: Help to be added.</p>'; 


// sequenced_newsletter.module:128
'description' => 'Sequenced module\'s list of sent emails (for debugging purpuses).',

You can use " " instead of ' ' here and skip the \ before 's

Avoid escaping quotation marks wherever possible.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.12 KB

Commited requested changes.

Scyther’s picture

Status: Needs review » Needs work

Coder reports
sequenced_newsletter.module Line 13: There should be no trailing spaces.

Please use Coder and check your code before posting it here. It helps both me, you, and others that don't have to check and correct more times then needed.

slashrsm’s picture

StatusFileSize
new3.13 KB

Sorry for that. Now I checked the code with that module. It should be OK now.

I apreciate your patience!

slashrsm’s picture

It looks like the reviewing process stoped a bit....

Can I do something to make this go on?

slashrsm’s picture

Status: Needs work » Needs review
Scyther’s picture

Status: Needs review » Needs work

I don't have no tips to get this done faster. For me, I don't have so much time to spend on this so it may take some times for me to review and respond. Hang in there and continue with the good job and hopefully you will be approved soon.

function _sequenced_newsletter_list_letters() {
  $out = "";
  $addresses = db_query("SELECT sid, title, date_spooled, mail FROM {sequenced_newsletter} as s, {node} as n, {simplenews_subscriptions} AS su WHERE s.nid=n.nid and s.sid=su.snid ORDER BY mail AND date_spooled DESC");
  $old_mail = "";
  while ($row = db_fetch_array($addresses)) {
    if ($old_mail != $row['mail']) {
      $out .= $old_mail == "" ? "<h2>" . $row['mail'] . "</h2><ul>" : "</ul>\n<h2>" . $row['mail'] . "</h2><ul>\n";
      $old_mail = $row['mail'];
    }

    $out .= "<li>" . $row['title'] . " (" . format_date($row['date_spooled']) . ")</li>\n";
  }

  $out .=  "</ul>\n";

  return $out;
}

$row['mail'] and $row['title'] is that user-submitted content? If yes (I think so), then it should be passed into check_plain() first.

Use check functions on output to prevent cross site scripting attacks

No piece of user-submitted content should ever be placed as-is into HTML.

* Use check_plain or theme('placeholder') for plain text.
* Use check_markup or filter_xss for markup containing text.
* Use the t() function with @ or % placeholders to construct safe, translatable strings.

See how to handle text in a secure fashion for more details.

from http://drupal.org/writing-secure-code

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.13 KB

Fixed and checked again with Coder.

Thank you for all suggestions. I appreciate your effort!

Scyther’s picture

Status: Needs review » Needs work

Do this alternatives do something?

      3 => t('1 minute - Just for debug'),
      4 => t('5 minutes - Just for debug'),

- - -

Code looks good otherwise.

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.1 KB

That was some options used just for debugging. Since I do not see any need to send emails every minute I removed it for now. I already have plans for future, when I will probably make this option more general. As that i will allow user to declare custom period time.

Scyther’s picture

Status: Needs review » Needs work

Misspelling on "diabled" maybe?

'#description' => t("When enabled sequenced newsletters will be sent. When diabled nothing will happen."),

- - -

What is the big different between your module and this http://drupal.org/project/simplenews_scheduler ?

slashrsm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.1 KB

Simplenews Scheduler will create a new "edition" of same newsletter node and send it when it is a time to do so. It will keep doing so until schedule is removed or subscriber unsubscribes from mailing list.

Sequenced newsletter will take different newsletter node every time and send it to subscriber.

Main differences are:

  • Sequenced newsletter will send different node every time - Simplenews scheduler will always send the same newsletter
  • Sequenced newsletter will send N emails to one user and stop sending them after that - Simplenews scheduler will send inf. emails (if not stopped by admin)
  • When sending emails with Sequenced newsletter users will in general recieve different emails from sequence 1..N - Simplenews scheduler will always send same email to all subscribers
Scyther’s picture

Okey! Sry I didn't get it when I read your first post, I was a bit tired.

slashrsm’s picture

NP :)

Scyther’s picture

For now I don't have any more to add. Maybe kiamlaluno can take a look at it and see if it should be approved.

slashrsm’s picture

THX for your effort!

slashrsm’s picture

Status: Needs review » Reviewed & tested by the community
avpaderno’s picture

Status: Reviewed & tested by the community » Needs review

The users who are applying for a CVS account cannot change the status of their own application to RTBC.

slashrsm’s picture

I'm sorry. I thought #22 is enough to do that... I'm still adopting Drupal's workflow and sometime I do not know what is OK to do and what not.

Thank you for your feedback.

Scyther’s picture

Status: Needs review » Reviewed & tested by the community

Did a overview again and found some.

1. Try not to use escape char \' in a t(), you can use " " around the text here instead.

      $output .= '<p>' . t('Module is configured on it\'s <a href="@settings">settings page</a>. Emails are sent through cron job; every time when cron runs module checks if it is already time to send emails. Emails are put in Simplenews spool, when necessary. Emails are then sent through Simplenews. Module also generates a, <a href="@list">list of all emails</a> sent to Simplenews spool.', array('@settings' => url('admin/settings/sequenced_newsletter'), '@list' => url('sequenced_newsletter/list'))) . '</p>';

2. _sequenced_newsletter_list_letters() you might want to reconstruct. Maybe use a theme function to put out the list, so it can be overrided. But after a while that list will be very long and you might want to add a pager option.

These two points are not errors, but proposals to improve. I have also tested the module and it work fine. So I will say this module is ready.

Will set this to rtbc and if kiamlaluno or someone else thinks that this two points should be changed before an approval, please make a note.

avpaderno’s picture

Status: Reviewed & tested by the community » Fixed

Escaping the string delimiter in a string passed to t() causes the string shown in l.d.o to contain \'; it should be fixed before the first official release of the module is released.
I trust Scyther for doing an accurate review, and I am going to approve this application.

Thank you for your contribution! I am going to update your account.

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.

slashrsm’s picture

THX you all!

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

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

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

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