You are here

function signup_list_user_signups in Signup 5

Same name and namespace in other branches
  1. 5.2 includes/views.none.inc \signup_list_user_signups()
  2. 6.2 includes/no_views.inc \signup_list_user_signups()

Returns an array of node titles with links for all events the specified user has signed up for.

3 calls to signup_list_user_signups()
signup_block in ./signup.module
Implementation of hook_block().
signup_user in ./signup.module
Implementation of hook_user().
signup_user_schedule in ./signup.module
Prints a schedule of the given user's signups.

File

./signup.module, line 965

Code

function signup_list_user_signups($uid) {
  $titles = array();

  // We don't want to return anything for anon users.
  if ($uid != 0) {
    $has_event = module_exists('event');
    $event_join = $has_event ? ' LEFT JOIN {event} e ON e.nid = n.nid' : '';
    $event_where = $has_event ? ' AND (e.event_start >= ' . time() . ' OR e.event_start IS NULL)' : '';
    $order_by = $has_event ? 'e.event_start' : 'n.title';
    $event_col = $has_event ? ', e.event_start' : '';

    // Pull all open signup nodes for this user.
    $result = db_query(db_rewrite_sql("SELECT n.nid, n.title{$event_col} FROM {node} n INNER JOIN {signup_log} s_l ON n.nid = s_l.nid {$event_join} WHERE s_l.uid = '%s' {$event_where} ORDER BY {$order_by}"), $uid);
    while ($node = db_fetch_array($result)) {
      $titles[$node['nid']] = l($node['title'], 'node/' . $node['nid']);
    }
  }
  return $titles;
}