You are here

function notify_admin_defaults in Notify 7

Menu callback, show admin list of user default settings.

1 string reference to 'notify_admin_defaults'
notify_menu in ./notify.module
Implements hook_menu().

File

./notify.admin.inc, line 614
Administrative pages callbacks for the Notify module.

Code

function notify_admin_defaults($form, &$form_state) {
  $form = array();
  $defnu = variable_get('notify_reg_default', 1);
  $perms = user_role_permissions(array(
    DRUPAL_ANONYMOUS_RID => 'anon',
  ));
  $anonp = array_key_exists('access notify', $perms[1]);
  if ($defnu && !$anonp) {
    drupal_set_message(t('If you want notification enabled by default for new users, you must grant the anonymous user role the permission to access notify.'), 'warning');
  }
  $set = 'defaults';
  $form['notify_defaults'] = array(
    '#type' => 'fieldset',
    '#title' => t('Notification default for new users'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('The default master switch for new users (check for enabled, uncheck for disabled).'),
  );
  $form['notify_defaults']['notify_reg_default'] = array(
    '#type' => 'checkbox',
    '#title' => t('Receive e-mail notifications'),
    '#return_value' => 1,
    '#default_value' => variable_get('notify_reg_default', 1),
  );
  $form['notify_defs'] = array(
    '#type' => 'fieldset',
    '#title' => t('Initial settings'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('These are the initial settings that will apply to new users registering, and to users that are enrolled in notifications by means of the automatic enrollment tickboxes under the “Users” tab.'),
  );
  $form['notify_defs']['node'] = array(
    '#type' => 'radios',
    '#title' => t('Notify new content'),
    '#default_value' => variable_get('notify_def_node', 1),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('Include new posts in the notification mail.'),
  );
  $form['notify_defs']['comment'] = array(
    '#type' => 'radios',
    '#access' => module_exists('comment'),
    '#title' => t('Notify new comments'),
    '#default_value' => variable_get('notify_def_comment', 0),
    '#options' => array(
      t('Disabled'),
      t('Enabled'),
    ),
    '#description' => t('Include new comments in the notification mail.'),
  );
  $form['notify_defs']['teasers'] = array(
    '#type' => 'radios',
    '#title' => t('How much to include?'),
    '#default_value' => variable_get('notify_def_teasers', 0),
    '#options' => array(
      t('Title only'),
      t('Title + Teaser/Excerpt'),
      t('Title + Body'),
      t('Title + Body + Fields'),
    ),
    '#description' => t('Select the amount of each item to include in the notification e-mail.'),
  );
  $set = 'ntype';
  $form[$set] = array(
    '#type' => 'fieldset',
    '#title' => t('Notification subscription by node type'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('Tick content types to make available for subscription. Having nothing checked defaults to making all content types available.'),
  );
  foreach (node_type_get_types() as $type => $object) {
    $form[$set][NOTIFY_NODE_TYPE . $type] = array(
      '#type' => 'checkbox',
      '#title' => $object->name,
      '#return_value' => 1,
      '#default_value' => variable_get(NOTIFY_NODE_TYPE . $type, 0),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );

  //return system_settings_form($form);
  return $form;
}