Gossamer Forum
Home : Products : DBMan : Installation :

Validate additions like in Links?

Quote Reply
Validate additions like in Links?
Hello, I would like to know if there is an easy solution to let users make additions and modifications to a database and then validate them in a way it is been doen in Links. I would like to keep the database as clean as possible and this seems the easiest way to me. Or are there other ideas??
Quote Reply
Re: Validate additions like in Links? In reply to
Sure Im interested.

Let me know how and when it is available.

Jeroen
Quote Reply
Re: Validate additions like in Links? In reply to
Okey dokey. You can pick up a text file of the changes at

http://www.drizzle.com/~hall/validate.txt

Let me know if you have any problems.



------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
Sorry I took so long to answer you. I finally got to the point where I could explain what I did.

Easy? Well, that depends on your definition of easy. There are quite a few things to add in order to get it to work. And it doesn't work the same way Links does, with a separate database for unvalidated records.

If you (or anyone) is interested, I can make my modification available.



------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
Now that's a useful mod! If this sort of thing is possible, would it be feasible to have something like "Emailizer" for links where the admin can send emails to users?

Thanks for the mod!


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Validate additions like in Links? In reply to
Why, thank you! :-) I found it to be necessary on my site which focuses on a very serious subject but there are jokers that come by every once in a while. I wanted to be able to weed them out before the public could view them.

Quote:
would it be feasible to have something like "Emailizer" for links where the admin can send emails to users?

Yep. In my own validation subroutine (sub val_form_record), I have the program do a whole lot of stuff, including composing an email to the user with some of the information they included in their record. Then, in sub val_success, I have a textfield that has the email message in it. There are some times that I want to edit the message before I send it.

The reason I didn't include it in my mod file is that when I wrote it I didn't know a whole lot about Perl (I still don't! Smile) and I didn't know how to write the sendmail part of the script. I use a free script from somewhere else to send the email. I didn't think it was appropriate to include that script in my mod.

Maybe one of these days I'll get my stuff together to write my own sendmail routine to put in it. It shouldn't be too hard to adapt the subroutine from Links, although the way I have the validation mod set up there's no way to tell whether a record has been added or modified.

I'm glad you like the mod and that it's a help to you. It feels good to be able to give back after all the help I've received from others here! Smile


------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
I just added your mod. It works well. I encountered one small problem though. When I add 1 test record, it goes to the sub modify_form_record instead of the val_form. If I add 2 test records, it goes to the sub html_val_form like it should. I had a look at sub html_val_form and in the header, there are references to stuff in the modify subroutine -- ie. &query("mod"); and { $in{'modify'}.

I deleted the line beginning with if (($numhits ==1) in the header of sub html_modify_form (before where it says &html_print_headers; etc. Things are working fine now. So it may be a good idea to add this to your instructions as it may cause some problems.

I have been considering adding working emailizer into dbman for some time now, maybe I'll do it over the holidays.

Thanks again.

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Validate additions like in Links? In reply to
Thanks, Jason, for pointing that out. I guess I forgot to look at that part of the val_form in what I did. I've got the new version up now in case anyone else wants it.

I look forward to your emailizer. Please let us know when you have it done.



------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
JPDeni, just wanted to say I installed your mod today (after installing dbman yesterday!) and it seems to be working. This seems to be exactly what I was looking for. Thanks.

------------------
Zot
http://www.zot-multimedia.com/
Quote Reply
Re: Validate additions like in Links? In reply to
Just wanted to let folks know that I'd left some things out in my previous mod -- it might work just fine for you, but there might be some problems, too. I've posted the updated mod at
http://www.drizzle.com/~hall/dbmod/validate.htm

I think I've got it fixed now. Smile



------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
That's a great mod, JPD... Thanks!

Since the entries are validated one-by-one, I'd like to suggest setting Validate to "Yes" automatically if the user is logged-in as an admin. For those of us who make entries ourselves, it can save time, and shouldn't be too difficult to add.

I do have a question for you... When I go to the validation screen, I have to remember what category was selected, because the drop-down menus that dbman builds default to ---. Is there any way to have dbman retain the category that was selected? I always use the &build_select_field routine, so maybe I'll have to ditch that, and code the select menus separately... or is there a way to rewrite that routine (&build_select_field in db.cgi) to select the value if it's available?

I hate to be difficult... but if you can help, that would be great!

Thanks in advance,

-Ryan
Quote Reply
Re: Validate additions like in Links? In reply to
I'm glad you like it. Smile

Quote:
Since the entries are validated one-by-one, I'd like to suggest setting Validate to "Yes" automatically if the user is logged-in as an admin.

Good point! I'll update it on my site, but you can add this now if you'd like:

In html.pl -- sub html_add_form

change

<input type=hidden name="Validated" value="No">
(from the mod)

to

|; # Don't forget to close off your quote from the previous lines!
if ($per_admin) {
print qq|<input type=hidden name="Validated" value="Yes">|;
}
else {
print qq|<input type=hidden name="Validated" value="No">|;
}

That should do it.

Quote:
When I go to the validation screen, I have to remember what category was selected, because the drop-down menus that dbman builds default to ---. Is there any way to have dbman retain the category that was selected?

Hmmmmmm. That shouldn't be happening. Does it retain the selected category in the select field when you Modify a record? You may not have your &build_select_field parameters set correctly. Check to make sure you have it like:

print &build_select_field ("Category", "$rec{'Category'}");

It works on my demo.


------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
The select fields are not remembering the contents because you have probably put each element on a new line in default.cfg.

They have to be on the same line (separated by commas), or on newlines with a . at the end of each line to join them in perl.

Hope that does the trick.
Quote Reply
Re: Validate additions like in Links? In reply to
Hi JP,

First off thanks for all your help on the forum and all the mods you've contributed, it's really appreciated!

Just had a quick look at the validate mod, and a small suggestion:

Move:

if ($per_admin) { # so you don't have to validate your own records
print qq|<input type=hidden name="Validated" value="Yes">|;
}
else
print qq|<input type=hidden name="Validated" value="No">|;
}

out of the add_form, and into db.cgi add_record routine. I would put:

$per_admin ?
($in{'Validated'} = 'Yes') :
($in{'Validated'} = 'No');

Right before $status = &validate_record.

The reason for moving in here, is so that if a user saves the form to their hard drive and changes the validate to Yes, the script will accept it. This way, the script doesn't even look at what the user puts in, but sets the validation automatically. This is how userid is handled, so a user couldn't post a record under someone else's userid.

Cheers,

Alex
Quote Reply
Re: Validate additions like in Links? In reply to
I added the validate record stuff and added the part to the db.cgi as Alex stated. I seem to be have a strange problem now but I am not sure if that is the cause. If I login as a normal user (add/delete/modify) and add an entry, it goes to the add_success as normal, but the added info *is not* displayed and is not added to the database. If I login as the admin and add an entry, the added info *is* displayed and is added to the database. I have the correct line for the form w/contents to be displayed :
&html_record(&get_record($in{$db_key})); etc...

If anyone has any ideas, please let me know.
Thanks.




------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Validate additions like in Links? In reply to
Alex--

Quote:
First off thanks for all your help on the forum and all the mods you've contributed, it's really appreciated!

Thank *you*! Smile

Quote:
Just had a quick look at the validate mod, and a small suggestion:...
The reason for moving in here, is so that if a user saves the form to their hard drive
and changes the validate to Yes, the script will accept it. This way, the script doesn't
even look at what the user puts in, but sets the validation automatically. This is how
userid is handled, so a user couldn't post a record under someone else's userid.

Boy, those users can sure be sneaky! I never thought about that. I hesitate to make too many changes to the db.cgi script because I want to be able to have it still usable for databases without the script. Also, it helps to make upgrades easier. But I think your point is a very good one and I'll make the change today.

Thanks!! Smile

Jason--

Quote:
I added the validate record stuff and added the part to the db.cgi as Alex stated. I seem to be have a strange problem now but I am not sure if that is the cause. If I login as a normal user (add/delete/modify) and add an entry, it goes to the add_success as normal, but the added info *is not* displayed and is not added to the database. If I login as the admin and add an entry, the added info *is* displayed and is added to the database. I have the correct line for the form contents to be displayed :
&html_record(&get_record($in{$db_key})); etc...

Hmmmmm. Are you saying that on the add_success page, after

The following record was added to the database:

you don't get the record displayed? I haven't tried what Alex wrote above, but it should work just the same. It works on my demo -- with my original mod. I'll change the db.cgi as Alex said and make sure it works, too.

As for the record not showing up in a search when a non-admin person adds it, that's what it's supposed to do. After you add a record as a non-admin user, log off and log back on as a user with admin permissions. Click the "Validate" link. Now log off again and log back on as the first user and do a search. You should find your record.

I may not have made it clear, but this mod requires that you (as admin) regularly check your database to validate new records.




Quote Reply
Re: Validate additions like in Links? In reply to
With regard to my post about the record not showing after a normal user adds.... what I meant was when a normal user adds a record, the $in stuff doesn't show up in the add_success yet if a person with admin status adds a record, the $in stuff does show up in the add_success. I fully understand how the validate works so it isn't a matter of misunderstanding in that way, its just a weird thing going on with the script.

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Validate additions like in Links? In reply to
No offense meant, Jason. I just wasn't sure I understood what your problem was.

I updated my demo to include Alex's mod and I don't get the error you had. I did have a problem, though, with adding. I got an error that said the "Validated" field could not be left blank. Changing the .cfg file to allow a null entry in that field fixed that problem.

Any chance I could look at your database? It would help a lot if I could -- well, maybe it would help. Smile



------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
No offense taken, my description of the problem wasn't clear.

One thing that I noticed in the .db after adding Alex's suggestion is that the "Validated" field is blank in the db, is it supposed to be that way?

You can see my database at:
extreme.nas.net/cgi-bin/db/db.cgi?db=reviews

Normal User:
ID - test
Password - test

Admin:
ID - temp
Password- temp

I haven't tested the page under Netscape that much so it may be a little quirky. If you have IE4, it may be better to use that. Feel free to add/delete/verify all you want.

I also made my .cfg, html.pl and db.cgi available if you want at extreme.nas.net/temp

** I temporarily ##'d out the thing that Alex suggested in the db.cgi because it wouldn't add 'Yes|No' to the db.

If you find any problems please let me know. Your help is greatly appreciated!


------------------
Jason
Extreme mtb
extreme.nas.net

[This message has been edited by jdulberg (edited December 29, 1998).]
Quote Reply
Re: Validate additions like in Links? In reply to
 
Quote:
No offense taken, my description of the problem wasn't clear.

Kewl! Smile

Nice site! Beautifully done!!!

Now as to your problem, I don't know what to tell you. Everything looks just fine. I'm assuming that it worked before you added the validate routine. Unless ...

A possibility could be a connection with $auth_modify_own. Try setting $auth_modify_own to 0 in your .cfg file and see what happens. If it works with this setting, then the problem is probably that the userid isn't being added to the record for some reason. That'll at least help to narrow it down. Smile

Did it work before you added the validation mod?

Quote:
One thing that I noticed in the .db after adding Alex's suggestion is that the
"Validated" field is blank in the db, is it supposed to be that way?

It seems so, but it works, at least on my demo. I usually "pretend I'm the script" and follow the whole procedure when I make a modification to the script. I haven't done that yet with Alex's mod. Smile

Quote:
I haven't tested the page under Netscape that much so it may be a little quirky. If you have IE4, it may be better to use that.

It doesn't work in Netscape. The "Add Success" and "Delete Form" (maybe others -- these are the ones I saw) show a completely black screen. Not a criticism, because I know you're working on it. Just thought you might like to know.

Still, it's a kicker of a site. Kudos!!


------------------
JPD
Quote Reply
Re: Validate additions like in Links? In reply to
Thanks for the compliments on my site. It's still pretty messy and as you said, some pages don't work in Netscape.

As for the validate mod... It did work before I added the validate stuff. I'll try reverting back to the original db.cgi to see if that is the problem. I tried changing modify_own to 0 and it didn't work - I had a look in the .db and the UID's are being added. I am having the same problem in my offline version as well so there isn't a problem with the .db itself.

Thanks for your help. I will try reverting back to the old db.cgi later tonight or tomorrow.


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: Validate additions like in Links? In reply to
This is different to the "emailizer" functionality mentioned above, but when I first read it I thought you guys were talking about email notification of new database entries, which is what I wanted for my db. I found this tidbit from Alex in the archives and thought others might find it as useful as I do:

In &add_record just before you go to the success page, try something like:
Quote:
open (MAIL, "|/usr/lib/sendmail -t") or &cgierr("can't get to sendmail. reason: $!");
print MAIL "To: youraddress\@server.com\n";
print MAIL "From: $in{'email_field'}\n";
print MAIL "Subject: Database addition\n\n";
print MAIL "The following was added: \n";
foreach $key (sort keys %in) {
print MAIL "$key: $in{$key}\n";
}
close MAIL;

That should do the trick. Hope it helps,

Alex

Cheers, and thanks again for the val mods. I added that last one Alex mentioned to automatically validate admin entries which was very helpful! Note that to work with JPDeni's mod you need to use the variable 'val'. (heh, I'm new to computers).

$per_admin ?
($in{'val'} = 'Yes') :
($in{'val'} = 'No');



------------------
Zot
http://www.zot-multimedia.com/
Quote Reply
Re: Validate additions like in Links? In reply to
zot,

I could not find the exact spot you are referring to. I have the newest dbman.

Where do I put this ?