You are here

function weather_user_main_page in Weather 7

Same name and namespace in other branches
  1. 6.5 weather.module \weather_user_main_page()
  2. 7.3 weather.forms.inc \weather_user_main_page()
  3. 7.2 weather.forms.inc \weather_user_main_page()

Show an overview of configured locations for a user.

Parameters

int $uid: The ID of the user.

Return value

string Themed output of all locations for the given user.

1 string reference to 'weather_user_main_page'
weather_menu in ./weather.module
Implement hook_menu().

File

./weather.forms.inc, line 104
Provide forms for configuration of weather displays.

Code

function weather_user_main_page($uid) {
  $header = array(
    t('Real name'),
    t('Weight'),
  );
  $path = 'user/' . $uid . '/weather/';
  $rows = array();
  $result = db_query('SELECT * FROM {weather_location}
    WHERE display_type=:type AND display_number=:number ORDER BY weight ASC, real_name ASC', array(
    ':type' => 'user',
    ':number' => $uid,
  ));
  foreach ($result as $location) {
    $rows[] = array(
      l($location->real_name, $path . $location->id),
      $location->weight,
    );
  }

  // Insert link for adding locations into the table as last row.
  $rows[] = array(
    array(
      'data' => l(t('Add location to this display'), $path . '/add'),
      'colspan' => 2,
    ),
  );
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  if (isset($form['pager']['#value'])) {
    $output .= drupal_render($form['pager']);
  }
  $output .= '<p>' . l(t('Edit configuration of display'), $path . 'display') . '</p>';
  return $output;
}