You are here

function makemeeting_mypage in Make Meeting Scheduler 7

Same name and namespace in other branches
  1. 6 makemeeting.pages.inc \makemeeting_mypage()

Show own polls page Only authenticated users can access this page

1 string reference to 'makemeeting_mypage'
makemeeting_menu in ./makemeeting.module
hook_menu implementation

File

./makemeeting.pages.inc, line 120

Code

function makemeeting_mypage() {
  global $user;
  $breadcrumb = array(
    l(t('Home'), NULL),
    l(t('Make Meetings'), 'makemeeting'),
    l(t('List of my polls'), 'makemeeting/mypage'),
  );
  drupal_set_breadcrumb($breadcrumb);

  // Get user's polls from the database
  $query = db_select('node', 'n')
    ->condition('type', 'makemeeting')
    ->condition('n.uid', $user->uid);
  $query
    ->fields('n', array(
    'title',
  ))
    ->join('makemeeting_poll_heads', 'p', 'p.nid = n.nid');
  $results = $query
    ->fields('p', array(
    'url',
    'admin_url',
  ))
    ->execute();
  $header = array(
    t('Title'),
    t('Poll URL'),
    t('Admin URL'),
  );
  $rows = array();
  foreach ($results as $r) {
    $rows[] = array(
      $r->title,
      l(t('show poll'), 'makemeeting/' . $r->url),
      l(t('edit poll'), 'makemeeting/' . $r->admin_url),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}