[Rt-commit] rt branch, 4.4/download-user-info, repushed
Craig Kaiser
craig at bestpractical.com
Fri Jun 22 09:15:57 EDT 2018
The branch 4.4/download-user-info was deleted and repushed:
was 0c7811fbb5dde5cf4575d01f0cf9c767a6cee5c4
now c42a2e696038fd817a2dfc078a9a86fdde3ccc2a
1: a7061699c ! 1: 7e03a7e76 Add column to transaction column map for content
@@ -1,8 +1,6 @@
Author: Craig Kaiser <craig at bestpractical.com>
Add column to transaction column map for content
-
- Column that returns the content of the transaction.
diff --git a/share/html/Elements/RT__Transaction/ColumnMap b/share/html/Elements/RT__Transaction/ColumnMap
--- a/share/html/Elements/RT__Transaction/ColumnMap
2: 195b4b2a4 < -: ------- Add 'UserDataSearchResultFormat' config option
-: ------- > 2: 272ff90f6 Add config options for download user data result formats
3: fc4af63af ! 3: e635cae75 Create helper for exporting user related information
@@ -2,13 +2,13 @@
Create helper for exporting user related information
- Export transaction and user record information pertaining to the current
- user, as a TSV file.
+ Export transaction and user record information pertaining to the
+ provided user id, as a TSV file.
-diff --git a/share/html/Helpers/MyRelatedInfo.tsv b/share/html/Helpers/MyRelatedInfo.tsv
+diff --git a/share/html/Helpers/UserRelatedData.tsv b/share/html/Helpers/UserRelatedData.tsv
new file mode 100644
--- /dev/null
-+++ b/share/html/Helpers/MyRelatedInfo.tsv
++++ b/share/html/Helpers/UserRelatedData.tsv
@@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
@@ -58,9 +58,10 @@
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
-+$Query => ''
+$PreserveNewLines => 0
+$Type => 'User'
++$Format => undef
++$id
+</%ARGS>
+
+<%INIT>
@@ -69,20 +70,25 @@
+ $Type && ( $Type eq 'User' || $Type eq 'Transaction');
+
+my $Collection;
-+my $Format;
+
+if ( $Type eq 'User' ) {
-+ $Format = "'__id__', '__Name__', '__EmailAddress__', '__RealName__', '__NickName__', '__Organization__', '__HomePhone__', '__WorkPhone__','__MobilePhone__', '__PagerPhone__', '__Address1__', '__Address2__', '__City__', '__State__','__Zip__', '__Country__', '__Gecos__', '__Lang__', '__FreeFormContactInfo__'";
++ $Format = RT->Config->Get('UserDataResultFormat') unless $Format;
+
-+ $Collection = RT::Users->new($session{'CurrentUser'});
-+ $Collection->Limit( FIELD => 'id', VALUE => $session{'CurrentUser'}->id );
++
++ if ( $session{'CurrentUser'}->id ne $id ) {
++ Abort('User does not have the right to view other users') unless
++ $session{'CurrentUser'}->UserObj->HasRight( Object => $RT::System, Right =>'AdminUsers');
++ }
++
++ $Collection = RT::Users->new( $session{'CurrentUser'} );
++ $Collection->Limit( FIELD => 'id', VALUE => $id );
+
+} elsif ( $Type eq 'Transaction' ) {
-+ $Format = "'__ObjectId__', '__id__', '__Created__', '__Description__', '__OldValue__', '__NewValue__', '__Content__'";
++ $Format = RT->Config->Get('UserTransactionDataResultFormat') unless $Format;
+
-+ $Collection = RT::Transactions->new($session{'CurrentUser'});
++ $Collection = RT::Transactions->new( $session{'CurrentUser'} );
+ $Collection->Limit( FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
-+ $Collection->Limit( FIELD => 'Creator', VALUE => $session{'CurrentUser'}->Id );
++ $Collection->Limit( FIELD => 'Creator', VALUE => $id );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Create' );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Correspond' );
+ $Collection->Limit( FIELD => 'Type', VALUE => 'Comment' );
4: 1720cfa35 ! 4: 8d49210fc Create portlet for downloading user information
@@ -1,11 +1,16 @@
Author: Craig Kaiser <craig at bestpractical.com>
Create portlet for downloading user information
+
+ Provide three links for downloading user information as a tsv file:
+ User record data
+ User transaction data
+ User ticket data
-diff --git a/share/html/Elements/MyRelatedInfo b/share/html/Elements/MyRelatedInfo
+diff --git a/share/html/Elements/UserRelatedData b/share/html/Elements/UserRelatedData
new file mode 100644
--- /dev/null
-+++ b/share/html/Elements/MyRelatedInfo
++++ b/share/html/Elements/UserRelatedData
@@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
@@ -60,13 +65,17 @@
+&>
+
+<div>
-+ <a href="/Helpers/MyRelatedInfo.tsv?Type=User" class="button"><&|/l&>Download My User Info</&></a>
-+ <a href="/Search/Results.tsv?Query=Requestor.id=<% $session{'CurrentUser'}->id %>&Format=<% $Format | un %>" class="button"><&|/l&>Download My Tickets</&></a>
-+ <a href="/Helpers/MyRelatedInfo.tsv?Type=Transaction" class="button"><&|/l&>Download My Transaction Info</&></a>
++ <a href="/Helpers/UserRelatedData.tsv?Type=User&id=<% $UserObj->id %>" class="button"><&|/l&>Download User Data</&></a>
++ <a href="/Search/Results.tsv?Query=Requestor.id=<% $UserObj->id %>&Format=<% $Format | un %>" class="button"><&|/l&>Download User Tickets</&></a>
++ <a href="/Helpers/UserRelatedData.tsv?Type=Transaction&id=<% $UserObj->id %>" class="button"><&|/l&>Download User Transaction Data</&></a>
+</div>
+</&>
+
+<%INIT>
-+my $Format = RT->Config->Get('UserDataSearchResultFormat') || RT->Config->Get('DefaultSearchResultFormat');
++my $Format = RT->Config->Get('UserDataSearchResultFormat');
+</%INIT>
++
++<%ARGS>
++$UserObj
++</%ARGS>
5: 926302317 ! 5: 798ed2e76 Add user data download portlet to admin user modify page
@@ -1,6 +1,6 @@
Author: Craig Kaiser <craig at bestpractical.com>
- Add user download portlet to admin user modify page
+ Add user data download portlet to admin user modify page
diff --git a/share/html/Admin/Users/Modify.html b/share/html/Admin/Users/Modify.html
--- a/share/html/Admin/Users/Modify.html
@@ -9,11 +9,7 @@
% }
</form>
-+%# Only show if current user is on their modify page
-+% if ( !$Create && $session{'CurrentUser'}->id == $UserObj->id ) {
-+<& /Elements/MyRelatedInfo &>
-+% }
-+
++<& /Elements/UserRelatedData, UserObj => $UserObj &>
<%INIT>
my $UserObj = RT::User->new($session{'CurrentUser'});
-: ------- > 6: 7899d5327 Add download user data portlet to AboutMe.html page
6: 0c7811fbb ! 7: c42a2e696 Create test for user information TSV download
@@ -58,7 +58,7 @@
+
+ # TSV file for user record information
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
-+ $agent->follow_link_ok( { text => 'Download My User Info' } );
++ $agent->follow_link_ok( { text => 'Download User Data' } );
+
+ my $user_info_tsv = <<EOF;
+id\tName\tEmailAddress\tRealName\tNickName\tOrganization\tHomePhone\tWorkPhone\tMobilePhone\tPagerPhone\tAddress1\tAddress2\tCity\tState\tZip\tCountry\tGecos\tLang\tFreeFormContactInfo
@@ -70,7 +70,7 @@
+
+ # TSV file for Transactions
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
-+ $agent->follow_link_ok( { text => 'Download My Transaction Info' } );
++ $agent->follow_link_ok( { text => 'Download User Transaction Data' } );
+
+ my $transaction_info_tsv = <<EOF;
+ObjectId\tid\tCreated\tDescription\tOldValue\tNewValue\tContent
@@ -84,7 +84,7 @@
+
+ # TSV file for user's Tickets
+ $agent->get_ok( $url . "Admin/Users/Modify.html?id=" . $root->id );
-+ $agent->follow_link_ok( { text => 'Download My Tickets' } );
++ $agent->follow_link_ok( { text => 'Download User Tickets' } );
+
+ my $ticket_info_tsv = <<EOF;
+id\tSubject\tStatus\tQueueName\tOwner\tPriority\tRequestors
More information about the rt-commit
mailing list