Return contact UID when saving contact

This commit is contained in:
Francis Lachapelle 2014-08-20 15:25:42 -04:00
parent a2460f9368
commit c98d580b29

View file

@ -36,7 +36,9 @@
#import <NGCards/NGVCard.h> #import <NGCards/NGVCard.h>
#import <SOGo/NSArray+Utilities.h> #import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h> #import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoContentObject.h>
#import <SOGo/SOGoUser.h> #import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h> #import <SOGo/SOGoUserDefaults.h>
@ -346,79 +348,25 @@ static Class SOGoContactGCSEntryK = Nil;
- (id <WOActionResults>) saveAction - (id <WOActionResults>) saveAction
{ {
SOGoObject <SOGoContactObject> *contact; SOGoContentObject <SOGoContactObject> *contact;
WORequest *request; WORequest *request;
WOResponse *response; WOResponse *response;
//id result; NSDictionary *params, *data;
NSDictionary *params;
//NSString *jsRefreshMethod;
SoSecurityManager *sm;
contact = [self clientObject]; contact = [self clientObject];
request = [context request]; request = [context request];
NSLog(@"%@", [request contentAsString]);
params = [[request contentAsString] objectFromJSONString]; params = [[request contentAsString] objectFromJSONString];
// LDIF NSDictionary (vCard)
// ---------------------------------------------
// sn familyname
// givenname givenname
// mozillanickname nickname
// displayname fullname
// title title
// o organization
// ou[] units[]
// telephonenumber tel;work
// homephone tel;home
// mobile tel;cell
// facsimiletelephonenumber tel;fax
// pager tel;pager
// mail email;work
// mozillasecondemail email;home
// mozillausehtmlmail x-mozilla-html
// mozillahomeurl url;home
// mozillaworkurl url;work
// nsaimid x-aim
// birth(year/month/day) bday
// c_info x-sogo-contactinfo
// description note
// vcardcategories categories
[contact setAttributes: params]; [contact setAttributes: params];
response = [self responseWithStatus: 204];
//[contact setLDIFRecord: ldifRecord];
//[self _fetchAndCombineCategoriesList];
[contact save]; [contact save];
// if (componentAddressBook && componentAddressBook != [self componentAddressBook]) // Return card UID and addressbook ID in a JSON payload
// { data = [NSDictionary dictionaryWithObjectsAndKeys:
// if ([contact isKindOfClass: SOGoContactGCSEntryK]) [[contact container] nameInContainer], @"pid",
// { [contact nameInContainer], @"id",
// sm = [SoSecurityManager sharedSecurityManager]; nil];
// if (![sm validatePermission: SoPerm_DeleteObjects response = [self responseWithStatus: 200
// onObject: componentAddressBook andString: [data jsonRepresentation]];
// inContext: context]
// && ![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
// onObject: componentAddressBook
// inContext: context])
// [(SOGoContactGCSEntry *) contact
// moveToFolder: (SOGoGCSFolder *)componentAddressBook]; // TODO:
// // handle
// // exception
// }
// }
// if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
// result = [self redirectToLocation: [self modulePath]];
// else
// {
// jsRefreshMethod
// = [NSString stringWithFormat: @"refreshContacts(\"%@\")",
// [contact nameInContainer]];
// result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
// }
return response; return response;
} }
@ -451,40 +399,5 @@ static Class SOGoContactGCSEntryK = Nil;
return [self redirectToLocation: url]; return [self redirectToLocation: url];
} }
#warning Could this be part of a common parent with UIxAppointment/UIxTaskEditor/UIxListEditor ?
- (id) newAction
{
NSString *objectId, *method, *uri;
id <WOActionResults> result;
SOGoContactGCSFolder *co;
SoSecurityManager *sm;
co = [self clientObject];
objectId = [co globallyUniqueObjectId];
if ([objectId length] > 0)
{
sm = [SoSecurityManager sharedSecurityManager];
if (![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
onObject: co
inContext: context])
{
method = [NSString stringWithFormat: @"%@/%@.vcf/editAsContact",
[co soURL], objectId];
}
else
{
method = [NSString stringWithFormat: @"%@/Contacts/personal/%@.vcf/editAsContact",
[self userFolderPath], objectId];
}
uri = [self completeHrefForMethod: method];
result = [self redirectToLocation: uri];
}
else
result = [NSException exceptionWithHTTPStatus: 500 /* Internal Error */
reason: @"could not create a unique ID"];
return result;
}
@end /* UIxContactEditor */ @end /* UIxContactEditor */