Gossamer Forum
Home : Products : DBMan : Customization :

Variation Of Validate Script

Quote Reply
Variation Of Validate Script
Good Evening Everyone. Hopefully you can help me out with this one :) I'll tell you what we need, and hopefully one of you can tell me if this is possible. I think it can be done, with modifications to the original Validate Records Mod.

Our database is a master record of all state registrations for Virginia ARES/RACES (Emergency Communications). When a user signs up and adds a record, they are presented with standard questions (name, address, etc.) and also certain key fields such as the Jurisdiction that person resides in. Currently there are 108 counties that make up this field. Each Jurisdiction/County has an assigned Emergency Coordinator to administer among other things, registrations. We need to have a way for that one person to be notified that a person in their county has created/modified their record, so it can be verified and validated.

Currently the Validate script will work perfectly for what we need, except for that it will only email one individual. Is it possible for the validate script to check and see what county the person put on their signup, and then email the Emergency Coordinator for that county? Somehow we would need to have a file that listed Counties, and also admin email address's, and then have the script handle it from there.

I hope this makes sense...if you need any further information, email me.


Thanks In Advance!

Chris Kinsler, K4CGK
Assistant Emergency Coordinator, Hanover/Henrico County Virginia
Virginia ARES/RACES Webmaster, http://www.aresva.org

Quote Reply
Re: Variation Of Validate Script In reply to
First I would like to commend you on outlining what you want to do. It makes answering your question a whole lot easier.

In your .cfg file, you could set up a series of variables:

$admin_email{'County1'} = 'admin@county1.com';
$admin_email{'County2'} = 'admin@county2.com';
$admin_email{'County3'} = 'admin@county3.com';


and so on -- one for each county.

It would also be best if your county was a select field rather than a text input field, since people might misspell a county name. The success of this depends on the input into the field being identical to the text within the brackets above.

In sub html_add_success, change

print MAIL "To: $admin_email\n";

to

print MAIL "To: $admin_email{$rec{'County'}}\n";

substituting the actual county field name for County (if it's different).

You can also paste the same code that you added to sub html_add_success into sub html_modify_success, if you want to be notified when a record is modified.

You can leave the $admin_email variable as it is, if you would like to have a general email address for the whole database.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Variation Of Validate Script In reply to
Thanks JP for the quick and detailed reply!!

This looks like it will work GREAT for what we need!

I do have one additional question that just recently came to mind, after speaking with our Section Manager. He requested that in addition to County level, he would like District level, Area Level, and State level emails sent out.

To Better explain, 10-15 counties make up a district, and there is a District Emergency Coordinator assigned to monitor the activities of each county. After talking with our SM, he requested that the Districts receive a copy of this email also -- but only for counties in their district.

This also applies to being sent to Area Level (3 of them), which are each made up of about 4-5 Districts. Each Area level Manager would also like to receive copies of regs/mods in their area.

Same applies with the State Coordinator, who wants to get them for the whole state.

I know this seems VERY redundant - but it was explained to me that we need to have this redundancy in order to make sure all signups, and requests get verified in a timely manner. When people register in this database and become validated, they become members, and as such, gain legal protection under state law. Hence, we need to make sure when someone signs up, everyone in the appropriate area gets notified, and the record is validated.

Is there a way to have the script handle this? We would need to have some way to tell DBMan that a certain county is part of DistrictXX, and AreaXX. Then it would need to email the County level, District Level, Area Level, and State Level Administrators. Somwhere we would also need to specify the email addresses of all districts and areas, as well as the State level email.

Thanks for any insite you may be able to give me.


Chris Kinsler
Assistant Emergency Coordinator, Henrico/Hanover County VA
Webmaster, ARES/RACES - http://www.aresva.org

Quote Reply
Re: Variation Of Validate Script In reply to
Again, you have been very clear in what you need. Thank you!!!!! Smile

This may take a little thinking, though.

The state coordinator isn't a problem. That's one email address.

The others have to be based on the input from the county field.

The simple (coding-wise) way to do it would be to set up similar variables like the $admin_email{'County'} ones. But that would be redundant.

Let me go test something. I'll be right back........

I think I've got it. Smile

In your .cfg file, set up email addresses for your district coordinators and area coordinators.--

$district_email{'District1'} = 'whatever@something.com';
$district_email{'District2'} = 'whoever@somethingelse.com';
$area_email{'Area1'} = 'whenever@another.com';
$area_email{'Area2'} = 'fred@flintstone.com';


Also set up variables to define which districts go to which counties and which areas go to which districts:

Code:

%districts = (
District1 => 'County1,County2,County3',
District2 => 'County4,County5,County6'
);

%areas = (
Area1 => 'District1,District2,District3',
Area51 => 'District4,District5,District6'
);
In html.pl, sub add_success (and sub modify_success), between

%rec = &get_record($in{$db_key});

and the beginning of the email routine, add

Code:

foreach $district (keys %districts) {
@district_array = split ',', $districts{$district};
if (grep $_ eq $rec{'County'}, @district_array) {
$target_district = $district;
last;
}
}
foreach $area (keys %areas) {
@area_array = split ',', $areas{$area};
if (grep $_ eq $target_district, @area_array) {
$target_area = $area;
last;
}
}
Then I think you can send out all the emails at the same time. Change

print MAIL "To: $admin_email\n";

to

print MAIL "To: $admin_email,$admin_email{$rec{'County'},$district_email{$target_district},$area_email{$target_area}\n";

This is assuming that $admin_email is the state coordinator. If not, you can add another variable for the state coordinator's email address, too, and stick it in there.

If this doesn't work, you may need to copy the email routine and have it send out separate emails to each person. But I don't think you'll have to.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Variation Of Validate Script In reply to
First Of All..As Always JP, I want to thank you for all of your help with not only my script, but with the scripts of everyone in this forum. It's great to have someone like you to help us out with such things!

Somehow I need to achieve the following in the database:

1) In the Validation script, I need to have a way to search for pending validations only in a certain county. As it is setup right now, the validate script will return a list of all people waiting to be validated. Since we have 108 counties, this list would not be manageable for the County level personnel to scroll through, just to find their people (in their county). Ideally I would like to see a popup choice box with the county names just above where the buttons are now. The county level admin would just logon and select Validate, and then select his/her county from the list, and press Validate Records. The database should ideally search for records that have that county in the field, and that have a validate status of no. Then the script would function as normal.

2) I would like to tie into the validate script two fields that would be auto-entered by the script. One would be a "Date Validated", and the other a "Validated By". The date would simply be entered by the script whenever a validation was processed. The Validated by field should be auto-entered as well, but with the User ID of the Admin processing the validation. These fields should not be modifiable, except by the script itself, and should be updated whenever a record is validated (or revalidated due to modification).

3) Is there any way for the script to compare the modifications submitted, to the old records - and then somehow flag the email to the admin, noting what was changed? For example, If a person changed their address - is there anyway the script can process this, and then in the email to everyone, somehow state that the Address field was changed? This would allow the admin to process the validation request more efficiently for record modifications - because he would know exactly what to go and look at.

4) I need to have a way to Auto-Capitalize all record additions and subsequent modifications to the database, in order to have a appearance that is the same across the board. I saw a modification that was posted, but have no idea how to implement it into the script (especially into the modification routine)

5) We need to have someway to interface with Majordomo. I have checked out the mod that is in the forum, but I don't believe it will do what we need. We will be running two lists, and the user will have the option to choose whether or not they want to receive the lists (with a default checkbox of no). If a record is added to the database, the script needs to check the fields, and ONLY if the field is checked yes, it needs to send out an subscribe email. This would have to be processed for both fields (lists) - and theirfore send out two emails if necessary. This also comes into play when the user modifies his/her record. If s/he no longer wishes to be a part of one, or both of the lists, the server needs to acknowledge that change of the field, and email out a unsubscribe request, if the field is changed to NO. Also I'm stumped as to how DBMan could pass on a email change request, if a user changes his/her email in DBMan (through the change email mod).


I appreciate any help that anyone can give with this! Thanks in advance!


Sincerely,

Chris Kinsler, K4CGK
Assistant Emergency Coordinator, Hanover/Henrico County ARES/RACES
Webmaster, Commonwealth of Virginia ARES/RACES - http://www.aresva.org

Quote Reply
Re: Variation Of Validate Script In reply to
In Reply To:
Ideally I would like to see a popup choice box with the county names just above where the buttons are now.
You could do that. Actually, what you could do is set up a form in the footer for validating:

Code:

if ($per_admin) {
print qq|
<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<input type=hidden name="Validated" value="No">
|;
print &build_select_field("County");
print qq|<INPUT TYPE="SUBMIT" NAME="validate_form" VALUE="Validate"></form>|;
}
Use the above instead of the Validate link in the footer.

In Reply To:
I would like to tie into the validate script two fields that would be auto-entered by the script. One would be a "Date Validated", and the other a "Validated By".
In sub validate_records, after

close (MAIL); $rec{$db_validated_field} = "Yes";

add


$rec{'Date Validated'} = &get_date;
$rec{'Validated By'} = $db_userid;


In Reply To:
Is there any way for the script to compare the modifications submitted, to the old records - and then somehow flag the email to the admin, noting what was changed?
Not without major changes to the validate mod. I am thinking about rewriting it so that the records which need validation are in a separate file. It might be possible to do some sort of flagging at that point, because the original record would not yet be modified. However, the rewriting of the mod is quite a ways down on my "to do" list, and I'm not sure how to go about this anyway.

In Reply To:
I need to have a way to Auto-Capitalize all record additions and subsequent modifications to the database, in order to have a appearance that is the same across the board. I saw a modification that was posted, but have no idea how to implement it into the script (especially into the modification routine)
The codes that "TheFew" posted go into sub parse_form, which changes the values as they come from the form. I think that's the best place to put them.

In Reply To:
5) We need to have someway to interface with Majordomo.
Sending an email to Majordomo when a record is added is not a problem. Piece o' cake. Changing the setting when a user modifies a record is much more problematic. This would take a rewrite of sub modify. It's something I would have to think about for quite a while before I could come up with a solution.

As for changing the email address, I don't know what email you send to Majordomo to change the email address, so I don't know if it can be done through DBMan or not.

Well, I was able to give you good news on some of your stuff. Smile Some of the other things are probably possible, but I don't have the code for it off the top of my head. And some of it I just don't know how to do.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Variation Of Validate Script In reply to
Thanks Again JP!

Two Quick & Easy (I Hope) Questions:

1) When a user modifies their record, the field is changed to NO. Where & What coding can I place, that will blank the 'Date_Validated' and 'Validated_By' Fields when it's modified?

2) Using TheFew's capitalization module makes ALL records (User ID's, and EVERYTHING be capitalized). This would work great, except that it changes the script to look for DEFAULT.CFG in some places, and default.cfg in others (notice case). It also makes the User ID that is emailed to the user become capitalized, yet the random password to be lowercase. This causes a problem because when the user enters the random password (lowercase), the script makes it uppercase before it gets to checking it - and theirfore creates a Invalid Password message. Do you recommend I use the part of his mod that specifies fields, or is there an easy fix for this?

Thanks!

Chris Kinsler, K4CGK
Assistant Emergency Coordinator, Hanover/Henrico County ARES/RACES
Webmaster, Commonwealth of Virginia ARES/RACES - http://www.aresva.org


Quote Reply
Re: Variation Of Validate Script In reply to
In Reply To:
1) When a user modifies their record, the field is changed to NO. Where & What coding can I place, that will blank the 'Date_Validated' and 'Validated_By' Fields when it's modified?
After

(!$per_admin) and ($in{$db_validated_field} = "No");

add

$in{'Date_Validated'} = '';
$in{'Validated_By'} = '';


In Reply To:
Do you recommend I use the part of his mod that specifies fields, or is there an easy fix for this?
Use the part that specifies fields.



JPD
http://www.jpdeni.com/dbman/