Ext.namespace("Zarafa.plugins.contactfax");
Zarafa.plugins.contactfax.ContactFax=Ext.extend(Zarafa.core.Plugin,{model:void 0,initPlugin:function(){Zarafa.plugins.contactfax.ContactFax.superclass.initPlugin.apply(this,arguments);this.registerInsertionPoint("context.contact.contextmenu.actions",this.createSendFaxContextItem,this)},getMailContextModel:function(){if(!this.model){var a=container.getHierarchyStore().getDefaultFolder("drafts");this.model=container.getContextByFolder(a).getModel()}return this.model},convertToFaxRecipient:function(a,
e){for(var f=["business_fax_number","home_fax_number","primary_fax_number"],d=[],b=0;4>b;b++)if(!Ext.isEmpty(e.get(f[b]))){var c=e.get(f[b])+"@"+container.getSettingsModel().get(this.getSettingsBase()+"/faxdomain"),c={entryid:Zarafa.core.EntryId.wrapContactProviderEntryId(e.get("entryid"),Zarafa.core.mapi.ObjectType.MAPI_MAILUSER),object_type:Zarafa.core.mapi.ObjectType.MAPI_MAILUSER,display_type:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_type_ex:Zarafa.core.mapi.DisplayType.DT_MAILUSER,display_name:e.get("display_name")+
" ("+c+")",smtp_address:c,email_address:c,address_type:"SMTP",recipient_type:a||Zarafa.core.mapi.RecipientType.MAPI_TO};d.push(Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.ZARAFA_RECIPIENT,c))}return d},openFaxMailCreateDialogForContacts:function(a,e){var f=this.getMailContextModel().createRecord(),d=f.getRecipientStore();a=Ext.isArray(a)?a:[a];for(var b=0,c=a.length;b<c;b++){var g=this.convertToFaxRecipient(Zarafa.core.mapi.RecipientType.MAPI_TO,
a[b]);d.add(g)}0<d.getCount()&&Zarafa.core.data.UIFactory.openCreateRecord(f)},hasFaxAddress:function(a){return!Ext.isEmpty(a.get("business_fax_number"))||!Ext.isEmpty(a.get("home_fax_number"))||!Ext.isEmpty(a.get("primary_fax_number"))},createSendFaxContextItem:function(){return{text:_("Send Fax"),iconCls:"icon_fax",scope:this,handler:function(a){this.openFaxMailCreateDialogForContacts(a.parentMenu.records)},beforeShow:function(a,e){for(var f=!1,d=0,b=e.length;d<b;d++){var c=e[d];if(!c.isMessageClass("IPM.Contact")||
this.hasFaxAddress(c)){f=!0;break}}a.setVisible(f)}}}});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"contactfax",displayName:_("Contact Fax"),pluginConstructor:Zarafa.plugins.contactfax.ContactFax}))});//# sourceMappingURL=contactfax.js.map
