mirror of
https://github.com/Kopano-dev/kopano-ol-extension.git
synced 2023-10-10 13:37:40 +02:00
[KOE-151] Added option SMTPGroupsAsContacts to GAB, to allow groups with SMTP addresses to be created as contacts
This commit is contained in:
parent
fa64452e7c
commit
f70e320d85
@ -237,6 +237,14 @@ namespace Acacia.Features.GAB
|
|||||||
}
|
}
|
||||||
private static readonly BoolOption OPTION_SUPPRESS_MODIFICATIONS = new BoolOption("SuppressModifications", true);
|
private static readonly BoolOption OPTION_SUPPRESS_MODIFICATIONS = new BoolOption("SuppressModifications", true);
|
||||||
|
|
||||||
|
[AcaciaOption("If enabled, groups with an SMTP address are created as contacts.")]
|
||||||
|
public bool SMTPGroupsAsContacts
|
||||||
|
{
|
||||||
|
get { return GetOption(OPTION_SMTP_GROUPS_AS_CONTACTS); }
|
||||||
|
set { SetOption(OPTION_SMTP_GROUPS_AS_CONTACTS, value); }
|
||||||
|
}
|
||||||
|
private static readonly BoolOption OPTION_SMTP_GROUPS_AS_CONTACTS = new BoolOption("SMTPGroupsAsContacts", false);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Modification suppression
|
#region Modification suppression
|
||||||
|
@ -519,7 +519,11 @@ namespace Acacia.Features.GAB
|
|||||||
if (Get<string>(value, "initials") != null) contact.Initials = Get<string>(value, "initials");
|
if (Get<string>(value, "initials") != null) contact.Initials = Get<string>(value, "initials");
|
||||||
if (Get<string>(value, "surname") != null) contact.LastName = Get<string>(value, "surname");
|
if (Get<string>(value, "surname") != null) contact.LastName = Get<string>(value, "surname");
|
||||||
if (Get<string>(value, "title") != null) contact.JobTitle = Get<string>(value, "title");
|
if (Get<string>(value, "title") != null) contact.JobTitle = Get<string>(value, "title");
|
||||||
if (Get<string>(value, "displayName") != null) contact.FullName = Get<string>(value, "displayName");
|
if (Get<string>(value, "displayName") != null)
|
||||||
|
{
|
||||||
|
contact.FileAs = Get<string>(value, "displayName");
|
||||||
|
contact.FullName = Get<string>(value, "displayName");
|
||||||
|
}
|
||||||
|
|
||||||
if (Get<string>(value, "smtpAddress") != null)
|
if (Get<string>(value, "smtpAddress") != null)
|
||||||
{
|
{
|
||||||
@ -590,13 +594,76 @@ namespace Acacia.Features.GAB
|
|||||||
if (!_feature.CreateGroups)
|
if (!_feature.CreateGroups)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
string smtpAddress = Get<string> (value, "smtpAddress");
|
||||||
|
if (!string.IsNullOrEmpty(smtpAddress) && _feature.SMTPGroupsAsContacts)
|
||||||
|
{
|
||||||
|
// Create a contact
|
||||||
|
using (IContactItem contact = Contacts.Create<IContactItem>())
|
||||||
|
{
|
||||||
|
Logger.Instance.Debug(this, "Creating group as contact: {0}", id);
|
||||||
|
contact.FullName = contact.FileAs = Get<string>(value, "displayName");
|
||||||
|
contact.Email1Address = smtpAddress;
|
||||||
|
contact.Email1AddressType = "SMTP";
|
||||||
|
|
||||||
|
SetItemStandard(contact, id, value, index);
|
||||||
|
|
||||||
|
if (_feature.GroupMembers)
|
||||||
|
{
|
||||||
|
// Add the group members as the body
|
||||||
|
ArrayList members = Get<ArrayList>(value, "members");
|
||||||
|
if (members != null)
|
||||||
|
{
|
||||||
|
string membersBody = null;
|
||||||
|
foreach (string memberId in members)
|
||||||
|
{
|
||||||
|
using (IItem item = FindItemById(memberId))
|
||||||
|
{
|
||||||
|
Logger.Instance.Debug(this, "Finding member {0} of {1}: {2}", memberId, id, item?.EntryID);
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
if (membersBody == null)
|
||||||
|
membersBody = "";
|
||||||
|
else
|
||||||
|
membersBody += "\n";
|
||||||
|
|
||||||
|
if (item is IContactItem)
|
||||||
|
{
|
||||||
|
IContactItem memberContact = (IContactItem)item;
|
||||||
|
membersBody += string.Format("{0} ({1})", memberContact.FullName, memberContact.Email1Address);
|
||||||
|
}
|
||||||
|
else if (item is IDistributionList)
|
||||||
|
{
|
||||||
|
IDistributionList memberGroup = (IDistributionList)item;
|
||||||
|
if (string.IsNullOrEmpty(memberGroup.SMTPAddress))
|
||||||
|
membersBody += memberGroup.DLName;
|
||||||
|
else
|
||||||
|
membersBody += string.Format("{0} ({1})", memberGroup.DLName, memberGroup.SMTPAddress);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
membersBody += item.Subject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contact.Body = membersBody;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contact.Save();
|
||||||
|
|
||||||
|
AddItemToGroups(contact, id, value, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create a proper group
|
||||||
using (IDistributionList group = Contacts.Create<IDistributionList>())
|
using (IDistributionList group = Contacts.Create<IDistributionList>())
|
||||||
{
|
{
|
||||||
Logger.Instance.Debug(this, "Creating group: {0}", id);
|
Logger.Instance.Debug(this, "Creating group: {0}", id);
|
||||||
group.DLName = Get<string>(value, "displayName");
|
group.DLName = Get<string>(value, "displayName");
|
||||||
if (Get<string>(value, "smtpAddress") != null)
|
if (smtpAddress != null)
|
||||||
{
|
{
|
||||||
group.SMTPAddress = Get<string>(value, "smtpAddress");
|
group.SMTPAddress = smtpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetItemStandard(group, id, value, index);
|
SetItemStandard(group, id, value, index);
|
||||||
@ -623,6 +690,7 @@ namespace Acacia.Features.GAB
|
|||||||
AddItemToGroups(group, id, value, index);
|
AddItemToGroups(group, id, value, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IItem FindItemById(string id)
|
private IItem FindItemById(string id)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GABSettings));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GABSettings));
|
||||||
this.checkFaxNumbers = new System.Windows.Forms.CheckBox();
|
this.checkFaxNumbers = new System.Windows.Forms.CheckBox();
|
||||||
|
this._layout = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.checkSMTPGroupsAsContacts = new System.Windows.Forms.CheckBox();
|
||||||
|
this._layout.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// checkFaxNumbers
|
// checkFaxNumbers
|
||||||
@ -39,13 +42,29 @@
|
|||||||
this.checkFaxNumbers.UseVisualStyleBackColor = true;
|
this.checkFaxNumbers.UseVisualStyleBackColor = true;
|
||||||
this.checkFaxNumbers.CheckedChanged += new System.EventHandler(this.checkFaxNumbers_CheckedChanged);
|
this.checkFaxNumbers.CheckedChanged += new System.EventHandler(this.checkFaxNumbers_CheckedChanged);
|
||||||
//
|
//
|
||||||
|
// _layout
|
||||||
|
//
|
||||||
|
resources.ApplyResources(this._layout, "_layout");
|
||||||
|
this._layout.Controls.Add(this.checkFaxNumbers, 0, 0);
|
||||||
|
this._layout.Controls.Add(this.checkSMTPGroupsAsContacts, 0, 0);
|
||||||
|
this._layout.Name = "_layout";
|
||||||
|
//
|
||||||
|
// checkSMTPGroupsAsContacts
|
||||||
|
//
|
||||||
|
resources.ApplyResources(this.checkSMTPGroupsAsContacts, "checkSMTPGroupsAsContacts");
|
||||||
|
this.checkSMTPGroupsAsContacts.Name = "checkSMTPGroupsAsContacts";
|
||||||
|
this.checkSMTPGroupsAsContacts.UseVisualStyleBackColor = true;
|
||||||
|
this.checkSMTPGroupsAsContacts.CheckedChanged += new System.EventHandler(this.checkSMTPGroupsAsContacts_CheckedChanged);
|
||||||
|
//
|
||||||
// GABSettings
|
// GABSettings
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this, "$this");
|
resources.ApplyResources(this, "$this");
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.BackColor = System.Drawing.SystemColors.Window;
|
this.BackColor = System.Drawing.SystemColors.Window;
|
||||||
this.Controls.Add(this.checkFaxNumbers);
|
this.Controls.Add(this._layout);
|
||||||
this.Name = "GABSettings";
|
this.Name = "GABSettings";
|
||||||
|
this._layout.ResumeLayout(false);
|
||||||
|
this._layout.PerformLayout();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
@ -54,5 +73,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private System.Windows.Forms.CheckBox checkFaxNumbers;
|
private System.Windows.Forms.CheckBox checkFaxNumbers;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel _layout;
|
||||||
|
private System.Windows.Forms.CheckBox checkSMTPGroupsAsContacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ namespace Acacia.Features.GAB
|
|||||||
if (feature != null)
|
if (feature != null)
|
||||||
{
|
{
|
||||||
checkFaxNumbers.Checked = feature.SyncFaxNumbers;
|
checkFaxNumbers.Checked = feature.SyncFaxNumbers;
|
||||||
|
checkSMTPGroupsAsContacts.Checked = feature.SMTPGroupsAsContacts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,5 +58,11 @@ namespace Acacia.Features.GAB
|
|||||||
_feature.SyncFaxNumbers = checkFaxNumbers.Checked;
|
_feature.SyncFaxNumbers = checkFaxNumbers.Checked;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkSMTPGroupsAsContacts_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_feature != null)
|
||||||
|
_feature.SMTPGroupsAsContacts = checkSMTPGroupsAsContacts.Checked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,13 +127,10 @@
|
|||||||
</data>
|
</data>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="checkFaxNumbers.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="checkFaxNumbers.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>4, 4</value>
|
<value>3, 26</value>
|
||||||
</data>
|
|
||||||
<data name="checkFaxNumbers.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
|
||||||
<value>6, 6, 6, 6</value>
|
|
||||||
</data>
|
</data>
|
||||||
<data name="checkFaxNumbers.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="checkFaxNumbers.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>259, 29</value>
|
<value>250, 17</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="checkFaxNumbers.TabIndex" type="System.Int32, mscorlib">
|
<data name="checkFaxNumbers.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
@ -148,28 +145,91 @@
|
|||||||
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>checkFaxNumbers.Parent" xml:space="preserve">
|
<data name=">>checkFaxNumbers.Parent" xml:space="preserve">
|
||||||
<value>$this</value>
|
<value>_layout</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>checkFaxNumbers.ZOrder" xml:space="preserve">
|
<data name=">>checkFaxNumbers.ZOrder" xml:space="preserve">
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="_layout.AutoSize" type="System.Boolean, mscorlib">
|
||||||
|
<value>True</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.ColumnCount" type="System.Int32, mscorlib">
|
||||||
|
<value>1</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.AutoSize" type="System.Boolean, mscorlib">
|
||||||
|
<value>True</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||||
|
<value>Fill</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
|
<value>3, 3</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>250, 17</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.TabIndex" type="System.Int32, mscorlib">
|
||||||
|
<value>1</value>
|
||||||
|
</data>
|
||||||
|
<data name="checkSMTPGroupsAsContacts.Text" xml:space="preserve">
|
||||||
|
<value>Synchronise groups with addresses as contacts</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>checkSMTPGroupsAsContacts.Name" xml:space="preserve">
|
||||||
|
<value>checkSMTPGroupsAsContacts</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>checkSMTPGroupsAsContacts.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>checkSMTPGroupsAsContacts.Parent" xml:space="preserve">
|
||||||
|
<value>_layout</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>checkSMTPGroupsAsContacts.ZOrder" xml:space="preserve">
|
||||||
|
<value>1</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||||
|
<value>Fill</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
|
<value>2, 2</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.RowCount" type="System.Int32, mscorlib">
|
||||||
|
<value>2</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>256, 46</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.TabIndex" type="System.Int32, mscorlib">
|
||||||
|
<value>1</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>_layout.Name" xml:space="preserve">
|
||||||
|
<value>_layout</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>_layout.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>_layout.Parent" xml:space="preserve">
|
||||||
|
<value>$this</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>_layout.ZOrder" xml:space="preserve">
|
||||||
|
<value>0</value>
|
||||||
|
</data>
|
||||||
|
<data name="_layout.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
|
||||||
|
<value><?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="checkFaxNumbers" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="checkSMTPGroupsAsContacts" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,Absolute,20" /><Rows Styles="Percent,50,Percent,50" /></TableLayoutSettings></value>
|
||||||
|
</data>
|
||||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
|
||||||
<value>11, 24</value>
|
<value>6, 13</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.AutoSize" type="System.Boolean, mscorlib">
|
<data name="$this.AutoSize" type="System.Boolean, mscorlib">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
|
||||||
<value>6, 6, 6, 6</value>
|
|
||||||
</data>
|
|
||||||
<data name="$this.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
<data name="$this.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
|
||||||
<value>4, 4, 4, 4</value>
|
<value>2, 2, 2, 2</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>267, 37</value>
|
<value>260, 50</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>$this.Name" xml:space="preserve">
|
<data name=">>$this.Name" xml:space="preserve">
|
||||||
<value>GABSettings</value>
|
<value>GABSettings</value>
|
||||||
|
@ -26,6 +26,7 @@ namespace Acacia.Stubs
|
|||||||
{
|
{
|
||||||
string CustomerID { get; set; }
|
string CustomerID { get; set; }
|
||||||
|
|
||||||
|
string FileAs { get; set; }
|
||||||
string FullName { get; set; }
|
string FullName { get; set; }
|
||||||
string FirstName { get; set; }
|
string FirstName { get; set; }
|
||||||
string LastName { get; set; }
|
string LastName { get; set; }
|
||||||
|
@ -46,6 +46,12 @@ namespace Acacia.Stubs.OutlookWrappers
|
|||||||
set { _item.FullName = value; }
|
set { _item.FullName = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string FileAs
|
||||||
|
{
|
||||||
|
get { return _item.FileAs; }
|
||||||
|
set { _item.FileAs = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public string FirstName
|
public string FirstName
|
||||||
{
|
{
|
||||||
get { return _item.FirstName; }
|
get { return _item.FirstName; }
|
||||||
|
Loading…
Reference in New Issue
Block a user