BaseDigestService: Format message according to receivers settings

Description

This patch fetches the locale of the receiver and formats the message accordingly.

Attachments

2

Activity

Show:

Aaron Zeckoski March 5, 2013 at 3:26 PM

PreferencesService.getPreferences(userId); allows you to specify the user without doing anything related to a session.
Would it be nice to have some kind of shortcut method in the API that does all this for someone? Maybe. It is needed in order to accomplish the work in this ticket? no.

Matthew Jones March 5, 2013 at 2:32 PM

Yea, the method (getUserTimezoneLocale) does this fallback as you describe. There's just no way to specify a user other than grabbing it from the sessionManager.

Aaron Zeckoski March 5, 2013 at 2:12 PM

Well, there is this prefs tool thingy where you can set your timezone. And I think something like this would get the result of that setting for the current user:

TimeZone timeZone = timeService.getLocalTimeZone();

Or something like this if you need it for a given user:
Preferences prefs = preferencesService.getPreferences(userId);
ResourceProperties tzProps = prefs.getProperties(TimeService.APPLICATION_ID);
String timeZone = tzProps.getProperty(TimeService.TIMEZONE_KEY);

Bear in mind that it might not be set in BOTH cases so you need to fallback to the local timezone of the server.

Matthew Jones March 5, 2013 at 2:09 PM

I don't see the method, looks like it would have to be added as a new api?
Currently getLocalTimeZone calls getUserTimeZoneLocale but it does a lookup from the session. You'd need a method that took a parameter for the user id, and if that wasn't passed (or null) in then lookup from the session

So like TimeZone getLocalTimeZone(String userId);

You might be to do a hack to create a session (sessionManager.setCurrentSession(s) and set a fake session with that user before doing the lookup in the code here, but that wouldn't be the best idea ever. The new method seems better.

(Current method)
/** Return string with user's prefered timezone and preferred locale

  •  

    • (dates are formatted according to the locale)
      **/
      protected String[] getUserTimezoneLocale()
      {
      // Check if we already cached this user's timezone
      String userId = sessionManager.getCurrentSessionUserId();

Gregory Thomas March 5, 2013 at 1:41 PM

So, question for either the CLE or Kernel people is there a function somewhere that grabs the preferred timezone of a specific user? If no, how much work would that be to make this feature request possible?

Non-Issue

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Labels

Environment

Sakai 2.8.1
Created April 16, 2012 at 3:55 AM
Updated April 25, 2018 at 3:39 PM
Resolved October 21, 2013 at 9:14 AM