[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[%#
  # u : user object
  # simple : boolean, if true an unadorned name will be displayed (no Gravatar, no menu) (default: false)
  # gravatar_size : size of the Gravatar icon (default 0, which disables the Gravatar)
  # gravatar_only : boolean, if true output just the Gravatar (not-simple only)
  # nick_only : boolean, if true, the nickname will be used instead of the full name
  # id : string, if provided the id of the vCard div
  #%]

[%
IF !u.id;
  "---";
  RETURN;
END;
DEFAULT gravatar_size = 0;
IF user.settings.show_gravatars.value != 'On';
  gravatar_size = 0;
END;
%]
<div class="vcard vcard_[% u.id FILTER none %]" [% IF id %]id="[% id FILTER html %]"[% END %]>
  [% FILTER collapse %]

    [% IF simple %]
      [% IF user.id %]
        <span class="fn" title="[% u.identity FILTER html %]">[% u.nick FILTER html %]</span>
      [% ELSE %]
        <span class="fn">[% u.nick FILTER html %]</span>
      [% END %]

    [% ELSE %]
      [% IF gravatar_size %]
        <img src="[% u.gravatar(gravatar_size * 2) FILTER none %]" class="gravatar"
          width="[% gravatar_size FILTER none %]" height="[% gravatar_size FILTER none %]">
      [% END %]
      [% UNLESS gravatar_only %]
        <a class="email [%= "disabled" UNLESS u.is_enabled %] [% " show_usermenu" IF user.id %]"
          [% IF user.id %]
            href="mailto:[% u.email FILTER html %]"
            data-user-email="[% u.email FILTER html %]"
            data-user-id="[% u.id FILTER html %]"
            data-show-edit="[% user.in_group('editusers') || user.in_group('disableusers') || user.bless_groups.size > 0 ? 1 : 0 %]"
            data-hide-profile="[% hide_profile ? 1: 0 %]"
            title="[% u.identity FILTER html %]"
          [% ELSE %]
            href="[% basepath FILTER none %]user_profile?user_id=[% u.id FILTER none %]"
          [% END %]
          >
          <span class="[% user.id ? 'fn' : 'fna' %]">[% nick_only ? u.nick : (u.name || u.nick) FILTER html %]</span>
          [%~~%]
        </a>
      [% END %]
    [% END %]
  [% END %]
</div>
