You are here

function weather_user_main_page in Weather 7.3

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

Show an overview of configured places for a user.

Parameters

int $uid: The ID of the user.

Return value

string Themed output of all places for the given user.

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

File

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

Code

function weather_user_main_page($uid) {
  $header = array(
    t('Displayed name'),
    t('Weight'),
  );
  $path = 'user/' . $uid . '/weather/';
  $rows = array();
  $result = db_query('SELECT * FROM {weather_displays_places}
    WHERE display_type=:type AND display_number=:number ORDER BY weight ASC, displayed_name ASC', array(
    ':type' => 'user',
    ':number' => $uid,
  ));
  foreach ($result as $location) {
    $rows[] = array(
      l($location->displayed_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;
}