Gossamer Forum
Home : Products : DBMan : Customization :

Help urgently requested...

Quote Reply
Help urgently requested...
Hi! I really do need someone to help me with this problem. Is there a way to write one of the fields in the .db file to the .pass file whenever a record is added or modified. More specifically, I have a field in my database called On leave with values, Yes or No. I need the values of this field to be added to the .pass file everytime a record is added or modified.

Thank you very much.

Julian
Quote Reply
Re: Help urgently requested... In reply to
vampy:

I know i've seen this before and thought this was in the FAQ but couldn't locate it.

I would suggest doing a search for the user "fharris" as I think it was him who was using something like this. Be sure to search for all time periods as this was awhile ago.

It might also be within the threads in the "Admin" section under "passwords" in the FAQ noted below. I'll check the references I haven't added yet in that section also to see if I can find it after I leave the forum.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Help urgently requested... In reply to
yeah, I know I saw it before somewhere before too. I tried searching both the forum and your website but I still can't find it. Damn... Don't I just hate myself for not thinking with foresight. Should have seen that I would require those codes sometime or other. Urrgggg... (pulling hair out)

I was thinking if it's possible to modify the codes for the mod "Change email address" to suit my purpose. I tried to figure how to modify those codes but I got a big headache at the end of it. Those codes allows the modifying of the password file as well as the database file. I thought for my purpose I need to switch it around. Instead of modifying the password file first then the database file, it should modify a database file first and then the password file.

Actually, I was just wondering the change email mod could be improved in such a way that you will not need to log in but still needs authentication.Meaning instead of logging in, the user will be presented a form after clicking a link (much like signup form) but in this case, there would be say the userid field, password field, old email address and new email address. Only if the userid and password is correct will the user be able to modify the email address of his own. This would save the user the hassle of logging in and then changing email address. Wonder if there is a way to do that? If there is, it would also solve my intial problem. I know this is a long shot in the dark and I'm sure that there is a easier way to achieve what I asked but being limited in perl, I can only adapt other people's code to suit my needs.

Thank you for your help and if you can give me more help I would be so, so, so delighted.

Julian
Quote Reply
Re: Help urgently requested... In reply to
Found the thread Julian ...

http://www.gossamer-threads.com/p/105166

Quote Reply
Re: Help urgently requested... In reply to
Umm... I saw that thread before but it's about having the data already in the .pass file and then passing that info to .db file. I require the exact opposite. .pass does not have the data initially or even if it does, it would be changed when ever the record is modified or when a record is added. I tried to think of a way to change things around but I really can't see how.

Thanks a lot for your help. I'll continue on my search and would very much appreciate if you do manage to find the thread that shows how to do that. If I don't remember wrongly, it's one thread by JPDeni. Urrggghhh... My stupid brain just isn't functioning.

Julian
Quote Reply
Re: Help urgently requested... In reply to
vampy:

I had to laugh when you said it was one thread by JPDeni. Out of the 900 threads referenced in the FAQ are contributions made by Carol Smile impossible to search by her nick alone to find anything specific :)

I'm a little more confused now by what you are wanting to do. Are you actually using the email change mod and wanting to quickly access that form without the users having to login? If so, you can pass their username and password in a link such as:

Log in with a username and password in a link?
Just use this:
?db=default&userid=admin&pw=admin&change_email_form=1

Of course you can replace the username and password with what you need!

There is also ways of Entering Data Externally via links.
This thread references this method:

Thread reference: http://gossamer-threads.com/p/97874
Subject: Entering Data Externally via links
Elle - 1-Aug-00

I still haven't located that other thread yet. The files are sooo huge in the directories on my hard drive, that I can't use my search program, I have to manually view many files and read them. And in the process condense them for use in the FAQ.



Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Help urgently requested... In reply to
Hi! I know what you mean by searching for Carol's threads. I tried that before and I'm still at page 75 of the search results. Don't get confused over what I said over in my last post. It was something I was thinking of while trying to figure out how to do what I want. I just want to solve this issue with mine first and then look into other areas.

Thanks a lot.

Julian
Quote Reply
Re: Help urgently requested... In reply to
Have you checked this thread http://gossamer-threads.com/p/112572 ?

AstroBoy suggests using a variation of "add permission" to add an additional field to the password file:
In Reply To:
Use a variation of the "add permission" mod to add a "language" field to the default.pass field.
eg: usename:password:1:0:0:0:0:english
~ Karen


Quote Reply
Re: Help urgently requested... In reply to
Well, after staring at the codes for DBman for the past 3 days I finally found my solution to the problem. Please tell me if there's any way i can shrink down the size of the codes. Below is my solution (add after the chunk of codes "if ($found) {
open (DB, ">$db_file_name") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB
in sub modify_record in db.cgi)

New codes(adapted from sub change_email):

open (PASSWD, "<$auth_pw_file") || &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;

foreach $pass (@passwds) { # Go through each pass and see if we match..
chomp ($pass);
($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $signup_date, $notify_date, $on_leave) = split (/:/, $pass);
}
open (PASSWD, "<$auth_pw_file") || &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
$found = '';
PASS: foreach $pass (@passwds) { # Go through each pass and see if we match..
next PASS if ($pass =~ /^$/); # Skip blank lines.
chomp ($pass);
if ($pass =~ /^$db_userid:/) {
$find = $pass;
}
else {
$write .= $pass . "\n";
}
}
if (!$find) {
&html_modify_failure ("Your userid was not found in the password file.");
}
open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
print PASS $write;
close PASS;

($userid, $pw, $view, $add, $del, $mod, $mem, $admin, $email, $signup_date, $notify_date, $on_leave) = split (/:/, $find);
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
print PASS "$userid:$pw:$view:$add:$del:$mod:$mem:$admin:$email:$signup_date:$notify_date:$in{'On Leave'}\n";
close PASS;
if ($in{'On Leave'} eq "Yes") {

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $in{'Email'}\n";
print MAIL "Subject: $html_title Instructor's Leave Notice\n\n";

print MAIL "-" x 75 . "\n\n";

print MAIL "Instructor $in{'Realname'} has notify that he/she is going on leave.\n\n";
print MAIL "Leave From: $in{'Leave From'}\n";
print MAIL "Leave To: $in{'Leave To'}\n\n";
close (MAIL);
}

Note it is very important for you to have those lines marked in red changed or else you will have the entire database file added to your password file. Thsoe lines initially use the same variables as defined in front so I change them to a different name so that the database does not write those values into the password file.

I tried it out and it is defintely working.

Julian