2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
2010-06-30 18:53:23 +02:00
|
|
|
Copyright (C) 2005-2010 Inverse inc.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-06-30 18:53:23 +02:00
|
|
|
This file is part of SOGo
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-06-30 18:53:23 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-06-15 21:34:10 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
2010-06-30 18:53:23 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-06-15 21:34:10 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-05-10 16:59:17 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2007-05-09 21:23:45 +02:00
|
|
|
#import <Foundation/NSString.h>
|
2010-07-16 21:35:25 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2008-07-16 06:17:46 +02:00
|
|
|
#import <Foundation/NSEnumerator.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-05-09 21:23:45 +02:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2008-07-16 06:17:46 +02:00
|
|
|
#import <NGObjWeb/SoPermissions.h>
|
|
|
|
#import <NGObjWeb/SoSecurityManager.h>
|
2006-10-20 23:15:26 +02:00
|
|
|
#import <NGObjWeb/SoObject.h>
|
2007-05-09 21:23:45 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
2008-03-07 23:09:33 +01:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-05-09 21:23:45 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
|
|
|
|
#import <NGCards/NGVCard.h>
|
2006-10-20 23:15:26 +02:00
|
|
|
|
2010-10-26 21:23:08 +02:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
|
|
|
#import <SOGo/NSString+Utilities.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
|
|
|
|
2008-07-16 06:17:46 +02:00
|
|
|
#import <Contacts/SOGoContactFolder.h>
|
|
|
|
#import <Contacts/SOGoContactFolders.h>
|
2006-09-16 00:23:29 +02:00
|
|
|
#import <Contacts/SOGoContactObject.h>
|
2008-03-07 23:09:33 +01:00
|
|
|
#import <Contacts/SOGoContactGCSEntry.h>
|
|
|
|
#import <Contacts/SOGoContactGCSFolder.h>
|
2006-09-16 00:23:29 +02:00
|
|
|
|
|
|
|
#import "UIxContactEditor.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
static Class SOGoContactGCSEntryK = Nil;
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@implementation UIxContactEditor
|
2006-09-16 00:23:29 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
SOGoContactGCSEntryK = [SOGoContactGCSEntry class];
|
|
|
|
}
|
|
|
|
|
2006-09-19 23:03:12 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
ldifRecord = nil;
|
2010-10-26 21:23:08 +02:00
|
|
|
addressBookItem = nil;
|
|
|
|
item = nil;
|
|
|
|
componentAddressBook = nil;
|
2006-09-19 23:03:12 +02:00
|
|
|
}
|
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2006-09-19 23:03:12 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
[ldifRecord release];
|
2010-10-26 21:23:08 +02:00
|
|
|
[addressBookItem release];
|
|
|
|
[item release];
|
|
|
|
[componentAddressBook release];
|
2006-09-16 00:23:29 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (NSMutableDictionary *) ldifRecord
|
|
|
|
{
|
|
|
|
NSDictionary *clientLDIFRecord;
|
|
|
|
NSString *queryValue;
|
|
|
|
|
|
|
|
if (!ldifRecord)
|
|
|
|
{
|
2012-03-21 16:50:07 +01:00
|
|
|
clientLDIFRecord = [[self clientObject] simplifiedLDIFRecord];
|
2011-12-30 21:39:07 +01:00
|
|
|
ldifRecord = [clientLDIFRecord mutableCopy];
|
|
|
|
queryValue = [self queryParameterForKey: @"contactEmail"];
|
|
|
|
if ([queryValue length] > 0)
|
|
|
|
[ldifRecord setObject: queryValue forKey: @"mail"];
|
|
|
|
queryValue = [self queryParameterForKey: @"contactFN"];
|
|
|
|
if ([queryValue length] > 0)
|
|
|
|
[ldifRecord setObject: queryValue forKey: @"displayname"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return ldifRecord;
|
|
|
|
}
|
|
|
|
|
2008-07-16 06:17:46 +02:00
|
|
|
- (void) setAddressBookItem: (id) _item
|
|
|
|
{
|
|
|
|
ASSIGN (addressBookItem, _item);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) addressBookItem
|
|
|
|
{
|
|
|
|
return addressBookItem;
|
|
|
|
}
|
|
|
|
|
2008-03-07 23:09:33 +01:00
|
|
|
- (NSString *) saveURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@/saveAsContact",
|
|
|
|
[[self clientObject] baseURL]];
|
|
|
|
}
|
|
|
|
|
2007-03-22 20:02:45 +01:00
|
|
|
- (NSArray *) htmlMailFormatList
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2007-03-22 20:02:45 +01:00
|
|
|
static NSArray *htmlMailFormatItems = nil;
|
|
|
|
|
|
|
|
if (!htmlMailFormatItems)
|
|
|
|
{
|
|
|
|
htmlMailFormatItems = [NSArray arrayWithObjects: @"FALSE", @"TRUE", nil];
|
|
|
|
[htmlMailFormatItems retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return htmlMailFormatItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemHtmlMailFormatText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"htmlMailFormat_%@", item]];
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 20:02:45 +01:00
|
|
|
- (void) setItem: (NSString *) newItem
|
2006-09-19 23:03:12 +02:00
|
|
|
{
|
2007-03-22 20:02:45 +01:00
|
|
|
item = newItem;
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 20:02:45 +01:00
|
|
|
- (NSString *) item
|
2006-09-19 23:03:12 +02:00
|
|
|
{
|
2007-03-22 20:02:45 +01:00
|
|
|
return item;
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* load/store content format */
|
|
|
|
|
|
|
|
/* helper */
|
|
|
|
|
2008-08-25 21:22:59 +02:00
|
|
|
- (NSString *) _completeURIForMethod: (NSString *) _method
|
|
|
|
{
|
2006-09-16 00:23:29 +02:00
|
|
|
// TODO: this is a DUP of UIxAppointmentEditor
|
|
|
|
NSString *uri;
|
|
|
|
NSRange r;
|
2008-08-25 21:22:59 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
uri = [[[self context] request] uri];
|
2008-08-25 21:22:59 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
/* first: identify query parameters */
|
2007-04-02 23:13:57 +02:00
|
|
|
r = [uri rangeOfString: @"?" options:NSBackwardsSearch];
|
2006-09-16 00:23:29 +02:00
|
|
|
if (r.length > 0)
|
|
|
|
uri = [uri substringToIndex:r.location];
|
2008-08-25 21:22:59 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
/* next: append trailing slash */
|
2007-04-02 23:13:57 +02:00
|
|
|
if (![uri hasSuffix: @"/"])
|
|
|
|
uri = [uri stringByAppendingString: @"/"];
|
2008-08-25 21:22:59 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
/* next: append method */
|
|
|
|
uri = [uri stringByAppendingString:_method];
|
2008-08-25 21:22:59 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
/* next: append query parameters */
|
|
|
|
return [self completeHrefForMethod:uri];
|
|
|
|
}
|
|
|
|
|
2008-07-16 06:17:46 +02:00
|
|
|
- (BOOL) isNew
|
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
return ([[self clientObject] isNew]);
|
2008-07-16 06:17:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) addressBooksList
|
|
|
|
{
|
|
|
|
NSEnumerator *folders;
|
|
|
|
NSMutableArray *addressBooksList;
|
|
|
|
SoSecurityManager *sm;
|
|
|
|
SOGoContactFolders *folderContainer;
|
2012-10-22 16:09:13 +02:00
|
|
|
id <SOGoContactFolder> folder, currentFolder;
|
2008-07-16 06:17:46 +02:00
|
|
|
|
2008-08-25 21:22:00 +02:00
|
|
|
addressBooksList = [NSMutableArray array];
|
2008-07-16 06:17:46 +02:00
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
|
|
|
folderContainer = [[[self clientObject] container] container];
|
|
|
|
folders = [[folderContainer subFolders] objectEnumerator];
|
|
|
|
folder = [self componentAddressBook];
|
|
|
|
currentFolder = [folders nextObject];
|
|
|
|
|
|
|
|
while (currentFolder)
|
|
|
|
{
|
|
|
|
if ([currentFolder isEqual: folder] ||
|
2011-12-30 21:39:07 +01:00
|
|
|
![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
onObject: currentFolder
|
|
|
|
inContext: context])
|
2008-07-16 06:17:46 +02:00
|
|
|
[addressBooksList addObject: currentFolder];
|
|
|
|
currentFolder = [folders nextObject];
|
|
|
|
}
|
2011-12-30 21:39:07 +01:00
|
|
|
|
2008-07-16 06:17:46 +02:00
|
|
|
return addressBooksList;
|
|
|
|
}
|
|
|
|
|
2012-10-22 16:09:13 +02:00
|
|
|
- (id <SOGoContactFolder>) componentAddressBook
|
2008-07-16 06:17:46 +02:00
|
|
|
{
|
2012-10-22 16:09:13 +02:00
|
|
|
return [[self clientObject] container];
|
2008-07-16 06:17:46 +02:00
|
|
|
}
|
|
|
|
|
2012-10-22 16:09:13 +02:00
|
|
|
- (void) setComponentAddressBook: (id <SOGoContactFolder>) _componentAddressBook
|
2008-08-22 08:44:27 +02:00
|
|
|
{
|
|
|
|
ASSIGN (componentAddressBook, _componentAddressBook);
|
|
|
|
}
|
|
|
|
|
2008-07-16 06:17:46 +02:00
|
|
|
- (NSString *) addressBookDisplayName
|
|
|
|
{
|
2014-04-02 16:15:59 +02:00
|
|
|
return [addressBookItem displayName];
|
2008-07-16 06:17:46 +02:00
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (BOOL) supportCategories
|
|
|
|
{
|
|
|
|
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setJsonContactCategories: (NSString *) jsonCategories
|
2010-10-26 21:23:08 +02:00
|
|
|
{
|
|
|
|
NSArray *newCategories;
|
|
|
|
|
|
|
|
newCategories = [jsonCategories objectFromJSONString];
|
|
|
|
if ([newCategories isKindOfClass: [NSArray class]])
|
2011-12-30 21:39:07 +01:00
|
|
|
[[self ldifRecord] setObject: newCategories
|
|
|
|
forKey: @"vcardcategories"];
|
|
|
|
else
|
|
|
|
[[self ldifRecord] removeObjectForKey: @"vcardcategories"];
|
2010-10-26 21:23:08 +02:00
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (NSString *) jsonContactCategories
|
2010-10-26 21:23:08 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
NSArray *categories;
|
2010-10-26 21:23:08 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
categories = [[self ldifRecord] objectForKey: @"vcardcategories"];
|
2010-10-26 21:23:08 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
return [categories jsonRepresentation];
|
2010-10-26 21:23:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _languageContactsCategories
|
|
|
|
{
|
|
|
|
NSArray *categoryLabels;
|
|
|
|
|
|
|
|
categoryLabels = [[self labelForKey: @"contacts_category_labels"]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [NSArray array];
|
|
|
|
|
|
|
|
return [categoryLabels trimmedComponents];
|
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (NSArray *) _fetchAndCombineCategoriesList
|
2010-10-26 21:23:08 +02:00
|
|
|
{
|
|
|
|
NSString *ownerLogin;
|
|
|
|
SOGoUserDefaults *ud;
|
2011-12-30 21:39:07 +01:00
|
|
|
NSArray *cats, *newCats, *contactCategories;
|
2010-10-26 21:23:08 +02:00
|
|
|
|
|
|
|
ownerLogin = [[self clientObject] ownerInContext: context];
|
|
|
|
ud = [[SOGoUser userWithLogin: ownerLogin] userDefaults];
|
|
|
|
cats = [ud contactsCategories];
|
|
|
|
if (!cats)
|
|
|
|
cats = [self _languageContactsCategories];
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
contactCategories = [[self ldifRecord] objectForKey: @"vcardcategories"];
|
|
|
|
if (contactCategories)
|
2010-10-26 21:23:08 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
newCats = [cats mergedArrayWithArray: contactCategories];
|
2010-10-26 21:23:08 +02:00
|
|
|
if ([newCats count] != [cats count])
|
|
|
|
{
|
|
|
|
cats = [newCats sortedArrayUsingSelector:
|
|
|
|
@selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
[ud setContactsCategories: cats];
|
|
|
|
[ud synchronize];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cats;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) contactCategoriesList
|
|
|
|
{
|
|
|
|
NSArray *cats;
|
|
|
|
NSString *list;
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
cats = [self _fetchAndCombineCategoriesList];
|
2010-10-26 21:23:08 +02:00
|
|
|
list = [cats jsonRepresentation];
|
|
|
|
if (!list)
|
|
|
|
list = @"[]";
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
/* actions */
|
|
|
|
|
2008-03-07 23:09:33 +01:00
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2008-03-07 23:09:33 +01:00
|
|
|
NSString *actionName;
|
|
|
|
|
|
|
|
actionName = [[request requestHandlerPath] lastPathComponent];
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
return ([actionName hasPrefix: @"save"]);
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) viewActionName
|
|
|
|
{
|
|
|
|
/* this is overridden in the mail based contacts UI to redirect to tb.edit */
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) editActionName
|
|
|
|
{
|
|
|
|
/* this is overridden in the mail based contacts UI to redirect to tb.edit */
|
2008-03-07 23:09:33 +01:00
|
|
|
return @"editAsContact";
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (BOOL) supportPhotos
|
2010-07-16 21:35:25 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
|
2010-07-16 21:35:25 +02:00
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (BOOL) hasPhoto
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
return [[self clientObject] hasPhoto];
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
- (NSString *) photoURL
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
NSURL *soURL;
|
2007-03-22 20:02:45 +01:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
soURL = [[self clientObject] soURL];
|
2006-09-16 00:23:29 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
return [NSString stringWithFormat: @"%@/photo", [soURL absoluteString]];
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2006-10-12 18:42:59 +02:00
|
|
|
- (id <WOActionResults>) saveAction
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2011-12-30 21:39:07 +01:00
|
|
|
SOGoObject <SOGoContactObject> *contact;
|
2006-09-18 17:28:15 +02:00
|
|
|
id result;
|
2006-10-12 18:42:59 +02:00
|
|
|
NSString *jsRefreshMethod;
|
2008-08-22 08:44:27 +02:00
|
|
|
SoSecurityManager *sm;
|
2006-09-16 00:23:29 +02:00
|
|
|
|
|
|
|
contact = [self clientObject];
|
2011-12-30 21:39:07 +01:00
|
|
|
[contact setLDIFRecord: ldifRecord];
|
|
|
|
[self _fetchAndCombineCategoriesList];
|
|
|
|
[contact save];
|
|
|
|
|
|
|
|
if (componentAddressBook && componentAddressBook != [self componentAddressBook])
|
2006-09-16 00:23:29 +02:00
|
|
|
{
|
2012-10-22 16:09:13 +02:00
|
|
|
if ([contact isKindOfClass: SOGoContactGCSEntryK])
|
2006-10-12 18:42:59 +02:00
|
|
|
{
|
2012-10-22 16:09:13 +02:00
|
|
|
sm = [SoSecurityManager sharedSecurityManager];
|
|
|
|
if (![sm validatePermission: SoPerm_DeleteObjects
|
|
|
|
onObject: componentAddressBook
|
|
|
|
inContext: context]
|
|
|
|
&& ![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
|
|
|
onObject: componentAddressBook
|
|
|
|
inContext: context])
|
|
|
|
[(SOGoContactGCSEntry *) contact
|
|
|
|
moveToFolder: (SOGoGCSFolder *)componentAddressBook]; // TODO:
|
|
|
|
// handle
|
|
|
|
// exception
|
2006-10-12 18:42:59 +02:00
|
|
|
}
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
2011-12-30 21:39:07 +01:00
|
|
|
|
|
|
|
if ([[[[self context] request] formValueForKey: @"nojs"] intValue])
|
|
|
|
result = [self redirectToLocation: [self modulePath]];
|
2006-09-18 17:28:15 +02:00
|
|
|
else
|
2011-12-30 21:39:07 +01:00
|
|
|
{
|
|
|
|
jsRefreshMethod
|
|
|
|
= [NSString stringWithFormat: @"refreshContacts(\"%@\")",
|
|
|
|
[contact nameInContainer]];
|
|
|
|
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
|
|
|
|
}
|
2006-09-18 17:28:15 +02:00
|
|
|
|
|
|
|
return result;
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) writeAction
|
|
|
|
{
|
2007-05-09 21:23:45 +02:00
|
|
|
NSString *email, *cn, *url;
|
|
|
|
NSMutableString *address;
|
2006-09-16 00:23:29 +02:00
|
|
|
|
2011-12-30 21:39:07 +01:00
|
|
|
[self ldifRecord];
|
|
|
|
email = [ldifRecord objectForKey: @"mail"];
|
|
|
|
if ([email length] == 0)
|
|
|
|
email = [ldifRecord objectForKey: @"mozillasecondemail"];
|
2006-10-19 19:35:28 +02:00
|
|
|
|
2006-09-16 00:23:29 +02:00
|
|
|
if (email)
|
2007-05-09 21:23:45 +02:00
|
|
|
{
|
|
|
|
address = [NSMutableString string];
|
2011-12-30 21:39:07 +01:00
|
|
|
cn = [ldifRecord objectForKey: @"cn"];
|
2007-05-09 21:23:45 +02:00
|
|
|
if ([cn length] > 0)
|
|
|
|
[address appendFormat: @"%@ <%@>", cn, email];
|
|
|
|
else
|
|
|
|
[address appendString: email];
|
2008-08-22 14:08:18 +02:00
|
|
|
|
2007-11-16 21:48:52 +01:00
|
|
|
url = [NSString stringWithFormat: @"%@/Mail/compose?mailto=%@",
|
|
|
|
[self userFolderPath], address];
|
2007-05-09 21:23:45 +02:00
|
|
|
}
|
2006-09-16 00:23:29 +02:00
|
|
|
else
|
2007-11-16 21:48:52 +01:00
|
|
|
url = [NSString stringWithFormat: @"%@/Mail/compose", [self userFolderPath]];
|
|
|
|
|
|
|
|
return [self redirectToLocation: url];
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2008-03-07 23:09:33 +01:00
|
|
|
#warning Could this be part of a common parent with UIxAppointment/UIxTaskEditor/UIxListEditor ?
|
2007-04-02 23:13:57 +02:00
|
|
|
- (id) newAction
|
|
|
|
{
|
2008-03-07 23:09:33 +01:00
|
|
|
NSString *objectId, *method, *uri;
|
|
|
|
id <WOActionResults> result;
|
|
|
|
SOGoContactGCSFolder *co;
|
2008-08-22 14:08:18 +02:00
|
|
|
SoSecurityManager *sm;
|
2006-10-27 20:12:13 +02:00
|
|
|
|
|
|
|
co = [self clientObject];
|
2008-03-07 23:09:33 +01:00
|
|
|
objectId = [co globallyUniqueObjectId];
|
|
|
|
if ([objectId length] > 0)
|
|
|
|
{
|
2008-08-22 14:08:18 +02:00
|
|
|
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];
|
|
|
|
}
|
2008-03-07 23:09:33 +01:00
|
|
|
uri = [self completeHrefForMethod: method];
|
|
|
|
result = [self redirectToLocation: uri];
|
|
|
|
}
|
2006-10-27 20:12:13 +02:00
|
|
|
else
|
2008-03-07 23:09:33 +01:00
|
|
|
result = [NSException exceptionWithHTTPStatus: 500 /* Internal Error */
|
|
|
|
reason: @"could not create a unique ID"];
|
2006-10-27 20:12:13 +02:00
|
|
|
|
2008-03-07 23:09:33 +01:00
|
|
|
return result;
|
2006-09-16 00:23:29 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* UIxContactEditor */
|
2008-06-20 06:11:41 +02:00
|
|
|
|