You are here

function subscriptions_form_helper in Subscriptions 5.2

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

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

4 calls to subscriptions_form_helper()
subscriptions_blog_ui_blog_form in ./subscriptions_blog_ui.module
Returns the blog subscription form.
subscriptions_content_node_form in ./subscriptions_content.module
Build the Thread subscriptions form at user/UID/subscriptions/node.
subscriptions_content_type_form in ./subscriptions_content.module
Build the Content Types subscriptions form at user/UID/subscriptions/type.
subscriptions_taxonomy_taxa_form in ./subscriptions_taxonomy.module
Build the Categories subscription form at user/UID/subscriptions/taxa.

File

./subscriptions.admin.inc, line 713

Code

function subscriptions_form_helper(&$form, &$defaults, $author_uid, $key, $title, $subscription) {
  static $intervals;
  if (!isset($intervals)) {
    $intervals = _subscriptions_send_intervals();
  }
  if ($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 ($subscription['author_uid'] > 0) {
    $author_value = check_plain(db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $subscription['author_uid'])));
  }
  elseif ($author_uid == 0) {
    $author_value = variable_get('anonymous', '???');
  }
  else {
    $author_value = '';
  }
  $form['labels'][$key][$author_uid] = array(
    '#type' => 'item',
    '#value' => $title,
  );
  $form['author'][$key][$author_uid] = array(
    '#value' => $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 $index => $name) {
    $form[$name][$key][$author_uid] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($defaults[$name][$key][$author_uid]),
    );
  }
}