예제 #1
0
def get_groups(uid):
    """Select all the groups id the user is member of."""
    query = """SELECT g.id, g.name
               FROM usergroup g, user_usergroup ug
               WHERE ug.id_user=%s AND
                     ug.id_usergroup=g.id
            """
    res = run_sql_cached(query, (uid, ), affected_tables=['usergroup', 'user_usergroup'])
    res = list(res)
    return res
def make_list_apache_firerole(name_action, arguments):
    """Given an action and a dictionary arguments returns a list of all the
    roles (and their descriptions) which are authorized to perform this
    action with these arguments, and whose FireRole definition expect
    an Apache Password membership.
    """
    roles = acc_find_possible_roles(name_action, **arguments)

    ret = []

    for role in roles:
        res = run_sql_cached('SELECT name, description, firerole_def_ser FROM accROLE WHERE id=%s', (role, ), affected_tables=['accROLE'])
        if acc_firerole_suggest_apache_p(deserialize(res[0][2])):
            ret.append((res[0][0], res[0][1]))
    return ret
예제 #3
0
def get_groups_with_description(uid):
    """Select all the groups the user is member of.
    @param uid: user id
    @return: ((id_usergroup,
              group_name,
              group_description, ))
    """
    query = """SELECT g.id,
                      g.name,
                      g.description
               FROM usergroup g, user_usergroup ug
               WHERE ug.id_user=%s AND
                     ug.id_usergroup=g.id
               ORDER BY g.name"""
    uid = int(uid)
    res = run_sql_cached(query, (uid, ), affected_tables=['usergroup', 'user_usergroup'])
    return res
예제 #4
0
def get_groups_by_user_status(uid, user_status, login_method='INTERNAL'):
    """Select all the groups the user is admin of.
    @param uid: user id
    @return: ((id_usergroup,
              group_name,
              group_description, ))
    """
    query = """SELECT g.id,
                      g.name,
                      g.description
               FROM usergroup g, user_usergroup ug
               WHERE ug.id_user=%s AND
                     ug.id_usergroup=g.id AND
                     ug.user_status=%s AND
                     g.login_method = %s
               ORDER BY g.name"""
    uid = int(uid)
    res = run_sql_cached(query, (uid, user_status, login_method), affected_tables=['usergroup', 'user_usergroup'])
    return res
예제 #5
0
def get_external_groups(uid):
    """Select all the groups the user is member of selecting the login_method.
    @param uid: user id
    @param login_method: the login_method (>0 external)
    @return: ((id_usergroup,
              group_name,
              group_description, ))
    """
    query = """SELECT g.id,
                      g.name,
                      g.description
               FROM usergroup g, user_usergroup ug
               WHERE ug.id_user=%s AND
                     ug.id_usergroup=g.id AND
                     g.login_method != 'INTERNAL'

               ORDER BY g.name"""
    uid = int(uid)
    res = run_sql_cached(query, (uid, ), affected_tables=['usergroup', 'user_usergroup'])
    return res