diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index b03803523..f5661a8aa 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -1892,6 +1892,11 @@ host. Defaults to `NO` when unset. +|U |SOGoSieveFilters +|Parameter used to define initial Sieve scripts for users. The user +can still modify the scripts and the initial values will be written +to the Sieve server upon first login. + |D |SOGoMailPollingIntervals |Parameter used to define the mail polling intervals (in minutes) available to the user. The parameter is an array that can contain the diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 762de1f85..2fdc521fd 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -34,11 +34,15 @@ #import +#import +#import + #import #import #if defined(SAML2_CONFIG) #import #endif +#import #import #import #import @@ -66,10 +70,16 @@ { SOGoUserFolder *co; NSString *loginModule; + SOGoSystemDefaults *sd; + SOGoDomainDefaults *dd; SOGoUserDefaults *ud; + NSArray *filters; NSURL *moduleURL; + sd = [SOGoSystemDefaults sharedSystemDefaults]; + dd = [[context activeUser] domainDefaults]; ud = [[context activeUser] userDefaults]; + loginModule = [ud loginModule]; if (!([loginModule isEqualToString: @"Calendar"] || [loginModule isEqualToString: @"Contacts"] @@ -80,6 +90,24 @@ loginModule = @"Calendar"; } + // We check if we must write the Sieve scripts to the server + // upon first login if no user preferences are found, and the SOGo + // admin has defined SOGoSieveFilters in the domain or system settings + if ([dd sieveScriptsEnabled] && [[[ud source] values] count] == 0 && + ((filters = [[dd source] objectForKey: @"SOGoSieveFilters"]) || (filters = [[sd source] objectForKey: @"SOGoSieveFilters"]))) + { + SOGoMailAccount *account; + SOGoMailAccounts *folder; + + [ud setSieveFilters: filters]; + [ud synchronize]; + + folder = [[self clientObject] mailAccountsFolder: @"Mail" + inContext: context]; + account = [folder lookupName: @"0" inContext: context acquire: NO]; + [account updateFilters]; + } + co = [self clientObject]; moduleURL = [NSURL URLWithString: loginModule relativeToURL: [co soURL]];