feat(preferences): allow hiding of vacation the vacation period
This is controllable using the new SOGoVacationPeriodEnabled domain defaults variable.pull/281/head
parent
32968092e2
commit
c2e7f6a866
|
@ -2071,13 +2071,17 @@ Requires Sieve script support on the IMAP host.
|
|||
|
||||
Defaults to `NO` when unset.
|
||||
|
||||
When enabling this parameter, one may have to also enable the associated
|
||||
|D |SOGoVacationPeriodEnabled
|
||||
|When enabling this parameter, one may have to also enable the associated
|
||||
cronjob in `/etc/cron.d/sogo` in order to activate automatic vacation
|
||||
message activation and expiration.
|
||||
message activation and expiration if your Sieve server does not support
|
||||
the date extension.
|
||||
|
||||
See the _Cronjob — Vacation messages activation and expiration_ section
|
||||
below for details.
|
||||
|
||||
Defaults to `YES` when unset.
|
||||
|
||||
|D |SOGoVacationDefaultSubject
|
||||
|Parameter used to define a default vacation subject if user don't specify a
|
||||
custom subject.
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
- (int) forwardConstraints;
|
||||
- (NSArray *) forwardConstraintsDomains;
|
||||
- (BOOL) vacationEnabled;
|
||||
- (BOOL) vacationPeriodEnabled;
|
||||
- (NSString *) vacationDefaultSubject;
|
||||
- (NSString *) vacationHeaderTemplateFile;
|
||||
- (NSString *) vacationFooterTemplateFile;
|
||||
|
|
|
@ -220,6 +220,18 @@
|
|||
return [self boolForKey: @"SOGoVacationEnabled"];
|
||||
}
|
||||
|
||||
- (BOOL) vacationPeriodEnabled
|
||||
{
|
||||
id o;
|
||||
|
||||
o = [self stringForKey: @"SOGoVacationPeriodEnabled"];
|
||||
|
||||
if (o)
|
||||
return [o boolValue];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *) vacationDefaultSubject
|
||||
{
|
||||
return [self stringForKey: @"SOGoVacationDefaultSubject"];
|
||||
|
|
|
@ -927,7 +927,9 @@ static NSString *sieveScriptName = @"sogo";
|
|||
}
|
||||
|
||||
// Start date of auto-reply
|
||||
if ([[values objectForKey: @"startDateEnabled"] boolValue] && dateCapability)
|
||||
if ([dd vacationPeriodEnabled] &&
|
||||
[[values objectForKey: @"startDateEnabled"] boolValue] &&
|
||||
dateCapability)
|
||||
{
|
||||
[req addObjectUniquely: @"date"];
|
||||
[req addObjectUniquely: @"relational"];
|
||||
|
@ -938,7 +940,9 @@ static NSString *sieveScriptName = @"sogo";
|
|||
}
|
||||
|
||||
// End date of auto-reply
|
||||
if ([[values objectForKey: @"endDateEnabled"] boolValue] && dateCapability)
|
||||
if ([dd vacationPeriodEnabled] &&
|
||||
[[values objectForKey: @"endDateEnabled"] boolValue] &&
|
||||
dateCapability)
|
||||
{
|
||||
[req addObjectUniquely: @"date"];
|
||||
[req addObjectUniquely: @"relational"];
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
BOOL result;
|
||||
|
||||
user = [SOGoUser userWithLogin: theLogin];
|
||||
|
||||
userDefaults = [user userDefaults];
|
||||
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
|
||||
[vacationOptions autorelease];
|
||||
|
@ -93,6 +94,14 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
// We do NOT enable the vacation message automatically if the domain
|
||||
// preference is disabled by default.
|
||||
if (![[user domainDefaults] vacationPeriodEnabled])
|
||||
{
|
||||
NSLog(@"SOGoVacationPeriodEnabled set to NO for the domain - ignoring.");
|
||||
return NO;
|
||||
}
|
||||
|
||||
[vacationOptions setObject: [NSNumber numberWithBool: NO] forKey: @"startDateEnabled"];
|
||||
}
|
||||
|
||||
|
|
|
@ -1108,6 +1108,11 @@ static NSArray *reminderValues = nil;
|
|||
return [[user domainDefaults] vacationEnabled];
|
||||
}
|
||||
|
||||
- (BOOL) isVacationPeriodEnabled
|
||||
{
|
||||
return [[user domainDefaults] vacationPeriodEnabled];
|
||||
}
|
||||
|
||||
- (NSString *) vacationHeader
|
||||
{
|
||||
NSString *path;
|
||||
|
@ -1142,54 +1147,6 @@ static NSArray *reminderValues = nil;
|
|||
return text;
|
||||
}
|
||||
|
||||
// - (void) setSieveFiltersValue: (NSString *) newValue
|
||||
// {
|
||||
// sieveFilters = [newValue objectFromJSONString];
|
||||
// if (sieveFilters)
|
||||
// {
|
||||
// if ([sieveFilters isKindOfClass: [NSArray class]])
|
||||
// [sieveFilters retain];
|
||||
// else
|
||||
// sieveFilters = nil;
|
||||
// }
|
||||
// }
|
||||
|
||||
// - (NSString *) sieveFiltersValue
|
||||
// {
|
||||
// return [sieveFilters jsonRepresentation];
|
||||
// }
|
||||
|
||||
// - (void) setEnableVacation: (BOOL) enableVacation
|
||||
// {
|
||||
// [vacationOptions setObject: [NSNumber numberWithBool: enableVacation]
|
||||
// forKey: @"enabled"];
|
||||
// }
|
||||
|
||||
// - (BOOL) enableVacation
|
||||
// {
|
||||
// return [[vacationOptions objectForKey: @"enabled"] boolValue];
|
||||
// }
|
||||
|
||||
// - (void) setAutoReplyText: (NSString *) theText
|
||||
// {
|
||||
// [vacationOptions setObject: theText forKey: @"autoReplyText"];
|
||||
// }
|
||||
|
||||
// - (NSString *) autoReplyText
|
||||
// {
|
||||
// return [vacationOptions objectForKey: @"autoReplyText"];
|
||||
// }
|
||||
|
||||
// - (void) setAutoReplyEmailAddresses: (NSString *) theAddresses
|
||||
// {
|
||||
// NSArray *addresses;
|
||||
|
||||
// addresses = [[theAddresses componentsSeparatedByString: @","]
|
||||
// trimmedComponents];
|
||||
// [vacationOptions setObject: addresses
|
||||
// forKey: @"autoReplyEmailAddresses"];
|
||||
// }
|
||||
|
||||
//
|
||||
// Used internally
|
||||
//
|
||||
|
@ -1334,105 +1291,6 @@ static NSArray *reminderValues = nil;
|
|||
return daysBetweenResponses;
|
||||
}
|
||||
|
||||
// - (void) setDaysBetweenResponses: (NSNumber *) theDays
|
||||
// {
|
||||
// [vacationOptions setObject: theDays
|
||||
// forKey: @"daysBetweenResponse"];
|
||||
// }
|
||||
|
||||
// - (NSString *) daysBetweenResponses
|
||||
// {
|
||||
// NSString *days;
|
||||
|
||||
// days = [vacationOptions objectForKey: @"daysBetweenResponse"];
|
||||
// if (!days)
|
||||
// days = @"7"; // defaults to 7 days
|
||||
|
||||
// return days;
|
||||
// }
|
||||
|
||||
// - (void) setIgnoreLists: (BOOL) ignoreLists
|
||||
// {
|
||||
// [vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
||||
// forKey: @"ignoreLists"];
|
||||
// }
|
||||
|
||||
// - (BOOL) ignoreLists
|
||||
// {
|
||||
// NSNumber *obj;
|
||||
// BOOL ignore;
|
||||
|
||||
// obj = [vacationOptions objectForKey: @"ignoreLists"];
|
||||
|
||||
// if (obj == nil)
|
||||
// ignore = YES; // defaults to YES
|
||||
// else
|
||||
// ignore = [obj boolValue];
|
||||
|
||||
// return ignore;
|
||||
// }
|
||||
|
||||
//
|
||||
// See http://sogo.nu/bugs/view.php?id=2332 for details
|
||||
//
|
||||
// - (void) setAlwaysSend: (BOOL) ignoreLists
|
||||
// {
|
||||
// [vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
||||
// forKey: @"alwaysSend"];
|
||||
// }
|
||||
|
||||
// - (BOOL) alwaysSend
|
||||
// {
|
||||
// NSNumber *obj;
|
||||
// BOOL ignore;
|
||||
|
||||
// obj = [vacationOptions objectForKey: @"alwaysSend"];
|
||||
|
||||
// if (obj == nil)
|
||||
// ignore = NO; // defaults to NO
|
||||
// else
|
||||
// ignore = [obj boolValue];
|
||||
|
||||
// return ignore;
|
||||
// }
|
||||
|
||||
// - (BOOL) enableVacationEndDate
|
||||
// {
|
||||
// return [[vacationOptions objectForKey: @"endDateEnabled"] boolValue];
|
||||
// }
|
||||
|
||||
// - (BOOL) disableVacationEndDate
|
||||
// {
|
||||
// return ![self enableVacationEndDate];
|
||||
// }
|
||||
|
||||
// - (void) setEnableVacationEndDate: (BOOL) enableVacationEndDate
|
||||
// {
|
||||
// [vacationOptions setObject: [NSNumber numberWithBool: enableVacationEndDate]
|
||||
// forKey: @"endDateEnabled"];
|
||||
// }
|
||||
|
||||
// - (void) setVacationEndDate: (NSCalendarDate *) endDate
|
||||
// {
|
||||
// NSNumber *time;
|
||||
|
||||
// time = [NSNumber numberWithInt: [endDate timeIntervalSince1970]];
|
||||
|
||||
// [vacationOptions setObject: time forKey: @"endDate"];
|
||||
// }
|
||||
|
||||
// - (NSCalendarDate *) vacationEndDate
|
||||
// {
|
||||
// int time;
|
||||
|
||||
// time = [[vacationOptions objectForKey: @"endDate"] intValue];
|
||||
|
||||
// if (time > 0)
|
||||
// return [NSCalendarDate dateWithTimeIntervalSince1970: time];
|
||||
// else
|
||||
// return [NSCalendarDate calendarDate];
|
||||
// }
|
||||
|
||||
/* mail forward */
|
||||
|
||||
//
|
||||
|
@ -1443,49 +1301,6 @@ static NSArray *reminderValues = nil;
|
|||
return [[user domainDefaults] forwardEnabled];
|
||||
}
|
||||
|
||||
// - (void) setEnableForward: (BOOL) enableForward
|
||||
// {
|
||||
// [forwardOptions setObject: [NSNumber numberWithBool: enableForward]
|
||||
// forKey: @"enabled"];
|
||||
// }
|
||||
|
||||
// - (BOOL) enableForward
|
||||
// {
|
||||
// return [[forwardOptions objectForKey: @"enabled"] boolValue];
|
||||
// }
|
||||
|
||||
// - (void) setForwardAddress: (NSString *) forwardAddress
|
||||
// {
|
||||
// NSArray *addresses;
|
||||
|
||||
// addresses = [[forwardAddress componentsSeparatedByString: @","]
|
||||
// trimmedComponents];
|
||||
// [forwardOptions setObject: addresses
|
||||
// forKey: @"forwardAddress"];
|
||||
// }
|
||||
|
||||
// - (NSString *) forwardAddress
|
||||
// {
|
||||
// id addresses;
|
||||
|
||||
// addresses = [forwardOptions objectForKey: @"forwardAddress"];
|
||||
|
||||
// return ([addresses respondsToSelector: @selector(componentsJoinedByString:)]
|
||||
// ? [(NSArray *)addresses componentsJoinedByString: @", "]
|
||||
// : (NSString *)addresses);
|
||||
// }
|
||||
|
||||
// - (void) setForwardKeepCopy: (BOOL) keepCopy
|
||||
// {
|
||||
// [forwardOptions setObject: [NSNumber numberWithBool: keepCopy]
|
||||
// forKey: @"keepCopy"];
|
||||
// }
|
||||
|
||||
// - (BOOL) forwardKeepCopy
|
||||
// {
|
||||
// return [[forwardOptions objectForKey: @"keepCopy"] boolValue];
|
||||
// }
|
||||
|
||||
- (NSString *) forwardConstraints
|
||||
{
|
||||
SOGoDomainDefaults *dd;
|
||||
|
@ -1617,52 +1432,6 @@ static NSArray *reminderValues = nil;
|
|||
: NO);
|
||||
}
|
||||
|
||||
// - (id <WOActionResults>) defaultAction
|
||||
// {
|
||||
// id <WOActionResults> results;
|
||||
// SOGoDomainDefaults *dd;
|
||||
// SOGoMailAccount *account;
|
||||
// SOGoMailAccounts *folder;
|
||||
// WORequest *request;
|
||||
|
||||
// request = [context request];
|
||||
// if ([[request method] isEqualToString: @"POST"])
|
||||
// {
|
||||
// dd = [[context activeUser] domainDefaults];
|
||||
// if ([dd sieveScriptsEnabled])
|
||||
// [userDefaults setSieveFilters: sieveFilters];
|
||||
// if ([dd vacationEnabled])
|
||||
// [userDefaults setVacationOptions: vacationOptions];
|
||||
// if ([dd forwardEnabled])
|
||||
// [userDefaults setForwardOptions: forwardOptions];
|
||||
|
||||
// if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]) || [self _isSieveServerAvailable])
|
||||
// {
|
||||
// [userDefaults synchronize];
|
||||
// folder = [[self clientObject] mailAccountsFolder: @"Mail"
|
||||
// inContext: context];
|
||||
// account = [folder lookupName: @"0" inContext: context acquire: NO];
|
||||
|
||||
// if ([account updateFilters])
|
||||
// // If Sieve is not enabled, the SOGoSieveManager will immediatly return a positive answer
|
||||
// // See [SOGoSieveManager updateFiltersForAccount:withUsername:andPassword:]
|
||||
// results = (id <WOActionResults>)[self responseWithStatus: 200
|
||||
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:hasChanged], @"hasChanged", nil]];
|
||||
|
||||
// else
|
||||
// results = (id <WOActionResults>)[self responseWithStatus: 502
|
||||
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Connection error", @"textStatus", nil]];
|
||||
// }
|
||||
// else
|
||||
// results = (id <WOActionResults>)[self responseWithStatus: 503
|
||||
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"textStatus", nil]];
|
||||
// }
|
||||
// else
|
||||
// results = self;
|
||||
|
||||
// return results;
|
||||
// }
|
||||
|
||||
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
||||
inContext: (WOContext*) context
|
||||
{
|
||||
|
|
|
@ -974,47 +974,49 @@
|
|||
</md-checkbox>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<md-checkbox
|
||||
ng-model="app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0"
|
||||
ng-change="app.toggleVacationStartDate()">
|
||||
<var:string label:value="Enable auto reply on" />
|
||||
</md-checkbox>
|
||||
<md-input-container>
|
||||
<label class="md-no-truncate"><var:string label:value="First day of vacation"/></label>
|
||||
<md-datepicker
|
||||
name="vacationStartDate"
|
||||
label:md-placeholder="Enter date"
|
||||
ng-disabled="!app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-required="app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-model="app.preferences.defaults.Vacation.startDate"
|
||||
md-date-filter="app.validateVacationStartDate"
|
||||
sg-reset-on-disabled="sg-reset-on-disabled"><!-- datepicker --></md-datepicker>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<var:if condition="isVacationPeriodEnabled">
|
||||
<div>
|
||||
<md-checkbox
|
||||
ng-model="app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0"
|
||||
ng-change="app.toggleVacationStartDate()">
|
||||
<var:string label:value="Enable auto reply on" />
|
||||
</md-checkbox>
|
||||
<md-input-container>
|
||||
<label class="md-no-truncate"><var:string label:value="First day of vacation"/></label>
|
||||
<md-datepicker
|
||||
name="vacationStartDate"
|
||||
label:md-placeholder="Enter date"
|
||||
ng-disabled="!app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-required="app.preferences.defaults.Vacation.startDateEnabled"
|
||||
ng-model="app.preferences.defaults.Vacation.startDate"
|
||||
md-date-filter="app.validateVacationStartDate"
|
||||
sg-reset-on-disabled="sg-reset-on-disabled"><!-- datepicker --></md-datepicker>
|
||||
</md-input-container>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<md-checkbox
|
||||
ng-model="app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0"
|
||||
ng-change="app.toggleVacationEndDate()">
|
||||
<var:string label:value="Disable auto reply on" />
|
||||
</md-checkbox>
|
||||
<md-input-container>
|
||||
<label class="md-no-truncate"><var:string label:value="Last day of vacation"/></label>
|
||||
<md-datepicker
|
||||
name="vacationEndDate"
|
||||
label:md-placeholder="Enter date"
|
||||
ng-disabled="!app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-required="app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-model="app.preferences.defaults.Vacation.endDate"
|
||||
md-date-filter="app.validateVacationEndDate"
|
||||
sg-reset-on-disabled="sg-reset-on-disabled"><!-- datepicker --></md-datepicker>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div>
|
||||
<md-checkbox
|
||||
ng-model="app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-true-value="1"
|
||||
ng-false-value="0"
|
||||
ng-change="app.toggleVacationEndDate()">
|
||||
<var:string label:value="Disable auto reply on" />
|
||||
</md-checkbox>
|
||||
<md-input-container>
|
||||
<label class="md-no-truncate"><var:string label:value="Last day of vacation"/></label>
|
||||
<md-datepicker
|
||||
name="vacationEndDate"
|
||||
label:md-placeholder="Enter date"
|
||||
ng-disabled="!app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-required="app.preferences.defaults.Vacation.endDateEnabled"
|
||||
ng-model="app.preferences.defaults.Vacation.endDate"
|
||||
md-date-filter="app.validateVacationEndDate"
|
||||
sg-reset-on-disabled="sg-reset-on-disabled"><!-- datepicker --></md-datepicker>
|
||||
</md-input-container>
|
||||
</div>
|
||||
</var:if>
|
||||
|
||||
<div>
|
||||
<md-checkbox
|
||||
|
|
Loading…
Reference in New Issue