You are here

function subscriptions_nodes in Subscriptions 5

query to get list of subscibed nodes

1 call to subscriptions_nodes()
subscriptions_page in ./subscriptions.module
displays subscribed content data on user and subuscription pages @ TODO clean up all of these parts

File

./subscriptions.module, line 1059

Code

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

  // query string for node subscriptions
  $query = 'SELECT td.tid, td.name, n.nid, n.type, n.title, s.stype, s.sid FROM ';
  $query .= '(({subscriptions} s LEFT JOIN {node} n ON n.nid = s.sid) ';
  $query .= 'LEFT JOIN {term_node} tn ON tn.nid = s.sid) ';
  $query .= 'LEFT JOIN {term_data} td ON td.tid = tn.tid ';
  $query .= 'WHERE n.status = 1 AND s.uid = %d AND s.stype = \'node\' ';
  $query .= 'ORDER BY n.type, n.title';
  $results = db_query($query, $account->uid);
  $data = array();
  while ($sub = db_fetch_object($results)) {
    $data[$sub->nid] = $sub;
  }
  return drupal_get_form('subscriptions_nodes_list_form', $data, $account);
}