## -*- coding: utf_8 -*-
<%
from fcp import connection
from fcp import fcpdefs
from fcutils import util
from fcp import mlitem
from fcws.fcweb import webutil
import time
%>
<%namespace name="fcnames" file="fcnames.html" import="renderFCNames"/>
<%
def AddEmail(fcpSession,where,servObj,email,index):
objID = servObj.objID
operation = fcpdefs.nvInsert
cmd = fcpdefs.cNameValidate
options = fcpdefs.nvIncLocalNames | fcpdefs.nvIncRemoteNames | fcpdefs.nvIncConferences | fcpdefs.nvIncAddrBook
nameValidateReq = None
cid = 0
cids = None
nItems = None
result, servObj.dirListObj, status = fcpSession.NameLookUp(nameValidateReq, cmd, objID, where, index, operation, options, email, cid, cids, nItems)
if status == 'done':
if result and servObj.dirListObj:
''' Multi-match - returns the actual Directory object that holds multiple names - not allowed'''
fcpSession.CloseObject(servObj.dirListObj.objID)
servObj.dirListObj = None
elif result and servObj.dirListObj is None:
''' Single-match or None '''
servObj.AddMsgName(where, result[0], index)
myMLItem = fcp.MyMLItem
name,email = util.SplitNameAndEmail(myMLItem.name)
''' The following can happen ONLY when we are adding a contact from an existing email.
Otherwise the name must not contain an email. '''
if email:
AddEmail(client,fcpdefs.dCopyName, fcp, email, 0)
if name and name!=myMLItem.name:
myMLItem.SetField(fcpdefs.dObjName,fcpdefs.fdString,name)
client.SendFieldDataToServer(fcp,fcpdefs.dObjName,fcpdefs.fdString,0,name,0)
f,m,l = util.ParseName(name)
if f:
myMLItem.SetField(1006,fcpdefs.fdString,f)
client.SendFieldDataToServer(fcp,1006,fcpdefs.fdString,0,f,0)
if m:
myMLItem.SetField(1008,fcpdefs.fdString,m)
client.SendFieldDataToServer(fcp,1008,fcpdefs.fdString,0,m,0)
if l:
myMLItem.SetField(1014,fcpdefs.fdString,l)
client.SendFieldDataToServer(fcp,1014,fcpdefs.fdString,0,l,0)
parentID = myMLItem.ParentWebID()
thisWebID = myMLItem.WebID()
jsonStr = fcp.MeAsJSON((client.serverTZ,client.clientTZ))
isEditable = True if fcp.rights & fcpdefs.acWrite else False
firstN = webutil.stripNone(fcp,1006)
middleN = webutil.stripNone(fcp,1008)
lastN = webutil.stripNone(fcp,1014)
picExists = myMLItem.FieldExists(1001)
if picExists:
picURL = '/FCP/' + fcpdefs.DESKTOPWEBID + '/' + parentID + '/' + thisWebID + '?ImageField=' + str(fcpdefs.dThumbnail) + '&ts=' + str(int(time.time()))
picTitle = util.html_escape(firstN + ' ' + middleN + ' ' + lastN)
picHTML = ''
else:
picHTML = '
'
windowTitle = webutil.stripNone(fcp,8010)
if name:
theQN = name
else:
theQN = '' if (myMLItem.GetEStatus() & fcpdefs.ItemIsNew) else windowTitle
body = fcp.body if fcp.body is not None else ""
toNames = fcp.GetMsgNameList(fcpdefs.dToName)
numToNames = len(toNames) if toNames else 0
toNameID = 'fcfid-'+str(fcpdefs.dToName)
ccNames = fcp.GetMsgNameList(fcpdefs.dCopyName)
numCcNames = len(ccNames) if ccNames else 0
ccNameID = 'fcfid-'+str(fcpdefs.dCopyName)
attachClasses = 'fc-form-row multiline'
if fcp.GetNthMLItem(0) is None:
attachClasses += ' fc-mouse-only'
%>