You are here

function _user_relationships_message_settings_form in User Relationships 7

Same name and namespace in other branches
  1. 5 user_relationships.module \_user_relationships_message_settings_form()
  2. 5.2 user_relationships.module \_user_relationships_message_settings_form()

Helper function to build the settings form for the notification messages

1 call to _user_relationships_message_settings_form()
user_relationships_admin_settings in ./user_relationships.admin.inc
Main settings

File

./user_relationships.admin.inc, line 491
User Relationships admin settings and config forms

Code

function _user_relationships_message_settings_form(&$form, $defaults = array()) {
  $replaceables = array(
    '!requester',
    '!requestee',
    '%relationship_name',
    '%relationship_plural_name',
    '!pending_relationship_requests',
  );
  $translations = _user_relationships_default_message_key_translations();
  foreach ($defaults as $key => $value) {
    if (is_array($value)) {
      $form[$key] = array(
        '#type' => 'fieldset',
        '#title' => isset($translations[$key]) ? $translations[$key] : t(drupal_ucfirst(str_replace('_', ' ', $key))),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
        '#description' => t('The following tokens are available for use in your custom messages: @replaceables.', array(
          '@replaceables' => implode($replaceables, ', '),
        )),
        '#group' => 'messages_settings',
      );
      _user_relationships_message_settings_form($form[$key], $value);
    }
    else {
      $form["user_relationships_msg_{$key}"] = array(
        '#type' => 'textfield',
        '#title' => isset($translations[$key]) ? $translations[$key] : t(drupal_ucfirst(str_replace('_', ' ', $key))),
        '#default_value' => variable_get("user_relationships_msg_{$key}", $value),
      );
    }
  }
}