CVS edit link for jerome.megel

Hello,
I introduce myself, Jérôme MEGEL Web developer for the society Actency in Strasbourg (France). For our Drupal projects we have developed a module for testing emails, instead of sending out emails the module display all sent emails in a modal frame.
It was really useful for us, when we were working on notifications for example, we didn't have a lot of emails in our boxes. Thanks to this module you don't annoy each person of your company because you are doing testing. You can also redirect all outgoing emails to one email (like reroute_email module) if you want to be sure SMTP config is OK.
The devel module can catch outgoing emails as well but you have to go to your watchdog page each time you want to see if an email has been sent.
Email tester is added in the package devel and you can access configuration through devel config page: http://emailtester.actency.fr/sites/default/files/email_tester_config.jpg
Permission has been set for the module, if someone doesn’t have the permission to see outgoing emails, he won’t see anything and he won’t receive any emails. You have to disable “emails in modal frame” in devel settings.
You can see a demo there: http://emailtester.actency.fr and a screenshot (in case demo don’t work): http://emailtester.actency.fr/sites/default/files/email_tester_scrshot.jpg
Now we really would like to share this module and to know if the community would appreciate it, because we are using it for every project.
Jérôme MEGEL
Actency
jerome.megel@actency.fr

Comments

jerome.megel’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +email, +Devel, +modal, +dialog
StatusFileSize
new37.32 KB

And that's the module.

avpaderno’s picture

Issue tags: -email, -Devel, -modal, -dialog +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.

avpaderno’s picture

Status: Needs review » 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. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see hoe Drupal variables, global variables, constants, and functions defined from the module should be named; how the code should be formatted.
  2. function email_tester_init() {
      jquery_ui_add(array('ui.core', 'ui.dialog', 'ui.draggable', 'ui.resizable', 'ui.accordion'));
      drupal_add_js(drupal_get_path('module', 'email_tester') .'/js/email_tester.js', 'module', 'header', TRUE);
      drupal_add_css(drupal_get_path('module', 'email_tester') .'/css/ui.all.css');
      
      // Only define our mail wrapper if the email_tester module is the current mail wrapper.
      if (variable_get('smtp_library', '') == drupal_get_filename('module', 'email_tester')) {
        /**
         * Save the mails sent out in $_SESSION instead of mailing.
         * $_SESSION['emails_to_disp'] will be displayed in hook_footer()
         */
        function drupal_mail_wrapper($message) {
          $reroute_email = variable_get('reroute_email', NULL);
          if($reroute_email) {
            $to = $reroute_email;
          }
          else {
            $to = $_SESSION['emails_to_disp'][$message['id']]['to'] ?
              $_SESSION['emails_to_disp'][$message['id']]['to'] .= ' ,  '.$message['to'] :
              $message['to'];
          }
          
          $_SESSION['emails_to_disp'][$message['id']] = array(
              'to' => $to,
              'from' => $message['from'],
              'language' => $message['language']->name,
              'subject' => $message['subject'],
              'body' => $message['body'],
          );
          return TRUE;
        }
      }
    }
    
    

    PHP doesn't have functions that are local to another function; every function is global.

  3. Hook implementation comments should be like the following one:
    /**
     * Implements hook_menu().
     */
    
  4. /**
     * Implementation of hook_enable().
     */
    function email_tester_enable() {
      // We save initial configuration to recover it when the module is disabled
      variable_set('backup_smtp_library', variable_get('smtp_library', ''));
      variable_set('smtp_library', drupal_get_filename('module', 'email_tester'));
    }
    
    /**
     * Implementation of hook_disable().
     */
    function email_tester_disable() {
      variable_set('smtp_library', variable_get('backup_smtp_library', ''));
      if(variable_get('devel_old_smtp_library', '') == drupal_get_filename('module', 'email_tester')) {
        variable_set('devel_old_smtp_library', '');
      }
    }
    
    

    Those hooks should be in the installation file.

  5. The module doesn't implement hook_uninstall().
  6.     case 'devel_admin_settings':
          $form['smtp_library']['#options'][drupal_get_filename('module', 'email_tester')] =
                  t('Display in modal frame').' (email_tester module)';
    
    

    Strings used in the user interface should be translated.

jerome.megel’s picture

Status: Needs work » Needs review
StatusFileSize
new38.23 KB

Hello and thanks a lot for taking care of my module,

1. I've modified it, I used coder module to test it and now it respects all coding standards (sorry for the time lost).

2. For this point I did this function the same way than in Devel module: devel.module line 1796 and the function is launched in mail.inc line 177, I dont think there is an other way to do it properly

3. Done

4. Done

5. Done, this module has nothing to uninstall (doesn't modify schema), i put the hook_uninstall with nothing inside, is it the good way ?

6. Done

Thanks

avpaderno’s picture

Status: Needs review » Needs work

Point #1, and #5 are still valid.

jerome.megel’s picture

Status: Needs work » Needs review
StatusFileSize
new38.22 KB

Hello,

I've modified my module:

Point #1: Should be OK:
- no more instructions have more than one line
- all arrays have indentations with 2 spaces
- no arrays have more than 80 characters
- all if structure are made properly (not anymore with ? and :)
- files are formatted with \n as the line ending

If there is something else wrong could you please say me what because my module has no problems found with coder module and I read all Drupal Coding Standards and applied it

Point #5: I delete the variable 'backup_smtp_library' in hook_uninstall

Many thanks

avpaderno’s picture

Status: Needs review » Needs work
  1.       $file_name = drupal_get_filename('module', 'email_tester');
          $text      = t('Display in modal frame') .' (email_tester module)';
    

    Strings used in the user interface should be translated (part of the message is not passed to t()).

  2.           <p><strong>'. t('From') .'</strong>:&nbsp;'. $email['from'] .'</p>
              <p><strong>'. t('To') .'</strong>:&nbsp;'. $email['to'] .'</p>
              <p><strong>'. t('Language') .'</strong>:&nbsp;'. $email['language'] .'</p>
              <p><strong>'. t('Subject') .'</strong>:&nbsp;'. $email['subject'] .'</p>
              <p><strong>'. t('Body') .'</strong>:&nbsp;'. $email['body'] .'</p>
    

    When possible, it is better to give more context to the translators; it's normally better to not include HTML tags in the string to translate, but not if that means to split a phrase. In these strings, it's better to use placeholders, like in:

              <p> . t('<strong>From</strong>:&nbsp;@from', array('@from' => $email['from'])  . '</p>
    

    Words can be translated differently, basing on the context; if translators see the context in which a word is placed, they can understand better how to translate it (in example, in Esperanto of is translated in different ways).

  3. Drupal variables set by the module should be prefixed by the module name; that doesn't happen with the variable backup_smtp_library, and reroute_email. That is also true for session variables (like $_SESSION['emails_to_disp']).
jerome.megel’s picture

Status: Needs work » Needs review
StatusFileSize
new38.33 KB

All points are done, I've updated translations as well

Thanks

drupalshrek’s picture

Status: Needs review » Needs work

Hello,

Please add a README.txt. See:
http://drupal.org/node/161085

jerome.megel’s picture

Status: Needs work » Needs review
StatusFileSize
new44.53 KB

Hello,
I've added the README.txt file

zzolo’s picture

Component: Miscellaneous » miscellaneous
Status: Needs review » Postponed

Hi. Please read all the following and the links provided as this is very important information about your CVS Application:

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for your application. Please read the following documentation on how this affects and benefits you and the application process:
Migrating from CVS Applications to (Git) Full Project Applications

  • The status of this application will be put to "postponed" and by following the instructions in the above link, you will be able to reopen it.
  • Or if your application has been "needs work" for more than 5 weeks, your application will be marked as "closed (won't fix)". You can still reopen it, by reading the instructions above.
avpaderno’s picture

Issue summary: View changes
Status: Postponed » Closed (won't fix)

As per previous comment, I am setting this issue to won't fix.

Since new users can now create full projects, applications have a different purpose and they are handled on a different issue queue. See Apply for permission to opt into security advisory coverage for more information.

avpaderno’s picture

Status: Closed (won't fix) » Closed (duplicate)
Related issues: +#1078328: [D7] Email tester
avpaderno’s picture

Component: miscellaneous » new project application