@ -13,14 +13,21 @@ class Admidio:
def __init__ ( self , mysql_host , mysql_user , mysql_pass , mysql_db ,
def __init__ ( self , mysql_host , mysql_user , mysql_pass , mysql_db ,
db_prefix ) :
db_prefix ) :
self . db = MySQLdb . connect (
host = mysql_host , user = mysql_user , passwd = mysql_pass , db = mysql_db )
self . cursor = self . db . cursor ( )
self . mysql_host = mysql_host
self . mysql_user = mysql_user
self . mysql_pass = mysql_pass
self . mysql_db = mysql_db
self . prefix = db_prefix
self . prefix = db_prefix
self . members = dict ( )
self . members = dict ( )
self . groups = dict ( )
self . groups = dict ( )
self . events = dict ( )
self . events = dict ( )
self . event_confirmation_id = None
self . event_confirmation_id = None
self . connect_db ( )
sql = f " SELECT usf_id,usf_name_intern FROM {self.prefix}_user_fields "
sql = f " SELECT usf_id,usf_name_intern FROM {self.prefix}_user_fields "
self . cursor . execute ( sql )
self . cursor . execute ( sql )
self . userfields = dict ( self . cursor . fetchall ( ) )
self . userfields = dict ( self . cursor . fetchall ( ) )
@ -34,25 +41,37 @@ class Admidio:
self . cursor . execute ( sql )
self . cursor . execute ( sql )
self . event_confirmation_id = self . cursor . fetchone ( ) [ 0 ]
self . event_confirmation_id = self . cursor . fetchone ( ) [ 0 ]
self . initMembers ( )
self . initGroups ( )
self . initEvents ( )
self . ready = True
self . db . close ( )
self . refresh ( )
def __del__ ( self ) :
def __del__ ( self ) :
self . db . close ( )
pass
def connect_db ( self ) :
self . db = MySQLdb . connect (
host = self . mysql_host ,
user = self . mysql_user ,
passwd = self . mysql_pass ,
db = self . mysql_db )
self . cursor = self . db . cursor ( )
def refresh ( self ) :
def refresh ( self ) :
""" Refresh all users, groups and events that are stored """
""" Refresh all users, groups and events that are stored """
self . connect_db ( )
self . ready = False
self . ready = False
self . members = dict ( )
self . groups = dict ( )
self . events = dict ( )
self . members . clear ( )
self . groups . clear ( )
self . events . clear ( )
self . initMembers ( )
self . initMembers ( )
self . initGroups ( )
self . initGroups ( )
self . initEvents ( )
self . initEvents ( )
self . ready = True
self . ready = True
self . db . close ( )
def initMembers ( self ) :
def initMembers ( self ) :
""" Initialises all members in the Admidio installation """
""" Initialises all members in the Admidio installation """