You are here

function subscriptions_content_form_mail_edit_trans_alter in Subscriptions 6

Implementation of hook_form_alter().

Add the comment parts to the subscriptions_content_node-nid mail_edit page.

File

./subscriptions_content.module, line 1173
Subscriptions to content events

Code

function subscriptions_content_form_mail_edit_trans_alter(&$form, &$form_state) {
  $mailkey = 'subscriptions_content_node-nid';
  if ($form['id']['#value'] == $mailkey) {
    $tr = 't';
    $langcode = $form['language']['#value'];
    $form['mail']['note'] = array(
      '#value' => '<div>' . t("Note: 'new' and 'update' notifications for %Pages subscriptions use the matching !content_type subscriptions template rather than this one, if allowed; this does not apply to 'comment'-only notifications.", array(
        '%Pages' => t('Pages/Threads'),
        '!content_type' => t('content type'),
      )) . '</div>',
      '#weight' => -1,
    );
    $comment_body = subscriptions_mail_template_load(SUBSCRIPTIONS_COMMENT_MAILKEY, $langcode, 'body', 'CITEM');
    $separator = subscriptions_mail_template_load(SUBSCRIPTIONS_COMMENT_MAILKEY, $langcode, 'subject', 'SEP');
    $form['mail']['comment_body'] = array(
      '#title' => t('Comment body'),
      '#type' => 'textarea',
      '#default_value' => $comment_body,
      '#rows' => 7,
      '#description' => t('The body of each comment.'),
    );
    $placeholders = subscriptions_content_mail_edit_tokens_list('comments');

    // Display the user documentation of placeholders supported by this module mailkey
    $doc = "<dl>\n";
    foreach ($placeholders as $name => $description) {
      $doc .= '<dt>' . $name . '</dt>';
      $doc .= '<dd>' . $description . '</dd>';
    }
    $doc .= "</dl>\n";
    $form['mail']['comment_token_help'] = array(
      '#title' => $tr('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['mail']['comment_token_help']['help'] = array(
      '#value' => $doc,
    );
    $form['mail']['comment_separator'] = array(
      '#title' => t('Comment separator'),
      '#type' => 'textarea',
      '#default_value' => $separator,
      '#rows' => 2,
      '#description' => t('The separator between comments (if needed).'),
    );
    $form['op']['#submit'][] = 'subscriptions_content_form_mail_edit_trans_save';
    if (isset($form['delete'])) {
      $form['delete']['#submit'][] = 'subscriptions_content_form_mail_edit_trans_delete';
    }
  }
}