You are here

function messaging_notify_admin_settings in Messaging 6

Admin settings, configure defaults for sending methods

1 string reference to 'messaging_notify_admin_settings'
messaging_notify_menu in messaging_notify/messaging_notify.module
Implementation of hook_menu()

File

messaging_notify/messaging_notify.module, line 25
Subscriptions to messaging events

Code

function messaging_notify_admin_settings() {

  // To what you can subscribe using what
  $form['allowed'] = array(
    '#type' => 'fieldset',
    '#title' => t('Method permissions'),
  );
  $form['allowed']['messaging_notify_subscribe'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allowed subscriptions'),
    '#options' => messaging_method_list(),
    '#default_value' => variable_get('messaging_notify_subscribe', array()),
    '#description' => t('Check the sending methods a user can subscribe to.'),
  );
  $form['allowed']['messaging_notify_receive'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allowed sending methods'),
    '#options' => messaging_method_list(),
    '#default_value' => variable_get('messaging_notify_receive', array()),
    '#description' => t('Check the sending methods that can be used for notifications.'),
  );

  /*
  $form['allowed']['update_permissions'] = array(
    '#type' => 'checkbox',
    '#title' => t('Update all existing accounts'),
    '#default_value' => FALSE,
  );
  */

  // Default settings for new accounts
  $form['update_methods'] = array(
    '#tree' => TRUE,
  );
  foreach (messaging_method_info() as $method => $info) {
    $key = 'messaging_notify_default_' . $method;
    $settings = variable_get($key, array());
    $method_list = array(
      '' => '',
    ) + messaging_method_list();
    unset($method_list[$method]);
    $form[$key] = array(
      '#type' => 'fieldset',
      '#title' => t('Defaults for %name', array(
        '%name' => $info['name'],
      )),
      '#collapsible' => TRUE,
      '#collapsed' => empty($settings['method']),
      '#tree' => TRUE,
    );
    $form[$key]['method'] = array(
      '#title' => t('Default send method'),
      '#type' => 'select',
      '#options' => $method_list,
      '#default_value' => !empty($settings['method']) ? $settings['method'] : '',
    );
    $form[$key]['interval'] = array(
      '#title' => t('Default send interval'),
      '#type' => 'select',
      '#options' => _notifications_send_intervals(),
      '#default_value' => !empty($settings['interval']) ? $settings['interval'] : 0,
    );
    $form[$key]['update'] = array(
      '#title' => t('Update all existing accounts.'),
      '#type' => 'checkbox',
      '#default_value' => 0,
      '#parents' => array(
        'update_methods',
        $method,
      ),
    );
  }
  $form['buttons']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  $form['buttons']['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
  );
  $form['buttons']['update'] = array(
    '#type' => 'submit',
    '#value' => t('Update user accounts'),
  );
  return $form;
}