You are here

function subscriptions_form_helper in Subscriptions 2.0.x

Same name and namespace in other branches
  1. 5.2 subscriptions.admin.inc \subscriptions_form_helper()
  2. 6 subscriptions.admin.inc \subscriptions_form_helper()
  3. 7 subscriptions.admin.inc \subscriptions_form_helper()

Helper function for the submodules to build the table(s) on their user/UID/subscriptions/... pages.

Parameters

array $form:

array $defaults:

int $author_uid:

string $key:

string $title:

array $subscription:

5 calls to subscriptions_form_helper()
subscriptions_og_page in subscriptions_og/subscriptions_og.module
Defines a user's overview of which groups she is subscribed to.
_subscriptions_blog_ui_blog_form in subscriptions_blog_ui/subscriptions_blog_ui.module
Returns the blog subscription form.
_subscriptions_content_node_form in subscriptions_content/subscriptions_content.admin.inc
Build the Thread subscriptions form at user/UID/subscriptions/node.
_subscriptions_content_type_form in subscriptions_content/subscriptions_content.admin.inc
Build the Content Types subscriptions form at user/UID/subscriptions/type.
_subscriptions_taxonomy_taxa_form in subscriptions_taxonomy/subscriptions_taxonomy.admin.inc
Build the Categories subscription form at user/UID/subscriptions/taxa.

File

./subscriptions.admin.old.php, line 1118
Subscriptions module (load-on-demand admin functions).

Code

function subscriptions_form_helper(array &$form, array &$defaults, $author_uid, $key, $title, array $subscription) {
  static $intervals;
  if (!isset($intervals)) {
    $intervals = _subscriptions_send_intervals();
  }
  if (isset($subscription['author_uid']) && $author_uid == $subscription['author_uid']) {
    $defaults['checkboxes'][$key][$author_uid] = 1;
  }
  $defaults['send_interval'][$key][$author_uid] = $subscription['send_interval'];
  if ($subscription['send_comments']) {
    $defaults['send_comments'][$key][$author_uid] = 1;
  }
  if ($subscription['send_updates']) {
    $defaults['send_updates'][$key][$author_uid] = 1;
  }
  if (isset($subscription['author_uid']) && $subscription['author_uid'] > 0) {
    $author_value = format_username(user_load($subscription['author_uid']));
  }
  elseif ($author_uid == 0) {
    $author_value = format_username(NULL);
  }
  else {
    $author_value = '';
  }
  $form['labels'][$key][$author_uid] = array(
    '#markup' => $title,
  );
  $form['author'][$key][$author_uid] = array(
    '#markup' => check_plain($author_value),
  );
  $form['send_interval'][$key][$author_uid] = array(
    '#type' => 'select',
    '#options' => $intervals,
    '#default_value' => $defaults['send_interval'][$key][$author_uid],
  );
  foreach (array(
    'checkboxes',
    'send_comments',
    'send_updates',
  ) as $col_name) {
    $form[$col_name][$key][$author_uid] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($defaults[$col_name][$key][$author_uid]),
    );
  }
  if (isset($subscription['extra_info'])) {
    $form['extra_info'][$key][$author_uid] = array(
      '#markup' => $subscription['extra_info'],
    );
  }
}