[Rt-commit] rt branch, 4.4/selfservice-show-more-user-info, created. rt-4.4.2-237-g4dd249c2c

Maureen Mirville maureen at bestpractical.com
Thu Jun 28 14:19:27 EDT 2018


The branch, 4.4/selfservice-show-more-user-info has been created
        at  4dd249c2cfb653d3f11786b26b569dcf9882d05f (commit)

- Log -----------------------------------------------------------------
commit 0c7220668c80653a5ce011090fb7ae26e80866c2
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Fri Jun 8 12:38:22 2018 -0400

    Clean up SelfService code that is not being used

diff --git a/share/html/SelfService/Prefs.html b/share/html/SelfService/Prefs.html
index b4c57c0fc..0c6736446 100644
--- a/share/html/SelfService/Prefs.html
+++ b/share/html/SelfService/Prefs.html
@@ -119,20 +119,11 @@ if ( $Lang ) {
     $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
 }
 
-if ($Signature) {
-    $Signature =~ s/(\r\n|\r)/\n/g;
-    if ($Signature ne $user->Signature) {
-        my ($val, $msg) = $user->SetSignature($Signature);
-        push (@results, "Signature: ".$msg);
-    }
-}
-
 #A hack to make sure that session gets rewritten.
 $session{'i'}++;
 </%INIT>
 
 <%ARGS>
-$Signature => undef
 $CurrentPass => undef
 $NewPass1 => undef
 $NewPass2 => undef

commit 6caaadbca9ded12a3b5a8533e2e9907e3098d2d2
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Wed May 9 10:46:03 2018 -0400

    Allow self service users varied access to their stored RT user information
    
    The self service user preferences page now has configurable displays
    using the config option, $SelfServiceUserPrefs. The default display
    remains the same (user can update locale and password). The full
    access viewing option allows the user to view all of their stored RT
    information (read only). The full access editing option allows users
    to make updates to their information.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 6fe7bc7a2..9236d6dfb 100644
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1798,6 +1798,36 @@ access ticked displays.
 
 Set($SelfServiceRegex, qr!^(?:/+SelfService/)!x );
 
+=item C<$SelfServiceUserPrefs>
+
+This option controls how the SelfService user preferences page is
+displayed. It accepts a string from one of the three possible modes
+below.
+
+=over
+
+=item C<brief> (the default)
+
+When set to C<brief>, self service users will be able to update
+their Timezone and Language preference and update their password.
+This is the default behavior of RT.
+
+=item C<full-view>
+
+When set to C<full-view>, users will have full access to all their
+user information stored in RT on a read-only page.
+
+=item C<full-edit>
+
+When set to C<full-edit>, users will be able to fully view and update
+all of their stored RT user information.
+
+=back
+
+=cut
+
+Set($SelfServiceUserPrefs, 'brief' );
+
 =back
 
 =head2 Articles
diff --git a/share/html/Prefs/AboutMe.html b/share/html/Prefs/AboutMe.html
index 7eaf36755..4082396c6 100644
--- a/share/html/Prefs/AboutMe.html
+++ b/share/html/Prefs/AboutMe.html
@@ -50,152 +50,7 @@
 
 <& /Elements/ListActions, actions => \@results &>
 
-<form action="<%RT->Config->Get('WebPath')%>/Prefs/AboutMe.html" method="post">
-<input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
-
-<table width="100%" border="0">
-<tr>
-
-<td valign="top" class="boxcontainer">
-<&| /Widgets/TitleBox, title => loc('Identity'), id => "user-prefs-identity" &>
-
-<input type="hidden" class="hidden" name="Name" value="<%$UserObj->Name%>" />
-<table cellspacing="0" cellpadding="0">
-  <tr>
-    <td class="label"><&|/l&>Email</&>: </td>
-    <td class="value"><input name="EmailAddress" value="<%$UserObj->EmailAddress%>" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Real Name</&>:</td>
-    <td class="value"><input name="RealName" value="<%$UserObj->RealName%>" /></td>  </tr>
-  <tr>
-    <td class="label"><&|/l&>Nickname</&>:</td>
-    <td class="value"><input name="NickName" value="<%$UserObj->NickName || ''%>" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Language</&>:</td>
-    <td class="value"><& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Timezone</&>:</td>
-    <td class="value"><& /Elements/SelectTimezone, Name => 'Timezone', Default => $UserObj->Timezone &></td>
-  </tr>
-<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
-</table>
-</&>
-<&| /Widgets/TitleBox, title => loc('Phone numbers'), id => "user-prefs-phone" &>
-<table cellspacing="0" cellpadding="0">
-  <tr>
-    <td class="label"><&|/l&>Residence</&>:</td>
-    <td class="value"><input name="HomePhone" value="<%$UserObj->HomePhone || ''%>" size="13" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Work</&>:</td>
-    <td class="value"><input name="WorkPhone" value="<%$UserObj->WorkPhone || ''%>" size="13" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Mobile</&>:</td>
-    <td class="value"><input name="MobilePhone" value="<%$UserObj->MobilePhone || ''%>" size="13" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Pager</&>:</td>
-    <td class="value"><input name="PagerPhone" value="<%$UserObj->PagerPhone || ''%>" size="13" /></td>
-  </tr>
-<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
-</table>
-</&>
-
-%if ($UserObj->Privileged) {
-<&| /Widgets/TitleBox, title => loc('Signature'), id => "user-prefs-signature" &>
-<textarea cols="80" rows="5" name="Signature" class="signature" wrap="hard">
-<%$UserObj->Signature || ''%></textarea>
-</&>
-% }
-
-% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormLeftColumn' );
-</td>
-<td valign="top" class="boxcontainer">
-
-<&| /Widgets/TitleBox, title => loc('Access control'), id => "user-prefs-password" &>
-% if ( $UserObj->__Value('Password') ne '*NO-PASSWORD*' ) {
-<& /Elements/EditPassword,
-    User => $UserObj,
-    Name => [qw(CurrentPass Pass1 Pass2)],
-&>
-% }
-
-<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
-
-</&>
-
-<&| /Widgets/TitleBox, title => loc('Location'), id => "user-prefs-location" &>
-<table cellspacing="0" cellpadding="0">
-  <tr>
-    <td class="label"><&|/l&>Organization</&>:</td>
-    <td class="value"><input name="Organization" value="<%$UserObj->Organization || ''%>" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Address1</&>:</td>
-    <td class="value"><input name="Address1" value="<%$UserObj->Address1 || ''%>" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Address2</&>:</td>
-    <td class="value"><input name="Address2" value="<%$UserObj->Address2 || ''%>" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>City</&>:</td>
-    <td><input name="City" value="<%$UserObj->City || ''%>" size="14" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>State</&>:</td>
-    <td class="value"><input name="State" value="<%$UserObj->State || ''%>" size="3" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Zip</&>:</td>
-    <td class="value"><input name="Zip" value="<%$UserObj->Zip || ''%>" size="9" /></td>
-  </tr>
-  <tr>
-    <td class="label"><&|/l&>Country</&>:</td>
-    <td class="value"><input name="Country" value="<%$UserObj->Country || ''%>" /></td>
-  </tr>
-<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
-</table>
-</&>
-
-
-
-<& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
-
-
-
-<& /Elements/Submit, Label => loc('Save Preferences') &>
-
-<&| /Widgets/TitleBox, title => loc('Secret authentication token'), id => "user-prefs-feeds" &>
-
-<&|/l&>All iCal feeds embed a secret token which authorizes you.  If the URL for one of your iCal feeds was exposed to the outside world, you can get a new secret, <b>breaking all existing iCal feeds</b>, below.</&>
-
-<a href="#" id="ResetAuthTokenPrompt" style="display: none">
-  <&|/l&>I want to reset my secret token.</&>
-</a>
-<& /Elements/Submit,
-    Label       => loc('Reset secret authentication token'),
-    Name        => "ResetAuthToken",
-    id          => "ResetAuthTokenContainer" &>
-<script>
-    jQuery("#ResetAuthTokenContainer").hide();
-    jQuery("#ResetAuthTokenPrompt").show().click(function(ev){
-        jQuery(this).slideUp();
-        jQuery("#ResetAuthTokenContainer").slideDown();
-        ev.preventDefault();
-    });
-</script>
-</&>
-
-% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormRightColumn' );
-</td>
-</tr>
-
-</table>
+<& Elements/EditAboutMe, UserObj => $UserObj, PasswordName => [ qw(CurrentPass Pass1 Pass2) ] &>
 
 % $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormEnd' );
 
diff --git a/share/html/Prefs/AboutMe.html b/share/html/Prefs/Elements/EditAboutMe
similarity index 71%
copy from share/html/Prefs/AboutMe.html
copy to share/html/Prefs/Elements/EditAboutMe
index 7eaf36755..c3e9b4434 100644
--- a/share/html/Prefs/AboutMe.html
+++ b/share/html/Prefs/Elements/EditAboutMe
@@ -45,20 +45,14 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-<& /Elements/Header, Title=>loc("Preferences") &>
-<& /Elements/Tabs &>
 
-<& /Elements/ListActions, actions => \@results &>
-
-<form action="<%RT->Config->Get('WebPath')%>/Prefs/AboutMe.html" method="post">
+<form name="EditAboutMe" action="" method="post">
 <input type="hidden" class="hidden" name="id" value="<%$UserObj->Id%>" />
 
 <table width="100%" border="0">
 <tr>
-
 <td valign="top" class="boxcontainer">
 <&| /Widgets/TitleBox, title => loc('Identity'), id => "user-prefs-identity" &>
-
 <input type="hidden" class="hidden" name="Name" value="<%$UserObj->Name%>" />
 <table cellspacing="0" cellpadding="0">
   <tr>
@@ -104,7 +98,6 @@
 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
 </table>
 </&>
-
 %if ($UserObj->Privileged) {
 <&| /Widgets/TitleBox, title => loc('Signature'), id => "user-prefs-signature" &>
 <textarea cols="80" rows="5" name="Signature" class="signature" wrap="hard">
@@ -113,26 +106,29 @@
 % }
 
 % $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormLeftColumn' );
+
 </td>
 <td valign="top" class="boxcontainer">
-
 <&| /Widgets/TitleBox, title => loc('Access control'), id => "user-prefs-password" &>
 % if ( $UserObj->__Value('Password') ne '*NO-PASSWORD*' ) {
 <& /Elements/EditPassword,
     User => $UserObj,
-    Name => [qw(CurrentPass Pass1 Pass2)],
+    Name => $PasswordName,
 &>
 % }
-
 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
-
 </&>
 
+%my $AdminUser = $session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' );
 <&| /Widgets/TitleBox, title => loc('Location'), id => "user-prefs-location" &>
 <table cellspacing="0" cellpadding="0">
   <tr>
     <td class="label"><&|/l&>Organization</&>:</td>
+%if ( $AdminUser ) {
     <td class="value"><input name="Organization" value="<%$UserObj->Organization || ''%>" /></td>
+%} else {
+    <td class="value"><%$UserObj->Organization || ''%></td>
+%}
   </tr>
   <tr>
     <td class="label"><&|/l&>Address1</&>:</td>
@@ -161,15 +157,11 @@
 <& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
 </table>
 </&>
-
-
-
 <& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
 
-
-
 <& /Elements/Submit, Label => loc('Save Preferences') &>
 
+%if ( $AdminUser ) {
 <&| /Widgets/TitleBox, title => loc('Secret authentication token'), id => "user-prefs-feeds" &>
 
 <&|/l&>All iCal feeds embed a secret token which authorizes you.  If the URL for one of your iCal feeds was exposed to the outside world, you can get a new secret, <b>breaking all existing iCal feeds</b>, below.</&>
@@ -190,117 +182,14 @@
     });
 </script>
 </&>
+%}
 
 % $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormRightColumn' );
 </td>
 </tr>
-
 </table>
 
-% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormEnd' );
-
-</form>
-
-
-<%INIT>
-
-my $UserObj = RT::User->new( $session{'CurrentUser'} );
-$UserObj->Load($id) if $id;
-$UserObj->Load($Name) if $Name && !$UserObj->id;
-unless ( $UserObj->id ) {
-    Abort(loc("Couldn't load user #[_1] or user '[_2]'", $id, $Name))
-        if $id && $Name;
-    Abort(loc("Couldn't load user #[_1]", $id))
-        if $id;
-    Abort(loc("Couldn't load user '[_1]'", $Name))
-        if $Name;
-    Abort(loc("Couldn't load user"));
-}
-$id = $UserObj->id;
-
-my @results;
-
-if ( $ARGS{'ResetAuthToken'} ) {
-    my ($status, $msg) = $UserObj->GenerateAuthToken;
-    push @results, $msg;
-}
-else {
-    my @fields = qw(
-        Name Comments Signature EmailAddress FreeformContactInfo 
-        Organization RealName NickName Lang Gecos HomePhone WorkPhone
-        MobilePhone PagerPhone Address1 Address2 City State Zip Country
-        Timezone
-    );
-
-    $m->callback(
-        CallbackName => 'UpdateLogic',
-        fields       => \@fields,
-        results      => \@results,
-        UserObj      => $UserObj,
-        ARGSRef      => \%ARGS,
-    );
-
-    push @results, UpdateRecordObject (
-        AttributesRef => \@fields,
-        Object => $UserObj,
-        ARGSRef => \%ARGS,
-    );
-
-    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
-
-    # Deal with special fields: Privileged, Enabled, and Password
-    if  ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
-        my ($code, $msg) = $UserObj->SetPrivileged( $Privileged );
-        push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
-    }
-
-    my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
-    if (defined $Pass1 && length $Pass1 ) {
-        my ($status, $msg) = $UserObj->SafeSetPassword(
-            Current      => $CurrentPass,
-            New          => $Pass1,
-            Confirmation => $Pass2,
-        );
-        push @results, loc("Password: [_1]", $msg);
-    }
-}
-
-
-MaybeRedirectForResults(
-    Actions   => \@results,
-);
-
-</%INIT>
-
-
 <%ARGS>
-$id => $session{'CurrentUser'}->Id
-$Name  => undef
-$Comments  => undef
-$Signature  => undef
-$EmailAddress  => undef
-$FreeformContactInfo => undef
-$Organization  => undef
-$RealName  => undef
-$NickName  => undef
-$Privileged => undef
-$SetPrivileged => undef
-$Enabled => undef
-$SetEnabled => undef
-$Lang  => undef
-$Gecos => undef
-$HomePhone => undef
-$WorkPhone  => undef
-$MobilePhone  => undef
-$PagerPhone  => undef
-$Address1 => undef
-$Address2  => undef
-$City  => undef
-$State  => undef
-$Zip  => undef
-$Country => undef
-$CurrentPass => undef
-$Pass1 => undef
-$Pass2 => undef
-$Create=> undef
+$UserObj
+$PasswordName
 </%ARGS>
diff --git a/share/html/Prefs/Elements/ShowAboutMe b/share/html/Prefs/Elements/ShowAboutMe
new file mode 100644
index 000000000..f82a10b7e
--- /dev/null
+++ b/share/html/Prefs/Elements/ShowAboutMe
@@ -0,0 +1,141 @@
+%# 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 }}}
+
+<table width="100%" border="0">
+  <tr>
+    <td valign="top" class="boxcontainer">
+      <&| /Widgets/TitleBox, title => loc('Identity'), id => "user-prefs-identity" &>
+      <input type="hidden" class="hidden" name="Name" value="<%$UserObj->Name%>" />
+      <table cellspacing="0" cellpadding="0">
+        <tr>
+          <td class="label"><&|/l&>Email</&>:</td>
+          <td class="value"><%$UserObj->EmailAddress%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Real Name</&>:</td>
+          <td class="value"><%$UserObj->RealName%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Nickname</&>:</td>
+          <td class="value"><%$UserObj->NickName || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Language</&>:</td>
+          <td class="value"><%$UserObj->Lang%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Timezone</&>:</td>
+          <td class="value"><%$UserObj->Timezone%></td>
+        </tr>
+      <& /Elements/ShowCustomFields, Object => $UserObj, Grouping => 'Identity', InTable => 1 &>
+      </table>
+      </&>
+      <&| /Widgets/TitleBox, title => loc('Phone numbers'), id => "user-prefs-phone" &>
+      <table cellspacing="0" cellpadding="0">
+        <tr>
+          <td class="label"><&|/l&>Residence</&>:</td>
+          <td class="value"><%$UserObj->HomePhone || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Work</&>:</td>
+          <td class="value"><%$UserObj->WorkPhone || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Mobile</&>:</td>
+          <td class="value"><%$UserObj->MobilePhone || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Pager</&>:</td>
+          <td class="value"><%$UserObj->PagerPhone || ''%></td>
+        </tr>
+      <& /Elements/ShowCustomFields, Object => $UserObj, Grouping => 'Phones', InTable => 1 &>
+      </table>
+      </&>
+    </td>
+    <td valign="top" class="boxcontainer">
+      <&| /Widgets/TitleBox, title => loc('Location'), id => "user-prefs-location" &>
+      <table cellspacing="0" cellpadding="0">
+        <tr>
+          <td class="label"><&|/l&>Organization</&>:</td>
+          <td class="value"><%$UserObj->Organization || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Address1</&>:</td>
+          <td class="value"><%$UserObj->Address1 || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Address2</&>:</td>
+          <td class="value"><%$UserObj->Address2 || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>City</&>:</td>
+          <td class="value"><%$UserObj->City || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>State</&>:</td>
+          <td class="value"><%$UserObj->State || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Zip</&>:</td>
+          <td class="value"><%$UserObj->Zip || ''%></td>
+        </tr>
+        <tr>
+          <td class="label"><&|/l&>Country</&>:</td>
+          <td class="value"><%$UserObj->Country || ''%></td>
+        </tr>
+      <& /Elements/ShowCustomFields, Object => $UserObj, Grouping => 'Location', InTable => 1 &>
+      </table>
+      </&>
+      <& /Elements/ShowCustomFieldCustomGroupings, Object => $UserObj &>
+    </td>
+  </tr>
+</table>
+
+<%ARGS>
+$UserObj
+</%ARGS>
diff --git a/share/html/SelfService/Prefs.html b/share/html/SelfService/Prefs.html
index 0c6736446..1fdcce848 100644
--- a/share/html/SelfService/Prefs.html
+++ b/share/html/SelfService/Prefs.html
@@ -48,6 +48,11 @@
 <& /SelfService/Elements/Header, Title => loc('Preferences') &>
 
 <& /Elements/ListActions, actions => \@results &>
+% if ( $pref eq 'full-edit' ) {
+<& /Prefs/Elements/EditAboutMe, UserObj => $user, PasswordName => $password &>
+% } elsif ( $pref eq 'full-view' ) {
+<& /Prefs/Elements/ShowAboutMe, UserObj => $user &>
+% } else {
 <form method="post">
 
 <table width="100%" border="0">
@@ -71,7 +76,7 @@
 % if ( $user->__Value('Password') ne '*NO-PASSWORD*' ) {
 <& /Elements/EditPassword,
     User => $user,
-    Name => [qw(CurrentPass NewPass1 NewPass2)],
+    Name => $password,
 &>
 % }
 </&>
@@ -81,46 +86,62 @@
 <& /Elements/Submit, Label => loc('Save Changes') &>
 </form>
 
+% }
 
 <%INIT>
 my @results;
 
 my $user = $session{'CurrentUser'}->UserObj;
+my $password = [ qw(CurrentPass NewPass1 NewPass2) ];
+
+my $pref = RT->Config->Get( 'SelfServiceUserPrefs' ) || '';
+
+if ( $pref ne 'full-view' ) {
 
-if (defined $NewPass1 && length $NewPass1 ) {
+  if ( defined $NewPass1 && length $NewPass1 ) {
     my ($status, $msg) = $user->SafeSetPassword(
-        Current      => $CurrentPass,
-        New          => $NewPass1,
-        Confirmation => $NewPass2,
+      Current      => $CurrentPass,
+      New          => $NewPass1,
+      Confirmation => $NewPass2,
     );
     push @results, loc("Password: [_1]", $msg);
-}
+  }
 
-my @fields = qw(
-        Lang Timezone
-    );
+  my @fields = qw(
+      Name Comments EmailAddress FreeformContactInfo Organization RealName
+      NickName Lang Gecos HomePhone WorkPhone MobilePhone PagerPhone Address1
+      Address2 City State Zip Country Timezone
+  );
 
-$m->callback(
+  $m->callback(
     CallbackName => 'UpdateLogic',
     fields       => \@fields,
     results      => \@results,
     UserObj      => $user,
     ARGSRef      => \%ARGS,
-);
+  );
 
-push @results, UpdateRecordObject (
+  push @results, UpdateRecordObject (
     AttributesRef => \@fields,
     Object => $user,
     ARGSRef => \%ARGS,
-);
+  );
 
-if ( $Lang ) {
+  push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $user );
+
+  if ( $Lang ) {
     $session{'CurrentUser'}->LanguageHandle($Lang);
     $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
-}
+  }
+
+  #A hack to make sure that session gets rewritten.
+  $session{'i'}++;
 
-#A hack to make sure that session gets rewritten.
-$session{'i'}++;
+  MaybeRedirectForResults(
+    Actions   => \@results,
+  );
+
+}
 </%INIT>
 
 <%ARGS>

commit 398002864e69602283152b8dfbfdfb4fcc65df6a
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Tue Jun 26 10:16:38 2018 -0400

    Remove ModifySelf rights check for Preferences tab in SelfService
    
    With the additional display options added with the SelfServiceUserPrefs
    config, it is not necessary to check if a user has the right to update
    the user's info. See previous commit.

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 40cb43e7c..77b85cf99 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -1219,7 +1219,8 @@ my $build_selfservice_nav = sub {
         sort_order   => 99,
     );
 
-    if ( $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
+    if ( ( RT->Config->Get('SelfServiceUserPrefs') || '' ) eq 'full-view' ||
+       $session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
         $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
     }
 
diff --git a/share/html/SelfService/Prefs.html b/share/html/SelfService/Prefs.html
index 1fdcce848..a2b3c1a55 100644
--- a/share/html/SelfService/Prefs.html
+++ b/share/html/SelfService/Prefs.html
@@ -96,7 +96,7 @@ my $password = [ qw(CurrentPass NewPass1 NewPass2) ];
 
 my $pref = RT->Config->Get( 'SelfServiceUserPrefs' ) || '';
 
-if ( $pref ne 'full-view' ) {
+if ( $pref eq 'brief' | $pref eq 'full-edit' ) {
 
   if ( defined $NewPass1 && length $NewPass1 ) {
     my ($status, $msg) = $user->SafeSetPassword(
@@ -107,11 +107,17 @@ if ( $pref ne 'full-view' ) {
     push @results, loc("Password: [_1]", $msg);
   }
 
-  my @fields = qw(
+  my @fields;
+
+  if ( $pref eq 'brief' ) {
+    @fields = qw( Lang Timezone );
+  } else {
+    @fields = qw(
       Name Comments EmailAddress FreeformContactInfo Organization RealName
       NickName Lang Gecos HomePhone WorkPhone MobilePhone PagerPhone Address1
       Address2 City State Zip Country Timezone
-  );
+    );
+  }
 
   $m->callback(
     CallbackName => 'UpdateLogic',

commit 4dd249c2cfb653d3f11786b26b569dcf9882d05f
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date:   Fri Jun 8 12:05:02 2018 -0400

    Add $SelfServiceUserPrefs config tests to verify SelfService display

diff --git a/t/web/self_service.t b/t/web/self_service.t
index 7afc008c6..c9d05f5b0 100644
--- a/t/web/self_service.t
+++ b/t/web/self_service.t
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 use RT::Test
-  tests  => 17,
+  tests  => undef,
   config => 'Set( $ShowUnreadMessageNotifications, 1 );'
 ;
 
@@ -51,4 +51,38 @@ $m->follow_link_ok(
 $m->content_contains( "<h1>$title</h1>", "contains <h1>$title</h1>" );
 $m->content_lacks( "There are unread messages on this ticket." );
 
+diag 'Test $SelfServiceUserPrefs config';
+{
+  # Verify the $SelfServiceUserPrefs config option renders the correct display at
+  # /SelfService/Prefs.html for each of the available options
+
+  is( RT->Config->Get( 'SelfServiceUserPrefs' ), 'brief', '$SelfServiceUserPrefs is set to "brief" by default' );
+
+  for my $config ( 'brief', 'full-view', 'full-edit' ) {
+    RT::Test->stop_server;
+    RT->Config->Set( SelfServiceUserPrefs => $config );
+    ( $url, $m ) = RT::Test->started_ok;
+    ok( $m->login('user_a' => 'password'), 'unprivileged user logged in' );
+    $m->get_ok( '/SelfService/Prefs.html');
+
+    if ( $config eq 'brief' ) {
+      $m->content_lacks( 'Nickname', "'Brief' option does not contain full user info" );
+      $m->content_contains( '<td class="value"><input type="password" name="CurrentPass"', "'Brief' option contains default user info" );
+    } elsif ( $config eq 'full-view' ) {
+      $m->content_lacks( '<td class="value"><input name="NickName" value="" /></td>', "'Full-view' option contains no input fields for full user info" );
+      $m->content_contains( '<td class="label">Nickname:</td>', "'Full-view' option contains full user info" );
+    } else {
+      RT::Test->add_rights( { Principal => $user_a, Right => ['ModifySelf'] } );
+      my $nickname = 'user_a_nickname';
+      $m->submit_form_ok({
+        form_name  => 'EditAboutMe',
+        with_fields     => { NickName => $nickname,}
+      }, 'Form submitted');
+      $m->text_contains("NickName changed from (no value) to '$nickname'", "NickName updated");
+    }
+  }
+}
+
 # TODO need more SelfService tests
+
+done_testing();

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


More information about the rt-commit mailing list