Need help with creating Admin sections
Moderator: General Moderators
Need help with creating Admin sections
Hi,
I am creating a sports league site as my first PHP project to learn PHP. I am not using any framework.
My admins are as follows
WebAdmin - Super User (God like) - Can CRUD anything
League Admins - They can CRU League that they belong to. CRUD Teams and Players that belong to their league
Team Admins - They can CRU Team that they belong to. CRUD Players that belong to their team
A league has a name, alias, type, and season. All this info is stores in tables called Leagues, LeagueTypes, and Seasons. There is a bridge table called "LeagueDetails" to store details of the league, i.e. name, alias, type and season. On the NewLeague page the Web Admin can add Name and Alias, then they go on another page to add the type and season.
I am planning to create a Dashboard for WebAdmin with following sections
Users - List of all registered admins
Leagues - List of all leagues currently active (This is a SQL JOIN statement that reads from a bridge table called LeagueDetails, Leagues, LeagueTypes, and Seasons)
That's where I am stuck right now and need help with.
Am I designing the league setup process correctly? Is there a better way?
I am having a hard time to figure out how should I assign the league admin to a league. Any suggestions?
Please guide.
Thanks.
I am creating a sports league site as my first PHP project to learn PHP. I am not using any framework.
My admins are as follows
WebAdmin - Super User (God like) - Can CRUD anything
League Admins - They can CRU League that they belong to. CRUD Teams and Players that belong to their league
Team Admins - They can CRU Team that they belong to. CRUD Players that belong to their team
A league has a name, alias, type, and season. All this info is stores in tables called Leagues, LeagueTypes, and Seasons. There is a bridge table called "LeagueDetails" to store details of the league, i.e. name, alias, type and season. On the NewLeague page the Web Admin can add Name and Alias, then they go on another page to add the type and season.
I am planning to create a Dashboard for WebAdmin with following sections
Users - List of all registered admins
Leagues - List of all leagues currently active (This is a SQL JOIN statement that reads from a bridge table called LeagueDetails, Leagues, LeagueTypes, and Seasons)
That's where I am stuck right now and need help with.
Am I designing the league setup process correctly? Is there a better way?
I am having a hard time to figure out how should I assign the league admin to a league. Any suggestions?
Please guide.
Thanks.
Re: Need help with creating Admin sections
Sounds fine so far, but the most precise you can be with details the more precise we can be with an analysis.
There are a few approaches. The simplest would be to have a bitmask in the user table indicating privileges:
Thing to note is that 2-League admin is specifically for league stuff - no team stuff. You wouldn't use that: your "league admin" would be 1 (team admin) + 2 (league admin) = 3.
To test if someone can act as a team admin you test
And similarly for acting as a league admin
Because of how bitmasks work, those conditions will always be true for web admins... if you set them at -1 - for NULL you'd need special treatment:
There are a few approaches. The simplest would be to have a bitmask in the user table indicating privileges:
Code: Select all
-1 Web admin (or NULL)
0 Regular user
1 Team admin
2 League admin
4 Unused
8 Unused
16 Unused
...To test if someone can act as a team admin you test
Code: Select all
(privilege & 1) > 0Code: Select all
(privilege & 2) > 0Code: Select all
if ($privilege === null || ($privilege & $level) > 0)Re: Need help with creating Admin sections
Thanks requinix. I never heard about bitmask so will check it out.
Can you suggest how will I edit a league as well as assign a league admin when I am using bridge tables since I want to make sure I don't insert duplicate rows?
Let me know what details you need.
Can you suggest how will I edit a league as well as assign a league admin when I am using bridge tables since I want to make sure I don't insert duplicate rows?
Let me know what details you need.
Re: Need help with creating Admin sections
This "bridge table" is, strictly speaking, unnecessary. It's a one-to-one relationship with leagues, and basically you're just sticking the league information in a separate table.
I don't get what that table has to do with being a league admin. The user can or cannot edit the league details - it doesn't really matter where those details actually are.
I don't get what that table has to do with being a league admin. The user can or cannot edit the league details - it doesn't really matter where those details actually are.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need help with creating Admin sections
Unless there are multiple leagues and a League Admin can only edit one or more leagues.
(#10850)
Re: Need help with creating Admin sections
So here's a scenario
Leagues table -> ID, Name, Alias
Records in the table
1 - TestLeague1 - TL1
2 - TestLeague2 - TL2
LeagueTypes -> ID, Type
1 - Twenty20
2 - One Day International
Seasons -> ID, Year
1 - 2012
2 - 2013
So a league can have different types. Eg. TestLeague1 - Twenty20 - 2012, TestLeague1 - One Day International - 2012
This relationship is stored in the bridge table. One league admin can administer more than one league. The reason I want the league admin to be able to CURD Teams is because if the scores or team info is entered by mistake by a team admin than it will need a higher privilege to correct the error.
In reality a game can either be a Twenty20 or One Day International, but a league can have only one type of games. However, the league that I play in has both types of games but played at different times. In short.. I am confused :'(
Leagues table -> ID, Name, Alias
Records in the table
1 - TestLeague1 - TL1
2 - TestLeague2 - TL2
LeagueTypes -> ID, Type
1 - Twenty20
2 - One Day International
Seasons -> ID, Year
1 - 2012
2 - 2013
So a league can have different types. Eg. TestLeague1 - Twenty20 - 2012, TestLeague1 - One Day International - 2012
This relationship is stored in the bridge table. One league admin can administer more than one league. The reason I want the league admin to be able to CURD Teams is because if the scores or team info is entered by mistake by a team admin than it will need a higher privilege to correct the error.
In reality a game can either be a Twenty20 or One Day International, but a league can have only one type of games. However, the league that I play in has both types of games but played at different times. In short.. I am confused :'(
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need help with creating Admin sections
I sounds like you have leagues, seasons and games. And that each game has a type. You probably need teams as well.
(#10850)
Re: Need help with creating Admin sections
I didn't post other tables since it would be out of scope for this question. However, here is a link https://docs.google.com/spreadsheet/ccc ... FE5eW45b2c to my db tables list. The ones in orange are the bridge tables.
Should I create a bridge table to assign league admins to the leagues? If so, I am guessing the bridge table will be between Users_Roles table and LeagueDetails table, correct?
If you have suggestions to make the db design better, feel free to suggest.
Thanks again.
Should I create a bridge table to assign league admins to the leagues? If so, I am guessing the bridge table will be between Users_Roles table and LeagueDetails table, correct?
If you have suggestions to make the db design better, feel free to suggest.
Thanks again.