/[theodore]/bunnyblog/modules/logintools/admin.py


UCC Code Repository

Contents of /bunnyblog/modules/logintools/admin.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download) (as text)
Tue Jan 29 14:32:01 2008 UTC (12 years, 2 months ago) by svn-admin
File MIME type: text/x-python
File size: 25611 byte(s)
Re-import of repository after repository database corruption.

1 # admin.py
2 # part of logintools
3 # A CGI Authentication and user account system
4 # Copyright (C) 2004/2005 Michael Foord
5 # E-mail: fuzzyman AT voidspace DOT org DOT uk
6
7 # Released subject to the BSD License
8 # Please see http://www.voidspace.org.uk/documents/BSD-LICENSE.txt
9
10 # Scripts maintained at http://www.voidspace.org.uk/python/index.shtml
11 # Comments, suggestions and bug reports welcome.
12
13 # For information about bugfixes, updates and support, please join the Pythonutils mailing list.
14 # http://voidspace.org.uk/mailman/listinfo/pythonutils_voidspace.org.uk
15 # Comments, suggestions and bug reports welcome.
16
17 import sys
18 import os
19 sys.path.append('../modules')
20 from configobj import ConfigObj
21 from pathutils import *
22 from cgiutils import *
23 from loginutils import *
24
25 ###################################################
26
27 def cSort(inlist, minisort=True):
28 """A case insensitive sort. If minisort is True then elements of the list for which element1.lower() == element2.lower() will also be sorted.
29 (See the examples/test stuff."""
30 sortlist = []
31 newlist = []
32 sortdict = {}
33 for entry in inlist:
34 try:
35 lentry = entry.lower()
36 except AttributeError:
37 sortlist.append(lentry)
38 else:
39 try:
40 sortdict[lentry].append(entry)
41 except KeyError:
42 sortdict[lentry] = [entry]
43 sortlist.append(lentry)
44
45 sortlist.sort()
46 for entry in sortlist:
47 try:
48 thislist = sortdict[entry]
49 if minisort: thislist.sort()
50 newlist = newlist + thislist
51 except KeyError:
52 newlist.append(entry)
53 return newlist
54
55
56 ####################################################
57 # Various default values etc
58
59 adminpage_file = 'admin_page.html'
60 adminmenu_file = 'admin_menu.txt'
61 adminconfig_file = 'admin_config.txt' # the template used for the 'edit config' option.
62 admininvite_file = 'admin_invite.txt' # the template to invite/create new users
63 adminuser_file = 'admin_eduser.txt' # template for edit/delete user
64
65 MAXADMINLEV = 3 # the maximum admin level it's possible for a user to have
66 MINMAXAGE = 600 # the minimum value for cookie max-age
67
68 pass_msg = '\nYour login name is "%s", your password is "%s".\nYou can change this once you have logged in.\n'
69 SCRIPTLOC = 'http://' + os.environ.get('HTTP_HOST', '') # XXXX do we trust this in all cases ? (i.e. not always http - https)
70 numonpage = 5 # number of users shown on a page at a time
71
72 # table elements used to display the accounts in edit users
73 edit_table_s = '<table width="90%" cellspacing="15" bgcolor="#3377bb" class="table">'
74 table_e = '</table>'
75 elem_h = '<tr><td align="center"><table border="4" width="100%" bgcolor="#dddddd">'
76 elem_f = '</table></td></tr>'
77 form_s = '''<form method="post" action="%s"><input type="hidden" name="login" value="admin">
78 <input type="hidden" name="action" value="%s"><input type="hidden" name="admin" value="%s">
79 <input type="hidden" name="start" value="%s"><input type="hidden" name="username" value="%s">
80 '''
81 form_e = '</form>'
82
83 account_table = form_s + '''<tr>
84 <td align="center"><strong>Login Name : </strong></td><td align="center"><input type="text" name="loginname" value="%s"></td>
85 <td align="center"><strong>Real Name : </strong></td><td align="center"><input type="text" name="realname" value="%s"></td></tr><tr>
86 <td align="center"><strong>Email : </strong></td><td align="center"><input type="text" name="email" value="%s"></td>
87 <td align="center"><strong>Admin Level</strong></td><td align="center"><input type="text" name="adminlev" value="%s"></td></tr><tr>
88 <td align="center"><strong>New Password : </strong></td><td align="center"><input type="text" name="pass1"></td>
89 <td align="center"><strong>Cookie max-age : </strong></td><td align="center"><input type="text" name="maxage" value="%s"></td></tr><tr>
90 <td align="center"><strong>Confirm Password : </strong></td><td align="center"><input type="text" name="pass2"></td>
91 <td align="center"><strong>Editable : </strong></td><td align="center"><input type="checkbox" name="editable" %s ></td></tr><tr><td align="center">
92 <input type="reset"></td><td>&nbsp;</td><td>&nbsp;</td><td align="center"><input type="submit" value="Submit Changes"></td></tr><tr>''' + form_e + form_s + '''
93 <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr>
94 <td>&nbsp;</td><td align="center"><input type="checkbox" name="confirm">Confirm Delete</td><td align="center"><input type="submit" value="Delete User">
95 </td><td>&nbsp;</td></tr>''' + form_e
96
97 ####################################################
98
99 # main menu - offering
100 # edit config
101 # edit users (including delete)
102 # invite/create new users
103
104 # display edit config (including values from the default user)
105 # edit config
106
107 # display invite/create
108 # invite new users
109 # create new user file
110
111 # edit user - can't edit or delete yourself or the 'main admin' (saves having to change newcookie)
112 # choose a user to edit or delete
113
114 # display edit user for that account
115 # or delete user (confirm ?)
116
117 # edit user -
118 # change password
119 # rename (change login name - ?)
120 # change display name
121 # change email address
122
123
124 def admin(theform, userdir, thisscript, userconfig, action, newcookie):
125 """Decide what admin action to perform. """
126 adminaction = theform.getfirst('admin', '')
127 if adminaction.startswith('editconfig'):
128 editconfig(theform, userdir, thisscript, userconfig, action, newcookie)
129 elif adminaction.startswith('invite'):
130 invite(theform, userdir, thisscript, userconfig, action, newcookie)
131 elif adminaction.startswith('edituser'):
132 edituser(theform, userdir, thisscript, userconfig, action, newcookie)
133 elif adminaction.startswith('doeditconfig'):
134 doeditconfig(theform, userdir, thisscript, userconfig, action, newcookie)
135 elif adminaction.startswith('doinvite'):
136 doinvite(theform, userdir, thisscript, userconfig, action, newcookie)
137 elif adminaction.startswith('edituser'):
138 edituser(theform, userdir, thisscript, userconfig, action, newcookie)
139 elif adminaction.startswith('doedituser'):
140 doedituser(theform, userdir, thisscript, userconfig, action, newcookie)
141 elif adminaction.startswith('deluser'):
142 deluser(theform, userdir, thisscript, userconfig, action, newcookie)
143
144 else:
145 displaymenu(theform, userdir, thisscript, userconfig, action, newcookie)
146
147 def displaymenu(theform, userdir, thisscript, userconfig, action, newcookie):
148 """Display the admin menu page."""
149 config = ConfigObj(userdir + 'config.ini')
150 templatedir = config['templatedir']
151
152 adminpage = readfile(templatedir+adminpage_file)
153 adminpage = adminpage.replace('**this script**', thisscript + '?action=' + action)
154
155 url = '?login=admin&admin=%s&action=' + action
156 adminmenu = readfile(templatedir+adminmenu_file)
157 adminmenu = adminmenu.replace('**edit config**', thisscript+url % 'editconfig')
158 adminmenu = adminmenu.replace('**edit users**', thisscript+url % 'edituser')
159 adminmenu = adminmenu.replace('**invite**', thisscript+url % 'invite')
160
161 adminpage = adminpage.replace('**admin**', adminmenu)
162 adminpage = adminpage.replace('**admin menu**', thisscript+'?login=admin'+'&action='+action)
163
164 print newcookie
165 print serverline
166 print
167 print adminpage
168 sys.exit()
169
170
171 def editconfig(theform, userdir, thisscript, userconfig, action, newcookie, msg=None, success=None):
172 """Display the screen to edit the main config file.
173 This includes the default user."""
174 config = ConfigObj(userdir + 'config.ini')
175 default = ConfigObj(userdir + 'default.ini')
176 templatedir = config['templatedir']
177
178 adminpage = readfile(templatedir+adminpage_file)
179 adminpage = adminpage.replace('**this script**', thisscript + '?action=' + action)
180 adminpage = adminpage.replace('**admin menu**', thisscript+'?login=admin'+'&action='+action)
181 # The values of this that are editable from config.ini are :
182 # newloginlink, adminmail, email_subject, email_message
183 #
184 # The values of this that are editable from default.ini are :
185 # max-age, editable
186
187 if msg:
188 adminpage = adminpage.replace('<br><!- message --> ', '<h2>'+msg+'</h2>')
189 if msg and not success:
190 loginlink = theform.getfirst('loginlink', '')
191 if loginlink:
192 loginlink = 'checked'
193 adminmail = theform.getfirst('adminmail', '')
194 emailsubj = theform.getfirst('emailsubject', '')
195 emailmsg = theform.getfirst('emailmsg', '')
196 maxage = theform.getfirst('maxage', '')
197 editable = theform.getfirst('editable', '')
198 if editable:
199 editable = 'checked'
200 else:
201 loginlink = config['newloginlink'].lower()
202 if loginlink == 'yes':
203 loginlink = 'checked'
204 else:
205 loginlink = ''
206 adminmail = config['adminmail']
207 emailsubj = config['email_subject']
208 emailmsg = config['email_message']
209 maxage = default['max-age']
210 editable = default['editable'].lower()
211 if editable == 'yes':
212 editable = 'checked'
213 else:
214 editable = ''
215
216 configmenu = readfile(templatedir+adminconfig_file)
217 configmenu = configmenu.replace('**loginlink**', loginlink)
218 configmenu = configmenu.replace('**adminmail**', adminmail)
219 configmenu = configmenu.replace('**email subject**', emailsubj)
220 configmenu = configmenu.replace('**email message**',emailmsg)
221 configmenu = configmenu.replace('**maxage**', maxage)
222 configmenu = configmenu.replace('**editable**', editable)
223 configmenu = configmenu.replace('**thisscript**', thisscript)
224 configmenu = configmenu.replace('**action**', action)
225
226 adminpage = adminpage.replace('**admin**', configmenu)
227 print newcookie
228 print serverline
229 print
230 print adminpage
231 sys.exit()
232
233 def invite(theform, userdir, thisscript, userconfig, action, newcookie, msg=None, success=None):
234 """Display the screen to create or invite a new user."""
235 config = ConfigObj(userdir + 'config.ini')
236 templatedir = config['templatedir']
237
238 adminpage = readfile(templatedir+adminpage_file)
239 adminpage = adminpage.replace('**this script**', thisscript + '?action=' + action)
240 adminpage = adminpage.replace('**admin menu**', thisscript+'?login=admin'+'&action='+action)
241
242 # Values to be filled in are :
243 # **create1** and **create2** - the one switched on should be 'checked', the other should be ''
244
245 if msg:
246 adminpage = adminpage.replace('<br><!- message --> ', '<h2>'+msg+'</h2>')
247 if msg and not success:
248 create = theform.getfirst('create', '')
249 if create == 'create':
250 create1 = 'checked'
251 create2 = ''
252 else:
253 create2 = 'checked'
254 create1 = ''
255 realname = theform.getfirst('realname', '')
256 username = theform.getfirst('username', '')
257 email = theform.getfirst('email', '')
258 pass1 = theform.getfirst('pass1', '')
259 pass2 = theform.getfirst('pass2', '')
260 adminlev = theform.getfirst('adminlev', '')
261 else:
262 create2 = 'checked'
263 create1 = ''
264 realname = ''
265 username = ''
266 email = ''
267 pass1 = randomstring(8)
268 pass2 = pass1
269 adminlev = '0'
270
271 invitemenu = readfile(templatedir+admininvite_file)
272 invitemenu = invitemenu.replace('**create1**', create1)
273 invitemenu = invitemenu.replace('**create2**', create2)
274 invitemenu = invitemenu.replace('**realname**', realname)
275 invitemenu = invitemenu.replace('**username**', username)
276 invitemenu = invitemenu.replace('**email**', email)
277 invitemenu = invitemenu.replace('**pass1**', pass1)
278 invitemenu = invitemenu.replace('**pass2**', pass2)
279 invitemenu = invitemenu.replace('**adminlev**', adminlev)
280
281 invitemenu = invitemenu.replace('**thisscript**', thisscript)
282 invitemenu = invitemenu.replace('**action**', action)
283
284 adminpage = adminpage.replace('**admin**', invitemenu)
285 print newcookie
286 print serverline
287 print
288 print adminpage
289 sys.exit()
290
291 def edituser(theform, userdir, thisscript, userconfig, action, newcookie, msg=None, success=None):
292 """Display the screen to edit or delete users.."""
293 config = ConfigObj(userdir + 'config.ini')
294 templatedir = config['templatedir']
295 realadminlev = int(userconfig['admin'])
296
297 adminpage = readfile(templatedir+adminpage_file)
298 adminpage = adminpage.replace('**this script**', thisscript + '?action=' + action)
299 adminpage = adminpage.replace('**admin menu**', thisscript+'?login=admin'+'&action='+action)
300
301 userlist = [entry[:-4] for entry in os.listdir(userdir) if os.path.isfile(userdir+entry) and entry[:-4] not in RESERVEDNAMES ]
302 mainadmin = config['adminuser']
303 username = userconfig['username']
304 if mainadmin in userlist:
305 userlist.remove(mainadmin)
306 if username in userlist:
307 userlist.remove(username)
308 userlist = cSort(userlist)
309
310 start = int(theform.getfirst('start', '1'))
311 length = len(userlist)
312 if start*numonpage > length:
313 start = length//numonpage + 1
314 url = '<a href="' + thisscript + '?start=%s&login=admin&admin=edituser&action=' + action + '">%s</a>'
315 indexline = '<div style="text-align:center;">%s</div>' % makeindexline(url, start, length, numonpage)
316
317 # need to be able to edit -
318 # username, realname, new password, confirm password, adminlev, email, max-age, editable
319 index = (start-1)*numonpage + 1
320 last = min(length+1, index+numonpage)
321 usermenu = indexline + '<br>' + edit_table_s
322 while index < last: # go through all the users
323 thisuser = userlist[index-1]
324 index += 1
325 thisuserc = ConfigObj(userdir+thisuser+'.ini')
326 adminlev = thisuserc['admin']
327 if realadminlev <= int(adminlev):
328 continue
329 loginname = thisuser
330 realname = thisuserc['realname']
331 email = thisuserc['email']
332 maxage = thisuserc['max-age']
333 editable = ''
334 if istrue(thisuserc['editable']):
335 editable = 'checked'
336 if theform.getfirst('username')==loginname and msg and not success:
337 realname = theform.getfirst('realname', '')
338 realname = theform.getfirst('realname', '')
339 email = theform.getfirst('email', '')
340 adminlev = theform.getfirst('adminlev', '')
341 maxage = theform.getfirst('maxage', '')
342 editable = theform.getfirst('editable', '')
343 if editable:
344 editable = 'checked'
345
346 thevals = (thisscript, action, 'doedituser', start, loginname,
347 loginname, realname, email, adminlev, maxage, editable,
348 thisscript, action, 'deluser', start, loginname)
349
350 usermenu += elem_h + (account_table % thevals) + elem_f
351
352 usermenu += table_e + '<br>' + indexline
353
354 eduserpage = readfile(templatedir+adminuser_file)
355 eduserpage = eduserpage.replace('**account table**', usermenu)
356 if msg:
357 adminpage = adminpage.replace('<br><!- message --> ', '<h2>%s</h2>' % msg)
358
359 adminpage = adminpage.replace('**admin**', eduserpage)
360 print newcookie
361 print serverline
362 print
363 print adminpage
364 sys.exit()
365
366 ##########################################################
367
368 def doeditconfig(theform, userdir, thisscript, userconfig, action, newcookie):
369 """Receives the submission from the edit config page."""
370 config = ConfigObj(userdir + 'config.ini')
371 default = ConfigObj(userdir + 'default.ini')
372
373 loginlink = theform.getfirst('loginlink', '')
374 adminmail = theform.getfirst('adminmail', '')
375 emailsubj = theform.getfirst('emailsubject', '')
376 emailmsg = theform.getfirst('emailmsg', '')
377 maxage = theform.getfirst('maxage', '')
378 editable = theform.getfirst('editable', '')
379
380 if adminmail and not validemail(adminmail):
381 editconfig(theform, userdir, thisscript, userconfig, action, newcookie, "The adminmail doesn't appear to be a valid address.")
382 if not maxage.isdigit():
383 editconfig(theform, userdir, thisscript, userconfig, action, newcookie, "maxage must be a number.")
384 if int(maxage) and int(maxage) < MINMAXAGE:
385 editconfig(theform, userdir, thisscript, userconfig, action, newcookie, "maxage must be greater than %s." % MINMAXAGE)
386
387 if loginlink:
388 config['newloginlink'] = 'Yes'
389 else:
390 config['newloginlink'] = 'No'
391 config['adminmail'] = adminmail
392 config['email_subject'] = emailsubj
393 config['email_message'] = emailmsg
394 config.write()
395 default['max-age'] = maxage
396 if editable:
397 default['editable'] = 'Yes'
398 else:
399 default['editable'] = 'No'
400 default.write()
401
402 displaymenu(theform, userdir, thisscript, userconfig, action, newcookie) # XXXX should we send a msg here 'COnfig File Edited' ?
403
404 #####################################################################
405
406 def doinvite(theform, userdir, thisscript, userconfig, action, newcookie):
407 """Receives the submission from the invite/create new user page."""
408 config = ConfigObj(userdir + 'config.ini')
409 default = ConfigObj(userdir + 'default.ini')
410
411 create = theform.getfirst('create', '')
412 realname = theform.getfirst('realname', '')
413 username = theform.getfirst('username', '')
414 email = validemail(theform.getfirst('email', ''))
415 pass1 = theform.getfirst('pass1', '')
416 pass2 = theform.getfirst('pass2', '')
417 adminlev = theform.getfirst('adminlev', '')
418
419 maxadminlev = min(int(userconfig['admin']), MAXADMINLEV)
420
421 if not email:
422 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'The email address appears to be invalid.')
423 if pass1 != pass2:
424 invite(theform, userdir, thisscript, userconfig, action, newcookie, "The two passwords don't match.")
425 if len(pass1) < 5:
426 invite(theform, userdir, thisscript, userconfig, action, newcookie, "The password must be at least five characters long.")
427 if not realname:
428 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'You must supply a realname.')
429 if not username:
430 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'You must supply a username.')
431 if not adminlev.isdigit():
432 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'Admin level must be a number.')
433 if int(adminlev) > maxadminlev:
434 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'Admin level is greater than the maximum allowed (%s).' % maxadminlev)
435
436 # now we need to check if the username already exists
437 tempstore = ConfigObj(userdir + 'temp.ini')
438 pendinglist = tempstore.get('pending', [])
439 if os.path.isfile(userdir+username+'.ini') or username in pendinglist or username.lower() in RESERVEDNAMES:
440 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'username already exists.')
441 for char in username.lower():
442 if not char in validchars:
443 invite(theform, userdir, thisscript, userconfig, action, newcookie, 'username contains invalid characters.')
444 # now we have verified the values - we *either* need to create a new username *or* send an invitiation
445
446 if create == 'create':
447 createuser(userdir, realname, username, email, pass1, adminlev)
448 msg = 'New User Created'
449 else:
450 inviteuser(userdir, realname, username, email, pass1, thisscript, adminlev)
451 msg = 'New User Invited'
452 invite(theform, userdir, thisscript, userconfig, action, newcookie, msg, True)
453
454
455 ####################################################################
456
457 def doedituser(theform, userdir, thisscript, userconfig, action, newcookie):
458 """Receives form submissions from the 'edit user' page."""
459 # parameters to get :
460 # username, realname, email, adminlev, pass1, pass2
461 username = theform.getfirst('username') # the user we are editing
462 loginname = theform.getfirst('loginname') # the new user name (won't usually change I guess)
463 realname = theform.getfirst('realname')
464 email = theform.getfirst('email')
465 adminlev = theform.getfirst('adminlev')
466 pass1 = theform.getfirst('pass1')
467 pass2 = theform.getfirst('pass2')
468 maxage = theform.getfirst('maxage')
469 editable = theform.getfirst('editable')
470
471 maxadminlev = min(int(userconfig['admin']), MAXADMINLEV)
472
473 # check all the account values
474 # this could be turned into a generic 'account checker' function if we wanted.
475 email = validemail(email)
476 if not email:
477 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'The Email Address Appears to Be Invalid.')
478 if not loginname:
479 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'You Must Supply a Login Name.')
480 for char in loginname.lower():
481 if not char in validchars:
482 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Login Name Contains Invalid Characters')
483 if not realname:
484 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'You Must Supply a Real Name')
485 if (pass1 or pass2) and not (pass1 and pass2):
486 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'To Change the Password - Enter it Twice')
487 if pass1 != pass2:
488 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'The Two Passwords Are Different')
489 if pass1 and len(pass1) < 5:
490 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Password Must Be at Least Five Characters')
491 if not adminlev.isdigit():
492 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'The Admin Level Must Be a Number')
493 if int(adminlev) > maxadminlev:
494 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Admin Level is Higher than the Max (%s).' % maxadminlev)
495 if not maxage.isdigit():
496 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Cookie "max-age" Must Be a Number')
497 if int(maxage) and int(maxage) < MINMAXAGE:
498 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Cookie "max-age" Must Be Greater Than %s' % MINMAXAGE)
499 if editable:
500 editable = 'Yes'
501 else:
502 editable = 'No'
503 # let's just check if the username has changed
504 thisuser = ConfigObj(userdir+username+'.ini')
505 if loginname != username:
506 pendinglist = ConfigObj(userdir + 'temp.ini').get('pending', [])
507 if os.path.isfile(userdir+loginname+'.ini') or loginname in pendinglist or loginname.lower() in RESERVEDNAMES:
508 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Login Name Chosen Already Exists')
509 thisuser.filename = userdir+loginname+'.ini' # change to new name
510 os.remove(userdir+username+'.ini') # free up the old name
511 if pass1:
512 from dataenc import pass_enc
513 thisuser['password'] = pass_enc(pass1, daynumber=True, timestamp=True)
514 #
515 thisuser['realname'] = realname
516 thisuser['email'] = email
517 thisuser['admin'] = adminlev
518 thisuser['max-age'] = maxage
519 thisuser['editable'] = editable
520 thisuser.write()
521
522 # edituser(theform, userdir, thisscript, userconfig, action, newcookie, '')
523 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Changes Made Successfully', True)
524
525 def deluser(theform, userdir, thisscript, userconfig, action, newcookie):
526 """Receives form submissions from when 'delete user' is hit."""
527 # parameters to get :
528 # username, realname, email, adminlev, pass1, pass2
529 username = theform.getfirst('username')
530 confirm = theform.getfirst('confirm')
531 if not confirm:
532 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Confirm Was Not Selected - Delete Not Done', True)
533 # XXXX we ought to check that the user being deleted isn't the main admin user and hasn't got a higher admin level
534 os.remove(userdir+username+'.ini') # is it really that easy
535 edituser(theform, userdir, thisscript, userconfig, action, newcookie, 'Delete Done Successfully', True)
536
537 ###############################################
538 # createuser is in loginutils - but this uses a couple of values defined in this module
539
540 def inviteuser(userdir, realname, username, email, password, thisscript, adminlev):
541 """Invite a new user."""
542 from newlogin import savedetails
543 from configobj import ConfigObj
544 formdict = {'username' : username, 'pass1' : password, 'admin' : adminlev,
545 'realname' : realname, 'email' : email, 'action' : '' }
546 thekey = savedetails(userdir, formdict)
547 config = ConfigObj(userdir + 'config.ini')
548 msg = config['email_message'] + '\n'
549 msg = msg + SCRIPTLOC + thisscript + '?login=confirm&id=' + thekey + (pass_msg % (username, password))
550 writefile('log.txt', msg)
551 sendmailme(email, msg, config['email_subject'], email, html=False)
552
553 """
554 CHANGELOG
555 =========
556
557 2005/10/30
558 ----------
559
560 Fixed the email function... oops.
561
562 2005/09/16
563 ----------
564
565 Removed dependency on caseless module (added ``cSort``).
566
567 2005/09/09
568 ----------
569
570 Changes to work with pythonutils 0.2.1
571
572 """

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26