function comment_notify_update_7003 in Comment Notify 7
Fix tokens in comment subscriber e-mail template.
File
- ./
comment_notify.install, line 156 - Installation/uninstallation for comment notify.
Code
function comment_notify_update_7003() {
$variables = array(
'comment_notify_author_subject' => 'author',
'comment_notify_node_notify_default_mailtext' => 'author',
'comment_notify_watcher_subject' => 'commenter',
'comment_notify_comment_notify_default_mailtext' => 'commenter',
);
foreach ($variables as $variable => $context) {
// If the variable is using the default value, this will return NULL and we
// can skip it.
if ($text = variable_get($variable)) {
$replacements = array(
// Replace all node tokens with comment:node.
'[comment:unsubscribe-url]' => '[comment-subscribed:unsubscribe-url]',
'[comment:name]' => '[comment:author]',
'[node:' => '[comment:node:',
);
if ($context == 'author') {
$replacements['[user:name]'] = '[comment:node:author]';
$replacements['[user:'] = '[comment:node:author:';
}
elseif ($context == 'commenter') {
$replacements['[user:name]'] = '[comment-subscribed:author]';
$replacements['[user:'] = '[comment-subscribed:author:';
}
$text = strtr($text, $replacements);
variable_set($variable, $text);
}
}
return 'Comment Notify token strings updated.';
}