You are here

function notifications_destination_manage_subform in Notifications 6.4

Destination manage subform. List/edit subscriptions for destination.

2 calls to notifications_destination_manage_subform()
notifications_destination_manage_form in includes/destination.inc
Destination manage subscriptions form
notifications_manage_destination_form in ./notifications.manage.inc
Manage destination form. Edit subscriptions for a destination

File

includes/destination.inc, line 300
Destination management

Code

function notifications_destination_manage_subform($destination) {
  module_load_include('manage.inc', 'notifications');
  $subscriptions = notifications_destination_get_subscriptions($destination, 20);

  // List of subscriptions for selection
  $select = array();
  $status = Notifications_Subscription::status_list();
  $send_methods = messaging_method_info(NULL, 'name');
  $send_intervals = notifications_send_intervals();
  $drupal_destination = drupal_get_destination();
  foreach ($subscriptions as $subs) {
    $select[$subs->sid] = '';
    $form['type'][$subs->sid] = array(
      '#value' => notifications_subscription_types($subs->type, 'title'),
    );
    $form['description'][$subs->sid] = array(
      '#value' => $subs
        ->get_name(),
    );
    $form['send_interval'][$subs->sid] = array(
      '#value' => !empty($send_intervals[$subs->send_interval]) ? $send_intervals[$subs->send_interval] : $subs->send_interval,
    );
    $form['status'][$subs->sid] = array(
      '#value' => $status[$subs->status],
    );
    $operations = array();
    if ($destination->uid || user_access('administer notifications')) {

      // Links for subscription for user. Permissions will be checked later.
      $operations[] = l(t('edit'), 'notifications/subscription/' . $subs->sid, array(
        'query' => $drupal_destination,
      ));
      $operations[] = l(t('drop'), 'notifications/unsubscribe/sid/' . $subs->sid, array(
        'query' => $drupal_destination,
      ));
    }
    elseif (function_exists('notifications_anonymous_manage_links')) {
      $operations[] = notifications_anonymous_manage_links('subscription', $subs);
    }
    $form['operations'][$subs->sid] = array(
      '#value' => implode(', ', $operations),
    );
  }
  $form['subscriptions'] = array(
    '#type' => 'checkboxes',
    '#options' => $select,
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 20, 0),
  );
  $form['#theme'] = 'notifications_manage_subscriptions';
  return $form;
}