You are here

function calendar_systems_user in Calendar Systems 6.2

Implements hook_user().

Adds user specific calendar configuration.

File

./calendar_systems.module, line 171
Contains Calendar Systems module hooks, helpers and API functions.

Code

function calendar_systems_user($op, &$edit, &$account, $category = NULL) {
  if ($op == 'form' && $category == 'account' && user_access('select different calendar')) {
    $form = array();

    // Get all avilable calendars names.
    $calendars = calendar_systems_calendars('names');

    // Add a dropdown widget under timezone
    // fieldset, so that she can choose her fave.
    // The value of user specific calendar will be
    // available in $account->calendar property.
    $form['timezone']['calendar'] = array(
      '#type' => 'select',
      '#title' => t('Default calendar'),
      '#description' => t('Selecting a different calendar will change all dates across the site.'),
      '#access' => user_access('select different calendar'),
      '#options' => $calendars += array(
        'default' => t('Site default calendar'),
      ),
      '#default_value' => $account->calendar ? $account->calendar : 'default',
    );

    // Render.
    return $form;
  }
}