mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-21 06:33:18 +00:00
@@ -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
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
- (BOOL) forwardEnabled;
|
||||
- (int) forwardConstraints;
|
||||
- (BOOL) vacationEnabled;
|
||||
- (NSString *) vacationHeaderTemplateFile;
|
||||
- (NSString *) vacationFooterTemplateFile;
|
||||
- (NSString *) mailingMechanism;
|
||||
- (NSString *) smtpServer;
|
||||
- (NSString *) smtpAuthenticationType;
|
||||
|
||||
@@ -220,6 +220,16 @@
|
||||
return [self boolForKey: @"SOGoVacationEnabled"];
|
||||
}
|
||||
|
||||
- (NSString *) vacationHeaderTemplateFile
|
||||
{
|
||||
return [self stringForKey: @"SOGoVacationHeaderTemplateFile"];
|
||||
}
|
||||
|
||||
- (NSString *) vacationFooterTemplateFile
|
||||
{
|
||||
return [self stringForKey: @"SOGoVacationFooterTemplateFile"];
|
||||
}
|
||||
|
||||
- (NSString *) mailingMechanism
|
||||
{
|
||||
NSString *mailingMechanism;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user