def header(db): print 'Content-type: text/html\n\n' fd = open('resources/header.html', 'r') print fd.read() fd.close() fd = open('resources/topnav.html', 'r') print fd.read() fd.close() print '<a href="?action=viewarchive">Last 24 hours</a>' if account.getAdmin(db): print ' | <a href="?action=listall">List all subscriptions</a> |' print '<a href="?action=listfields">Edit filter fields</a>' print '</div>' print '</div>' print '<hr />' print '<div class="notify">'
def showModifyForm(db, recordid): action = 'update' if recordid == -1: eventType = '' param = account.getUser() action = 'add' name = '' defaultfilters = True else: sub = account.getSubscription(db, recordid) sub = sub.fetch_row() eventType = sub[0][1] param = sub[0][2] name = sub[0][3] defaultfilters = False print '''<form action="" name="modifyForm" method="POST"> <input type="hidden" name="action" value="''' + action + '''" />''' if not recordid == -1: print '<input type="hidden" name="id" value="' + str(recordid) + '" />' print '''<table> <tr> <td>Name:</td> <td><input type="text" name="name" value="''' + name + '''" /></td> </tr> <tr> <td>Notification type:</td> <td><select name="eventType" onChange="disableAddress()">''' db.query('SELECT field FROM eventTypes WHERE type="event" AND admin=0') res = db.store_result() for type in res.fetch_row(0): if type[0] == eventType: print '<option selected>' + type[0] + '</option>\n' else: print '<option>' + type[0] + '</option>\n' if account.getAdmin(db): db.query('SELECT field FROM eventTypes WHERE type="event" AND admin=1') res = db.store_result() for type in res.fetch_row(0): if type[0] == eventType: print '<option selected>' + type[0] + '</option>\n' else: print '<option>' + type[0] + '</option>\n' print '</select></td></tr>' print ''' <tr> <td>Address:</td> <td><input type="text" name="param" value="''' + param + '''" /></td> </tr>''' res = account.getFilters(db, recordid, defaultfilters) res = res.items() res.sort() for field in res: dict = {} dict['name'] = field[0] dict['value'] = field[1][0] dict['ignore'] = field[1][1] if dict['ignore'] == 1: dict['ignore'] = 'checked ' else: dict['ignore'] = '' print '''<tr> <td>%(name)s</td> <td><input type="text" name="filter-%(name)s" value="%(value)s" /><input type="checkbox" name="ignore-%(name)s" %(ignore)s/></td> </tr>''' % dict print '''