Added fix to phpbb3 when userid returns none.

This commit is contained in:
Raynaldo Rivera 2014-11-29 16:06:13 -07:00
parent de34d35add
commit e7950a26f7

View File

@ -62,7 +62,10 @@ class Phpbb3Manager:
cursor = connections['phpbb3'].cursor() cursor = connections['phpbb3'].cursor()
cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [username]) cursor.execute(Phpbb3Manager.SQL_USER_ID_FROM_USERNAME, [username])
row = cursor.fetchone() row = cursor.fetchone()
if row is not None:
return row[0] return row[0]
else:
return None
@staticmethod @staticmethod
def __get_all_groups(): def __get_all_groups():
@ -158,6 +161,7 @@ class Phpbb3Manager:
@staticmethod @staticmethod
def update_groups(username, groups): def update_groups(username, groups):
userid = Phpbb3Manager.__get_user_id(username) userid = Phpbb3Manager.__get_user_id(username)
if userid is not None:
forum_groups = Phpbb3Manager.__get_all_groups() forum_groups = Phpbb3Manager.__get_all_groups()
user_groups = set(Phpbb3Manager.__get_user_groups(userid)) user_groups = set(Phpbb3Manager.__get_user_groups(userid))
act_groups = set([g.replace(' ', '-') for g in groups]) act_groups = set([g.replace(' ', '-') for g in groups])
@ -178,6 +182,7 @@ class Phpbb3Manager:
def remove_group(username, group): def remove_group(username, group):
cursor = connections['phpbb3'].cursor() cursor = connections['phpbb3'].cursor()
userid = Phpbb3Manager.__get_user_id(username) userid = Phpbb3Manager.__get_user_id(username)
if userid is not None:
groupid = Phpbb3Manager.__get_group_id(group) groupid = Phpbb3Manager.__get_group_id(group)
if userid: if userid: