admin_plus.py 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from .tool.func import *
  2. def admin_plus_2(conn):
  3. curs = conn.cursor()
  4. if flask.request.method == 'POST':
  5. if admin_check(None, 'admin_plus (' + name + ')') != 1:
  6. return re_error('/error/3')
  7. curs.execute("delete from alist where name = ?", [name])
  8. if flask.request.form.get('ban', 0) != 0:
  9. curs.execute("insert into alist (name, acl) values (?, 'ban')", [name])
  10. if flask.request.form.get('toron', 0) != 0:
  11. curs.execute("insert into alist (name, acl) values (?, 'toron')", [name])
  12. if flask.request.form.get('check', 0) != 0:
  13. curs.execute("insert into alist (name, acl) values (?, 'check')", [name])
  14. if flask.request.form.get('acl', 0) != 0:
  15. curs.execute("insert into alist (name, acl) values (?, 'acl')", [name])
  16. if flask.request.form.get('hidel', 0) != 0:
  17. curs.execute("insert into alist (name, acl) values (?, 'hidel')", [name])
  18. if flask.request.form.get('give', 0) != 0:
  19. curs.execute("insert into alist (name, acl) values (?, 'give')", [name])
  20. if flask.request.form.get('owner', 0) != 0:
  21. curs.execute("insert into alist (name, acl) values (?, 'owner')", [name])
  22. conn.commit()
  23. return redirect('/admin_plus/' + url_pas(name))
  24. else:
  25. data = '<ul>'
  26. exist_list = ['', '', '', '', '', '', '', '']
  27. curs.execute('select acl from alist where name = ?', [name])
  28. acl_list = curs.fetchall()
  29. for go in acl_list:
  30. if go[0] == 'ban':
  31. exist_list[0] = 'checked="checked"'
  32. elif go[0] == 'toron':
  33. exist_list[2] = 'checked="checked"'
  34. elif go[0] == 'check':
  35. exist_list[3] = 'checked="checked"'
  36. elif go[0] == 'acl':
  37. exist_list[4] = 'checked="checked"'
  38. elif go[0] == 'hidel':
  39. exist_list[5] = 'checked="checked"'
  40. elif go[0] == 'give':
  41. exist_list[6] = 'checked="checked"'
  42. elif go[0] == 'owner':
  43. exist_list[7] = 'checked="checked"'
  44. if admin_check() != 1:
  45. state = 'disabled'
  46. else:
  47. state = ''
  48. data += '''
  49. <li><input type="checkbox" ''' + state + ' name="ban" ' + exist_list[0] + '> ' + load_lang('ban_authority') + '''</li>
  50. <li><input type="checkbox" ''' + state + ' name="toron" ' + exist_list[2] + '> ' + load_lang('discussion_authority') + '''</li>
  51. <li><input type="checkbox" ''' + state + ' name="check" ' + exist_list[3] + '> ' + load_lang('user_check_authority') + '''</li>
  52. <li><input type="checkbox" ''' + state + ' name="acl" ' + exist_list[4] + '> ' + load_lang('document_acl_authority') + '''</li>
  53. <li><input type="checkbox" ''' + state + ' name="hidel" ' + exist_list[5] + '> ' + load_lang('history_hide_authority') + '''</li>
  54. <li><input type="checkbox" ''' + state + ' name="give" ' + exist_list[6] + '> ' + load_lang('authorization_authority') + '''</li>
  55. <li><input type="checkbox" ''' + state + ' name="owner" ' + exist_list[7] + '> ' + load_lang('owner_authority') + '''</li>
  56. </ul>
  57. '''
  58. return easy_minify(flask.render_template(skin_check(),
  59. imp = [load_lang('admin_group_add'), wiki_set(), custom(), other2([0, 0])],
  60. data = '''
  61. <form method="post">
  62. ''' + data + '''
  63. <hr class=\"main_hr\">
  64. <button id="save" ''' + state + ''' type="submit">''' + load_lang('save') + '''</button>
  65. </form>
  66. ''',
  67. menu = [['manager', load_lang('return')]]
  68. ))