diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 75afd3e51..4b9dabd08 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -1998,6 +1998,30 @@ message expiration. See the _Cronjob — Vacation messages expiration_ section below for details. +|D |SOGoVacationHeaderTemplateFile +|Parameter used to specify the path of a text file whose content must be +prepended to the user's vacation message. For example: + +`SOGoVacationHeaderTemplateFile = /etc/sogo/autoresponder.header.txt;` + +The following template variables can appear in the content: + +[options="compact"] +* `%{username}` +* `%{daysBetweenResponse}` + +|D |SOGoVacationFooterTemplateFile +|Parameter used to specify the path of a text file whose content must be +appended to the user's vacation message. For example: + +`SOGoVacationFooterTemplateFile = /etc/sogo/autoresponder.footer.txt;` + +See `SOGoVacationHeaderTemplateFile` for available template variables. + +|D |SOGoVacationHeaderTemplateFile +|Parameter used to specify the path of a text file whose content must be +prepended to the user's vacation message. + |D |SOGoForwardEnabled |Parameter used to activate the edition from the preferences window of a forwarding email address. Requires Sieve script support on the IMAP @@ -2280,7 +2304,7 @@ be put under `~sogo/GNUstep/Library/SOGo/Templates/PreferencesUI/`. and the follow keys are supported: `vendor` (which must be set to "generic" for now), `junkEmailAddress` which sets the email address to whom SOGo will send junk mails to, `notJunkEmailAddress` which sets the email address to -whome SOGo will send non-junk mails to and `limit`, which is an integer value +whom SOGo will send non-junk mails to and `limit`, which is an integer value and sets the maximum number of mails that will be attached to a junk/not junk report sent by SOGo. Example: `SOGoMailJunkSettings = { vendor = "generic"; junkEmailAddress = "spam@foo.com"; diff --git a/NEWS b/NEWS index b8c2003d7..4c243b38b 100644 --- a/NEWS +++ b/NEWS @@ -4,14 +4,17 @@ New features - [core] now possible to define default Sieve filters (#2949) - [core] now possible to set vacation message start date (#3679) + - [web] add a header and/or footer to the vacation message (#1961) Enhancements + - [core] when restoring data using sogo-tool, regenerate Sieve script (#3029) - [web] always display name of month in week view (#3724) - [web] use a speed dial (instead of a dialog) for card/list creation - [web] use a speed dial for event/task creation - - [core] when restoring data using sogo-tool, regenerate Sieve script (#3029) Bug fixes + - [core] properly handle sorted/deleted calendars (#3723) + - [core] properly handle flattened timezone definitions (#2690) - [web] fixed generic avatar in lists (#3719) - [web] fixed validation in Sieve filter editor - [web] properly encode rawsource of events and tasks to avoid XSS issues (#3718) @@ -21,8 +24,6 @@ Bug fixes - [web] fixed time format when user chooses the default one - [web] added missing delegators identities in mail editor (#3720) - [web] honor the domain default SOGoAppointmentSendEMailNotifications (#3729) - - [core] properly handle sorted/deleted calendars (#3723) - - [core] properly handle flattened timezone definitions (#2690) 3.1.2 (2016-06-06) ------------------ diff --git a/SoObjects/SOGo/GNUmakefile b/SoObjects/SOGo/GNUmakefile index 783c00d3e..7148c0ac6 100644 --- a/SoObjects/SOGo/GNUmakefile +++ b/SoObjects/SOGo/GNUmakefile @@ -86,7 +86,8 @@ SOGo_HEADER_FILES = \ WOResponse+SOGo.h \ WOContext+SOGo.h \ \ - SOGoCredentialsFile.h + SOGoCredentialsFile.h \ + SOGoTextTemplateFile.h all:: @touch SOGoBuild.m @@ -165,7 +166,8 @@ SOGo_OBJC_FILES = \ WOResponse+SOGo.m \ WOContext+SOGo.m \ \ - SOGoCredentialsFile.m + SOGoCredentialsFile.m \ + SOGoTextTemplateFile.m SOGo_C_FILES += lmhash.c diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index d603d8eac..cfc704df8 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -52,6 +52,8 @@ - (BOOL) forwardEnabled; - (int) forwardConstraints; - (BOOL) vacationEnabled; +- (NSString *) vacationHeaderTemplateFile; +- (NSString *) vacationFooterTemplateFile; - (NSString *) mailingMechanism; - (NSString *) smtpServer; - (NSString *) smtpAuthenticationType; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 55fc9cd24..fbdf4fae4 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -220,6 +220,16 @@ return [self boolForKey: @"SOGoVacationEnabled"]; } +- (NSString *) vacationHeaderTemplateFile +{ + return [self stringForKey: @"SOGoVacationHeaderTemplateFile"]; +} + +- (NSString *) vacationFooterTemplateFile +{ + return [self stringForKey: @"SOGoVacationFooterTemplateFile"]; +} + - (NSString *) mailingMechanism { NSString *mailingMechanism; diff --git a/SoObjects/SOGo/SOGoSieveManager.m b/SoObjects/SOGo/SOGoSieveManager.m index 6e7f2f2bc..12c4efdb8 100644 --- a/SoObjects/SOGo/SOGoSieveManager.m +++ b/SoObjects/SOGo/SOGoSieveManager.m @@ -27,6 +27,7 @@ #import #import #import +#import #import #import @@ -833,7 +834,8 @@ static NSString *sieveScriptName = @"sogo"; { NSMutableString *vacation_script; NSArray *addresses; - NSString *text; + NSString *text, *templateFilePath; + SOGoTextTemplateFile *templateFile; BOOL ignore, alwaysSend; int days, i; @@ -845,6 +847,24 @@ static NSString *sieveScriptName = @"sogo"; text = [values objectForKey: @"autoReplyText"]; b = YES; + /* Add autoresponder header if configured */ + templateFilePath = [dd vacationHeaderTemplateFile]; + if (templateFilePath) + { + templateFile = [SOGoTextTemplateFile textTemplateFromFile: templateFilePath]; + if (templateFile) + text = [NSString stringWithFormat: @"%@%@", [templateFile textForUser: user], text]; + } + + /* Add autoresponder footer if configured */ + templateFilePath = [dd vacationFooterTemplateFile]; + if (templateFilePath) + { + templateFile = [SOGoTextTemplateFile textTemplateFromFile: templateFilePath]; + if (templateFile) + text = [NSString stringWithFormat: @"%@%@", text, [templateFile textForUser: user]]; + } + if (days == 0) days = 7; diff --git a/SoObjects/SOGo/SOGoTextTemplateFile.h b/SoObjects/SOGo/SOGoTextTemplateFile.h new file mode 100644 index 000000000..0f56764a3 --- /dev/null +++ b/SoObjects/SOGo/SOGoTextTemplateFile.h @@ -0,0 +1,40 @@ +/* SOGoTextTemplateFile.h - this file is part of SOGo + * + * Copyright (C) 2016 Inverse inc. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGOTEXTTEMPLATEFILE_H +#define SOGOTEXTTEMPLATEFILE_H + +@class SOGoUser; + +@interface SOGoTextTemplateFile : NSObject +{ + NSString *_textTemplate; +} + ++ (id) textTemplateFromFile: (NSString *) file; + +- (id) initFromFile: (NSString *) file + withEncoding: (NSStringEncoding) enc; + +- (NSString *) textForUser: (SOGoUser *) user; + +@end + +#endif /* SOGOTEXTTEMPLATEFILE_H */ diff --git a/SoObjects/SOGo/SOGoTextTemplateFile.m b/SoObjects/SOGo/SOGoTextTemplateFile.m new file mode 100644 index 000000000..3f0be7fc6 --- /dev/null +++ b/SoObjects/SOGo/SOGoTextTemplateFile.m @@ -0,0 +1,104 @@ +/* SOGoTextTemplateFile.m - this file is part of SOGo + * + * Copyright (C) 2016 Inverse inc. + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import + +#import "NSDictionary+Utilities.h" +#import "SOGoUser.h" +#import "SOGoUserDefaults.h" + +#import "SOGoTextTemplateFile.h" + +@implementation SOGoTextTemplateFile + ++ (id) textTemplateFromFile: (NSString *) file +{ + SOGoTextTemplateFile *newTemplate; + newTemplate = [[self alloc] initFromFile: file + withEncoding: NSUTF8StringEncoding]; + [newTemplate autorelease]; + return newTemplate; +} + + +- (id) init +{ + if ((self = [super init])) + { + _textTemplate = nil; + } + return self; +} + +- (void) dealloc +{ + [_textTemplate release]; + [super dealloc]; +} + +- (id) initFromFile: (NSString *) file + withEncoding: (NSStringEncoding) enc +{ + id ret; + NSData *textTemplateData; + + ret = nil; + if (file) + { + if ((self = [self init])) + { + textTemplateData = [NSData dataWithContentsOfFile: file]; + if (textTemplateData == nil) + NSLog(@"Failed to load text template file: %@", file); + else + { + _textTemplate = [[[NSString alloc] initWithData: textTemplateData + encoding: enc] retain]; + ret = self; + } + } + } + return ret; +} + +- (NSString *) textForUser: (SOGoUser *) user +{ + NSDictionary *values, *variables; + NSNumber *days; + SOGoUserDefaults* ud; + + // username + ud = [user userDefaults]; + + // daysBetweenResponse + values = [ud vacationOptions]; + days = [values objectForKey: @"daysBetweenResponse"]; + if ([days intValue] == 0) + days = [NSNumber numberWithInt: 7]; + + variables = [NSDictionary dictionaryWithObjectsAndKeys: + [user cn], @"username", + days, @"daysBetweenResponse", nil]; + + return [variables keysWithFormat: _textTemplate]; +} + +@end diff --git a/UI/PreferencesUI/UIxPreferences.h b/UI/PreferencesUI/UIxPreferences.h index dd3a00862..712f3962c 100644 --- a/UI/PreferencesUI/UIxPreferences.h +++ b/UI/PreferencesUI/UIxPreferences.h @@ -57,6 +57,7 @@ - (BOOL) _isSieveServerAvailable; - (id) _sieveClient; +- (NSString *) _vacationTextForTemplate: (NSString *) templateFilePath; @end diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 91d4a7b96..98808a6a9 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -41,6 +41,7 @@ #import #import #import +#import #import #import #import @@ -1103,6 +1104,40 @@ static NSArray *reminderValues = nil; return [[user domainDefaults] vacationEnabled]; } +- (NSString *) vacationHeader +{ + NSString *path; + + path = [[user domainDefaults] vacationHeaderTemplateFile]; + + return [self _vacationTextForTemplate: path]; +} + +- (NSString *) vacationFooter +{ + NSString *path; + + path = [[user domainDefaults] vacationFooterTemplateFile]; + + return [self _vacationTextForTemplate: path]; +} + +- (NSString *) _vacationTextForTemplate: (NSString *) templateFilePath +{ + NSString *text; + SOGoTextTemplateFile *templateFile; + + text = nil; + if (templateFilePath) + { + templateFile = [SOGoTextTemplateFile textTemplateFromFile: templateFilePath]; + if (templateFile) + text = [templateFile textForUser: user]; + } + + return text; +} + // - (void) setSieveFiltersValue: (NSString *) newValue // { // sieveFilters = [newValue objectFromJSONString]; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 06a27ff81..e1b13e571 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -820,9 +820,15 @@
+ +

+