You are here

function notifications_content_page_thread in Notifications 5

Same name and namespace in other branches
  1. 6 notifications_content/notifications_content.pages.inc \notifications_content_page_thread()
  2. 6.2 notifications_content/notifications_content.pages.inc \notifications_content_page_thread()
  3. 6.3 notifications_content/notifications_content.pages.inc \notifications_content_page_thread()

Subscriptions page callback: List thread subscriptions

2 string references to 'notifications_content_page_thread'
notifications_content_menu in notifications_content/notifications_content.module
Implementation of hook_menu_()
notifications_content_notifications in notifications_content/notifications_content.module
Implementation of hook_notifications()

File

notifications_content/notifications_content.module, line 518
Subscriptions to content events

Code

function notifications_content_page_thread($account = NULL) {
  global $user;
  if (is_null($account)) {
    $account = $user;
  }

  // query string for node subscriptions
  $query = "SELECT s.*, f.value AS nid, n.type AS node_type, n.title FROM {notifications} s \n    INNER JOIN {notifications_fields} f ON s.sid = f.sid LEFT JOIN {node} n ON f.value = CAST(n.nid AS CHAR(255))\n    WHERE s.uid = %d AND s.type = 'thread' AND s.event_type = 'node' AND s.conditions = 1 AND f.field = 'nid'\n    ORDER BY node_type, n.title";
  $results = pager_query($query, NOTIFICATIONS_CONTENT_PAGER, 0, NULL, $account->uid);
  $subscriptions = $list = array();
  $content_types = notifications_content_types('name');
  while ($sub = db_fetch_object($results)) {
    $subscriptions[$sub->nid] = $sub;
    $list[$sub->nid] = '[' . $content_types[$sub->node_type] . '] ' . l($sub->title, 'node/' . $sub->nid);
  }
  if (!$subscriptions) {
    $output = t('You are not currently subscribed to any active threads');
  }
  else {
    $output = t('You are currently subscribed to the following threads:');
    $defaults = array(
      'type' => 'thread',
      'event_type' => 'node',
    );
    $options = array(
      'title' => t('Title'),
    );
    $output .= drupal_get_form('notifications_user_form', $account, 'thread', $subscriptions, $list, $defaults, $options);
    $output .= theme('pager', NULL, NOTIFICATIONS_CONTENT_PAGER);
  }
  return $output;
}