mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-29 09:00:31 +00:00
(feat) now possible to set vacation message start date (fixes #3679)
This commit is contained in:
@@ -2509,11 +2509,11 @@ If your mail server requires use of SMTP AUTH, specify a credential file
|
|||||||
using `-p /path/to/credFile`. This file should contain the username and
|
using `-p /path/to/credFile`. This file should contain the username and
|
||||||
password, separated by a colon (`username:password`)
|
password, separated by a colon (`username:password`)
|
||||||
|
|
||||||
_Cronjob_ — Vacation messages expiration
|
_Cronjob_ — Vacation messages activation and expiration
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
When vacation messages are enabled (see the parameter
|
When vacation messages are enabled (see the parameter
|
||||||
_SOGoVacationEnabled_), users can set an expiration date to messages
|
_SOGoVacationEnabled_), users can set an activation or expiration date to messages
|
||||||
auto-reply. For this feature to work, you must run a _cronjob_ under the
|
auto-reply. For this feature to work, you must run a _cronjob_ under the
|
||||||
"sogo" user.
|
"sogo" user.
|
||||||
|
|
||||||
@@ -2527,7 +2527,7 @@ contain the username and password, separated by a colon
|
|||||||
The _cronjob_ should look like this:
|
The _cronjob_ should look like this:
|
||||||
|
|
||||||
----
|
----
|
||||||
0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply -p /etc/sogo/sieve.creds
|
0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds
|
||||||
----
|
----
|
||||||
|
|
||||||
Managing User Accounts
|
Managing User Accounts
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
New features
|
New features
|
||||||
- [core] now possible to define default Sieve filters (#2949)
|
- [core] now possible to define default Sieve filters (#2949)
|
||||||
|
- [core] now possible to set vacation message start date (#3679)
|
||||||
|
|
||||||
Enhancements
|
Enhancements
|
||||||
- [web] always display name of month in week view (#3724)
|
- [web] always display name of month in week view (#3724)
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Vacation messages expiration
|
# Vacation messages expiration
|
||||||
# The credentials file should contain the sieve admin credentials (username:passwd)
|
# The credentials file should contain the sieve admin credentials (username:passwd)
|
||||||
#0 0 * * * sogo /usr/sbin/sogo-tool expire-autoreply -p /etc/sogo/sieve.creds
|
#0 0 * * * sogo /usr/sbin/sogo-tool update-autoreply -p /etc/sogo/sieve.creds
|
||||||
|
|
||||||
# Session cleanup - runs every minute
|
# Session cleanup - runs every minute
|
||||||
# - Ajust the nbMinutes parameter to suit your needs
|
# - Ajust the nbMinutes parameter to suit your needs
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ $(SOGO_TOOL)_OBJC_FILES += \
|
|||||||
SOGoToolBackup.m \
|
SOGoToolBackup.m \
|
||||||
SOGoToolCheckDoubles.m \
|
SOGoToolCheckDoubles.m \
|
||||||
SOGoToolDumpDefaults.m \
|
SOGoToolDumpDefaults.m \
|
||||||
SOGoToolExpireAutoReply.m \
|
SOGoToolUpdateAutoReply.m \
|
||||||
SOGoToolExpireUserSessions.m \
|
SOGoToolExpireUserSessions.m \
|
||||||
SOGoToolRemove.m \
|
SOGoToolRemove.m \
|
||||||
SOGoToolRemoveDoubles.m \
|
SOGoToolRemoveDoubles.m \
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
/* SOGoToolUserPreferences.m - this file is part of SOGo
|
/* SOGoToolUpdateAutoReply.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2013 Inverse inc.
|
* Copyright (C) 2011-2016 Inverse inc.
|
||||||
*
|
|
||||||
* Author: Francis Lachapelle <flachapelle@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -45,10 +43,10 @@
|
|||||||
|
|
||||||
#import "SOGoTool.h"
|
#import "SOGoTool.h"
|
||||||
|
|
||||||
@interface SOGoToolExpireAutoReply : SOGoTool
|
@interface SOGoToolUpdateAutoReply : SOGoTool
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SOGoToolExpireAutoReply
|
@implementation SOGoToolUpdateAutoReply
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
@@ -56,27 +54,28 @@
|
|||||||
|
|
||||||
+ (NSString *) command
|
+ (NSString *) command
|
||||||
{
|
{
|
||||||
return @"expire-autoreply";
|
return @"update-autoreply";
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *) description
|
+ (NSString *) description
|
||||||
{
|
{
|
||||||
return @"disable auto reply for reached end dates";
|
return @"enable or disable auto reply for reached start/end dates";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) usage
|
- (void) usage
|
||||||
{
|
{
|
||||||
fprintf (stderr, "expire-autoreply -p credentialFile\n\n"
|
fprintf (stderr, "update-autoreply -p credentialFile\n\n"
|
||||||
" -p credentialFile Specify the file containing the sieve admin credentials\n"
|
" -p credentialFile Specify the file containing the sieve admin credentials\n"
|
||||||
" The file should contain a single line:\n"
|
" The file should contain a single line:\n"
|
||||||
" username:password\n"
|
" username:password\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The expire-autoreply action should be configured as a daily cronjob.\n");
|
"The update-autoreply action should be configured as a daily cronjob.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) removeAutoReplyForLogin: (NSString *) theLogin
|
- (BOOL) updateAutoReplyForLogin: (NSString *) theLogin
|
||||||
withSieveUsername: (NSString *) theUsername
|
withSieveUsername: (NSString *) theUsername
|
||||||
andPassword: (NSString *) thePassword
|
andPassword: (NSString *) thePassword
|
||||||
|
disabling: (BOOL) disabling
|
||||||
{
|
{
|
||||||
NSMutableDictionary *vacationOptions;
|
NSMutableDictionary *vacationOptions;
|
||||||
SOGoUserDefaults *userDefaults;
|
SOGoUserDefaults *userDefaults;
|
||||||
@@ -88,7 +87,15 @@
|
|||||||
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
|
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
|
||||||
[vacationOptions autorelease];
|
[vacationOptions autorelease];
|
||||||
|
|
||||||
[vacationOptions setObject: [NSNumber numberWithBool: NO] forKey: @"enabled"];
|
if (disabling)
|
||||||
|
{
|
||||||
|
[vacationOptions setObject: [NSNumber numberWithBool: NO] forKey: @"enabled"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[vacationOptions setObject: [NSNumber numberWithBool: NO] forKey: @"startDateEnabled"];
|
||||||
|
}
|
||||||
|
|
||||||
[userDefaults setVacationOptions: vacationOptions];
|
[userDefaults setVacationOptions: vacationOptions];
|
||||||
result = [userDefaults synchronize];
|
result = [userDefaults synchronize];
|
||||||
|
|
||||||
@@ -115,7 +122,10 @@
|
|||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
// Can't update Sieve script -- Reactivate auto-reply
|
// Can't update Sieve script -- Reactivate auto-reply
|
||||||
[vacationOptions setObject: [NSNumber numberWithBool: YES] forKey: @"enabled"];
|
if (disabling)
|
||||||
|
[vacationOptions setObject: [NSNumber numberWithBool: YES] forKey: @"enabled"];
|
||||||
|
else
|
||||||
|
[vacationOptions setObject: [NSNumber numberWithBool: YES] forKey: @"startDateEnabled"];
|
||||||
[userDefaults setVacationOptions: vacationOptions];
|
[userDefaults setVacationOptions: vacationOptions];
|
||||||
[userDefaults synchronize];
|
[userDefaults synchronize];
|
||||||
}
|
}
|
||||||
@@ -124,7 +134,7 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) expireAutoReplyWithUsername: (NSString *) theUsername
|
- (void) updateAutoReplyWithUsername: (NSString *) theUsername
|
||||||
andPassword: (NSString *) thePassword
|
andPassword: (NSString *) thePassword
|
||||||
{
|
{
|
||||||
GCSChannelManager *cm;
|
GCSChannelManager *cm;
|
||||||
@@ -134,8 +144,7 @@
|
|||||||
NSString *sql, *profileURL, *user, *c_defaults;
|
NSString *sql, *profileURL, *user, *c_defaults;
|
||||||
NSURL *tableURL;
|
NSURL *tableURL;
|
||||||
SOGoSystemDefaults *sd;
|
SOGoSystemDefaults *sd;
|
||||||
BOOL enabled;
|
unsigned int endTime, startTime, now;
|
||||||
unsigned int endTime, now;
|
|
||||||
|
|
||||||
now = [[NSCalendarDate calendarDate] timeIntervalSince1970];
|
now = [[NSCalendarDate calendarDate] timeIntervalSince1970];
|
||||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||||
@@ -169,18 +178,33 @@
|
|||||||
{
|
{
|
||||||
defaults = [c_defaults objectFromJSONString];
|
defaults = [c_defaults objectFromJSONString];
|
||||||
vacationOptions = (NSDictionary *) [defaults objectForKey: @"Vacation"];
|
vacationOptions = (NSDictionary *) [defaults objectForKey: @"Vacation"];
|
||||||
enabled = [[vacationOptions objectForKey: @"enabled"] boolValue];
|
if ([[vacationOptions objectForKey: @"enabled"] boolValue])
|
||||||
if (enabled)
|
|
||||||
{
|
{
|
||||||
enabled = [[vacationOptions objectForKey: @"endDateEnabled"] boolValue];
|
// We handle the start date
|
||||||
if (enabled)
|
if ([[vacationOptions objectForKey: @"startDateEnabled"] boolValue])
|
||||||
|
{
|
||||||
|
startTime = [[vacationOptions objectForKey: @"startDate"] intValue];
|
||||||
|
if (now >= startTime)
|
||||||
|
{
|
||||||
|
if ([self updateAutoReplyForLogin: user
|
||||||
|
withSieveUsername: theUsername
|
||||||
|
andPassword: thePassword
|
||||||
|
disabling: NO])
|
||||||
|
NSLog(@"Enabled auto-reply of user %@", user);
|
||||||
|
else
|
||||||
|
NSLog(@"An error occured while enabling auto-reply of user %@", user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// We handle the end date
|
||||||
|
if ([[vacationOptions objectForKey: @"endDateEnabled"] boolValue])
|
||||||
{
|
{
|
||||||
endTime = [[vacationOptions objectForKey: @"endDate"] intValue];
|
endTime = [[vacationOptions objectForKey: @"endDate"] intValue];
|
||||||
if (endTime <= now)
|
if (endTime <= now)
|
||||||
{
|
{
|
||||||
if ([self removeAutoReplyForLogin: user
|
if ([self updateAutoReplyForLogin: user
|
||||||
withSieveUsername: theUsername
|
withSieveUsername: theUsername
|
||||||
andPassword: thePassword])
|
andPassword: thePassword
|
||||||
|
disabling: YES])
|
||||||
NSLog(@"Removed auto-reply of user %@", user);
|
NSLog(@"Removed auto-reply of user %@", user);
|
||||||
else
|
else
|
||||||
NSLog(@"An error occured while removing auto-reply of user %@", user);
|
NSLog(@"An error occured while removing auto-reply of user %@", user);
|
||||||
@@ -238,7 +262,7 @@
|
|||||||
|
|
||||||
if (authname && authpwd)
|
if (authname && authpwd)
|
||||||
{
|
{
|
||||||
[self expireAutoReplyWithUsername: authname andPassword: authpwd];
|
[self updateAutoReplyWithUsername: authname andPassword: authpwd];
|
||||||
rc = YES;
|
rc = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,6 +858,18 @@
|
|||||||
</md-checkbox>
|
</md-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div layout="row">
|
||||||
|
<md-checkbox
|
||||||
|
ng-model="app.preferences.defaults.Vacation.startDateEnabled"
|
||||||
|
ng-true-value="1"
|
||||||
|
ng-false-value="0">
|
||||||
|
<var:string label:value="Enable auto reply on" />
|
||||||
|
</md-checkbox>
|
||||||
|
<md-datepicker
|
||||||
|
ng-disabled="app.preferences.defaults.Vacation.startDateEnabled == 0"
|
||||||
|
ng-model="app.preferences.defaults.Vacation.startDate"><!-- datepicker --></md-datepicker>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div layout="row">
|
<div layout="row">
|
||||||
<md-checkbox
|
<md-checkbox
|
||||||
ng-model="app.preferences.defaults.Vacation.endDateEnabled"
|
ng-model="app.preferences.defaults.Vacation.endDateEnabled"
|
||||||
|
|||||||
@@ -39,6 +39,12 @@
|
|||||||
// We also convert our date objects into real date, otherwise we'll have strings
|
// We also convert our date objects into real date, otherwise we'll have strings
|
||||||
// or undefined values and the md-datepicker does NOT like this.
|
// or undefined values and the md-datepicker does NOT like this.
|
||||||
if (data.Vacation) {
|
if (data.Vacation) {
|
||||||
|
if (data.Vacation.startDate)
|
||||||
|
data.Vacation.startDate = new Date(parseInt(data.Vacation.startDate) * 1000);
|
||||||
|
else {
|
||||||
|
data.Vacation.startDateEnabled = 0;
|
||||||
|
data.Vacation.startDate = new Date();
|
||||||
|
}
|
||||||
if (data.Vacation.endDate)
|
if (data.Vacation.endDate)
|
||||||
data.Vacation.endDate = new Date(parseInt(data.Vacation.endDate) * 1000);
|
data.Vacation.endDate = new Date(parseInt(data.Vacation.endDate) * 1000);
|
||||||
else {
|
else {
|
||||||
@@ -59,6 +65,11 @@
|
|||||||
if (angular.isUndefined(data.Vacation.daysBetweenResponse))
|
if (angular.isUndefined(data.Vacation.daysBetweenResponse))
|
||||||
data.Vacation.daysBetweenResponse = 7;
|
data.Vacation.daysBetweenResponse = 7;
|
||||||
|
|
||||||
|
if (angular.isUndefined(data.Vacation.startDate)) {
|
||||||
|
data.Vacation.startDateEnabled = 0;
|
||||||
|
data.Vacation.startDate = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
if (angular.isUndefined(data.Vacation.endDate)) {
|
if (angular.isUndefined(data.Vacation.endDate)) {
|
||||||
data.Vacation.endDateEnabled = 0;
|
data.Vacation.endDateEnabled = 0;
|
||||||
data.Vacation.endDate = new Date();
|
data.Vacation.endDate = new Date();
|
||||||
@@ -218,6 +229,10 @@
|
|||||||
delete preferences.defaults.SOGoMailComposeFontSizeEnabled;
|
delete preferences.defaults.SOGoMailComposeFontSizeEnabled;
|
||||||
|
|
||||||
if (preferences.defaults.Vacation) {
|
if (preferences.defaults.Vacation) {
|
||||||
|
if (preferences.defaults.Vacation.startDateEnabled)
|
||||||
|
preferences.defaults.Vacation.startDate = preferences.defaults.Vacation.startDate.getTime()/1000;
|
||||||
|
else
|
||||||
|
preferences.defaults.Vacation.startDate = 0;
|
||||||
if (preferences.defaults.Vacation.endDateEnabled)
|
if (preferences.defaults.Vacation.endDateEnabled)
|
||||||
preferences.defaults.Vacation.endDate = preferences.defaults.Vacation.endDate.getTime()/1000;
|
preferences.defaults.Vacation.endDate = preferences.defaults.Vacation.endDate.getTime()/1000;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user