When the user logs in, I have a script that extracts these permissions and stores them as sessions to be used around the CMS as needed.
I currently have a script that manually sets all these permissions (see code snippet below), but Im getting sick of manually updating and adding the code for new permissions every time I add a new module or function.
What I would like to do is have a script that can automatically detect the permissions and set the sessions. The permission values are either 0 (not allowed) or 1 (allowed).
The script I currently have is like this:
// Permissions include "db.php"; $q = "SELECT * FROM u_groups WHERE ugroup_id = '$user_groups'"; $r = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($r); // Admin Panel $perm_adminpanel = $row['perm_adminpanel']; // Access to admin panel $_SESSION['perm_adminpanel'] = $perm_adminpanel; $perm_configadmin = $row['perm_configadmin']; // Configure Admin Settings $_SESSION['perm_configadmin'] = $perm_configadmin; $perm_setperm = $row['perm_setperm']; // Allowed to set permissions for groups $_SESSION['perm_setperm'] = $perm_setperm; $perm_addgroup = $row['perm_addgroup']; // Allowed to create new groups $_SESSION['perm_addgroup'] = $perm_addgroup;
so I image it would go:
include "db.php"; $q = "SELECT * FROM u_groups WHERE ugroup_id = '$user_groups'"; $r = mysql_query($q) or die(mysql_error()); $row = mysql_fetch_array($r); // here would invoke some kind of loop? $value = $row[$name]; $_SESSION['name'] = $value; // end the loop
If I havent been clear enough, please let me know and I will try and explain it better.....