Add a header and/or footer to the vacation message

Fixes #1961
pull/214/head
Francis Lachapelle 2016-06-14 14:10:17 -04:00
parent 7f4474f47c
commit 4744170628
13 changed files with 259 additions and 7 deletions

View File

@ -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";

7
NEWS
View File

@ -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)
------------------

View File

@ -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

View File

@ -52,6 +52,8 @@
- (BOOL) forwardEnabled;
- (int) forwardConstraints;
- (BOOL) vacationEnabled;
- (NSString *) vacationHeaderTemplateFile;
- (NSString *) vacationFooterTemplateFile;
- (NSString *) mailingMechanism;
- (NSString *) smtpServer;
- (NSString *) smtpAuthenticationType;

View File

@ -220,6 +220,16 @@
return [self boolForKey: @"SOGoVacationEnabled"];
}
- (NSString *) vacationHeaderTemplateFile
{
return [self stringForKey: @"SOGoVacationHeaderTemplateFile"];
}
- (NSString *) vacationFooterTemplateFile
{
return [self stringForKey: @"SOGoVacationFooterTemplateFile"];
}
- (NSString *) mailingMechanism
{
NSString *mailingMechanism;

View File

@ -27,6 +27,7 @@
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/SOGoDomainDefaults.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoTextTemplateFile.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGImap4/NGSieveClient.h>
@ -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;

View File

@ -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 */

View File

@ -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 <Foundation/NSData.h>
#import <Foundation/NSValue.h>
#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

View File

@ -57,6 +57,7 @@
- (BOOL) _isSieveServerAvailable;
- (id) _sieveClient;
- (NSString *) _vacationTextForTemplate: (NSString *) templateFilePath;
@end

View File

@ -41,6 +41,7 @@
#import <SOGo/SOGoSystemDefaults.h>
#import <SOGo/SOGoUserFolder.h>
#import <SOGo/SOGoParentFolder.h>
#import <SOGo/SOGoTextTemplateFile.h>
#import <SOGo/WOResourceManager+SOGo.h>
#import <SOGo/SOGoBuild.h>
#import <Mailer/SOGoMailAccount.h>
@ -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];

View File

@ -820,9 +820,15 @@
<div layout="column" flex-offset="5" ng-show="app.preferences.defaults.Vacation.enabled == 1">
<md-input-container class="md-block md-flex">
<label><var:string label:value="Auto reply message"/></label>
<var:if condition="vacationHeader.length">
<p class="text-preview" md-colors="::{color: 'default-background-600'}"><var:string value="vacationHeader"/></p>
</var:if>
<textarea const:name="autoReplyText"
const:id="autoReplyText"
ng-model="app.preferences.defaults.Vacation.autoReplyText"/>
<var:if condition="vacationFooter.length">
<p class="text-preview" md-colors="::{color: 'default-background-600'}"><var:string value="vacationFooter"/></p>
</var:if>
</md-input-container>
<div layout="row" layout-align="start center">

View File

@ -0,0 +1,6 @@
/// PreferencesUI.scss -*- Mode: scss; indent-tabs-mode: nil; basic-offset: 2 -*-
.text-preview {
white-space: pre-wrap;
word-wrap: break-word;
}

View File

@ -5,6 +5,7 @@
@import 'ContactsUI.scss';
@import 'MessageEditorUI';
@import 'SchedulerUI';
@import 'PreferencesUI';
@import 'AdministrationUI';
.view[layout=row],