You are here

function subscriptions_user in Subscriptions 5

Same name and namespace in other branches
  1. 5.2 subscriptions.module \subscriptions_user()
  2. 6 subscriptions.module \subscriptions_user()

Implementation of hook_user().

File

./subscriptions.module, line 82

Code

function subscriptions_user($type, $edit, &$user, $category = NULL) {
  switch ($type) {
    case 'form':
      if ($category == 'account' && (user_access('maintain own subscriptions') || user_access('admin users subscriptions'))) {
        $form['subscriptions'] = array(
          '#type' => 'fieldset',
          '#title' => t('Subscription settings'),
          '#weight' => 5,
          '#collapsible' => TRUE,
        );
        $form['subscriptions']['subscriptions_auto'] = array(
          '#type' => 'checkbox',
          '#title' => t('Autosubscribe'),
          '#default_value' => isset($edit['subscriptions_auto']) ? $edit['subscriptions_auto'] : variable_get('subscriptions_autoset', 0),
          '#description' => t('Checking this box allows you to be automatically subscribed to any thread you create or post a comment to. You will receive an email with a title and link to the post.'),
        );
        $form['subscriptions']['subscriptions_teaser'] = array(
          '#type' => 'checkbox',
          '#title' => t('Include teaser'),
          '#default_value' => isset($edit['subscriptions_teaser']) ? $edit['subscriptions_teaser'] : variable_get('subscriptions_teaser', 0),
          '#description' => t('Checking this box adds an excerpt of the post to the subscription email.'),
        );
        return $form;
      }
      break;
    case 'delete':
      db_query('DELETE FROM {subscriptions} WHERE uid = %d', $user->uid);
      break;
  }
}