+2005-07-22 Helge Hess <helge.hess@opengroupware.org>
+
+ * v0.9.170
+
+ * UIxMailEditor.m: the mail editor now presets the proper 'from' based
+ on the 'account' query parameter
+
+ * UIxMailEditorAction.m: the compose action now adds the current
+ account as a query parameter when calling the compose panel
+
2005-07-22 Marcus Mueller <znek@mulle-kybernetik.com>
* English.lproj/Localizable.strings: added error labels for JavaScript
ASSIGNCOPY(self->from, _value);
}
- (NSString *)from {
- if (![self->from isNotNull])
+ if (![self->from isNotEmpty])
return [[[self context] activeUser] email];
return self->from;
}
return ((self->sentFolder = [folder retain]));
}
+- (void)_presetFromBasedOnAccountsQueryParameter {
+ /* preset the from field to the primary identity of the given account */
+ /* Note: The compose action sets the 'accounts' query parameter */
+ NSString *accountID;
+ SOGoMailAccounts *accounts;
+ SOGoMailAccount *account;
+ SOGoMailIdentity *identity;
+
+ if (useLocationBasedSentFolder) /* from will be based on location */
+ return;
+
+ if ([self->from isNotEmpty]) /* a from is already set */
+ return;
+
+ accountID = [[[self context] request] formValueForKey:@"account"];
+ if (![accountID isNotEmpty])
+ return;
+
+ accounts = [[self clientObject] mailAccountsFolder];
+ if ([accounts isExceptionOrNull])
+ return; /* we don't treat this as an error but are tolerant */
+
+ account = [accounts lookupName:accountID inContext:[self context]
+ acquire:NO];
+ if ([account isExceptionOrNull])
+ return; /* we don't treat this as an error but are tolerant */
+
+ identity = [account valueForKey:@"preferredIdentity"];
+ if (![identity isNotNull]) {
+ [self warnWithFormat:@"Account has no preferred identity: %@", account];
+ return;
+ }
+
+ [self setFrom:[identity email]];
+}
+
- (SOGoMailIdentity *)selectedMailIdentity {
SOGoMailAccounts *accounts;
NSEnumerator *e;
SOGoMailIdentity *identity;
accounts = [[self clientObject] mailAccountsFolder];
- if ([accounts isKindOfClass:[NSException class]]) return (id)accounts;
+ if ([accounts isExceptionOrNull]) return (id)accounts;
// TODO: This is still a hack because we detect the identity based on the
// from. In Agenor all of the identities have unique emails, but this
#endif
[self loadInfo:[[self clientObject] fetchInfo]];
+ [self _presetFromBasedOnAccountsQueryParameter];
return self;
}
SOGoDraftsFolder *drafts;
WOResponse *r;
NSString *url;
+ id accountFolder;
drafts = [self draftsFolder];
if (![drafts isNotNull])
if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"];
url = [url stringByAppendingString:@"edit"];
- // TODO: debug log
- [self logWithFormat:@"compose on %@: %@", drafts, url];
+ /* attach mail-account info */
+
+ accountFolder = [[self clientObject] valueForKey:@"mailAccountFolder"];
+ if (![accountFolder isExceptionOrNull]) {
+ url = [url stringByAppendingString:@"?account="];
+ url = [url stringByAppendingString:[accountFolder nameInContainer]];
+ }
+
+ /* perform redirect */
+
+ [self debugWithFormat:@"compose on %@: %@", drafts, url];
r = [[self context] response];
[r setStatus:302 /* moved */];