## -*- coding: utf_8 -*- <% from fcp import fcpdefs from fcp import mlitem from fcutils import util from fcws.fcweb import webutil from extension import clib from cStringIO import StringIO %> <%namespace name="toolbar" file="toolbars.html" import="create"/> <% myMLItem = fcp.MyMLItem thisWebID = myMLItem.WebID() parentWebID = myMLItem.ParentWebID() windowTitle = webutil.stripNone(fcp, fcpdefs.dObjName) toolbar.create(fcp) fcJSON = '' sessionObject = client.FindServerObjectByObjID(fcpdefs.SESSIONDATAOBJID) clientTZ = client.clientTZ serverTZ = sessionObject.GetEscapedFormField(fcpdefs.serverTimeZone)[1] if serverTZ is None or serverTZ == 0: serverTZ = clientTZ = 0 #servObjList contains my calendar & punch through calendars if servObjList!=None and len(servObjList)>0: nCalendars=len(servObjList) jsonMLDSStr = StringIO() jsonMLDSStr.write('{"MYMLITEM":'+myMLItem.AsJSONArrayItem(mlitem.sendAll)+',"RIGHTS":'+str(fcp.rights)) jsonMLDSStr.write(',"CALENDARS":[') calendars = '' #punch through calendars: servObjList only has the ones that are being displayed but MLDSList has them all i = 0 mySubCalendar = fcp.GetNthMLItem(0) while mySubCalendar: if mySubCalendar.IsCalendar(): if calendars != '': calendars = calendars + ',' calendars = calendars + mySubCalendar.AsJSONArrayItem(mlitem.sendAll) i=i+1 mySubCalendar = fcp.GetNthMLItem(i) jsonMLDSStr.write(calendars + ']') jsonMLDSStr.write(',"NFILES":'+str(fcp.NFiles)+',"MLDS":[') for i in range(nCalendars): calendar = servObjList[i] if calendar.sortedMeetings!=None and len(calendar.sortedMeetings)>0: nEvents = len(calendar.sortedMeetings) for j in range(nEvents): item = calendar.sortedMeetings[j] if item: if item.Colour == 0: color = "#FFFFFF" else: color = item.Colour & 0xFFFFFFFF color = "#%06X" % (color>>8) mlItem = calendar.GetMLItemByWebID(item.WebID) if mlItem is not None: mtgStartDateServer = mlItem.GetField(fcpdefs.mtgStartDate,0) isRepeat = 'true' if mlItem.GetField(fcpdefs.mtgRepeatType,0)!=0 else 'false' #this is used together with webID to provide a unique index for tMLDS #have to make sure positive so that it is consistent with what notification gives us #when start=0, meeting sorter returns 1 so set it back to 0 mtgPositiveStart = item.MeetingStart & 0xFFFFFFFF if mtgPositiveStart == 1: mtgPositiveStart = 0 startofthisrepeat_clientTZ = startofthisrepeat_serverTZ = item.StartOfThisRepeat & 0xFFFFFFFF if clientTZ != serverTZ: startofthisrepeat_serverTZ = clib.ConvertTime(startofthisrepeat_clientTZ,clientTZ,serverTZ) #startofthisrepeat identifies a series of multiday day chunks that belong together (also for repeating events, see below) #startofthisrepeat_serverTZ is the original start time used for splitting events and also used in comparison to startoffirstrepeat to determine if event if first in series #duration is actual duration of the event (not 24hr chunks given by meetingsorter) needed for repeating multiday events that get updated from notification jsonObj = mlItem.AsJSONArrayItem(mlitem.sendAll) jsonObj = jsonObj.rstrip('}') jsonMLDSStr.write(jsonObj + ',"webid":"'+ str(item.WebID) + '-' + str(mtgPositiveStart) +'",') jsonMLDSStr.write('"id":"'+ str(item.WebID) + '-' + str(mtgPositiveStart) +'",') jsonMLDSStr.write('"start_date":' + str(mtgPositiveStart) + ',') jsonMLDSStr.write('"end_date":' + str(mtgPositiveStart + (item.Duration & 0xFFFFFFFF)) + ',') jsonMLDSStr.write('"startoffirstrepeat":' + str(mtgStartDateServer) + ',') jsonMLDSStr.write('"isRepeat":' + str(isRepeat) + ',') jsonMLDSStr.write('"startofthisrepeat":' + str(startofthisrepeat_clientTZ) + ',') jsonMLDSStr.write('"startofthisrepeat_serverTZ":' + str(startofthisrepeat_serverTZ) + ',') jsonMLDSStr.write('"multidayevent":' + str(item.MultidayEvent) + ',') jsonMLDSStr.write('"color":"' + str(color) + '"},') fcJSON = jsonMLDSStr.getvalue().encode('utf8') jsonMLDSStr.close() lenJsonString = len(fcJSON) if fcJSON[lenJsonString-1]==',': fcJSON = fcJSON[0:lenJsonString-1] fcJSON = fcJSON +']}' %>