Gossamer Forum
Home : Products : DBMan : Customization :

Need some help with modifications to Validate Mod

Quote Reply
Need some help with modifications to Validate Mod
Hi! I was wondering whether anyone can help me out with my problem here. I will list them down as follows:

1) I would like to add a extra field to my database which woudl contain the date that a student graduate. However, this date should only be added when I (admin) change one of the field which is already in the database to "Graduated".
2) I also realised that there is a mod on autoarchiving and autodeletion for records. Howvever, if I did not read the instrcutions wrongly, they require that the $db_key to be set to 1. I can't set it to one as one of the mod that I'm using won't work with it set to 1. Is there another way that I can autoarchive and autodelete my records after a certain time?
3) If yes to question 2, I would like it to be setup up in such a way that upon the admin modifying the record to show that the student has graduated, it would automatically be sent to archiving after 90 days. After which, the record would be sent for deletion after another 6 months.

I hope that this is not to complicating.

Thanks.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
In Reply To:
1) I would like to add a extra field to my database which woudl contain the date that a student graduate. However, this date should only be added when I (admin) change one of the field which is already in the database to "Graduated".
This is probably doable, but a pain. The problem is not with adding the date. The problem is with not overwriting the date if the record is modified at a later time.

In Reply To:
2) I also realised that there is a mod on autoarchiving and autodeletion for records. Howvever, if I did not read the instrcutions wrongly, they require that the $db_key to be set to 1. I can't set it to one as one of the mod that I'm using won't work with it set to 1. Is there another way that I can autoarchive and
autodelete my records after a certain time?
I don't know of anything that would require the $db_key being set to 1. Where did you read this?

In Reply To:
3) If yes to question 2, I would like it to be setup up in such a way that upon the admin modifying the record to show that the student has graduated, it would automatically be sent to archiving after 90 days. After which, the record would be sent for deletion after another 6 months.
I'm sure such a thing would be possible. I am not comfortable writing anything that is an "auto" anything, but you might be able to get with the person who wrote the mod to which you are referring to help you.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
With regards to your first reply to my first question, don't worry about the date being overwritten if the record is modified later on. This is because I will set it up in such a way that archived records cannot be modified by anyone. Hope this makes things easier.

Opps, with regards to autoarchiving, it should be that it requires a counter field for the $db_key. I can't use $db_key as explained before.

Thanks.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Sorry...but I just figured out that the instrcutions for the archving mod is sort of inaccurate. I installed it and it worked even though my $db_key is not a counter. At leats I think it is working. I tried archiving both normal users records and also admin records. I also tried to unarchive them and they both pop back into the database.

Now I'm facing a slight problem. The problem is one that I did not realised it till now. I installed the "force new users to add record" mod a few weeks ago. I just realsied that when one delete any records, it would force the user to add new record as though as the user just registered. I discover this problem when I was trying out the archiving mod. When a record is archive, it is deleted from the database and inserted into another file, so the database thinks that the record is deleted and forces the user to add a new record.

I hope that you can help me find some way of telling the database that if the record is deleted or archived, it will not force the user to add a new record. Forcing a new record should only be done when the user first register.

As to my second request, I hope that you can help me with the problem of having an extra field which would print the date that the student graduated only when the admin changes one of the field to "Graduated". At other times, this new field would have a default value such as "Not available yet".

Thanks.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
The reason that the archive mod says the $db_key field needs to be a counter is so that you won't have two records with the same key value. If you can guarantee that there won't be two records in the archive.db with the same key value, that's fine.

Regarding your problem with forcing new users to add a record -- can users add a record after their first one?

Regarding your "new" field. Do you have the field currently in your database? That's the first thing to do.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Users can't add after they have one record. The add permission is removed after they add one record.
I have not added the new field to my databse yet as I do not knwo how to configure the field to my needs.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
If the "add" permission is removed from the .pass file after they add a record, then set up your "force new users to add a record" like this:

Code:

if ($per_add) {
%rec = &get_record($db_userid);
unless ($rec{$db_key}) {
$in{'add_form'} = 1;
&html_add_form;
return;
}

}
As to configuring your new field, wouldn't it just be an admin-only date field?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Yes, it will only be an admin-field. I'll try out with the code you gave and give you a reply if it works.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Well, it's working. But let me ask you another question. I installed a mod that allows me to modify multiple records. I saw on the discussion threads that one of the user was having a problem initially in modfiying multiple records. It gave the error messages that certain field cannot be left blank. You posted a solution asking the user to add:

my (%rec) = @_;

and as well as replacing all the %in with %rec in the sub validate_record

I did as you suggested and yes it solved the problem of modifying mulitple records but now when I want to modify only a single record, it gave me the same error messages as before. Any ideas why?

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
I just figured it out.

Change every instance of

$status = &validate_record;

to

$status = &validate_record(%in);

This is in sub add_record (twice) and sub modify_record.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Thanks. It worked as usual. I could kiss you from head to toe. Now the only thing left is how to have an extra field that woudl only print out a date when admin changes the value of another field.

If you are working on getting the database automatically archiving records when one of the field is updated by an admin, forget about it. You are right about having things going automatic, they usually caused chaos.


Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
You're a smart person. You agree with me!! Wink

Okay.

In sub modify_record, after

my ($status, $line, @lines, @data, $output, $found, $restricted);

add

Code:

if ($per_admin && ($in{'Graduated'} eq 'Yes')) {
$in{'Grad_Date'} = &get_date;
}
This is all really speculative, since I don't know what your field names are or what the value is if someone has graduated, or if you want the current date. But this is the general idea.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
I'll try it out and let you know the results.

Julian
Quote Reply
Re: Need some help with modifications to Validate Mod In reply to
Yup, everything is working as it should be. Took me some time to figure out that I should not use &get_date in the database cfg file when I define the new field. Causes it to print the current date no matter what happens. But now everything is workingas it should.

Three cheers to you!

Julian