[Rt-commit] rt branch, create-action, updated. 361ffbaf1852a07f54fcdf463a5e105d7de7d191
sartak at bestpractical.com
sartak at bestpractical.com
Wed Oct 21 18:05:10 EDT 2009
The branch, create-action has been updated
via 361ffbaf1852a07f54fcdf463a5e105d7de7d191 (commit)
from cb495d63562b5aea733890e9433ec9192798fbbe (commit)
Summary of changes:
lib/RT/View/Form/Field/SelectUser.pm | 54 +++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit 361ffbaf1852a07f54fcdf463a5e105d7de7d191
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Oct 21 18:04:54 2009 -0400
Transplant mason ShowUser logic into a jifty form field
diff --git a/lib/RT/View/Form/Field/SelectUser.pm b/lib/RT/View/Form/Field/SelectUser.pm
index afa0076..ebf67ba 100644
--- a/lib/RT/View/Form/Field/SelectUser.pm
+++ b/lib/RT/View/Form/Field/SelectUser.pm
@@ -2,6 +2,7 @@ package RT::View::Form::Field::SelectUser;
use warnings;
use strict;
use base 'Jifty::Web::Form::Field::Select';
+use Email::Address;
sub _render_user {
my $self = shift;
@@ -13,7 +14,58 @@ sub _render_user {
$user = $user_object;
}
- return $user->name;
+ my $style = RT->config->get('username_format', Jifty->web->current_user);
+ return $self->_render_user_concise($user)
+ if $style eq 'concise';
+ return $self->_render_user_verbose($user);
+}
+
+sub _render_user_concise {
+ my $self = shift;
+ my $user = shift;
+
+ if ($user->privileged) {
+ return $user->real_name
+ || $user->nickname
+ || $user->name
+ || $user->email;
+ }
+
+ return $user->email
+ || $user->name
+ || $user->real_name
+ || $user->nickname;
+}
+
+sub _render_user_verbose {
+ my $self = shift;
+ my $user = shift;
+
+ my ($phrase, $comment);
+ my $addr = $user->email;
+
+ $phrase = $user->real_name
+ if $user->real_name
+ && lc $user->real_name ne lc $addr;
+
+ $comment = $user->name
+ if lc $user->name ne lc $addr;
+
+ $comment = "($comment)"
+ if defined $comment and length $comment;
+
+ my $address = Email::Address->new($phrase, $addr, $comment);
+
+ $address->comment('')
+ if $comment && lc $address->user eq lc $comment;
+
+ if ( $phrase and my ($l, $r) = ($phrase =~ /^(\w+) (\w+)$/) ) {
+ $address->phrase('')
+ if $address->user =~ /^\Q$l\E.\Q$r\E$/
+ || $address->user =~ /^\Q$r\E.\Q$l\E$/;
+ }
+
+ return $address->format;
}
sub _render_select_values {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list