feat(core): add SOGoDisableExport option to disable export for mail, calendar and contacts

This commit is contained in:
Hivert Quentin
2023-11-03 18:20:12 +01:00
parent e0ef59d5f2
commit d0b4b50456
12 changed files with 152 additions and 49 deletions
+20 -8
View File
@@ -34,6 +34,7 @@
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoSystemDefaults.h>
#import <Appointments/SOGoWebAppointmentFolder.h>
#import <Appointments/SOGoAppointmentFolderICS.h>
@@ -47,15 +48,26 @@
WOResponse *response;
SOGoAppointmentFolderICS *folderICS;
NSString *disposition;
SOGoSystemDefaults *sd;
folderICS = [self clientObject];
response = [self responseWithStatus: 200
andString: [folderICS contentAsString]];
[response setHeader: @"text/calendar; charset=utf-8"
forKey: @"content-type"];
disposition = [NSString stringWithFormat: @"attachment; filename=\"%@.ics\"",
[[folderICS displayName] asQPSubjectString: @"utf-8"]];
[response setHeader: disposition forKey: @"Content-Disposition"];
sd = [SOGoSystemDefaults sharedSystemDefaults];
if (nil != [sd disableExport] && NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingCalendar])
{
response = [self responseWithStatus: 401
andJSONRepresentation: [NSDictionary dictionaryWithObject: @"Exporting calendar folder is not authorized"
forKey: @"message"]];
}
else
{
folderICS = [self clientObject];
response = [self responseWithStatus: 200
andString: [folderICS contentAsString]];
[response setHeader: @"text/calendar; charset=utf-8"
forKey: @"content-type"];
disposition = [NSString stringWithFormat: @"attachment; filename=\"%@.ics\"",
[[folderICS displayName] asQPSubjectString: @"utf-8"]];
[response setHeader: disposition forKey: @"Content-Disposition"];
}
return response;
}