I improved commenting tt_roles table as follows.
Code: Select all
# Structure for table tt_roles. This table stores customized team roles.
CREATE TABLE `tt_roles` (
`id` int(11) NOT NULL auto_increment, # Role id. Identifies roles for all groups on the server.
`team_id` int(11) NOT NULL, # Team id the role is defined for.
`name` varchar(80) default NULL, # Role name - custom role name. In case we are editing a
# predefined role (USER, etc.), we can rename the role here.
`rank` int(11) default 0, # Role rank, an integer value between 0-324. Predefined role ranks:
# USER - 4, CLIENT - 16, COMANAGER - 68, MANAGER - 324.
# Rank is used to determine what "lesser roles" are in each group
# for sutuations such as "manage_users".
# It also identifies a role within a team (by its "rank").
# Value of rank is to be used in role field in tt_users table,
# just like standard roles now.
`rights` text default NULL, # Comma-separated list of rights assigned to a role.
# NULL here for predefined roles (4, 16, 68, 324 - manager)
# means a hard-coded set of default access rights.
`status` tinyint(4) default 1, # Role status.
PRIMARY KEY (`id`)
# Create an index that guarantees unique active and inactive role ranks in each group.
create unique index role_idx on tt_roles(team_id, rank, status);
bonnedav wrote:When you delete a role it should remove the DB entry completely, not just set status to null. Unless you have an un-delete option, it just clutters up the DB. Same way with other tables as well.
Although un-delete option is not available at the moment, the NULL status is needed at least in some installations for situations when users delete something by mistake. It gets an admin a chance to recover the data.
bonnedav wrote:role_idx still sounds like the same thing as role.id. maybe i am just misunderstanding? It looks fine in phpmyadmin so just stick with it.
One is a column in a table, another is an index on the entire table. UNIQUE
refers to an index where all rows of the index must be unique. I used it here to prohibit creating active roles with the same rank. Used an index, because primary key is ID, which is used to find a record in a table. Perhaps there is a better way. Here we kind of use a rank as role id, which does not sound quite right, but makes things simple?
bonnedav wrote:Also, how deep can sub groups go?
As deep as one wants?
bonnedav wrote:I think that when a manager creates a sub group he should be able to enable/disable sub group management for the new group's manager.
Then go to role editor (when implemented, not available now) and remove the "manage_subgroups"
right from their role?