You are here

function me_user in me aliases 6

Same name and namespace in other branches
  1. 6.2 me.module \me_user()

Implementation of hook_user().

File

./me.module, line 698
Provides 'me' aliases to allow users to enter 'me' in common paths instead of their user id.

Code

function me_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'categories':
      if (me_variable_get('me_user_override')) {
        return array(
          array(
            'name' => 'me',
            'title' => t("'@me' alias", array(
              '@me' => _me_get_me_alias(TRUE),
            )),
            'weight' => 2,
          ),
        );
      }
      break;
    case 'form' && $category == 'me':
      $form = array();
      $form['me_uid'] = array(
        '#type' => 'item',
        '#title' => t('User id'),
        '#value' => $account->uid,
      );
      $form['me_disable'] = array(
        '#type' => 'checkbox',
        '#title' => t("Disable '%me' alias for this account", array(
          '%me' => _me_get_me_alias(TRUE),
        )),
        '#description' => t('This option stops your user id from being replaced with %me. %me will still work when entered into the address bar, but you will be redirected to a page with your uid in its place.', array(
          '%me' => _me_get_me_alias(TRUE),
        )),
        '#default_value' => !empty($account->me_disable),
      );
      return $form;
    case 'view':
      if (me_variable_get('me_user_override')) {
        $enabled = 'enabled';
        if (!empty($account->me_disable)) {
          $enabled = 'disabled';
        }
        $account->content['me'] = array(
          '#type' => 'markup',
          '#value' => t("'%me' aliases are {$enabled} for this account. Account user id is '@uid'.", array(
            '%me' => _me_get_me_alias(TRUE),
            '@uid' => $account->uid,
          )),
          '#weight' => 10,
        );
      }
      break;
  }
}