DisplayCustomFieldsInUserPrefs

From Request Tracker Wiki
Jump to navigation Jump to search

What This Is

This patch causes any user-based custom fields to show up on the user preferences page. If you allow users SeeCustomField, they'll be able to see the fields that apply to them; if they're allowed ModifyCustomField, they'll be able to change them.

The patch below was made against RT 3.5.5; I suspect the logic can be transplanted as far back as 3.2, though.

How To Install This

  1. Save the text below as /tmp/UserPrefs.patch
  2. mkdir /path/to/rt/local/html/User
  3. cd /path/to/rt/local/html/User
  4. cp /path/to/rt/share/html/User/Prefs.html
  5. patch -p3 < /tmp/UserPrefs.patch

Patch for RT 3.5.5

--- share/html/User/Prefs.html  2005-07-25 03:25:52.000000000 -0700
 +++ local/html/User/Prefs.html  2005-11-23 10:12:31.000000000 -0800
 @@ -154,8 +154,23 @@
      <td class="value"><input name="Country" value="<%$UserObj->Country%>"></td>   </tr>
  </table>
  </&>
 +<br/>
 +<&| /Widgets/TitleBox, title => loc('Custom Fields') &>
 +<table>
 +% my $CFs = $UserObj->CustomFields;
 +% while (my $CF = $CFs->Next) {
 +<tr valign="TOP"><td align="RIGHT">
 +<% $CF->Name %>:
 +</td><td>
 +<& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
 +</td></tr>
 +% }
 +<tr>
 +</tr>
 +</table>
 +</&>
  </td>
  </tr>
  <tr>
 
 @@ -214,8 +229,10 @@
         $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
      }
 
      push (@results,@fieldresults);
 +    push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
 +
 
 
  # {{{ Deal with special fields: Privileged, Enabled and Password
  if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
 
 

Patch for 3.6.1

Looks like it works for 3.6.1 too. I did not use the patch mechanism but copied some code from /Admin/Users/Modify.html and the 'push results-sentance' from here.