from .tool.func import *
def give_acl_2(name):
with get_db_connect() as conn:
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 += [['document_edit_acl', flask.request.form.get('document_edit_acl', '')]]
acl_data += [['document_move_acl', flask.request.form.get('document_move_acl', '')]]
acl_data += [['document_delete_acl', flask.request.form.get('document_delete_acl', '')]]
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', 'document_edit_acl', 'document_move_acl', 'document_delete_acl', '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('view_acl'), 'view', '2', '1.'],
[load_lang('document_acl'), 'decu', '3', '1.1.'],
[load_lang('document_edit_acl'), 'document_edit_acl', '4', '1.1.1.'],
[load_lang('document_move_acl'), 'document_move_acl', '4', '1.1.2.'],
[load_lang('document_delete_acl'), 'document_delete_acl', '4', '1.1.3.'],
[load_lang('discussion_acl'), 'dis', '2', '2.'],
]
else:
acl_get_list = [
[load_lang('document_acl'), 'decu', '2', '1.']
]
for i in acl_get_list:
data += '' + \
'