[Bps-public-commit] RT-BugTracker-Public branch, 5.0-compatibility, updated. 1.00-36-g0c3bba7

Dianne Skoll dianne at bestpractical.com
Tue Feb 23 16:25:22 EST 2021


The branch, 5.0-compatibility has been updated
       via  0c3bba781115f3fba5ce7f277bf534dfbb332170 (commit)
      from  5c7a8c5c60f3d368df3022a0f407414997abb4fd (commit)

Summary of changes:
 html/Elements/ShowUserPublic | 68 --------------------------------------------
 lib/RT/BugTracker/Public.pm  | 30 +++++++++++++++++++
 2 files changed, 30 insertions(+), 68 deletions(-)
 delete mode 100644 html/Elements/ShowUserPublic

- Log -----------------------------------------------------------------
commit 0c3bba781115f3fba5ce7f277bf534dfbb332170
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Tue Feb 23 16:25:05 2021 -0500

    Move username formatting out of Mason and into RT::User

diff --git a/html/Elements/ShowUserPublic b/html/Elements/ShowUserPublic
deleted file mode 100644
index 437a8b7..0000000
--- a/html/Elements/ShowUserPublic
+++ /dev/null
@@ -1,68 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
-%#                                          <sales at bestpractical.com>
-%#
-%# (Except where explicitly superseded by other copyright notices)
-%#
-%#
-%# LICENSE:
-%#
-%# This work is made available to you under the terms of Version 2 of
-%# the GNU General Public License. A copy of that license should have
-%# been provided with this software, but in any event can be snarfed
-%# from www.gnu.org.
-%#
-%# This work is distributed in the hope that it will be useful, but
-%# WITHOUT ANY WARRANTY; without even the implied warranty of
-%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-%# General Public License for more details.
-%#
-%# You should have received a copy of the GNU General Public License
-%# along with this program; if not, write to the Free Software
-%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-%# 02110-1301 or visit their web page on the internet at
-%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
-%#
-%#
-%# CONTRIBUTION SUBMISSION POLICY:
-%#
-%# (The following paragraph is not intended to limit the rights granted
-%# to you to modify and distribute this software under the terms of
-%# the GNU General Public License and is only of importance to you if
-%# you choose to contribute your changes and enhancements to the
-%# community by submitting them to Best Practical Solutions, LLC.)
-%#
-%# By intentionally submitting any modifications, corrections or
-%# derivatives to this work, or any other work intended for use with
-%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
-%# you are the copyright holder for those contributions and you grant
-%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
-%# royalty-free, perpetual, license to use, copy, create derivative
-%# works based on those contributions, and sublicense and distribute
-%# those contributions and any derivatives thereof.
-%#
-%# END BPS TAGGED BLOCK }}}
-<% $Address || $User->RealName || $User->Name %>\
-<%ARGS>
-$User => undef
-$Address => undef
-</%ARGS>
-<%INIT>
-if ( !$User && $Address ) {
-    $User = RT::User->new( $session{'CurrentUser'} );
-    $User->LoadByEmail( $Address->address );
-    if ( $User->Id ) {
-        $Address = '';
-    } else {
-        $Address = $Address->address;
-    }
-} else {
-    $Address = $User->EmailAddress;
-}
-if ( $Address && RT::BugTracker::Public->IsPublicUser ) {
-    $Address =~ s/@/ [...] /;
-}
-</%INIT>
diff --git a/lib/RT/BugTracker/Public.pm b/lib/RT/BugTracker/Public.pm
index 95b1383..b043220 100644
--- a/lib/RT/BugTracker/Public.pm
+++ b/lib/RT/BugTracker/Public.pm
@@ -296,6 +296,36 @@ sub GetArticleContent {
     return;
 }
 
+# "public" UsernameFormat
+package RT::User;
+
+sub _FormatUserPublic
+{
+    my $self = shift;
+    my %args = @_;
+    my $session = \%HTML::Mason::Commands::session;
+
+    if (!$args{User} && $args{Address}) {
+        $args{User} = RT::User->new( $session->{'CurrentUser'} );
+        $args{User}->LoadByEmail($args{Address}->address);
+        if ($args{User}->Id) {
+            $args{Address} = '';
+        } else {
+            $args{Address} = $args{Address}->address;
+        }
+    } else {
+        $args{Address} = $args{User}->EmailAddress;
+    }
+    if ( $args{Address} && RT::BugTracker::Public->IsPublicUser ) {
+        $args{Address} =~ s/@/ [...] /;
+    }
+
+    return $args{Address} || $args{User}->RealName || $args{User}->Name;
+}
+
+# Switch back to original package
+package RT::BugTracker::Public;
+
 =head1 AUTHOR
 
 Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list