|
|
@ -10,36 +10,44 @@ class Admidio: |
|
|
|
def __init__(self, mysql_host, mysql_user, mysql_pass, mysql_db): |
|
|
|
self.db = MySQLdb.connect( |
|
|
|
host=mysql_host, user=mysql_user, passwd=mysql_pass, db=mysql_db) |
|
|
|
self.cursor = self.db.cursor() |
|
|
|
self.members = dict() |
|
|
|
self.groups = dict() |
|
|
|
self.userfields = None |
|
|
|
self.initAll() |
|
|
|
self.events = dict() |
|
|
|
sql = "SELECT usf_id,usf_name_intern FROM `adm_user_fields`" |
|
|
|
self.cursor.execute(sql) |
|
|
|
self.userfields = dict(self.cursor.fetchall()) |
|
|
|
|
|
|
|
sql = """SELECT usr_id, usr_login_name, usr_password |
|
|
|
FROM adm_users WHERE usr_valid = 1""" |
|
|
|
self.cursor.execute(sql) |
|
|
|
self.initMembers() |
|
|
|
self.initGroups() |
|
|
|
|
|
|
|
def __del__(self): |
|
|
|
self.db.close() |
|
|
|
|
|
|
|
def initAll(self): |
|
|
|
"""initializes all Members and Groups""" |
|
|
|
c = self.db.cursor() |
|
|
|
# Initializing member. Get ID and Name for the user fields. |
|
|
|
sql = "SELECT usf_id,usf_name_intern FROM `adm_user_fields`" |
|
|
|
c.execute(sql) |
|
|
|
self.userfields = dict(c.fetchall()) |
|
|
|
def initMembers(self): |
|
|
|
"""Initialises all members in the Admidio installation""" |
|
|
|
|
|
|
|
sql = """SELECT usr_id, usr_login_name, usr_password |
|
|
|
FROM adm_users WHERE usr_valid = 1""" |
|
|
|
c.execute(sql) |
|
|
|
self.cursor.execute(sql) |
|
|
|
|
|
|
|
for row in c.fetchall(): |
|
|
|
for row in self.cursor.fetchall(): |
|
|
|
self.members[row[0]] = member.Member( |
|
|
|
self.db, row[0], row[1], |
|
|
|
row[2], self.userfields, self) |
|
|
|
print(self.members[row[0]]) |
|
|
|
|
|
|
|
sql = """SELECT rol_id, rol_name, rol_description FROM adm_roles |
|
|
|
WHERE rol_visible=1 AND rol_valid=1""" |
|
|
|
c.execute(sql) |
|
|
|
for row in c.fetchall(): |
|
|
|
def initGroups(self): |
|
|
|
"""Initialises all groups in the Admidio installation""" |
|
|
|
|
|
|
|
sql = """SELECT rol_id, rol_name, rol_description |
|
|
|
FROM adm_roles |
|
|
|
WHERE rol_visible=1 AND rol_valid=1""" |
|
|
|
self.cursor.execute(sql) |
|
|
|
|
|
|
|
for row in self.cursor.fetchall(): |
|
|
|
self.groups[row[0]] = group.Group(self.db, row[0], row[1], self) |
|
|
|
|
|
|
|
def getMemberFromID(self, user_id): |
|
|
|