Gossamer Forum
Home : Products : DBMan : Customization :

different permissions in multiple databases

Quote Reply
different permissions in multiple databases
i have multiple databases with the same users and would like to use same authorization file so they don't have to login to each database separately. i have the login issue working fine. i also am using the MOD for a special new permission level and the mass email MOD. now i want to set permission levels in the cfg files for each database for certain functions. for example, in one database i want users to be able to use mass email if they can view the record but in another database in only want the admin or special level to be able to use mass email.

in db.cgi the following lines are currently coded to only allow admin to send mass mail.

Code:

elsif ($in{'mass_mail_form'}) { if ($per_admin) { &html_mass_mail_form; } else { &html_unauth; } }
elsif ($in{'mass_mail'}) { if ($per_admin) { &mass_mail; } else { &html_unauth; } }


i want to change $per_admin to a variable in the cfg file. maybe one cfg would have $mass_mail_per = admin while the other would have $mass_mail_per = view. how would i get db.cgi to read and apply that setting depending on which database it is? i hope i've explained my situation!
Quote Reply
Re: [delicia] different permissions in multiple databases In reply to
There's a problem with using the .cfg file for such a purpose, in that the .cfg file is read before the permissions are defined. The only way I can think to do it is, before

Code:
# Main Menu.


add

Code:
if ($db_setup eq "databaseone") {
$mass_mail_per = $per_view;
}
else {
$mass_mail_per = $per_admin;
}





and use $mass_mail_per to determine the permission to use the mass mail feature.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.

Last edited by:

JPDeni: Feb 19, 2006, 8:26 AM
Quote Reply
Re: [JPDeni] different permissions in multiple databases In reply to
ok i think i figured it out! but i would like to know if you see any problems and if the code could be streamlined any.

in cfg file i have variable $massmail which determines whether massmail is even turned on for the database.
then i have another variable in cfg called $massmail_per which can be set to add, spec, or admin (i may add others later)

in auth.pl i have added in two subroutines right before return statement with permissions:

###
if ($massmail) {
if ($massmail_per eq 'admin') { $mail = $admin; }
elsif ($massmail_per eq 'spec') { $mail = $spec; }
elsif ($massmail_per eq "add") { $mail = $add; }
else { $mail = 0; }
}

and i added $mail after $admin in the return statements. i also added $per_massmail in db.cgi where it looks at permissions near beginning of file. then i used $per_massmail when displaying menu and in the db.cgi section to be sure permission is ok for running massmail.

to streamline code above, i wanted to say $mail = $($massmail_per); ie stick a $ in front of the variable value
Quote Reply
Re: [delicia] different permissions in multiple databases In reply to
If it works, that's great. It seems to me that it's more work than is necessary, but you may have reasons to do it that way.

Quote:

to streamline code above, i wanted to say $mail = $($massmail_per); ie stick a $ in front of the variable value

I've never seen that construction, but who knows? Maybe it'll work. The only way you'll know for sure is to try it.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] different permissions in multiple databases In reply to
that construction doesn't work but it seems there should be a way to do it.

the reason i wanted to use this solution is because i don't like anything in db.cgi that is 'hardcoded' for a particular database. that way i can use the same db.cgi for everything and not have to look for all those special things throughout. instead i put all my special variables in the cfg file. plus, by having them all in one place, i don't forget to set one of my flags.
Quote Reply
Re: [delicia] different permissions in multiple databases In reply to
ok i've got it!

in cfg file i set the $massmail_level to 2, 3, 4, 5, 6, 7 (corresponding to view, add, delete, modify, special, admin) instead of using $massmail_per i mentioned before. example: if i want only someone with admin permission to be able to use massmail, i use following:
$massmail_level = 7;

in auth.pl:

@dpw = split (/:/, $permission); #added this line to get an array (i believe that's the term)
($name, $pw, $view, $add, $del, $mod, $spec, $admin) = split (/:/, $permission);
...
#added these lines:
if ($massmail) {
$mail = $dpw[$massmail_level];
$mail = int($mail);
}

as mentioned before, i added $mail to the return statements and accepted the new field as $per_mail in db.cgi.
Quote Reply
Re: [delicia] different permissions in multiple databases In reply to
Very good. There's always more than one way to skin a cat. :-D


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [delicia] different permissions in multiple databases In reply to
Quote:
that construction doesn't work but it seems there should be a way to do it.


Try reading the page at http://www.unix.org.ua/...rl/prog3/ch08_01.htm on References. I think that's what you want to do. It's the sort of thing that I've read several times and I understand it, but then it goes away and I don't understand any more. My poor ol' brain just can't seem to hang on to it. Maybe you'll have better luck. :-)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.