diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index 5702f10cc..f90584c91 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -99,6 +99,7 @@ - (NSString *) cn; - (SOGoDateFormatter *) dateFormatterInContext: (WOContext *) context; +- (NSDictionary *) currentDay; /* defaults */ - (SOGoUserDefaults *) userDefaults; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index e240550f1..263c6e7e5 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -394,6 +394,39 @@ return dateFormatter; } +- (NSDictionary *) currentDay +{ + NSCalendarDate *now; + NSDictionary *description, *abbr; + NSDictionary *locale; + SOGoUserDefaults *ud; + WOResourceManager *resMgr; + NSUInteger seconds; + + now = [NSCalendarDate calendarDate]; + ud = [self userDefaults]; + resMgr = [[WOApplication application] resourceManager]; + locale = [resMgr localeForLanguageNamed: [ud language]]; + + [now setTimeZone: [ud timeZone]]; + seconds = [now hourOfDay]*3600 + [now minuteOfHour]*60 + [now secondOfMinute]; + + abbr = [NSDictionary dictionaryWithObjectsAndKeys: + [now descriptionWithCalendarFormat: @"%a" locale: locale], @"weekday", + [now descriptionWithCalendarFormat: @"%b" locale: locale], @"month", + nil]; + description = [NSDictionary dictionaryWithObjectsAndKeys: + [now descriptionWithCalendarFormat: @"%A" locale: locale], @"weekday", + [now descriptionWithCalendarFormat: @"%B" locale: locale], @"month", + [now descriptionWithCalendarFormat: @"%d" locale: locale], @"day", + [now descriptionWithCalendarFormat: @"%Y" locale: locale], @"year", + abbr, @"abbr", + [NSNumber numberWithInt: (24*3600 - seconds)], @"secondsBeforeTomorrow", + nil]; + + return description; +} + - (SOGoUserDefaults *) userDefaults { if (!_defaults) diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index f808627d7..e2e62f269 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -602,6 +602,27 @@ return result; } +/** + * @api {get} /so/:username/date Get current day + * @apiVersion 1.0.0 + * @apiName GetCurrentDate + * @apiGroup Common + * @apiExample {curl} Example usage: + * curl -i http://localhost/SOGo/so/sogo1/date + * + * @apiSuccess (Success 200) {String} weekday Full weekday name according to user's locale + * @apiSuccess (Success 200) {String} month Full month name according to user's locale + * @apiSuccess (Success 200) {String} day Day of month as two digit decimal number (leading zero) + * @apiSuccess (Success 200) {String} year Year as a decimal number with century + * @apiSuccess (Success 200) {Object} abbr Abbreviations + * @apiSuccess (Success 200) {String} abbr.weekday Abbreviated weekday name according to user's locale + * @apiSuccess (Success 200) {String} abbr.month Abbreviated month name according to user's locale + */ +- (id ) dateAction +{ + return [self responseWithStatus: 200 andJSONRepresentation: [[context activeUser] currentDay]]; +} + - (id) recoverAction { return [self responseWithStatus: 200 diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index c9e230177..022f21997 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -211,6 +211,11 @@ pageName = "SOGoUserHomePage"; actionName = "foldersSearch"; }; + date = { + protectedBy = "View"; + pageName = "SOGoUserHomePage"; + actionName = "date"; + } }; }; // SOGoGroupsFolder = { diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 74f6c4295..44f59a425 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -39,6 +39,7 @@ #import #import +#import #import #import #import @@ -440,6 +441,11 @@ static SoProduct *commonProduct = nil; return _selectedDate; } +- (NSString *) currentDayDescription +{ + return [[[context activeUser] currentDay] jsonRepresentation]; +} + - (NSString *) dateStringForDate: (NSCalendarDate *) _date { [_date setTimeZone: [userDefaults timeZone]]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index 6f030c28f..9d581737c 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -211,12 +211,11 @@
-

monday

-

january

-

2015

+

+

+

- -

15

+

diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 75bd3e7fb..5155ad3bb 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -310,12 +310,11 @@
-

monday

-

january

-

2015

+

+

+

- -

15

+

diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index 36560c135..8b7e11641 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -201,6 +201,8 @@ var UserIdentification = ''; var UserLanguage = ''; + // This is the equivalent of an AJAX call to /SOGo/so/_UserLogin_/date + var currentDay = ; diff --git a/UI/WebServerResources/js/Common/ui.js b/UI/WebServerResources/js/Common/ui.js index c301f40cc..6b99d9a76 100644 --- a/UI/WebServerResources/js/Common/ui.js +++ b/UI/WebServerResources/js/Common/ui.js @@ -116,7 +116,17 @@ return l; }) - .controller('navController', ['$scope', '$timeout', '$mdSidenav', '$mdBottomSheet', '$mdMedia', '$log', 'sgConstant', function ($scope, $timeout, $mdSidenav, $mdBottomSheet, $mdMedia, $log, sgConstant) { + .controller('navController', ['$scope', '$timeout', '$interval', '$http', '$mdSidenav', '$mdBottomSheet', '$mdMedia', '$log', 'sgConstant', function ($scope, $timeout, $interval, $http, $mdSidenav, $mdBottomSheet, $mdMedia, $log, sgConstant) { + // Show current day in top bar + $scope.currentDay = window.currentDay; + $timeout(function() { + // Update date when day ends + $interval(function() { + $http.get('../date').success(function(data) { + $scope.currentDay = data; + }); + }, 24 * 3600 * 1000); + }, window.secondsBeforeTomorrow * 1000); $scope.toggleLeft = function () { $mdSidenav('left').toggle()