1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * Creates a personna. 26 * @class 27 * This class represents a personna. 28 * 29 * @param {ZmIdentity} identity the identity 30 * @param {Object} list the list 31 * @extends ZmAccount 32 */ 33 ZmPersona = function(identity, list) { 34 if (arguments.length == 0) { return; } 35 36 ZmAccount.call(this, ZmAccount.TYPE_PERSONA, identity.id, null, list); 37 38 identity.sendFromDisplay = identity.sendFromDisplay || appCtxt.get(ZmSetting.DISPLAY_NAME); 39 identity.sendFromAddress = identity.sendFromAddress || appCtxt.get(ZmSetting.USERNAME); 40 identity.sendFromAddressType = identity.sendFromAddressType || ZmSetting.SEND_AS; 41 this.identity = identity; 42 }; 43 ZmPersona.prototype = new ZmAccount; 44 ZmPersona.prototype.constructor = ZmPersona; 45 46 ZmPersona.prototype.toString = 47 function() { 48 return "ZmPersona"; 49 }; 50 51 52 // 53 // Public methods 54 // 55 56 ZmPersona.prototype.setName = 57 function(name) { 58 this.getIdentity().name = AjxStringUtil.htmlEncode(name); 59 }; 60 61 ZmPersona.prototype.getName = 62 function() { 63 return AjxStringUtil.htmlDecode(this.getIdentity().name); 64 }; 65 66 ZmPersona.prototype.setEmail = 67 function(email) { 68 this.getIdentity().sendFromAddress = email; 69 }; 70 71 ZmPersona.prototype.getEmail = 72 function() { 73 return this.getIdentity().sendFromAddress; 74 }; 75 76 ZmPersona.prototype.getIdentity = 77 function() { 78 return this.identity; 79 }; 80 81 ZmPersona.prototype.create = 82 function(callback, errorCallback, batchCmd) { 83 return this.getIdentity().create(callback, errorCallback, batchCmd); 84 }; 85 86 ZmPersona.prototype.save = 87 function(callback, errorCallback, batchCmd) { 88 return this.getIdentity().save(callback, errorCallback, batchCmd); 89 }; 90 91 ZmPersona.prototype.doDelete = 92 function(callback, errorCallback, batchCmd) { 93 return this.getIdentity().doDelete(callback, errorCallback, batchCmd); 94 }; 95