mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-28 17:57:38 +00:00
Merge remote-tracking branch 'upstream/master' into merge-upstream
Conflicts: SoObjects/SOGo/SOGoUserManager.m Tools/SOGoToolRestore.m
This commit is contained in:
+28
-19
@@ -1,9 +1,6 @@
|
||||
/* SOGoToolBackup.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2011 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Francis Lachapelle <flachapelle@inverse.ca>
|
||||
* Copyright (C) 2009-2015 Inverse inc.
|
||||
*
|
||||
* 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
|
||||
@@ -42,6 +39,7 @@
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/SOGoUserProfile.h>
|
||||
#import <SOGo/SOGoUserSettings.h>
|
||||
#import <SOGo/SOGoSystemDefaults.h>
|
||||
#import <Contacts/NSDictionary+LDIF.h>
|
||||
|
||||
#import "SOGoTool.h"
|
||||
@@ -55,7 +53,7 @@
|
||||
@interface SOGoToolBackup : SOGoTool
|
||||
{
|
||||
NSString *directory;
|
||||
NSArray *userIDs;
|
||||
NSArray *usersToBackup;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -83,7 +81,7 @@
|
||||
if ((self = [super init]))
|
||||
{
|
||||
directory = nil;
|
||||
userIDs = nil;
|
||||
usersToBackup = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -92,7 +90,7 @@
|
||||
- (void) dealloc
|
||||
{
|
||||
[directory release];
|
||||
[userIDs release];
|
||||
[usersToBackup release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -143,6 +141,7 @@
|
||||
|
||||
lm = [SOGoUserManager sharedUserManager];
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
max = [users count];
|
||||
user = [users objectAtIndex: 0];
|
||||
@@ -198,11 +197,11 @@
|
||||
NSLog (@"user '%@' unknown", user);
|
||||
}
|
||||
[allUsers autorelease];
|
||||
|
||||
ASSIGN (userIDs, [allUsers objectsForKey: @"c_uid" notFoundMarker: nil]);
|
||||
|
||||
ASSIGN (usersToBackup, allUsers);
|
||||
DESTROY(pool);
|
||||
|
||||
return ([userIDs count] > 0);
|
||||
return ([usersToBackup count] > 0);
|
||||
}
|
||||
|
||||
- (BOOL) parseArguments
|
||||
@@ -410,19 +409,29 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) exportUser: (NSString *) uid
|
||||
- (BOOL) exportUser: (NSDictionary *) theUser
|
||||
{
|
||||
NSString *exportPath, *gcsUID, *ldapUID;
|
||||
NSMutableDictionary *userRecord;
|
||||
NSString *exportPath;
|
||||
|
||||
SOGoSystemDefaults *sd;
|
||||
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
userRecord = [NSMutableDictionary dictionary];
|
||||
exportPath = [directory stringByAppendingPathComponent: uid];
|
||||
|
||||
return ([self extractUserFolders: uid
|
||||
ldapUID = [theUser objectForKey: @"c_uid"];
|
||||
exportPath = [directory stringByAppendingPathComponent: ldapUID];
|
||||
|
||||
gcsUID = [theUser objectForKey: @"c_uid"];
|
||||
|
||||
if ([sd enableDomainBasedUID] && [gcsUID rangeOfString: @"@"].location == NSNotFound)
|
||||
gcsUID = [NSString stringWithFormat: @"%@@%@", gcsUID, [theUser objectForKey: @"c_domain"]];
|
||||
|
||||
|
||||
return ([self extractUserFolders: gcsUID
|
||||
intoRecord: userRecord]
|
||||
&& [self extractUserLDIFRecord: uid
|
||||
&& [self extractUserLDIFRecord: ldapUID
|
||||
intoRecord: userRecord]
|
||||
&& [self extractUserPreferences: uid
|
||||
&& [self extractUserPreferences: gcsUID
|
||||
intoRecord: userRecord]
|
||||
&& [userRecord writeToFile: exportPath
|
||||
atomically: NO]);
|
||||
@@ -438,10 +447,10 @@
|
||||
|
||||
pool = [NSAutoreleasePool new];
|
||||
|
||||
max = [userIDs count];
|
||||
max = [usersToBackup count];
|
||||
for (count = 0; rc && count < max; count++)
|
||||
{
|
||||
rc = [self exportUser: [userIDs objectAtIndex: count]];
|
||||
rc = [self exportUser: [usersToBackup objectAtIndex: count]];
|
||||
if ((count % 10) == 0)
|
||||
[pool emptyPool];
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef enum SOGoToolRestoreMode {
|
||||
{
|
||||
NSString *directory;
|
||||
NSString *userID;
|
||||
NSString *filename;
|
||||
NSString *restoreFolder;
|
||||
BOOL destructive; /* destructive mode not handled */
|
||||
SOGoToolRestoreMode restoreMode;
|
||||
|
||||
+21
-9
@@ -1,6 +1,6 @@
|
||||
/* SOGoToolRestore.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009-2014 Inverse inc.
|
||||
* Copyright (C) 2009-2015 Inverse inc.
|
||||
*
|
||||
* 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
|
||||
@@ -73,6 +73,7 @@
|
||||
{
|
||||
directory = nil;
|
||||
userID = nil;
|
||||
filename = nil;
|
||||
restoreFolder = nil;
|
||||
destructive = NO;
|
||||
}
|
||||
@@ -84,6 +85,7 @@
|
||||
{
|
||||
[directory release];
|
||||
[userID release];
|
||||
[filename release];
|
||||
[restoreFolder release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -152,25 +154,35 @@
|
||||
|
||||
- (BOOL) fetchUserID: (NSString *) identifier
|
||||
{
|
||||
BOOL rc;
|
||||
SOGoSystemDefaults *sd;
|
||||
SOGoUserManager *lm;
|
||||
NSDictionary *infos;
|
||||
SOGoSystemDefaults *sd;
|
||||
NSString *uid = nil;
|
||||
|
||||
BOOL rc;
|
||||
|
||||
lm = [SOGoUserManager sharedUserManager];
|
||||
infos = [lm contactInfosForUserWithUIDorEmail: identifier];
|
||||
uid = nil;
|
||||
|
||||
if (infos)
|
||||
{
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if ([sd enableDomainBasedUID])
|
||||
uid = [infos objectForKey: @"c_uid"];
|
||||
|
||||
if ([sd enableDomainBasedUID] && [uid rangeOfString: @"@"].location == NSNotFound)
|
||||
uid = [NSString stringWithFormat: @"%@@%@",
|
||||
[infos objectForKey: @"c_uid"],
|
||||
[infos objectForKey: @"c_domain"]];
|
||||
[infos objectForKey: @"c_uid"],
|
||||
[infos objectForKey: @"c_domain"]];
|
||||
|
||||
if ([[infos objectForKey: @"DomainLessLogin"] boolValue])
|
||||
ASSIGN(filename, [infos objectForKey: @"c_uid"]);
|
||||
else
|
||||
uid = [infos objectForKey: @"c_uid"];
|
||||
ASSIGN(filename, uid);
|
||||
}
|
||||
|
||||
ASSIGN (userID, uid);
|
||||
|
||||
if (userID)
|
||||
rc = YES;
|
||||
else
|
||||
@@ -608,7 +620,7 @@
|
||||
NSString *importPath;
|
||||
BOOL rc;
|
||||
|
||||
importPath = [directory stringByAppendingPathComponent: userID];
|
||||
importPath = [directory stringByAppendingPathComponent: filename];
|
||||
userRecord = [NSDictionary dictionaryWithContentsOfFile: importPath];
|
||||
if (userRecord)
|
||||
{
|
||||
@@ -626,7 +638,7 @@
|
||||
else
|
||||
{
|
||||
rc = NO;
|
||||
NSLog (@"user backup file could not be loaded");
|
||||
NSLog(@"user backup (%@) file could not be loaded", importPath);
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
/* sogo-tool.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
* Copyright (C) 2009-2015 Inverse inc.
|
||||
*
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user