You are here

function subscriptions_page in Subscriptions 6

Same name and namespace in other branches
  1. 5.2 subscriptions.admin.inc \subscriptions_page()
  2. 5 subscriptions.module \subscriptions_page()

Display subscribed content data on the user and site subscriptions pages. @ TODO clean up all of these parts

1 string reference to 'subscriptions_page'
subscriptions_menu in ./subscriptions.module
Implementation of hook_menu().

File

./subscriptions.admin.inc, line 231
Subscriptions module (load-on-demand admin functions).

Code

function subscriptions_page($account, $stype) {
  $stypes = subscriptions_types();
  if (!isset($stypes[$stype])) {
    drupal_not_found();
    return;
  }
  if (subscriptions_arg(0) == 'admin') {
    $form['header'] = array(
      '#type' => 'fieldset',
      '#title' => t('Admin Information'),
      '#attributes' => array(
        'class' => 'error',
      ),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#weight' => -2,
    );
    if (empty($_SESSION['subscriptions']['bulk_op'])) {
      $form['header'][] = array(
        '#type' => 'item',
        '#value' => t('The selected subscriptions will be given to <b>newly created</b> users.'),
      );
      $tr = 't';
      $rid = subscriptions_arg(5);
      $form['header']['role'] = array(
        '#type' => 'fieldset',
        '#title' => $tr('Roles'),
        '#collapsible' => TRUE,
        '#collapsed' => !is_numeric($rid),
      );
      $form['header']['role']['header'] = array(
        '#type' => 'markup',
        '#value' => '<div>' . t('If a user has one or more roles assigned at creation time, then she will receive the additional subscriptions defined for these roles.') . '</div>',
        '#weight' => -5,
      );
      $form['header']['role']['roles'] = array(
        '#type' => 'select',
        '#title' => t('Role(s)'),
        '#default_value' => is_numeric($rid) ? $rid : DRUPAL_AUTHENTICATED_RID,
        '#options' => user_roles(TRUE),
        '#description' => t('Select the role to load or role(s) to save.'),
        '#multiple' => TRUE,
      );
      $form['header']['role']['load'] = array(
        '#type' => 'submit',
        '#value' => t('Load'),
      );
    }
    else {
      $bulk_op = $_SESSION['subscriptions']['bulk_op'];
      $variables = _subscriptions_page_user_bulk_variables();
      $output = $variables['info'] . '<br />';
      $output .= t('Select the subscriptions to !change and click [@Save] to perform the action for the selected users.', $variables);
      if ($bulk_op == 'unsub') {
        $output .= '<br /><strong>' . t('This action cannot be undone!') . '</strong>';
      }
      $form['header']['info'] = array(
        '#type' => 'item',
        '#value' => $output,
      );
    }
  }
  else {
    subscriptions_suspended(subscriptions_arg(1, 'uid'), TRUE);

    //if (variable_get('subscriptions_hide_overview_page', 0)) {

    //  $dummy_form_state = NULL;
    //  $form = subscriptions_user_suspend_form($dummy_form_state, $account);

    //}
    $form['header'][] = array(
      '#value' => t('Current subscriptions:'),
      '#weight' => -2,
    );
  }
  $form['footer'] = array(
    '#type' => 'item',
    '#description' => t('The master checkboxes on the left turn the given subscription on or off. Click and Shift-click to turn a range of subscriptions on or off.') . '<br />' . t('Depending on the setup of the site, you may have additional options for active subscriptions.'),
    '#weight' => 10,
  );
  $callback = $stypes[$stype]['page'];
  $output = function_exists($callback) ? $callback($account, $form) : '';

  //drupal_add_link(array(

  //  'rel' => 'alternate',
  //  'type' => 'application/rss+xml',
  //  'title' => t('!name Subscriptions', array('!name' => $user->name)),
  //  'href' => url('subscriptions/feed'),

  //));
  drupal_set_title(isset($account) ? check_plain($account->name) : t('Subscriptions'));
  return theme('box', '', $output);

  // . theme('xml_icon', url('subscriptions/feed'));
}