]> err.no Git - scalable-opengroupware.org/blobdiff - UI/Contacts/UIxContactEditor.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1155 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Contacts / UIxContactEditor.m
index 0b6dd7b7420601d050e977d5957d705451a84ca9..578c65ce39feffabc2249ee2624bb648d080bc30 100644 (file)
   02111-1307, USA.
 */
 
-#import <NGCards/NGVCard.h>
-#import <NGCards/NSArray+NGCards.h>
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSString.h>
 
+#import <NGObjWeb/NSException+HTTP.h>
 #import <NGObjWeb/SoObject.h>
+#import <NGObjWeb/WORequest.h>
+#import <NGExtensions/NSNull+misc.h>
+
+#import <NGCards/NGVCard.h>
+#import <NGCards/NSArray+NGCards.h>
 
 #import <Contacts/SOGoContactObject.h>
 #import <Contacts/SOGoContactFolder.h>
-#import "common.h"
 
 #import "UIxContactEditor.h"
 
 
 - (id) writeAction
 {
-  NSString *email, *url;
+  NSString *email, *cn, *url;
+  NSMutableString *address;
 
   card = [[self clientObject] vCard];
   [self initSnapshot];
     email = [snapshot objectForKey: @"workMail"];
 
   if (email)
-    url = [NSString stringWithFormat: @"Mail/compose?mailto=%@", email];
+    {
+      address = [NSMutableString string];
+      cn = [card fn];
+      if ([cn length] > 0)
+       [address appendFormat: @"%@ <%@>", cn, email];
+      else
+       [address appendString: email];
+       
+      url = [NSString stringWithFormat: @"Mail/compose?mailto=%@", address];
+    }
   else
     url = @"Mail/compose";
 
     objectId = nil;
 
   if ([objectId length] == 0)
-    return [NSException exceptionWithHTTPStatus:500 /* Internal Error */
+    return [NSException exceptionWithHTTPStatus: 500 /* Internal Error */
                         reason: @"could not create a unique ID"];
 
   nextMethod = [NSString stringWithFormat: @"../%@/%@", 
                         objectId, [self editActionName]];
-  uri = [self _completeURIForMethod:nextMethod];
-  return [self redirectToLocation:uri];
+  uri = [self _completeURIForMethod: nextMethod];
+  return [self redirectToLocation: uri];
 }
 
 @end /* UIxContactEditor */