from .tool.func import * def give_acl_2(conn, name): curs = conn.cursor() check_ok = '' ip = ip_check() if flask.request.method == 'POST': check_data = 'acl (' + name + ')' else: check_data = None user_data = re.search(r'^user:(.+)$', name) if user_data: if check_data and ip_or_user(ip) != 0: return redirect('/login') if user_data.group(1) != ip_check(): if admin_check(5) != 1: if check_data: return re_error('/error/3') else: check_ok = 'disabled' else: if admin_check(5) != 1: if check_data: return re_error('/error/3') else: check_ok = 'disabled' if flask.request.method == 'POST': acl_data = [['decu', flask.request.form.get('decu', '')]] acl_data += [['dis', flask.request.form.get('dis', '')]] acl_data += [['view', flask.request.form.get('view', '')]] acl_data += [['why', flask.request.form.get('why', '')]] curs.execute(db_change("select title from acl where title = ?"), [name]) if curs.fetchall(): for i in acl_data: curs.execute(db_change("update acl set data = ? where title = ? and type = ?"), [i[1], name, i[0]]) else: for i in acl_data: curs.execute(db_change("insert into acl (title, data, type) values (?, ?, ?)"), [name, i[1], i[0]]) all_d = '' for i in ['decu', 'dis', 'view']: if flask.request.form.get(i, '') == '': all_d += 'normal' if i != 'view': all_d += ' | ' else: all_d += flask.request.form.get(i, '') if i != 'view': all_d += ' | ' admin_check(5, check_data + ' (' + all_d + ')') conn.commit() return redirect('/acl/' + url_pas(name)) else: data = '' acl_list = get_acl_list('user') if re.search(r'^user:', name) else get_acl_list() if not re.search(r'^user:', name): acl_get_list = [ [load_lang('document_acl'), 'decu'], [load_lang('discussion_acl'), 'dis'], [load_lang('view_acl'), 'view'] ] else: acl_get_list = [ [load_lang('document_acl'), 'decu'] ] for i in acl_get_list: data += '' + \ '

' + i[0] + '

' + \ '
' + \ '' data += '
' curs.execute(db_change("select data from acl where title = ? and type = ?"), [name, 'why']) acl_data = curs.fetchall() acl_why = html.escape(acl_data[0][0]) if acl_data else '' data += '' + \ '
' + \ '' + \ '' data += '''

''' + load_lang('explanation') + '''

''' return easy_minify(flask.render_template(skin_check(), imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('acl') + ')', 0])], data = '''
(''' + load_lang('main_acl_setting') + ''') ''' + data + '''
''', menu = [ ['w/' + url_pas(name), load_lang('document')], ['manager', load_lang('admin')], ['admin_log?search=' + url_pas('acl (' + name + ')'), load_lang('acl_record')] ] ))