mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-23 12:25:23 +00:00
feat(core): add SOGoDisableExport option to disable export for mail, calendar and contacts
This commit is contained in:
@@ -696,6 +696,10 @@ Defaults to `NO` when unset.
|
||||
|S |SOGoDisableSharingAnyAuthUser
|
||||
|List of modules where sharing with any authenticated user option should be disabled, for example `(Mail, Calendar)`. Modules can be `Mail`, `Contacts` and `Calendar`. Default value empty list (sharing enabled for everybody).
|
||||
|
||||
|S |SOGoDisableExport
|
||||
|List of modules where export should be disabled, for example `(Mail, Calendar)`. Modules can be `Mail`, `Contacts` and `Calendar`. Default value empty list (export enabled for everybody).
|
||||
|
||||
|
||||
|S |SOGoPasswordChangeEnabled
|
||||
|Parameter used to allow or not users to change their passwords from
|
||||
SOGo.
|
||||
|
||||
@@ -131,6 +131,7 @@ NSComparisonResult languageSort(id el1, id el2, void *context);
|
||||
|
||||
- (NSArray *) disableSharing;
|
||||
- (NSArray *) disableSharingAnyAuthUser;
|
||||
- (NSArray *) disableExport;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -832,5 +832,17 @@ NSComparisonResult languageSort(id el1, id el2, void *context)
|
||||
return disableSharingAnyAuthUser;
|
||||
}
|
||||
|
||||
- (NSArray *) disableExport
|
||||
{
|
||||
static NSArray *disableExport = nil;
|
||||
|
||||
if (!disableExport)
|
||||
{
|
||||
disableExport = [self stringArrayForKey: @"SOGoDisableExport"];
|
||||
[disableExport retain];
|
||||
}
|
||||
|
||||
return disableExport;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <SoObjects/SOGo/NSArray+Utilities.h>
|
||||
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
|
||||
@@ -78,35 +80,47 @@ static NSArray *photoTags = nil;
|
||||
id currentChild;
|
||||
SOGoContactGCSFolder *sourceFolder;
|
||||
NSMutableString *content;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
content = [NSMutableString string];
|
||||
sourceFolder = [self clientObject];
|
||||
contactsId = [[[[context request] contentAsString] objectFromJSONString] objectForKey: @"uids"];
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if (nil != [sd disableExport] && NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingContacts])
|
||||
{
|
||||
response = [self responseWithStatus: 401
|
||||
andJSONRepresentation: [NSDictionary dictionaryWithObject: @"Exporting contacts folder is not authorized"
|
||||
forKey: @"message"]];
|
||||
|
||||
if (!contactsId)
|
||||
contactsId = [sourceFolder toOneRelationshipKeys];
|
||||
}
|
||||
else
|
||||
{
|
||||
content = [NSMutableString string];
|
||||
sourceFolder = [self clientObject];
|
||||
contactsId = [[[[context request] contentAsString] objectFromJSONString] objectForKey: @"uids"];
|
||||
|
||||
uids = [contactsId objectEnumerator];
|
||||
while ((uid = [uids nextObject]))
|
||||
{
|
||||
currentChild = [sourceFolder lookupName: uid
|
||||
inContext: [self context]
|
||||
acquire: NO];
|
||||
if ([currentChild respondsToSelector: @selector (vCard)])
|
||||
[content appendFormat: @"%@", [[currentChild ldifRecord] ldifRecordAsString]];
|
||||
else if ([currentChild respondsToSelector: @selector (vList)])
|
||||
[content appendFormat: @"%@", [[currentChild vList] ldifString]];
|
||||
[content appendString: @"\n"];
|
||||
}
|
||||
if (!contactsId)
|
||||
contactsId = [sourceFolder toOneRelationshipKeys];
|
||||
|
||||
response = [context response];
|
||||
[response setHeader: @"application/directory; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
filename = [NSString stringWithFormat: @"%@.ldif",
|
||||
[[sourceFolder displayName] asQPSubjectString: @"utf-8"]];
|
||||
disposition = [NSString stringWithFormat: @"attachment; filename=\"%@\"", filename];
|
||||
[response setHeader: disposition forKey: @"Content-Disposition"];
|
||||
[response setContent: [content dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
uids = [contactsId objectEnumerator];
|
||||
while ((uid = [uids nextObject]))
|
||||
{
|
||||
currentChild = [sourceFolder lookupName: uid
|
||||
inContext: [self context]
|
||||
acquire: NO];
|
||||
if ([currentChild respondsToSelector: @selector (vCard)])
|
||||
[content appendFormat: @"%@", [[currentChild ldifRecord] ldifRecordAsString]];
|
||||
else if ([currentChild respondsToSelector: @selector (vList)])
|
||||
[content appendFormat: @"%@", [[currentChild vList] ldifString]];
|
||||
[content appendString: @"\n"];
|
||||
}
|
||||
|
||||
response = [context response];
|
||||
[response setHeader: @"application/directory; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
filename = [NSString stringWithFormat: @"%@.ldif",
|
||||
[[sourceFolder displayName] asQPSubjectString: @"utf-8"]];
|
||||
disposition = [NSString stringWithFormat: @"attachment; filename=\"%@\"", filename];
|
||||
[response setHeader: disposition forKey: @"Content-Disposition"];
|
||||
[response setContent: [content dataUsingEncoding: NSUTF8StringEncoding]];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -507,6 +507,20 @@ Class SOGoContactSourceFolderK, SOGoGCSFolderK;
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) isContactExportEnabled {
|
||||
BOOL result;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
result = YES;
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if (nil != [sd disableExport]
|
||||
&& NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingContacts]) {
|
||||
result = NO;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (id) defaultAction
|
||||
{
|
||||
// NSString *check;
|
||||
|
||||
@@ -590,8 +590,20 @@
|
||||
- (WOResponse *) exportFolderAction
|
||||
{
|
||||
WOResponse *response;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
response = [[self clientObject] archiveAllMessagesInContext: context];
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if (nil != [sd disableExport] && NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingMail])
|
||||
{
|
||||
response = [self responseWithStatus: 401
|
||||
andJSONRepresentation: [NSDictionary dictionaryWithObject: @"Exporting mail folder is not authorized"
|
||||
forKey: @"message"]];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
response = [[self clientObject] archiveAllMessagesInContext: context];
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -597,6 +597,20 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) isMailExportEnabled {
|
||||
BOOL result;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
result = YES;
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if (nil != [sd disableExport]
|
||||
&& NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingMail]) {
|
||||
result = NO;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end /* UIxMailMainFrame */
|
||||
|
||||
@interface UIxMailFolderTemplate : UIxComponent
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -376,6 +376,20 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
- (BOOL) isCalendarExportEnabled {
|
||||
BOOL result;
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
result = YES;
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if (nil != [sd disableExport]
|
||||
&& NSNotFound != [[sd disableExport] indexOfObject: kDisableSharingCalendar]) {
|
||||
result = NO;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/* Component Viewer, parent class of Appointment Viewer and Task Viewer */
|
||||
|
||||
@@ -104,11 +104,13 @@
|
||||
<var:string label:value="Import"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<md-menu-item>
|
||||
<md-button type="button" ng-click="folder.exportCards(false)">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<var:if condition="isContactExportEnabled">
|
||||
<md-menu-item>
|
||||
<md-button type="button" ng-click="folder.exportCards(false)">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
</var:if>
|
||||
<var:if condition="isContactSharingEnabled">
|
||||
<md-menu-divider><!-- divider --></md-menu-divider>
|
||||
<md-menu-item>
|
||||
|
||||
@@ -243,11 +243,13 @@
|
||||
<var:string label:value="Empty Junk Folder"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<md-menu-item>
|
||||
<md-button type="button" ng-click="$menuCtrl.folder.exportFolder()">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<var:if condition="isMailExportEnabled">
|
||||
<md-menu-item>
|
||||
<md-button type="button" ng-click="$menuCtrl.folder.exportFolder()">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
</var:if>
|
||||
<md-menu-item>
|
||||
<md-button type="button" ng-click="$menuCtrl.showAdvancedSearch()">
|
||||
<var:string label:value="Search"/>
|
||||
|
||||
@@ -579,11 +579,13 @@
|
||||
<var:string label:value="Import"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<md-menu-item ng-hide="::$menuCtrl.calendar.isWebCalendar">
|
||||
<md-button ng-click="$menuCtrl.calendar.export()">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<var:if condition="isCalendarExportEnabled">
|
||||
<md-menu-item ng-hide="::$menuCtrl.calendar.isWebCalendar">
|
||||
<md-button ng-click="$menuCtrl.calendar.export()">
|
||||
<var:string label:value="Export"/>
|
||||
</md-button>
|
||||
</md-menu-item>
|
||||
<var:if>
|
||||
<var:if condition="isCalendarSharingEnabled">
|
||||
<md-divider
|
||||
ng-hide="::($menuCtrl.calendar.isSubscription || $menuCtrl.calendar.isWebCalendar)">
|
||||
|
||||
Reference in New Issue
Block a user