diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index db6b4e0ab..0a60e71f0 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2515,6 +2515,21 @@ Possible values are: Defaults to `below`. +|U |SOGoMailUseSignatureOnNew +|Add signature to new message + +Defaults to `YES`. + +|U |SOGoMailUseSignatureOnReply +|Add signature to reply + +Defaults to `YES`. + +|U |SOGoMailUseSignatureOnForward +|Add signature to forward + +Defaults to `YES`. + |U |SOGoMailComposeMessageType |The message composition format. Possible values are: diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index 00c662f1e..e1394e231 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -1072,19 +1072,16 @@ static NSString *userAgent = nil; ud = [[context activeUser] userDefaults]; - // TODO: Change mailMessageForwarding for reply - if ([[ud mailMessageForwarding] isEqualToString: @"inline"]) - { - [self setText: [sourceMail contentForReply]]; - if ([sourceMail isEncrypted]) - [self _fetchAttachmentsFromEncryptedMail: sourceMail onlyImages: YES]; - else if ([sourceMail isOpaqueSigned]) - [self _fetchAttachmentsFromOpaqueSignedMail: sourceMail onlyImages: YES]; - else - [self _fetchAttachmentsFromMail: sourceMail onlyImages: YES]; - } - [self save]; + [self setText: [sourceMail contentForReply]]; + if ([sourceMail isEncrypted]) + [self _fetchAttachmentsFromEncryptedMail: sourceMail onlyImages: YES]; + else if ([sourceMail isOpaqueSigned]) + [self _fetchAttachmentsFromOpaqueSignedMail: sourceMail onlyImages: YES]; + else + [self _fetchAttachmentsFromMail: sourceMail onlyImages: YES]; + + [self save]; [self storeInfo]; } @@ -1135,7 +1132,7 @@ static NSString *userAgent = nil; // TODO: use subject for filename? // error = [newDraft saveAttachment:content withName:@"forward.eml"]; signature = [[self mailAccountFolder] signature]; - if ([signature length]) + if ([signature length] && [ud mailUseSignatureOnForward]) { nl = (isHTML ? @"
" : @"\n"); space = (isHTML ? @" " : @" "); diff --git a/SoObjects/Mailer/SOGoMailForward.m b/SoObjects/Mailer/SOGoMailForward.m index 355fde586..f442759e8 100644 --- a/SoObjects/Mailer/SOGoMailForward.m +++ b/SoObjects/Mailer/SOGoMailForward.m @@ -234,6 +234,12 @@ return [sourceMail contentForEditing]; } +- (BOOL)isSignatureEnabled { + SOGoUserDefaults *ud; + ud = [[context activeUser] userDefaults]; + return [ud mailUseSignatureOnForward]; +} + - (NSString *) signature { BOOL fromSentMailbox; @@ -275,7 +281,7 @@ if (identity) { signature = [identity objectForKey: @"signature"]; - if ([signature length]) + if ([signature length] && [self isSignatureEnabled]) { nl = (htmlComposition ? @"
" : @"\n"); space = (htmlComposition ? @" " : @" "); diff --git a/SoObjects/Mailer/SOGoMailReply.m b/SoObjects/Mailer/SOGoMailReply.m index 8c9cacfe8..a263459ff 100644 --- a/SoObjects/Mailer/SOGoMailReply.m +++ b/SoObjects/Mailer/SOGoMailReply.m @@ -22,6 +22,8 @@ #import #import +#import + #import "SOGoMailObject+Draft.h" #import "SOGoMailReply.h" @@ -85,6 +87,12 @@ return s; } +- (BOOL)isSignatureEnabled { + SOGoUserDefaults *ud; + ud = [[context activeUser] userDefaults]; + return [ud mailUseSignatureOnReply]; +} + @end @implementation SOGoMailArabicReply diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index b8afc96e7..0862ed18e 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -109,6 +109,9 @@ SOGoMailMessageForwarding = "inline"; SOGoMailReplyPlacement = "below"; SOGoMailSignaturePlacement = "below"; + SOGoMailUseSignatureOnNew = YES; + SOGoMailUseSignatureOnReply = YES; + SOGoMailUseSignatureOnForward = YES; SOGoRefreshViewIntervals = ( 1, 2, 5, 10, 20, 30, 60 ); SOGoMailListViewColumnsOrder = ( "Thread", "Flagged", "Attachment", "Subject", "From", "Unread", "Date", "Priority", diff --git a/SoObjects/SOGo/SOGoUserDefaults.h b/SoObjects/SOGo/SOGoUserDefaults.h index 478f33c74..3c81d3824 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.h +++ b/SoObjects/SOGo/SOGoUserDefaults.h @@ -175,6 +175,13 @@ extern NSString *SOGoPasswordRecoverySecondaryEmail; - (void) setMailSignaturePlacement: (NSString *) newValue; - (NSString *) mailSignaturePlacement; +- (BOOL)mailUseSignatureOnNew; +- (void)setMailUseSignatureOnNew:(BOOL)newValue; +- (BOOL)mailUseSignatureOnReply; +- (void)setMailUseSignatureOnReply:(BOOL)newValue; +- (BOOL)mailUseSignatureOnForward; +- (void)setMailUseSignatureOnForward:(BOOL)newValue; + - (void) setAllowUserReceipt: (BOOL) allow; - (BOOL) allowUserReceipt; - (void) setUserReceiptNonRecipientAction: (NSString *) action; diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index 7b4b14d6f..28d8a494c 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -707,6 +707,36 @@ NSString *SOGoPasswordRecoverySecondaryEmail = @"SecondaryEmail"; return signaturePlacement; } +- (BOOL) mailUseSignatureOnNew +{ + return [self boolForKey: @"SOGoMailUseSignatureOnNew"]; +} + +- (void) setMailUseSignatureOnNew: (BOOL) newValue +{ + [self setBool: newValue forKey: @"SOGoMailUseSignatureOnNew"]; +} + +- (BOOL) mailUseSignatureOnReply +{ + return [self boolForKey: @"SOGoMailUseSignatureOnReply"]; +} + +- (void) setMailUseSignatureOnReply: (BOOL) newValue +{ + [self setBool: newValue forKey: @"SOGoMailUseSignatureOnReply"]; +} + +- (BOOL) mailUseSignatureOnForward +{ + return [self boolForKey: @"SOGoMailUseSignatureOnForward"]; +} + +- (void) setMailUseSignatureOnForward: (BOOL) newValue +{ + [self setBool: newValue forKey: @"SOGoMailUseSignatureOnForward"]; +} + - (void) setAllowUserReceipt: (BOOL) allow { [self setBool: allow forKey: @"SOGoMailReceiptAllow"]; diff --git a/UI/MailerUI/UIxMailAccountActions.m b/UI/MailerUI/UIxMailAccountActions.m index c97944eb6..79f2a9b76 100644 --- a/UI/MailerUI/UIxMailAccountActions.m +++ b/UI/MailerUI/UIxMailAccountActions.m @@ -155,9 +155,9 @@ { [headers setObject: [self _emailFromIdentity: identity] forKey: @"from"]; signature = [identity objectForKey: @"signature"]; - if ([signature length]) + ud = [[context activeUser] userDefaults]; + if ([signature length] && [ud mailUseSignatureOnNew]) { - ud = [[context activeUser] userDefaults]; [newDraftMessage setIsHTML: [[ud mailComposeMessageType] isEqualToString: @"html"]]; isHTML = [newDraftMessage isHTML]; nl = (isHTML? @"
" : @"\n"); diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 4c19f3e35..64a0f7c6e 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -753,7 +753,7 @@ // Add signature signature = [identity objectForKey: @"signature"]; - if ([signature length]) + if ([signature length] && [ud mailUseSignatureOnForward]) { nl = (htmlComposition? @"
" : @"\n"); space = (htmlComposition ? @" " : @" "); diff --git a/UI/PreferencesUI/English.lproj/Localizable.strings b/UI/PreferencesUI/English.lproj/Localizable.strings index a220f4cc2..4c5110e0d 100644 --- a/UI/PreferencesUI/English.lproj/Localizable.strings +++ b/UI/PreferencesUI/English.lproj/Localizable.strings @@ -195,6 +195,9 @@ "Compose messages in" = "Compose messages in"; "composemessagestype_html" = "HTML"; "composemessagestype_text" = "Plain text"; +"Insert signature on new message" = "Insert signature on new message"; +"Insert signature on reply" = "Insert signature on reply"; +"Insert signature on forward" = "Insert signature on forward"; /* Base font size for messages composed in HTML */ "Default font size" = "Default font size"; diff --git a/UI/PreferencesUI/French.lproj/Localizable.strings b/UI/PreferencesUI/French.lproj/Localizable.strings index 665f4dc51..67335a58c 100644 --- a/UI/PreferencesUI/French.lproj/Localizable.strings +++ b/UI/PreferencesUI/French.lproj/Localizable.strings @@ -195,6 +195,9 @@ "Compose messages in" = "Composer les messages en"; "composemessagestype_html" = "HTML"; "composemessagestype_text" = "Texte"; +"Insert signature on new message" = "Insérer la signature sur un nouveau message"; +"Insert signature on reply" = "Insérer la signature sur une réponse"; +"Insert signature on forward" = "Insérer la signature sur un transfert"; /* Base font size for messages composed in HTML */ "Default font size" = "Taille de la police par défaut"; diff --git a/UI/PreferencesUI/UIxJSONPreferences.m b/UI/PreferencesUI/UIxJSONPreferences.m index 6a9dd6061..26ef076da 100644 --- a/UI/PreferencesUI/UIxJSONPreferences.m +++ b/UI/PreferencesUI/UIxJSONPreferences.m @@ -343,8 +343,18 @@ static SoProduct *preferencesProduct = nil; if (![[defaults source] objectForKey: @"SOGoMailReplyPlacement"]) [[defaults source] setObject: [defaults mailReplyPlacement] forKey: @"SOGoMailReplyPlacement"]; - if (![[defaults source] objectForKey: @"SOGoMailSignaturePlacement"]) - [[defaults source] setObject: [defaults mailSignaturePlacement] forKey: @"SOGoMailSignaturePlacement"]; + if (![[defaults source] objectForKey: @"SOGoMailUseSignatureOnNew"]) + [[defaults source] setObject: [NSNumber numberWithBool: [defaults mailUseSignatureOnNew]] forKey: @"SOGoMailUseSignatureOnNew"]; + + if (![[defaults source] objectForKey: @"SOGoMailUseSignatureOnReply"]) + [[defaults source] setObject: [NSNumber numberWithBool: [defaults mailUseSignatureOnReply]] forKey: @"SOGoMailUseSignatureOnReply"]; + + if (![[defaults source] objectForKey: @"SOGoMailUseSignatureOnForward"]) + [[defaults source] setObject: [NSNumber numberWithBool: [defaults mailUseSignatureOnForward]] forKey: @"SOGoMailUseSignatureOnForward"]; + + if (![[defaults source] objectForKey: @"SOGoMailAddOutgoingAddresses"]) + [[defaults source] setObject: [NSNumber numberWithBool: [defaults mailAddOutgoingAddresses]] forKey: @"SOGoMailAddOutgoingAddresses"]; + if (![[defaults source] objectForKey: @"SOGoMailComposeMessageType"]) [[defaults source] setObject: [defaults mailComposeMessageType] forKey: @"SOGoMailComposeMessageType"]; diff --git a/UI/Templates/PreferencesUI/UIxPreferences.wox b/UI/Templates/PreferencesUI/UIxPreferences.wox index 69863d653..05b4b75c9 100644 --- a/UI/Templates/PreferencesUI/UIxPreferences.wox +++ b/UI/Templates/PreferencesUI/UIxPreferences.wox @@ -803,6 +803,30 @@ +
+ + + + + + + + + +
+
diff --git a/UI/WebServerResources/js/Mailer/MessageEditorController.js b/UI/WebServerResources/js/Mailer/MessageEditorController.js index 4c6f487ad..253b0d689 100644 --- a/UI/WebServerResources/js/Mailer/MessageEditorController.js +++ b/UI/WebServerResources/js/Mailer/MessageEditorController.js @@ -402,38 +402,44 @@ nlNb = 2; else nlNb = 1; + + if ((vm.isNew() && Preferences.defaults.SOGoMailUseSignatureOnNew === 1) + || (!vm.isNew() && Preferences.defaults.SOGoMailUseSignatureOnForward === 1 && vm.message && vm.message.origin && vm.message.origin.action && vm.message.origin.action === 'forward') + || (!vm.isNew() && Preferences.defaults.SOGoMailUseSignatureOnReply === 1 && vm.message && vm.message.origin && vm.message.origin.action && vm.message.origin.action === 'reply') + ) { + if (identity && identity.signature) + signature = nl.repeat(nlNb) + '--' + space + nl + identity.signature; + else + signature = ''; - if (identity && identity.signature) - signature = nl.repeat(nlNb) + '--' + space + nl + identity.signature; - else - signature = ''; + previousIdentity = _.find(this.identities, function (currentIdentity, index) { - previousIdentity = _.find(this.identities, function (currentIdentity, index) { - if (currentIdentity.signature) { - var currentSignature = new RegExp('(' + reNl + '){' + nlNb + '}--' + space + reNl + - currentIdentity.signature.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g, '\\$&')); - if (vm.message.editable.text.search(currentSignature) >= 0) { - vm.message.editable.text = vm.message.editable.text.replace(currentSignature, signature); - return true; + if (currentIdentity.signature) { + var currentSignature = new RegExp('(' + reNl + '){' + nlNb + '}--' + space + reNl + + currentIdentity.signature.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g, '\\$&')); + if (vm.message.editable.text.search(currentSignature) >= 0) { + vm.message.editable.text = vm.message.editable.text.replace(currentSignature, signature); + return true; + } } - } - return false; - }); - - if (!previousIdentity && signature.length > 0) { - // Must place signature at proper place - if (!this.isNew() && this.replyPlacement == 'above' && this.signaturePlacement == 'above') { - var quotedMessageIndex = this.message.editable.text.search(new RegExp(reNl + '.+?:( ?' + reNl + '){' + nlNb + '}(> |
= 0) { - this.message.editable.text = - this.message.editable.text.slice(0, quotedMessageIndex) + - signature + - this.message.editable.text.slice(quotedMessageIndex); + return false; + }); + + if (!previousIdentity && signature.length > 0) { + // Must place signature at proper place + if (!this.isNew() && this.replyPlacement == 'above' && this.signaturePlacement == 'above') { + var quotedMessageIndex = this.message.editable.text.search(new RegExp(reNl + '.+?:( ?' + reNl + '){' + nlNb + '}(> |
= 0) { + this.message.editable.text = + this.message.editable.text.slice(0, quotedMessageIndex) + + signature + + this.message.editable.text.slice(quotedMessageIndex); + } else { + this.message.editable.text = signature + this.message.editable.text; + } } else { - this.message.editable.text = signature + this.message.editable.text; + this.message.editable.text += signature; } - } else { - this.message.editable.text += signature; } } };