[Rt-commit] rt branch, 4.4/download-user-info, created. rt-4.4.2-243-g43b9b1a35

Craig Kaiser craig at bestpractical.com
Mon May 21 13:51:19 EDT 2018


The branch, 4.4/download-user-info has been created
        at  43b9b1a351a3b920972770915fc256d31863e90e (commit)

- Log -----------------------------------------------------------------
commit 725dd1cde1646eb33656127662154472e093c1ff
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon May 21 13:32:56 2018 -0400

    Create helper for exporting TSV data

diff --git a/share/html/Helpers/Results.tsv b/share/html/Helpers/Results.tsv
new file mode 100644
index 000000000..6b488b478
--- /dev/null
+++ b/share/html/Helpers/Results.tsv
@@ -0,0 +1,107 @@
+%# 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 }}}
+<%ARGS>
+$Format           => undef
+$Query            => ''
+$OrderBy          => 'id'
+$Order            => 'ASC'
+$PreserveNewLines => 0
+$Type             => undef
+$UserId           => undef
+</%ARGS>
+
+<%INIT>
+my $Collection;
+
+if ( !$Type ) {
+    $Collection = RT::Tickets->new( $session{'CurrentUser'} );
+    $Format = RT->Config->Get('UserDataSearchResultFormat') || RT->Config->Get('DefaultSearchResultFormat');
+    $Collection->FromSQL( $Query );
+    if ( $OrderBy =~ /\|/ ) {
+        # Multiple Sorts
+        my @OrderBy = split /\|/, $OrderBy;
+        my @Order   = split /\|/, $Order;
+        $Collection->OrderByCols(
+            map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
+            ( 0 .. $#OrderBy )
+        );
+    }
+    else {
+        $Collection->OrderBy( FIELD => $OrderBy, ORDER => $Order );
+    }
+} elsif ( $Type eq 'User' ) {
+    $Format = RT->Config->Get('UserDataSearchResultFormat') || "'__id__', '__Name__', '__EmailAddress__', '__RealName__', '__NickName__', '__Organization__', '__HomePhone__', '__WorkPhone__','__MobilePhone__', '__PagerPhone__', '__Address1__', '__Address2__', '__City__', '__State__','__Zip__', '__Country__', '__Gecos__', '__Lang__', '__FreeFormContactInfo__'";
+
+    my $user = RT::User->new($session{'CurrentUser'});
+    if ( $UserId ) {
+        $user->Load( $UserId );
+    } else {
+        $user->Load($session{'CurrentUser'});
+    }
+
+    $Collection = RT::Users->new($session{'CurrentUser'});
+    $Collection->Limit( FIELD => 'id', VALUE => $user->Id );
+
+} elsif ( $Type eq 'Transaction' ) {
+    $Format = RT->Config->Get('UserDataSearchResultFormat') || "'__ObjectId__', '__id__', '__Created__', '__Description__', '__OldValue__', '__NewValue__', '__Content__'";
+
+    my $user = RT::User->new($session{'CurrentUser'});
+    if ( $UserId ) {
+        $user->Load( $UserId );
+    } else {
+        $user->Load($session{'CurrentUser'});
+    }
+
+    $Collection = RT::Transactions->new($session{'CurrentUser'});
+    $Collection->Limit( FIELD => 'Creator', VALUE => $user->Id );
+    $Collection->Limit( FIELD => 'Type', VALUE => 'Correspondence' );
+    $Collection->Limit( FIELD => 'Type', VALUE => 'Comment' );
+}
+
+$m->comp( "/Elements/TSVExport", Collection => $Collection, Format => $Format, PreserveNewLines => $PreserveNewLines );
+</%INIT>
diff --git a/share/html/Search/Results.tsv b/share/html/Search/Results.tsv
deleted file mode 100644
index 1bbdded74..000000000
--- a/share/html/Search/Results.tsv
+++ /dev/null
@@ -1,72 +0,0 @@
-%# BEGIN BPS TAGGED BLOCK {{{
-%#
-%# COPYRIGHT:
-%#
-%# This software is Copyright (c) 1996-2018 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 }}}
-<%ARGS>
-$Format => undef
-$Query => ''
-$OrderBy => 'id'
-$Order => 'ASC'
-$PreserveNewLines => 0
-</%ARGS>
-<%INIT>
-my $Tickets = RT::Tickets->new( $session{'CurrentUser'} );
-$Tickets->FromSQL( $Query );
-if ( $OrderBy =~ /\|/ ) {
-    # Multiple Sorts
-    my @OrderBy = split /\|/, $OrderBy;
-    my @Order   = split /\|/, $Order;
-    $Tickets->OrderByCols(
-        map { { FIELD => $OrderBy[$_], ORDER => $Order[$_] } }
-        ( 0 .. $#OrderBy )
-    );
-}
-else {
-    $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order );
-}
-
-$m->comp( "/Elements/TSVExport", Collection => $Tickets, Format => $Format, PreserveNewLines => $PreserveNewLines );
-</%INIT>

commit 196535932ab76e9f409906bc92debf982f4bf3bd
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon May 21 13:35:01 2018 -0400

    Update ticket search to use tsv helper

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 40cb43e7c..b2f3b2cf9 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -982,7 +982,7 @@ my $build_main_nav = sub {
 
             my $more = $current_search_menu->child( more => title => loc('Feeds') );
 
-            $more->child( spreadsheet => title => loc('Spreadsheet'), path => "/Search/Results.tsv$args" );
+            $more->child( spreadsheet => title => loc('Spreadsheet'), path => "/Helpers/Results.tsv$args" );
 
             my %rss_data = map {
                 $_ => $QueryArgs->{$_} || $fallback_query_args{$_} || '' }

commit a1c91325c467eaa69f5465dbdcfb857f4a47c53f
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon May 21 13:38:15 2018 -0400

    Add column to transaction column map for content

diff --git a/share/html/Elements/RT__Transaction/ColumnMap b/share/html/Elements/RT__Transaction/ColumnMap
index 28a82f1e0..d709a5440 100644
--- a/share/html/Elements/RT__Transaction/ColumnMap
+++ b/share/html/Elements/RT__Transaction/ColumnMap
@@ -105,6 +105,11 @@ my $COLUMN_MAP = {
             }
         },
     },
+    Content => {
+        title       => 'Content', # loc
+        Attribute   => 'Content', # loc
+        value       => sub { return $_[0]->Content },
+    },
 };
 
 

commit 37438085658beaf18fb480f4603ce8c3b614e135
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon May 21 13:42:54 2018 -0400

    Add portlet for downloading user information

diff --git a/share/html/Elements/UserRelatedInfo b/share/html/Elements/UserRelatedInfo
new file mode 100644
index 000000000..15121b272
--- /dev/null
+++ b/share/html/Elements/UserRelatedInfo
@@ -0,0 +1,71 @@
+%# 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 }}}
+<&|/Widgets/TitleBox,
+    class => 'user-related-info',
+    title => loc("User related info"),
+&>
+
+<div class="row">
+    <div class="col-md-12">
+        <a href="/Helpers/Results.tsv?Type=User&UserId=<% $id %>"><button>Download My User Info</button></a>
+        <a href="/Helpers/Results.tsv?<% $query_tickets %>"><button>Download My Tickets</button></a>
+        <a href="/Helpers/Results.tsv?Type=Transaction&UserId=<% $id %>"><button>Download My Transaction Info</button></a>
+    </div>
+</div>
+</&>
+<%init>
+my $user = RT::User->new($session{'CurrentUser'});
+$user->Load( $id );
+
+# Build Ticket Query
+my $query_tickets = "Query=Requestor.id = " . $id;
+</%init>
+
+<%ARGS>
+$id        => undef
+</%ARGS>

commit 43b9b1a351a3b920972770915fc256d31863e90e
Author: Craig Kaiser <craig at bestpractical.com>
Date:   Mon May 21 13:43:18 2018 -0400

    Add user download portlet to Admin modify page

diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
index 3b8bc42fc..d657df51e 100644
--- a/share/html/Admin/Users/Modify.html
+++ b/share/html/Admin/Users/Modify.html
@@ -232,6 +232,8 @@
 % }
 </form>
 
+<& /Elements/UserRelatedInfo, id => $id &>
+
 <%INIT>
 
 my $UserObj = RT::User->new($session{'CurrentUser'});
@@ -308,6 +310,27 @@ if ( $UserObj->Id ) {
     }
 }
 
+if ( $ARGS{Anonymize} ) {
+    my @attrs = keys %{ $UserObj->_CoreAccessible };
+
+    # Remove identifying user information from record
+    foreach my $attr (@attrs) {
+        my $method = 'Set' . $attr;
+            $UserObj->$method('');
+    }
+    my $valid_email = 1;
+    my $number = '';
+    while ( $valid_email ) {
+        my @Chars = ('1'..'9');
+        for (1..9) {
+            $number .= $Chars[int rand @Chars];
+        }
+        $valid_email = !$UserObj->ValidateEmail('anon_' . $number . '@example.com');
+    }
+    $UserObj->SetName('anon_' . $number);
+    $UserObj->SetEmailAddress('anon_' . $number . '@example.com');
+}
+
 # This code does automatic redirection if any updates happen.
 MaybeRedirectForResults(
     Actions   => \@results,

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


More information about the rt-commit mailing list