You are here

function signature_forum_field_extra_fields in Signatures for Forums 7

Allow the administrator to enable and disable signatures for content types and their comment bundles.

Allow the administrator to reposition the signature_forum display and form elements.

Set reasonable defaults on first time use.

Implementation of hook_field_extra_fields().

1 call to signature_forum_field_extra_fields()
_signature_forum_update_extra_fields_visibilities in ./signature_forum.module
Use the visbilities defined by hook_field_extra_fields() as default visibilities.

File

./signature_forum.module, line 430
Tweaks signatures in ways inspired by other traditional forum software:

Code

function signature_forum_field_extra_fields() {
  $extra = array();
  if (variable_get('user_signatures')) {
    $per_post = variable_get('signature_forum_defaults_mode', SIGNATURE_FORUM_PER_POST_DISABLED) != SIGNATURE_FORUM_PER_POST_DISABLED;
    foreach (node_type_get_types() as $type) {
      $comment_bundle = 'comment_node_' . $type->type;

      // Let signatures be only visible in forum posts, by default.
      // Note that unless #1256368 will make it into core,
      // _signature_forum_update_extra_fields_visibilities has to be called for
      // this.
      $visible = $type->type == 'forum';

      // Populate the extra fields array with display elements.
      $extra['node'][$type->type] = array(
        'display' => array(
          'signature_forum' => array(
            'label' => t('User signature'),
            'description' => t('The personal signature of the node author.'),
            'weight' => 20,
            'visible' => $visible,
          ),
        ),
      );
      $extra['comment'][$comment_bundle] = array(
        'display' => array(
          'signature_forum' => array(
            'label' => t('User signature'),
            'description' => t('The personal signature of the comment author.'),
            'weight' => 20,
            'visible' => $visible,
          ),
        ),
      );

      // Add form elements.
      if ($per_post) {
        $extra['node'][$type->type] = array(
          'form' => array(
            'signature_forum_status' => array(
              'label' => t('Display user signature'),
              'description' => t('A checkbox whether a signature should be displayed for the node.'),
              'weight' => 3,
            ),
          ),
        );
        $extra['comment'][$comment_bundle] = array(
          'form' => array(
            'signature_forum_status' => array(
              'label' => t('Display user signature'),
              'description' => t('A checkbox whether a signature should be displayed for the comment.'),
              'weight' => 3,
            ),
          ),
        );
      }
    }
  }
  return $extra;
}