You are here

function system_update_177 in Drupal 4

Same name and namespace in other branches
  1. 5 modules/system/system.install \system_update_177()

File

database/updates.inc, line 1714

Code

function system_update_177() {
  $ret = array();
  $message_ids = array(
    'welcome_subject' => 'Welcome subject',
    'welcome_body' => 'Welcome body text',
    'approval_subject' => 'Approval subject',
    'approval_body' => 'Approval body text',
    'pass_subject' => 'Password reset subject',
    'pass_body' => 'Password reset body text',
  );
  foreach ($message_ids as $message_id => $message_text) {
    if ($admin_setting = variable_get('user_mail_' . $message_id, FALSE)) {

      // Insert newlines and escape for display as HTML
      $admin_setting = nl2br(check_plain($message_text . "\n\n" . $admin_setting));
      watchdog('legacy', $admin_setting);
      $last = db_fetch_object(db_query('SELECT max(wid) AS wid FROM {watchdog}'));

      // Deleting is required, because _user_mail_text() checks for the existance of the variable.
      variable_del('user_mail_' . $message_id);
      $ret[] = array(
        'query' => strtr('The mail template %message_id has been reset to the default. The old template <a href="%url">has been saved</a>.', array(
          '%message_id' => 'user_mail_' . $message_id,
          '%url' => url('admin/logs/event/' . $last->wid),
        )),
        'success' => TRUE,
      );
    }
  }
  return $ret;
}