def form_editForm(self, data): domains = [] if self.avatarId.isAdmin: for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) # Form population userData = self.lc.getUser(self.cid) devList = [] #extList = [] rouList = [] UserExtForm = [] fkeyForm = [] if Settings.sambaDN and self.domain == Settings.defaultDomain and PBXUtils.enabled( ): includeList = [] includeList = self.sysconf.PBXExtensions.get( userData['uid'][0], {'extensions': []})['extensions'] devIncList = self.sysconf.PBXExtensions.get( userData['uid'][0], {'devices': []})['devices'] extList = PBXUtils.getAvaExtenNumSelect(True, includeList) #for ext in PBXUtils.getAvailibleExtensions(): # extList.append((str(ext), str(ext))) for dev in PBXUtils.getAllAvaExtDeviceEndPoints(devIncList): devList.append((str(dev), str(dev))) queueList = [ (queue, queue) for queue in self.sysconf.PBX.get('queues', {}).keys() ] rouList = self.sysconf.PBXRouters.keys() extensionWidget = formal.widgetFactory(formal.SelectChoice, options=extList) deviceWidget = formal.widgetFactory(formal.SelectChoice, options=devList) #queueWidget = formal.widgetFactory(formal.SelectChoice, options = queueList) userExtensions = PBXUtils.getExtensionSelect() queueOptions = formal.widgetFactory(formal.SelectChoice, options=[(1, "Level 1 Member"), (2, "Level 2 Member"), (3, "Level 3 Member") ]) queues = [] for queue in self.sysconf.PBX.get('queues', {}).keys()[0:-1]: queues.append( formal.Field('queue%s' % queue, formal.Integer(), queueOptions, label="Queue %s" % queue)) try: queue = self.sysconf.PBX.get('queues', {}).keys()[-1] except: queue = None if queue: queues.append( formal.Field( 'queue%s' % queue, formal.Integer(), queueOptions, label="Queue %s" % queue, description= "Each extension may be part of many queues, each queue membersip has a specific weighting. The weighting determines the order in which calls may be seeded. Level 2 members only get calls seeded to them once Level 1 has been saturated etc." )) fKeyOptions = formal.widgetFactory(formal.SelectChoice, options=userExtensions) fKeys = [] maxKeys = 54 for i in range(maxKeys): fKeys.append( formal.Field('fkeys%s' % i, formal.String(), fKeyOptions, label="Key %s" % i)) fKeys.append( formal.Field( 'fkeys%s' % maxKeys, formal.String(), fKeyOptions, label="Key %s" % maxKeys, description= "Select the extensions for the function keys above")) userExtFormContent = [ formal.Field('userExtEnabled', formal.Boolean(), label=self.text.userFormLabelExtEnabled), formal.Field('userExtOutbound', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options=[(i, i) for i in rouList]), label=self.text.userFormLabelOutbound, description=self.text.userFormDescOutbound), #formal.Field('userExtQueues', formal.Sequence(formal.String()), # formal.widgetFactory(formal.CheckboxMultiChoice, # options = queueList), # label = self.text.userFormLabelQueues, # description = self.text.userFormDescQueues), ] userExtFormContent.extend(queues) userExtFormContent.extend([ formal.Field( 'userLowBW', formal.Boolean(), label="Low Bandwidth", description= 'Indicates that the devices(if applicable) should use a low bandwidth codec' ), formal.Field( 'userExtTimeout', formal.Integer(), label="Timeout", description= "How many seconds should we wait before giving up on this extension, note that setting this to 0 will force the extension to use the default timeout" ), formal.Field( 'userExtqTimeout', formal.Integer(), label="Queue Timeout", description= "How many seconds should we wait before giving up on this queue member, 0 will indicate to use the default" ), formal.Field('userExtCallerID', formal.String(), label=self.text.userFormLabelCallID), formal.Field('userExtNumber0', formal.String(), extensionWidget, label=self.text.userFormLabelExtNumber), formal.Field('userExtNumber1', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber2', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber3', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber4', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber5', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber6', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber7', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber8', formal.String(), extensionWidget, label=""), formal.Field('userExtNumber9', formal.String(), extensionWidget, label=""), tags.div(_class="userLine")[tags.a( href="#", onclick="addExten();")[self.text.userFormLabelAddExt]], #formal.Field('userExtFwdUA', formal.String(), label = self.text.userFormLabelRedNoAnswer, # description = self.text.userFormDescRedNoAnswer), formal.Field('userExtDev0', formal.String(), deviceWidget, label=self.text.userFormLabelDev), formal.Field('userExtDev1', formal.String(), deviceWidget, label=""), formal.Field('userExtDev2', formal.String(), deviceWidget, label=""), formal.Field('userExtDev3', formal.String(), deviceWidget, label=""), formal.Field('userExtDev4', formal.String(), deviceWidget, label=""), formal.Field('userExtDev5', formal.String(), deviceWidget, label=""), formal.Field('userExtDev6', formal.String(), deviceWidget, label=""), formal.Field('userExtDev7', formal.String(), deviceWidget, label=""), formal.Field('userExtDev8', formal.String(), deviceWidget, label=""), formal.Field('userExtDev9', formal.String(), deviceWidget, label=""), tags.div(_class="userLine")[tags.a( href="#", onclick="addExtDev();")[self.text.userFormLabelAddDev]], formal.Field('userExtVoiceMail', formal.Boolean(), label=self.text.userFormLabelVoiceMail), formal.Field('userExtVoiceMailPin', formal.String(), label=self.text.userFormLabelVoiceMailPin), ]) UserExtForm = formal.Group('userExtension')[userExtFormContent] fkeyForm = formal.Group('userFKeys')[fKeys] form = formal.Form( self.submitForm )[formal.Group('userSettings')[tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")["%s@%s" % (self.cid, self.domain)]], formal.Field('uid', formal .String(required=True, validators=Base .UserNameValidators), label=self.text. userFormLabelUsername), formal.Field('givenName', formal.String( required=True), label=self.text. userFormLabelName), formal.Field('sn', formal.String(), label=self.text. userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label=self.text. userFormLabelPass), ], formal.Group('mailSettings') [formal.Field('mailForwardingAddress0', formal.String(), label=self. text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addForward();" )[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div( _class="userLine")[tags.a(href="#", onclick="addAlias();" )[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label=self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), formal.Field('vacvalidity', formal.Date(), label="Valid until", description= "Disable the vacation note automatically on this date" )], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label=self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label=self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label=self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [( i, i) for i in domains]), label=self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label=self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label=self.text.userFormLabelCopy, description=self.text.userFormTextCopy)], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label=self.text.userFormLabelVPN, description=self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label=self.text.userFormLabelFTP, description=self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label=self.text.userFormLabelGlobalFTP, description=self.text.userFormTextGlobal)], UserExtForm, fkeyForm] form.addAction(self.submitForm) tData = copy.deepcopy(userData) tData['userSettings.uid'] = tData['uid'][0] tData['userSettings.givenName'] = tData.get('givenName', [""])[0] tData['userSettings.sn'] = tData.get('sn', [""])[0] if tData.get('loginShell'): if '/bin/bash' in tData['loginShell']: tData['userAccess.ftpEnabled'] = True if self.sysconf.FTP.get('globals'): if tData['uid'][0] in self.sysconf.FTP['globals']: tData['userAccess.ftpGlobal'] = True tData['userSettings.userPassword'] = '' # Strip password address = "%s@%s" % (tData['uid'][0], self.domain) for i in os.listdir('/etc/openvpn/keys/'): if "%s.%s" % (self.cid, self.domain) in i and "key" in i: tData['userAccess.vpnEnabled'] = True if self.sysconf.Mail.get('copys', []): for addr, dest in self.sysconf.Mail['copys']: if addr == address: tData['userPermissions.copyto'] = dest if userData.get('accountStatus', False): tData['userPermissions.accountStatus'] = True else: tData['userPermissions.accountStatus'] = False if userData.get('mailForwardingAddress', False): for cnt, address in enumerate(userData['mailForwardingAddress']): tData['mailSettings.mailForwardingAddress%s' % cnt] = address if userData.get('mailAlternateAddress', False): for cnt, address in enumerate(userData['mailAlternateAddress']): tData['mailSettings.mailAlternateAddress%s' % cnt] = address emp = userData.get('employeeType', [False]) if 'squid' in emp: tData['userPermissions.employeeType'] = True else: tData['userPermissions.employeeType'] = False if 'tumsAdmin' in emp: tData['userPermissions.tumsAdmin'] = True else: tData['userPermissions.tumsAdmin'] = False if 'tumsReports' in emp: tData['userPermissions.tumsReports'] = True else: tData['userPermissions.tumsReports'] = False if emp[0]: for i in emp: if 'tumsUser[' in i: tData['userPermissions.tumsUser'] = i.split('[')[-1].split( ']')[0].split(',') try: vac = open( "/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = True except: pass # No vacation note try: vac = open( "/var/spool/mail/vacation/DISABLED%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = False except: pass # No disabled note either. if os.path.exists('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)): n = open('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)).read().strip('\n') d = datetime.date(*[int(i) for i in n.split('-')]) tData['mailSettings.vacvalidity'] = d #Populate Userextension Data if PBXUtils.enabled(): ext = self.sysconf.PBXExtensions.get( tData['uid'][0], { 'enabled': False, 'lowbw': False, 'outbound': [], 'callerID': "", 'voiceMail': False, 'voiceMailPin': '', 'fkeys': [], 'extensions': [], 'devices': [], 'queues': {} }) tData['userExtension.userExtEnabled'] = ext['enabled'] tData['userExtension.userExtOutbound'] = ext['outbound'] tData['userExtension.userExtTimeout'] = ext.get('timeout', 0) tData['userExtension.userExtqTimeout'] = ext.get('qtimeout', 0) #tData['userExtension.userExtQueues'] = ext.get('queues', []) queueSettings = ext.get('queues', {}) if type(queueSettings) == list: n = {} for queue in queueSettings: n[queue] = 1 queueSettings = n for queue in self.sysconf.PBX.get('queues', {}).keys(): tData['userExtension.queue%s' % queue] = queueSettings.get( queue, None) tData['userExtension.userExtCallerID'] = ext['callerID'] tData['userExtension.userExtVoiceMail'] = ext['voiceMail'] tData['userExtension.userExtVoiceMailPin'] = ext['voiceMailPin'] tData['userExtension.userLowBW'] = ext.get('lowbw', False) for i in range(0, 9): try: tData['userExtension.userExtNumber%s' % i] = ext['extensions'][i] except: pass try: tData['userExtension.userExtDev%s' % i] = ext['devices'][i] except: pass for i in range(54): try: tData['userFKeys.fkeys%s' % i] = ext['fkeys'][i] except: pass form.data = tData return form
def form_editForm(self, data): domains = [] if self.avatarId.isAdmin: for i in self.flatFil: thisdom = i.split('dm=')[-1].split(',')[0] if not thisdom in domains: domains.append(thisdom) # Form population userData = self.lc.getUser(self.cid) devList = [] #extList = [] rouList = [] UserExtForm = [] fkeyForm = [] if Settings.sambaDN and self.domain==Settings.defaultDomain and PBXUtils.enabled(): includeList = [] includeList = self.sysconf.PBXExtensions.get(userData['uid'][0], {'extensions':[]})['extensions'] extList = PBXUtils.getAvaExtenNumSelect(True, includeList) #for ext in PBXUtils.getAvailibleExtensions(): # extList.append((str(ext), str(ext))) for dev in PBXUtils.getAllAvaExtDeviceEndPoints(): devList.append((str(dev), str(dev))) queueList = [(queue, queue) for queue in self.sysconf.PBX.get('queues', {}).keys()] rouList = self.sysconf.PBXRouters.keys() extensionWidget = formal.widgetFactory(formal.SelectChoice, options = extList) deviceWidget = formal.widgetFactory(formal.SelectChoice, options = devList) #queueWidget = formal.widgetFactory(formal.SelectChoice, options = queueList) userExtensions = PBXUtils.getExtensionSelect() fKeyOptions = formal.widgetFactory(formal.SelectChoice, options = userExtensions) fKeys = [] maxKeys = 11 for i in range(maxKeys): fKeys.append(formal.Field('fkeys%s' % i, formal.String(), fKeyOptions, label = "Key %s" % i)) fKeys.append(formal.Field('fkeys%s'%maxKeys, formal.String(), fKeyOptions, label = "Key %s"%maxKeys, description = "Select the extensions for the function keys above")) UserExtForm = formal.Group('userExtension')[ formal.Field('userExtEnabled', formal.Boolean(), label = self.text.userFormLabelExtEnabled), formal.Field('userExtOutbound', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options=[(i,i) for i in rouList]), label = self.text.userFormLabelOutbound, description = self.text.userFormDescOutbound), formal.Field('userExtQueues', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, options = queueList), label = self.text.userFormLabelQueues, description = self.text.userFormDescQueues), formal.Field('userExtCallerID', formal.String(), label = self.text.userFormLabelCallID), formal.Field('userExtNumber0', formal.String(), extensionWidget, label = self.text.userFormLabelExtNumber), formal.Field('userExtNumber1', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber2', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber3', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber4', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber5', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber6', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber7', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber8', formal.String(), extensionWidget,label = ""), formal.Field('userExtNumber9', formal.String(), extensionWidget,label = ""), tags.div(_class="userLine")[tags.a(href="#", onclick="addExten();")[self.text.userFormLabelAddExt]], formal.Field('userExtFwdUA', formal.String(), label = self.text.userFormLabelRedNoAnswer, description = self.text.userFormDescRedNoAnswer), formal.Field('userExtDev0', formal.String(), deviceWidget,label = self.text.userFormLabelDev), formal.Field('userExtDev1', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev2', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev3', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev4', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev5', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev6', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev7', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev8', formal.String(), deviceWidget,label = ""), formal.Field('userExtDev9', formal.String(), deviceWidget,label = ""), tags.div(_class="userLine")[tags.a(href="#", onclick="addExtDev();")[self.text.userFormLabelAddDev]], formal.Field('userExtVoiceMail', formal.Boolean(), label = self.text.userFormLabelVoiceMail), formal.Field('userExtVoiceMailPin', formal.String(), label = self.text.userFormLabelVoiceMailPin), ] fkeyForm = formal.Group('userFKeys')[fKeys] form = formal.Form(self.submitForm)[ formal.Group('userSettings')[ tags.div(_class="field")[ tags.label[self.text.userFormLabelEmailAddress], tags.div(id="emailAd", _class="inputs")[ "%s@%s"% (self.cid, self.domain) ] ], formal.Field('uid', formal.String(required=True), label = self.text.userFormLabelUsername), formal.Field('givenName', formal.String(required=True), label = self.text.userFormLabelName), formal.Field('sn', formal.String(), label = self.text.userFormLabelSurname), formal.Field('userPassword', formal.String(), formal.CheckedPassword, label= self.text.userFormLabelPass), ], formal.Group('mailSettings')[ formal.Field('mailForwardingAddress0', formal.String(), label=self.text.userFormLabelForward), formal.Field('mailForwardingAddress1', formal.String(), label=""), formal.Field('mailForwardingAddress2', formal.String(), label=""), formal.Field('mailForwardingAddress3', formal.String(), label=""), formal.Field('mailForwardingAddress4', formal.String(), label=""), formal.Field('mailForwardingAddress5', formal.String(), label=""), formal.Field('mailForwardingAddress6', formal.String(), label=""), formal.Field('mailForwardingAddress7', formal.String(), label=""), formal.Field('mailForwardingAddress8', formal.String(), label=""), formal.Field('mailForwardingAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addForward();")[self.text.userFormLabelAddline]], formal.Field('mailAlternateAddress0', formal.String(), label=self.text.userFormLabelAlias), formal.Field('mailAlternateAddress1', formal.String(), label=""), formal.Field('mailAlternateAddress2', formal.String(), label=""), formal.Field('mailAlternateAddress3', formal.String(), label=""), formal.Field('mailAlternateAddress4', formal.String(), label=""), formal.Field('mailAlternateAddress5', formal.String(), label=""), formal.Field('mailAlternateAddress6', formal.String(), label=""), formal.Field('mailAlternateAddress7', formal.String(), label=""), formal.Field('mailAlternateAddress8', formal.String(), label=""), formal.Field('mailAlternateAddress9', formal.String(), label=""), tags.div(_class="userLine")[tags.a(href="#", onclick="addAlias();")[self.text.userFormLabelAddline]], formal.Field('vacen', formal.Boolean(), label = self.text.userFormLabelVacationActive, description=self.text.userFormTextVacationNote), formal.Field('vacation', formal.String(), formal.TextArea, label=self.text.userFormLabelVacation), formal.Field('vacvalidity', formal.Date(), label = "Valid until", description="Disable the vacation note automatically on this date") ], formal.Group('userPermissions')[ formal.Field('employeeType', formal.Boolean(), label = self.text.userFormLabelWeb), formal.Field('accountStatus', formal.Boolean(), label = self.text.userFormLabelEmail), formal.Field('tumsAdmin', formal.Boolean(), label = self.text.userFormLabelAdmin), formal.Field('tumsUser', formal.Sequence(formal.String()), formal.widgetFactory(formal.CheckboxMultiChoice, [(i,i) for i in domains]), label = self.text.userFormLabelDomainAdmin), formal.Field('tumsReports', formal.Boolean(), label = self.text.userFormLabelReports), formal.Field('copyto', formal.String(), label = self.text.userFormLabelCopy, description = self.text.userFormTextCopy) ], formal.Group('userAccess')[ formal.Field('vpnEnabled', formal.Boolean(), label = self.text.userFormLabelVPN, description = self.text.userFormTextVPN), formal.Field('ftpEnabled', formal.Boolean(), label = self.text.userFormLabelFTP, description = self.text.userFormTextFTP), formal.Field('ftpGlobal', formal.Boolean(), label = self.text.userFormLabelGlobalFTP, description = self.text.userFormTextGlobal) ], UserExtForm, fkeyForm ] form.addAction(self.submitForm) tData = copy.deepcopy(userData) tData['userSettings.uid'] = tData['uid'][0] tData['userSettings.givenName'] = tData.get('givenName', [""])[0] tData['userSettings.sn'] = tData.get('sn', [""])[0] if tData.get('loginShell'): if '/bin/bash' in tData['loginShell']: tData['userAccess.ftpEnabled'] = True if self.sysconf.FTP.get('globals'): if tData['uid'][0] in self.sysconf.FTP['globals']: tData['userAccess.ftpGlobal'] = True tData['userSettings.userPassword'] = '' # Strip password address = "%s@%s" % (tData['uid'][0], self.domain) for i in os.listdir('/etc/openvpn/keys/'): if "%s.%s" % (self.cid, self.domain) in i and "key" in i: tData['userAccess.vpnEnabled'] = True if self.sysconf.Mail.get('copys', []): for addr, dest in self.sysconf.Mail['copys']: if addr == address: tData['userPermissions.copyto'] = dest if userData.get('accountStatus', False): tData['userPermissions.accountStatus'] = True else: tData['userPermissions.accountStatus'] = False if userData.get('mailForwardingAddress', False): for cnt,address in enumerate(userData['mailForwardingAddress']): tData['mailSettings.mailForwardingAddress%s' % cnt] = address if userData.get('mailAlternateAddress', False): for cnt,address in enumerate(userData['mailAlternateAddress']): tData['mailSettings.mailAlternateAddress%s' % cnt] = address emp = userData.get('employeeType', [False]) if 'squid' in emp: tData['userPermissions.employeeType'] = True else: tData['userPermissions.employeeType'] = False if 'tumsAdmin' in emp: tData['userPermissions.tumsAdmin'] = True else: tData['userPermissions.tumsAdmin'] = False if 'tumsReports' in emp: tData['userPermissions.tumsReports'] = True else: tData['userPermissions.tumsReports'] = False if emp[0]: for i in emp: if 'tumsUser[' in i: tData['userPermissions.tumsUser'] = i.split('[')[-1].split(']')[0].split(',') try: vac = open("/var/spool/mail/vacation/%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = True except: pass # No vacation note try: vac = open("/var/spool/mail/vacation/DISABLED%s@%s.txt" % (self.cid, self.domain), 'r') tData['mailSettings.vacation'] = vac.read() tData['mailSettings.vacen'] = False except: pass # No disabled note either. if os.path.exists('/var/spool/mail/vacation/%s@%s.validity' % (self.cid, self.domain)): n = open('/var/spool/mail/vacation/%s@%s.validity'% (self.cid, self.domain)).read().strip('\n') d = datetime.date(*[int(i) for i in n.split('-')]) tData['mailSettings.vacvalidity'] = d #Populate Userextension Data if PBXUtils.enabled(): ext = self.sysconf.PBXExtensions.get(tData['uid'][0], { 'enabled': False, 'outbound': [], 'callerID': "", 'voiceMail': False, 'voiceMailPin': '', 'fkeys': [], 'extensions': [], 'devices': [], 'queues': [] }) tData['userExtension.userExtEnabled'] = ext['enabled'] tData['userExtension.userExtOutbound'] = ext['outbound'] tData['userExtension.userExtQueues'] = ext.get('queues', []) tData['userExtension.userExtCallerID'] = ext['callerID'] tData['userExtension.userExtVoiceMail'] = ext['voiceMail'] tData['userExtension.userExtVoiceMailPin'] = ext['voiceMailPin'] for i in range(0,9): try: tData['userExtension.userExtNumber%s'%i]=ext['extensions'][i] except: pass try: tData['userExtension.userExtDev%s'%i]=ext['devices'][i] except: pass for i in range(12): try: tData['userFKeys.fkeys%s'%i] = ext['fkeys'][i] except: pass form.data = tData return form