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': curs.execute(db_change("select title from acl where title = ?"), [name]) if curs.fetchall(): curs.execute(db_change("update acl set decu = ? where title = ?"), [flask.request.form.get('decu', ''), name]) curs.execute(db_change("update acl set dis = ? where title = ?"), [flask.request.form.get('dis', ''), name]) curs.execute(db_change("update acl set why = ? where title = ?"), [flask.request.form.get('why', ''), name]) curs.execute(db_change("update acl set view = ? where title = ?"), [flask.request.form.get('view', ''), name]) else: curs.execute(db_change("insert into acl (title, decu, dis, why, view) values (?, ?, ?, ?, ?)"), [ name, flask.request.form.get('decu', ''), flask.request.form.get('dis', ''), flask.request.form.get('why', ''), flask.request.form.get('view', '') ]) curs.execute(db_change("select title from acl where title = ? and decu = '' and dis = '' and view = ''"), [name]) if curs.fetchall(): curs.execute(db_change("delete from acl where title = ?"), [name]) 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 = '

' + load_lang('document_acl') + '


' if not re.search(r'^user:', name): data += '

' + load_lang('discussion_acl') + '


' data += '

' + load_lang('view_acl') + '



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

''' if check_ok == '': if acl_data: data += '' + \ '
' + \ '' + \ '' else: data += '' + \ '
' + \ '' + \ '' return easy_minify(flask.render_template(skin_check(), imp = [name, wiki_set(), custom(), other2([' (' + 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')]] ))