diff -urp mail_edit/mail_edit.info mail_edit_new/mail_edit.info --- mail_edit/mail_edit.info 2007-12-13 19:35:17.000000000 +0100 +++ mail_edit_new/mail_edit.info 2008-05-27 14:40:03.000000000 +0200 @@ -2,9 +2,10 @@ name = Mail Editor description = Allows editing of all mails package = Mail +core = 6.x ; Information added by drupal.org packaging script on 2007-12-13 -version = "5.x-1.1" +version = "6.x-1.1" project = "mail_edit" datestamp = "1197570917" diff -urp mail_edit/mail_edit.install mail_edit_new/mail_edit.install --- mail_edit/mail_edit.install 2007-12-05 17:46:27.000000000 +0100 +++ mail_edit_new/mail_edit.install 2008-05-27 14:40:03.000000000 +0200 @@ -1,30 +1,38 @@ t('Table of the mail_edit module.'), + 'fields' => array( + 'description' => array( + 'description' => t('Description'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE), + 'subject' => array( + 'description' => t('Subject'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE), + 'body' => array( + 'description' => t('Body'), + 'type' => 'text'), + 'mailkey' => array( + 'description' => t('Mailkey'), + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE), + ), + 'primary key' => array('mailkey'), + ); + return $schema; +} + function mail_edit_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {mail_edit} ( - description varchar(255) NOT NULL, - subject varchar(255) NOT NULL, - body TEXT, - mailkey varchar(255) NOT NULL, - PRIMARY KEY (mailkey) - ) /*!40100 DEFAULT CHARACTER SET utf8 */"); - break; - case 'pgsql': - db_query("CREATE TABLE {mail_edit} ( - description varchar(255) NOT NULL, - subject varchar(255) NOT NULL, - body text, - mailkey varchar(255) NOT NULL, - PRIMARY KEY (mailkey) - )"); - break; - } + drupal_install_schema('mail_edit'); } function mail_edit_uninstall() { - db_query("DROP TABLE {mail_edit}"); + drupal_uninstall_schema('mail_edit'); } diff -urp mail_edit/mail_edit.module mail_edit_new/mail_edit.module --- mail_edit/mail_edit.module 2007-12-13 19:29:02.000000000 +0100 +++ mail_edit_new/mail_edit.module 2008-05-27 14:40:03.000000000 +0200 @@ -1,24 +1,22 @@ user_access('administer site configuration'), - 'callback' => 'mail_edit_overview', - 'description' => t('Edit mails being sent out by Drupal.'), - 'path' => 'admin/build/mail_edit', - 'title' => t('Mail templates'), +function mail_edit_menu() { + $items['admin/build/mail_edit'] = array( + 'access arguments' => array('administer site configuration'), + 'page callback' => 'mail_edit_overview', + 'description' => 'Edit mails being sent out by Drupal.', + 'title' => 'Mail templates', ); - } + return $items; } /** * Implementation of hook_mail_alter(). */ -function mail_edit_mail_alter(&$mailkey, &$to, &$subject, &$body, &$from, &$headers) { +function mail_edit_mail_alter(&$message) { + // &$mailkey, &$to, &$subject, &$body, &$from, &$headers global $user, $base_url; static $stored_variables, $alters; if (!isset($stored_variables)) { @@ -32,34 +30,34 @@ function mail_edit_mail_alter(&$mailkey, '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen('http://')), '!date' => format_date(time()), - '!login_uri' => url('user', NULL, NULL, TRUE), - '!mailkey' => $mailkey, + '!login_uri' => url('user', array('absolute' => TRUE)), + '!mailkey' => $message['mailkey'], ); } - if (!isset($alters[$mailkey])) { + if (!isset($alters[$message['mailkey']])) { $sql = "SELECT * FROM {mail_edit} m"; if (module_exists('pm_subscriptions')) { $sql .= ' LEFT JOIN {pm_subscriptions_mail_edit} p ON m.mailkey = p.mailkey'; } $sql .= " WHERE m.mailkey = '%s'"; - $alters[$mailkey] = db_fetch_object(db_query($sql, $mailkey)); + $alters[$message['mailkey']] = db_fetch_object(db_query($sql, $message['mailkey'])); } - if (!empty($alters[$mailkey])) { - $alter = $alters[$mailkey]; + if (!empty($alters[$message['mailkey']])) { + $alter = $alters[$message['mailkey']]; $sender = $user; - $recipient = user_load(array('mail' => $to)); + $recipient = user_load(array('mail' => $message['to'])); $is_privatemsg = !empty($alter->type) && $recipient; $variables = $stored_variables; $variables['!site'] = t(variable_get('site_name', 'drupal')); $variables['!sender_name'] = $sender->name; - $variables['!sender_page'] = url("user/$sender->uid", NULL, NULL, TRUE); - $variables['!sender_contact_page'] = (empty($sender->contact) ? t('(disabled)') : url("user/$sender->uid/contact", NULL, NULL, TRUE)); + $variables['!sender_page'] = url("user/$sender->uid", array('absolute' => TRUE)); + $variables['!sender_contact_page'] = (empty($sender->contact) ? t('(disabled)') : url("user/$sender->uid/contact", array('absolute' => TRUE))); $variables['!sender_has_contact_page'] = (empty($sender->contact) ? 0 : 1); if ($recipient) { $variables['!recipient_name'] = $recipient->name; - $variables['!recipient_page'] = url("user/$recipient->uid", NULL, NULL, TRUE); - $variables['!edit_uri'] = url('user/'. $account->uid .'/edit', NULL, NULL, TRUE); - if (substr($mailkey, 0, 5) == 'user-') { + $variables['!recipient_page'] = url("user/$recipient->uid", array('absolute' => TRUE)); + $variables['!edit_uri'] = url('user/'. $account->uid .'/edit', array('absolute' => TRUE)); + if (substr($message['mailkey'], 0, 5) == 'user-') { $variables['!username'] = $recipient->name; $variables['!login_url'] = user_pass_reset_url($recipient); $variables['!mailto'] = $recipient->mail; @@ -67,23 +65,23 @@ function mail_edit_mail_alter(&$mailkey, } foreach (module_implements('mail_edit_variables') as $module) { $function = $module .'_mail_edit_variables'; - $function($variables, $mailkey, $sender, $recipient); + $function($variables, $message['mailkey'], $sender, $recipient); } if ($alter->subject) { if (function_exists('subscriptions_template_preprocess')) { $alter->subject = subscriptions_template_preprocess($alter->subject, $variables); } - $subject = strtr($alter->subject, $variables); + $message['subject'] = strtr($alter->subject, $variables); } if ($alter->body) { if (function_exists('subscriptions_template_preprocess')) { $alter->body = subscriptions_template_preprocess($alter->body, $variables); } - $body = strtr($alter->body, $variables); + $message['body'] = strtr($alter->body, $variables); } if ($is_privatemsg) { - $to = NULL; - module_invoke('privatemsg', 'send_privatemsg', $recipient, $subject, $body, FILTER_FORMAT_DEFAULT, 0, $alter->type, $variables); + $message['to'] = NULL; + module_invoke('privatemsg', 'send_privatemsg', recipient, $message['subject'], $message['body'], FILTER_FORMAT_DEFAULT, 0, $alter->type, $variables); } } } @@ -103,7 +101,7 @@ function mail_edit_overview($mailkey = ' $keys = array_merge($keys, $matches[2]); } $keys = array_merge($keys, module_invoke_all('mailkeys')); - cache_set('mail_edit_overview', 'cache', serialize($keys)); + cache_set('mail_edit_overview', serialize($keys), 'cache'); } if ($mailkey && (array_search($mailkey, $keys) !== FALSE)) { return drupal_get_form('mail_edit_form', $mailkey); @@ -191,9 +189,9 @@ function mail_edit_form($mailkey) { return $form; } -function mail_edit_form_submit($form_id, $form_values) { - $args = array($form_values['description'], $form_values['subject'], $form_values['body'], $form_values['mailkey']); - if ($form_values['insert']) { +function mail_edit_form_submit($form, &$form_state) { + $args = array($form_state['values']['description'], $form_state['values']['subject'], $form_state['values']['body'], $form_state['values']['mailkey']); + if ($form_state['values']['insert']) { db_query("INSERT INTO {mail_edit} (description, subject, body, mailkey) VALUES ('%s', '%s', '%s', '%s')", $args); } else { @@ -202,10 +200,18 @@ function mail_edit_form_submit($form_id, return 'admin/build/mail_edit'; } +function mail_edit_theme() { + return array( + 'mail_edit_variables' => array( + 'arguments' => array('element'), + ), + ); +} + function theme_mail_edit_variables($element) { $output = "
Usable variables are:
"; $output .= "