building an admin tree with varying node types

From: Date: Wed, 05 Nov 2008 06:47:00 +0000
Subject: building an admin tree with varying node types
Groups: php.general 
Request: Send a blank email to php-general+get-282900@lists.php.net to get a copy of this message
Hi. I'm trying to build a new admin interface for my cms, in a single screen. I was thinking to have a tree-view on the left side of that screen, something like +Site-Name + UserGroups and Users (node-type section)
    + Administrators (node-type usergroup)
       - administrator (node-type user)
    + Editors (node-type usergroup)
       - Joe
    + Regular users
       - guest
+ Site main pages (node-type section)
    - frontpage (node-type article)
    - contactpage
Then on the right side of the screen, i'd have pieces of HTML+JS ("weblets") provide a "form service" to display/edit properties of different node-types. Since i have to store access-rights for the different nodes, i have created a sql table that holds my tree, like: CREATE TABLE master_admin_tree ( /* tn == tree node */
   tn_id                    integer,
   tn_language_id                integer,
   tn_parent_id                integer,
   tn_path                    longtext,
   tn_level_order                integer,
   tn_label                varchar(250),
   tn_description                longtext,
   tn_type_id                integer,
   tn_value_int                integer,
   tn_value_vc                varchar(250),      tn_value_text                longtext,
       /* stores many values in JSON format */
   tn_flags_int                integer,
   tn_flags_text                longtext,
   tn_owner_user_id            integer,
   tn_owner_group_id            integer,
   resource_rights_id            integer,
PRIMARY KEY (tn_id, tn_language_id) ); The problem is that i'd rather not store all user-groups and users in this table. Users and groups are stored in their own tables, just 2 flat list tables without tree-structure. I wonder if it would get too complicated to load the users and groups from their own tables, format them to be tree-nodes in master_admin_tree, put them in the tree and work with them. I can't fully envision the problems that might arise with a dynamic loading approach like this, but i do know it would be a bitch to put a tree-node in master_admin_tree that loads up the desired groups-list (that's doable), but then to load the users in those groups as nodes under each group. Should i just go for redundant data in master_admin_tree and on creation of a user also put a tree record in master_admin_tree? Or is there a way to load,store and manage tree-nodes that represent records in other flat-list tables?

« previous php.general (#282900) next »