%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title=>loc("Ticketing Preferences") &>
-<& /User/Elements/Tabs,
- current_tab => 'User/Prefs.html',
- Title => loc("Preferences") &>
+<& /Elements/Tabs &>
<& /Elements/ListActions, actions => \@results &>
<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" &>
<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">
User => $UserObj,
Name => [qw(CurrentPass Pass1 Pass2)],
&>
+
+<& /Elements/EditCustomFields, Object => $UserObj, Grouping => 'Access control' &>
+
</&>
<&| /Widgets/TitleBox, title => loc('Location'), id => "user-prefs-location" &>
<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>
</&>
-<&| /Widgets/TitleBox, title => loc('Custom Fields') &>
-<table>
-% my $CustomFields = $UserObj->CustomFields;
-% while ( my $CF = $CustomFields->Next ) {
-<tr valign="top">
-<td align="right"><% loc( $CF->Name ) %>:</td>
-<td><& /Elements/EditCustomField,
- %ARGS, Object => $UserObj, CustomField => $CF
-&></td></tr>
-% }
-</table>
-</&>
-% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormRightColumn' );
-</td>
-</tr>
+<& /Elements/EditCustomFieldCustomGroupings, Object => $UserObj &>
-<tr><td colspan="2" valign="top" class="boxcontainer">
-%if ($UserObj->Privileged) {
-<br />
-<&| /Widgets/TitleBox, title => loc('Signature') &>
-<textarea cols="80" rows="5" name="Signature" class="signature" wrap="hard">
-<%$UserObj->Signature || ''%></textarea>
-</&>
-% }
-</td></tr>
-<tr><td colspan="2" valign="top" class="boxcontainer">
-<&| /Widgets/TitleBox, title => loc('Secret authentication token'), id => "user-prefs-feeds" &>
-<&|/l&><p>All iCal feeds embed a secret token which authorizes you. If the URL one of your iCal feeds got exposed to the outside world, you can get a new secret, <b>breaking all existing iCal feeds</b> below.</p></&>
+<& /Elements/Submit, Label => loc('Save Preferences') &>
+
+<&| /Widgets/TitleBox, title => loc('Secret authentication token'), id => "user-prefs-feeds" &>
-<& /Elements/Submit, Label => loc('Reset secret authentication token'), Name => "ResetAuthToken" &>
+<&|/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>
</&>
-</td></tr>
+
+% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormRightColumn' );
+</td>
+</tr>
</table>
% $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormEnd' );
-<& /Elements/Submit, Label => loc('Save Preferences') &>
</form>
my @results;
-my @fields = qw(
- Name Comments Signature EmailAddress FreeformContactInfo
- Organization RealName NickName Lang EmailEncoding WebEncoding
- ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
- AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
- Address2 City State Zip Country Lang 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 );
-
-if ( $Lang ) {
- $session{'CurrentUser'}->LanguageHandle($Lang);
- $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
+if ( $ARGS{'ResetAuthToken'} ) {
+ my ($status, $msg) = $UserObj->GenerateAuthToken;
+ push @results, $msg;
}
+else {
+ my @fields = qw(
+ Name Comments Signature EmailAddress FreeformContactInfo
+ Organization RealName NickName Lang EmailEncoding WebEncoding
+ ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
+ AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
+ Address2 City State Zip Country Timezone
+ );
-# 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));
-}
+ $m->callback(
+ CallbackName => 'UpdateLogic',
+ fields => \@fields,
+ results => \@results,
+ UserObj => $UserObj,
+ ARGSRef => \%ARGS,
+ );
-my %password_cond = $UserObj->CurrentUserRequireToSetPassword;
-if (defined $Pass1 && length $Pass1 ) {
- my ($status, $msg) = $UserObj->SafeSetPassword(
- Current => $CurrentPass,
- New => $Pass1,
- Confirmation => $Pass2,
+ push @results, UpdateRecordObject (
+ AttributesRef => \@fields,
+ Object => $UserObj,
+ ARGSRef => \%ARGS,
);
- push @results, loc("Password: [_1]", $msg);
-}
-if ( $ARGS{'ResetAuthToken'} ) {
- my ($status, $msg) = $UserObj->GenerateAuthToken;
- push @results, $msg;
+ 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>