[Rt-commit] rt branch, 4.2/user-summary, created. rt-4.1.6-332-g321bc55

Kevin Falcone falcone at bestpractical.com
Thu Mar 7 21:31:54 EST 2013


The branch, 4.2/user-summary has been created
        at  321bc55f93b8a35eabc5ced84e45321cd94a176f (commit)

- Log -----------------------------------------------------------------
commit 866cd1167ab93d9ff2d78b52a522909f6f81ab5a
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 18:05:19 2013 -0500

    Small PageWidget for searching for users
    
    Uses the normal user autocomplete endpoint.

diff --git a/share/html/Elements/GotoUser b/share/html/Elements/GotoUser
new file mode 100644
index 0000000..6527381
--- /dev/null
+++ b/share/html/Elements/GotoUser
@@ -0,0 +1,72 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<form name="UserSearch" method="post" action="<% RT->Config->Get('WebPath') %>/User/Search.html">
+<input type="text" name="UserString" value="" id="autocomplete-UserString" />
+<input type="hidden" name="UserName" value="">
+<script type="text/javascript">
+jQuery(function(){
+    jQuery("#autocomplete-UserString").autocomplete({
+        source: <% RT->Config->Get('WebPath') |n,j%>+"/Helpers/Autocomplete/Users?return=Name",
+        // Auto-submit once a user is chosen
+        select: function( event, ui ) {
+            //jQuery(event.target).val(ui.item.value);
+            var form = jQuery(event.target).closest('form');
+            form.find('input[name=UserName]').val(ui.item.value);
+            form.submit();
+        }
+    });
+});
+</script>
+% if ($Button) {
+  <input type="submit" name="UserSearch" value="<&|/l&>Search</&>" class="button" />
+%#  <& /Elements/Submit, Label => 'Search' &>
+% }
+</form>
+<%ARGS>
+$Button => undef,
+</%ARGS>

commit bf887068a043a572f0169d8b4856fe0075a41a94
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 18:12:08 2013 -0500

    Simple User Search
    
    Embeds the GotoUser widget and redirects off to a User Summary once a
    username has been chosen

diff --git a/share/html/User/Search.html b/share/html/User/Search.html
new file mode 100644
index 0000000..b003904
--- /dev/null
+++ b/share/html/User/Search.html
@@ -0,0 +1,71 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<& /Elements/Header, Title => loc('User Search') &>
+<& /Elements/Tabs &>
+    
+<& /Elements/GotoUser, Button => 1 &>
+<p> <&|/l&>This will search for users by looking in the following fields:</&> <% $search_fields %></p>
+
+<%INIT>
+
+if ($UserName) {
+    my $user = RT::User->new( $session{'CurrentUser'} );
+    my ($status, $msg) = $user->Load($UserName);
+    if ($status) {
+        RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."User/Summary.html?id=".$user->Id);
+    } else {
+        RT->Logger->error("Unable to load $UserName: $msg");
+    }
+}
+my $search_fields = join ", ", map loc($_), keys %{RT->Config->Get('UserAutocompleteFields')};
+
+</%INIT>
+<%ARGS>
+$UserString => undef,
+$UserName   => undef,
+</%ARGS>

commit f61b91589b6b572c7a5e1e11ab18b6f95c2284ab
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 18:15:16 2013 -0500

    User Summary
    
    Shows the user search again, followed by a list of portlets specified in
    UserSummaryPortlets.  No user customization available, just a simple
    list of things to display

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 833c768..c5751d2 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -937,6 +937,16 @@ RealName and EmailAddress.
 
 Set($UsernameFormat, "concise");
 
+=item C<@UserSummaryPortlets>
+
+A list of portlets to be displayed on the User Summary page.
+By default, we show all of the available portlets.
+Extensions may provide their own portlets for this page.
+
+=cut
+
+Set(@UserSummaryPortlets, (qw/ExtraInfo ActiveTickets InactiveTickets/));
+
 =item C<$WebBaseURL>, C<$WebURL>
 
 Usually you don't want to set these options. The only obvious reason
diff --git a/share/html/User/Summary.html b/share/html/User/Summary.html
new file mode 100644
index 0000000..3f3288b
--- /dev/null
+++ b/share/html/User/Summary.html
@@ -0,0 +1,83 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<& /Elements/Header, Title => loc('User Summary') &>
+<& /Elements/Tabs &>
+    
+<& /Elements/GotoUser, Button => 1 &>
+
+% $m->callback( CallbackName => 'BeforePortlets', User => $User );
+
+% for my $portlet (@$portlets) {
+    <% $show_portlet->($portlet) %>
+% }
+
+% $m->callback( CallbackName => 'AfterPortlets', User => $User );
+
+<%INIT>
+my $User = RT::User->new( $session{'CurrentUser'} );
+my ($status, $msg) = $User->Load($id);
+unless ($status) {
+    RT->Logger->error("Unable to load user $id: $msg");
+    Abort("Unable to load User $id");
+}
+
+my $portlets = RT->Config->Get('UserSummaryPortlets');
+
+my $show_portlet = sub {
+    my $portlet = shift;
+    my $full_path = "/User/Elements/Portlets/$portlet";
+    unless ( $m->comp_exists($full_path) ) {
+        RT->Logger->error("Unable to find $portlet in /User/Elements/Portlets - specified in UserSummaryPortlets");
+        return;
+    }
+    $m->comp( $full_path, User => $User );
+};
+</%INIT>
+<%ARGS>
+$id => undef,
+</%ARGS>

commit f70b63ce0fd0b70cb0399bb21a11f6339bd8fd41
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 18:19:35 2013 -0500

    ExtraInfo User portlet
    
    Thin wrapper around Elements/User/ExtraInfo, uses the
    UserSummaryExtraInfo config to control how much data you want on your
    User Summary.  It seems natural that you might list 4 or 5 attributes in
    More About Requestors and then list more here.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index c5751d2..ba35f43 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -937,6 +937,19 @@ RealName and EmailAddress.
 
 Set($UsernameFormat, "concise");
 
+=item C<$UserSummaryExtraInfo>
+
+This controls what information is displayed on the User Summary
+portal. By default the user's Real Name, Email Address and Username
+are displayed. You can remove these or add more as needed. This
+expects a Format string of user attributes. Please note that not all
+the attributes are supported in this display because we're not
+building a table.
+
+=cut
+
+Set($UserSummaryExtraInfo, "RealName, EmailAddress, Name");
+
 =item C<@UserSummaryPortlets>
 
 A list of portlets to be displayed on the User Summary page.
diff --git a/share/html/User/Elements/Portlets/ExtraInfo b/share/html/User/Elements/Portlets/ExtraInfo
new file mode 100644
index 0000000..f424532
--- /dev/null
+++ b/share/html/User/Elements/Portlets/ExtraInfo
@@ -0,0 +1,58 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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, title => loc('User Information') &>
+<div class="details">
+
+% $m->callback( User => $User, CallbackName => 'BeforeExtraInfo' );
+<& /User/Elements/UserInfo, User => $User, FormatConfig => 'UserSummaryExtraInfo', ClassPrefix => 'user-summary-extra' &>
+
+</div>
+</&>
+<%ARGS>
+$User
+</%ARGS>

commit c8660a307c1c1b5aeaae9678df19f2142e240b85
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 18:21:08 2013 -0500

    Active and Inactive ticket lists for a given user
    
    Controllable by the UserSummaryTicketListFormat, displayed by default on
    the User Summary

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index ba35f43..4ba7808 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -960,6 +960,20 @@ Extensions may provide their own portlets for this page.
 
 Set(@UserSummaryPortlets, (qw/ExtraInfo ActiveTickets InactiveTickets/));
 
+=item C<$UserSummaryTicketListFormat>
+
+Control the appearance of the Active and Inactive ticket lists in the
+User Summary.
+
+=cut
+
+Set($UserSummaryTicketListFormat, q{
+       '<a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a>',
+       '(__OwnerName__)',
+       '<a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a>',
+       '__Status__',
+});
+
 =item C<$WebBaseURL>, C<$WebURL>
 
 Usually you don't want to set these options. The only obvious reason
diff --git a/share/html/User/Elements/Portlets/ActiveTickets b/share/html/User/Elements/Portlets/ActiveTickets
new file mode 100644
index 0000000..7756d8d
--- /dev/null
+++ b/share/html/User/Elements/Portlets/ActiveTickets
@@ -0,0 +1,68 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<& /User/Elements/TicketList ,
+    User => $User,
+    conditions => $conditions,
+    Rows => $Rows,
+    WatcherTypes => [qw(Watcher)],
+    Title => loc('Active Tickets'),
+    TitleBox => 1,
+    Format => RT->Config->Get('UserSummaryTicketListFormat'),
+&>
+<%INIT>
+unless ( @$conditions ) {
+    foreach (RT::Queue->ActiveStatusArray()) {
+        push @$conditions, { cond => "Status = '$_'", name => loc($_) };
+    }
+}
+</%INIT>
+<%ARGS>
+$User => undef
+$conditions => []
+$Rows => 10
+</%ARGS>
diff --git a/share/html/User/Elements/Portlets/InactiveTickets b/share/html/User/Elements/Portlets/InactiveTickets
new file mode 100644
index 0000000..d13692d
--- /dev/null
+++ b/share/html/User/Elements/Portlets/InactiveTickets
@@ -0,0 +1,68 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<& /User/Elements/TicketList ,
+    User => $User,
+    conditions => $conditions,
+    Rows => $Rows,
+    WatcherTypes => [qw(Watcher)],
+    Title => loc('Inactive Tickets'),
+    TitleBox => 1,
+    Format => RT->Config->Get('UserSummaryTicketListFormat'),
+&>
+<%INIT>
+unless ( @$conditions ) {
+    foreach (RT::Queue->InactiveStatusArray()) {
+        push @$conditions, { cond => "Status = '$_'", name => loc($_) };
+    }
+}
+</%INIT>
+<%ARGS>
+$User => undef
+$conditions => []
+$Rows => 10
+</%ARGS>

commit 0f3bef1c4834e9fc38ec5ad37bf08bf8fc3866df
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:02:45 2013 -0500

    Allow you to pass in a default
    
    This lets me replicate Simple Search's 'sticky' searching which I find
    invaluable.

diff --git a/share/html/Elements/GotoUser b/share/html/Elements/GotoUser
index 6527381..f662a38 100644
--- a/share/html/Elements/GotoUser
+++ b/share/html/Elements/GotoUser
@@ -46,7 +46,7 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <form name="UserSearch" method="post" action="<% RT->Config->Get('WebPath') %>/User/Search.html">
-<input type="text" name="UserString" value="" id="autocomplete-UserString" />
+<input type="text" name="UserString" value="<% $Default %>" id="autocomplete-UserString" />
 <input type="hidden" name="UserName" value="">
 <script type="text/javascript">
 jQuery(function(){
@@ -68,5 +68,6 @@ jQuery(function(){
 % }
 </form>
 <%ARGS>
-$Button => undef,
+$Button  => undef
+$Default => ''
 </%ARGS>
diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index b003904..43c9ac4 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -48,7 +48,7 @@
 <& /Elements/Header, Title => loc('User Search') &>
 <& /Elements/Tabs &>
     
-<& /Elements/GotoUser, Button => 1 &>
+<& /Elements/GotoUser, Button => 1, Default => $UserString||'' &>
 <p> <&|/l&>This will search for users by looking in the following fields:</&> <% $search_fields %></p>
 
 <%INIT>

commit ad6d742755072cfa7faeea447974bbf7a51de7cf
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:07:28 2013 -0500

    Focus the search box by default when loading the User Search

diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index 43c9ac4..b852dea 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -45,7 +45,7 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title => loc('User Search') &>
+<& /Elements/Header, Title => loc('User Search'), Focus => 'autocomplete-UserString' &>
 <& /Elements/Tabs &>
     
 <& /Elements/GotoUser, Button => 1, Default => $UserString||'' &>

commit 94d08f065d6728e89a6d85c4275624955bd7dc3e
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:01:03 2013 -0500

    Rip out the central user searching logic from the Autocompleter
    
    This lets any other front-end user searching borrow the logic (and
    Oracle-aware magic) already present in the autocompleter.

diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index 5e0fc35..3c0c677 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -91,48 +91,9 @@ my %fields = %{ RT->Config->Get('UserAutocompleteFields')
 # using that operator
 %fields = ( $return => $op ) if $op;
 
-my $users = RT::Users->new( $CurrentUser );
-$users->RowsPerPage( $max );
-
-$users->LimitToPrivileged() if $privileged;
-
-while (my ($name, $op) = each %fields) {
-    $op = 'STARTSWITH'
-        unless $op =~ /^(?:LIKE|(?:START|END)SWITH|=|!=)$/i;
-
-    $users->Limit(
-        FIELD           => $name,
-        OPERATOR        => $op,
-        VALUE           => $term,
-        ENTRYAGGREGATOR => 'OR',
-        SUBCLAUSE       => 'autocomplete',
-    );
-}
-
-# Exclude users we don't want
-foreach (split /\s*,\s*/, $exclude) {
-    $users->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=');
-}
+my $users = $m->comp('/User/Elements/Search', %ARGS, fields => \%fields);
 
 my @suggestions;
-
-if ( RT->Config->Get('DatabaseType') eq 'Oracle' ) {
-    $users->Limit(
-        FIELD    => $return,
-        OPERATOR => 'IS NOT',
-        VALUE    => 'NULL',
-    );
-}
-else {
-    $users->Limit( FIELD => $return, OPERATOR => '!=', VALUE => '' );
-    $users->Limit(
-        FIELD           => $return,
-        OPERATOR        => 'IS NOT',
-        VALUE           => 'NULL',
-        ENTRYAGGREGATOR => 'AND'
-    );
-}
-
 while ( my $user = $users->Next ) {
     next if $user->id == RT->SystemUser->id
          or $user->id == RT->Nobody->id;
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/User/Elements/Search
similarity index 65%
copy from share/html/Helpers/Autocomplete/Users
copy to share/html/User/Elements/Search
index 5e0fc35..ee35449 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/User/Elements/Search
@@ -45,58 +45,18 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-% $r->content_type('application/json; charset=utf-8');
-<% JSON( \@suggestions ) |n %>
-% $m->abort;
-<%ARGS>
-$return => ''
-$term => undef
-$delim => undef
-$max => 10
-$privileged => undef
-$exclude => ''
-$op => undef
-</%ARGS>
 <%INIT>
-# Only allow certain return fields
-$return = 'EmailAddress'
-    unless $return =~ /^(?:EmailAddress|Name|RealName)$/;
-
-$m->abort unless defined $return
-             and defined $term
-             and length $term;
-
-# Use our delimeter if we have one
-if ( defined $delim and length $delim ) {
-    if ( $delim eq ',' ) {
-        $delim = qr/,\s*/;
-    } else {
-        $delim = qr/\Q$delim\E/;
-    }
-
-    # If the field handles multiple values, pop the last one off
-    $term = (split $delim, $term)[-1] if $term =~ $delim;
-}
-
-my $CurrentUser = $session{'CurrentUser'};
-
-# Require privileged users or overriding config
-$m->abort unless $CurrentUser->Privileged
-              or RT->Config->Get('AllowUserAutocompleteForUnprivileged');
+my $users = RT::Users->new( $session{'CurrentUser'} );
 
-my %fields = %{ RT->Config->Get('UserAutocompleteFields')
-                || { EmailAddress => 1, Name => 1, RealName => 'LIKE' } };
+return $users unless defined $return
+                     and defined $term
+                     and length $term;
 
-# If an operator is provided, check against only the returned field
-# using that operator
-%fields = ( $return => $op ) if $op;
-
-my $users = RT::Users->new( $CurrentUser );
 $users->RowsPerPage( $max );
 
 $users->LimitToPrivileged() if $privileged;
 
-while (my ($name, $op) = each %fields) {
+while (my ($name, $op) = each %$fields) {
     $op = 'STARTSWITH'
         unless $op =~ /^(?:LIKE|(?:START|END)SWITH|=|!=)$/i;
 
@@ -114,8 +74,6 @@ foreach (split /\s*,\s*/, $exclude) {
     $users->Limit(FIELD => 'id', VALUE => $_, OPERATOR => '!=');
 }
 
-my @suggestions;
-
 if ( RT->Config->Get('DatabaseType') eq 'Oracle' ) {
     $users->Limit(
         FIELD    => $return,
@@ -133,13 +91,13 @@ else {
     );
 }
 
-while ( my $user = $users->Next ) {
-    next if $user->id == RT->SystemUser->id
-         or $user->id == RT->Nobody->id;
-
-    my $suggestion = { label => $user->Format, value => $user->$return };
-    $m->callback( CallbackName => "ModifySuggestion", suggestion => $suggestion, user => $user );
-    push @suggestions, $suggestion;
-}
-
+return $users;
 </%INIT>
+<%ARGS>
+$privileged => undef
+$fields => RT->Config->Get('UserAutocompleteFields')
+$term => undef
+$exclude => ''
+$return => undef
+$max => 10
+</%ARGS>

commit b35c1a64fe30d228f957dec045b85a9e01851365
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:11:15 2013 -0500

    Use /Elements/User/Search to allow non-autocomplete-searching
    
    This displays users very similarly to the Admin user search list.
    You can refine the search, switch back to autocomplete and eventually
    click through to a user.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 4ba7808..cfa6a57 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -937,6 +937,20 @@ RealName and EmailAddress.
 
 Set($UsernameFormat, "concise");
 
+=item C<$UserSummaryFormat>
+
+This controls the display of lists of users returned from the User
+Summary Search. The display of users in the Admin interface is
+controlled by C<%AdminSearchResultFormat>.
+
+=cut
+
+Set($UserSummaryFormat,
+         q{ '<a href="__WebPath__/User/Summary.html?id=__id__">__id__</a>/TITLE:#'}
+        .q{,'<a href="__WebPath__/User/Summary.html?id=__id__">__Name__</a>/TITLE:Name'}
+        .q{,__RealName__, __EmailAddress__}
+);
+
 =item C<$UserSummaryExtraInfo>
 
 This controls what information is displayed on the User Summary
diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index b852dea..c098922 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -51,6 +51,27 @@
 <& /Elements/GotoUser, Button => 1, Default => $UserString||'' &>
 <p> <&|/l&>This will search for users by looking in the following fields:</&> <% $search_fields %></p>
 
+% if ($UserString) {
+
+% unless ( $users->Count ) {
+<p><&|/l&>No users matching search criteria found.</&></p>
+% } else {
+<p><&|/l&>Select a user</&>:</p>
+
+<& /Elements/CollectionList,
+    OrderBy => 'Name',
+    Order => 'ASC',
+    Rows  => 100,
+    %ARGS,
+    Format => $Format,
+    Collection => $users,
+    AllowSorting => 1,
+    PassArguments => [qw(Format Rows Page Order OrderBy q)],
+&>
+
+% }
+% }
+
 <%INIT>
 
 if ($UserName) {
@@ -62,6 +83,11 @@ if ($UserName) {
         RT->Logger->error("Unable to load $UserName: $msg");
     }
 }
+
+my $users = $m->comp('/User/Elements/Search', return => 'Name', term => $UserString);
+
+my $Format = RT->Config->Get('UserSummaryFormat');
+
 my $search_fields = join ", ", map loc($_), keys %{RT->Config->Get('UserAutocompleteFields')};
 
 </%INIT>

commit 1be750a004ac583890faf35ed3640f0332af0abd
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:39:10 2013 -0500

    Rename UserAutocompleteFields to UserSearchFields
    
    Now that I'm using them in two places, it's really misleading to call
    them Autocomplete fields.
    
    Log loudly about rename but also be nice and make it 'just work'

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index cfa6a57..156085b 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1406,7 +1406,9 @@ is ignored. Helpful when owners list is huge in the query builder.
 
 Set($AutocompleteOwnersForSearch, 0);
 
-=item C<$UserAutocompleteFields>
+=item C<$UserSearchFields>
+
+Used by the User Autocompleter as well as the User Search.
 
 Specifies which fields of L<RT::User> to match against and how to
 match each field when autocompleting users.  Valid match methods are
@@ -1414,7 +1416,7 @@ LIKE, STARTSWITH, ENDSWITH, =, and !=.
 
 =cut
 
-Set($UserAutocompleteFields, {
+Set($UserSearchFields, {
     EmailAddress => 'STARTSWITH',
     Name         => 'STARTSWITH',
     RealName     => 'LIKE',
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 6675137..1ece3c0 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -780,6 +780,24 @@ our %META = (
                 if $self->Meta('LogToScreen')->{'Source'}{'Package'};
         },
     },
+    UserAutocompleteFields => {
+        PostSet => sub {
+            my $self  = shift;
+            my $value = shift;
+            $self->SetFromConfig(
+                Option => \'UserSearchFields',
+                Value  => [$value],
+                %{$self->Meta('UserAutocompleteFields')->{'Source'}}
+            );
+        },
+        PostLoadCheck => sub {
+            my $self = shift;
+            RT->Deprecated(
+                Message => "You set \$UserAutocompleteFields in your config, but it's been renamed to \$UserSearchFields.  Please update your config.",
+                Remove => "4.4"
+            ) if $self->Meta('UserAutocompleteFields')->{'Source'}{'Package'};
+        },
+    },
     CustomFieldGroupings => {
         Type            => 'HASH',
         PostLoadCheck   => sub {
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index 3c0c677..0a772e8 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -84,7 +84,7 @@ my $CurrentUser = $session{'CurrentUser'};
 $m->abort unless $CurrentUser->Privileged
               or RT->Config->Get('AllowUserAutocompleteForUnprivileged');
 
-my %fields = %{ RT->Config->Get('UserAutocompleteFields')
+my %fields = %{ RT->Config->Get('UserSearchFields')
                 || { EmailAddress => 1, Name => 1, RealName => 'LIKE' } };
 
 # If an operator is provided, check against only the returned field
diff --git a/share/html/User/Elements/Search b/share/html/User/Elements/Search
index ee35449..ea95ad7 100644
--- a/share/html/User/Elements/Search
+++ b/share/html/User/Elements/Search
@@ -95,7 +95,7 @@ return $users;
 </%INIT>
 <%ARGS>
 $privileged => undef
-$fields => RT->Config->Get('UserAutocompleteFields')
+$fields => RT->Config->Get('UserSearchFields')
 $term => undef
 $exclude => ''
 $return => undef
diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index c098922..2e15c16 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -88,7 +88,7 @@ my $users = $m->comp('/User/Elements/Search', return => 'Name', term => $UserStr
 
 my $Format = RT->Config->Get('UserSummaryFormat');
 
-my $search_fields = join ", ", map loc($_), keys %{RT->Config->Get('UserAutocompleteFields')};
+my $search_fields = join ", ", map loc($_), keys %{RT->Config->Get('UserSearchFields')};
 
 </%INIT>
 <%ARGS>

commit 5b0752d587ef9ed1a0b6b876fa9411705dc8cf73
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 19:40:15 2013 -0500

    Switch from manual deprecated to RT->Deprecated
    
    This makes the logging 'louder' (warn vs info) but I don't believe that
    to be a bad thing.

diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 1ece3c0..8a6545e 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -775,9 +775,10 @@ our %META = (
         },
         PostLoadCheck => sub {
             my $self = shift;
-            # XXX: deprecated, remove in 4.4
-            $RT::Logger->info("You set \$LogToScreen in your config, but it's been renamed to \$LogToSTDERR.  Please update your config.")
-                if $self->Meta('LogToScreen')->{'Source'}{'Package'};
+            RT->Deprecated(
+                Message => "You set \$LogToScreen in your config, but it's been renamed to \$LogToSTDERR.  Please update your config.",
+                Remove => "4.4"
+            ) if $self->Meta('LogToScreen')->{'Source'}{'Package'};
         },
     },
     UserAutocompleteFields => {

commit 1942cd9fb32bdc9a8a0d33fcc5f860efa9497f8b
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Wed Feb 27 22:34:52 2013 -0500

    link to the User Search

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 66082b8..caaefdc 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -491,6 +491,8 @@ my $build_main_nav = sub {
 
     $search->child( articles => title => loc('Articles'),   path => "/Articles/Article/Search.html" );
 
+    $search->child( users => title => loc('Users'),   path => "/User/Search.html" );
+
 
     my $tools = Menu->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
     my $articles = $tools->child( articles => title => loc('Articles'), path => "/Articles/index.html");

commit 321bc55f93b8a35eabc5ced84e45321cd94a176f
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 7 20:21:42 2013 -0500

    A simple Create Ticket portlet
    
    Sets this user as the Requestor

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 156085b..94f1b1d 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -972,7 +972,7 @@ Extensions may provide their own portlets for this page.
 
 =cut
 
-Set(@UserSummaryPortlets, (qw/ExtraInfo ActiveTickets InactiveTickets/));
+Set(@UserSummaryPortlets, (qw/ExtraInfo CreateTicket ActiveTickets InactiveTickets/));
 
 =item C<$UserSummaryTicketListFormat>
 
diff --git a/share/html/User/Elements/Portlets/CreateTicket b/share/html/User/Elements/Portlets/CreateTicket
new file mode 100644
index 0000000..421bb4f
--- /dev/null
+++ b/share/html/User/Elements/Portlets/CreateTicket
@@ -0,0 +1,60 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 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 }}}
+<div class="quick-create user">
+<&| /Widgets/TitleBox, title => loc('Quick ticket creation') &>
+<form action="<%RT->Config->Get('WebPath')%>/Ticket/Create.html">
+<&|/l&>Create a ticket with this user as the Requestor</&>
+<input type="hidden" name="Requestors" value="<%$User->EmailAddress%>">
+<& /Elements/SelectNewTicketQueue &>
+<input type="submit" name="Create">
+</form>
+</&>
+</div>
+<%ARGS>
+$User
+</%ARGS>

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


More information about the Rt-commit mailing list