Gossamer Forum
Home : Products : DBMan : Customization :

Adding a field only ADMIN can see, and adding a field(s) into an existing db

Quote Reply
Adding a field only ADMIN can see, and adding a field(s) into an existing db
Ok, First off, thanks for the great script. It is a life saver, and is so easy to use and modify that you should get money for it! Or at least make it shareware!

I have dbman running on my website at http://www.kickas.org/cgi-bin/dbman/db.cgi and have NO problems with the current setup, but I want to add a new field that only ADMIN can see.

problem is, I have the script set so only ADMIN can edit/modify/delete records.
Here are the current authorizations settings:
Code:
$auth_no_authentication = 0;
$auth_time = 21600; $auth_logging = 1;
$auth_allow_default = 1;
@auth_default_permissions = (1,0,0,0,0);
$auth_signup = 0;
@auth_signup_permissions = (1,0,0,0,0);
$auth_modify_own = 0;
$auth_view_own = 0;
$auth_user_field = -1;

As you can see, only ADMIN can alter the records. The record fields are as follows:
Code:
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
As_Name => [1, 'alpha', 40, 255, 1, '', ''],
Full_Name => [2, 'alpha', 40, 255, 0, '', ''],
BirthDay => [3, 'numer', 2, 2, 0, '', ''],
BirthMonth => [4, 'alpha', 3, 3, 0, '', ''],
BirthYear => [5, 'numer', 4, 4, 0, '', ''],
Country => [6, 'alpha', 10, 255, 0, '', ''],
Street => [7, 'alpha', 0, 255, 0, '', ''],
City => [8, 'alpha', 40, 255, 0, '', ''],
State => [9, 'alpha', 40, 255, 0, '', ''],
Zip_Code => [10, 'numer', 5, 12, 0, '', ''],
Email => [11, 'alpha', 50, 255, 0, '', ''],
Home_Page => [12, 'alpha', 50, 255, 0, '', ''],
ICQ_Name => [13, 'alpha', 20, 255, 0, '', ''],
ICQ_Number => [14, 'alpha', 12, 255, 0, '', ''],
ICQ_Remarks => [15, 'alpha', 40, 255, 0, '', ''],
Last_Updated => [16, 'date', 12, 15, 0, &get_date, ''],
);

Now, I want to add:

A record for a phone number, which is only for ADMIN to see!
Code:
Phone_Number => [17, 'alpha', 20, 20, 0, , ''],

I picture URL and title for all to see, which is located on the site:
Code:
Picture_Url => [18, 'alpha', 50, 255, 0, , ''],
Picture_Title => [19, 'alpha', 20, 20, 0, , ''],

And, finally, I would like to add details about a story that they submitted, if they submitted one as follows:
Code:
Story_Url => [20, 'alpha', 50, 255, 0, , ''],
Story_Title => [21, 'alpha', 20, 20, 0, , ''],

Finally, I need to add a password field for each user, and initialize the password with something that I can email them so that they can edit their own record:
Code:
Password => [22, 'alpha', 12, 12, 0, , ''],


Now, I know that is allot to add to a database that is currently set, and active, with over 150 entries already.

So, my questions is, how do I:
A. Modify the script so that certain fields in the records are not displayed, and are only available to ADMIN.
B. How do I initialize the password protection to allow the current records that I have added and allow the current email address holder to edit them. I have it turned off now. Can I just add the last field for the password, and enter in "changeme" for each field in the db field, or is it encrypted? Or is it stored elswhere?
C. I wrote a small script that grabs all of the birthdays and creates a text file that is called via a SSI call here:
http://www.kickas.org/support/birthday.shtml
I also did this for a ICQ list here:
http://www.kickas.org/com/icqlist.shtml
Can I have dbman output this text file as a SSI call, instead of writing an additional script to create the html file?
D. And lastly, is there a way for me to initiate a cookie feature, where I set a cookie when they visit the main page, and it can display a greeting, update notice, or counter, and grab those settings from the db file? This is a tough one, but I figured I'd throw it out there.

DBMAN and Links 2.0 are literally the back bone of my support group site, and I can't praise these scripts enough. It empowers the visitors, and makes my job a whole lot easier when updating all of the data that the people submit to me.

Contact me at tbk@home.com or whatever you find neccessary!

Thanks again!
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
Hi,
for admin fields set the form-length to
-2

telefon => [17,numer,-2,.......],

if you don't use "auto-generation" for the record form, you shall define the Telefon field in your html.pl html_record_form and html_record.
than it works,i think
bek
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
Adding new fields is not a problem. However, I would highly recommend that you do not keep passwords in your database file (UNLESS you are going to put the database file in a password protected directory outside of the regular DBMAN directory).

Here are answers to your questions:

a) That is easy. Add these following codes in your sub html_record routine:

Code:
|;
if ($per_admin) {
print qq| $rec{'Fieldname'}|;
print qq| $rec{'Fieldname'}|;
}
print qq|

Just replace the Fieldname with the name of the fields that you only want to see as administrator. Also, you can add HTML codes between the print qq| and |; codes.

b) The password in the .pass file is encrypted. But the password field that you want to add (which in my opinion, which is shared by other DBMAN users and programmers) is NOT encrypted. There is a Secure Password Mod located at the following web page that you can download and use in your scripts:

www.jpdeni.com/dbman/mods.html

I would suggest using that script if at any time you want users to be able to modify their own records.

c) SSI calls do not work in cgi scripts, but what you can do is use OPEN database codes to open those other databases and then insert variables into DBMAN. There is a Thread over in the DBMAN Installation Forum that discusses how to do this.

d) In terms of Cookies, there are some DBMAN programmers who have done this in their site. There is a Thread over in the DBMAN Installation Forum that provides information about adding Cookies to the DBMAN scripts.

Some words of advice:

1) Check out the Resource Center first and see if there are FAQ or Mods that you can add to your scripts.

2) Carefully search through the Forums for keywords relating to your requests. (Two of the four requests you've given have been discussed many times and even in the last week. Smile.)

Hope this helps.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited September 19, 1999).]
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
Thanks Eliot & bek,

I have searched the mods, and even installed some of them, like the clickable links, email, url, friendly display, ignoring the empty fields and such.

i just thought I was getting in over my head adding fields to the db that is already active, and even more hesitant when adding a password protection feature that was never added in the first place. I had the feeling that adding a password field may have been a bad idea, and I was right. Glad I asked!

Thanks again, and if you have any other ideas or code you can throw my way, I greatly appreciate!

You all KICKAS!

[This message has been edited by TonyB (edited September 19, 1999).]
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
By adding new fields to your default.cfg file, you will need to add the delimiter and default values in your database file. If you don't, then your database file will be corrupted. I have written a script that will automatically add delimiter characters and default values into existing database file.

I have it on my server located at the following web address:

www.anthrotech.com/cgi/dbman/mods/upgrade.txt

Feel free to use it. Make sure that you use it for each new field you add to your database.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
Thanks! It sures beats editing the db by hand! i had to do that last time when I moved over to this server, and added a field or 2. What a pain!
Quote Reply
Re: Adding a field only ADMIN can see, and adding a field(s) into an existing db In reply to
Any ideas why the August 11 mod which allows selective viewing (adding) to fields on a form depending on whether or not you are an administrator only displays fields of 1 character in length on autogenerated forms.

I've set my field lengths to -2 and when a non-administrator logs on, the administrator fields only are suppressed . But when I log on as an administrator and want to work with the fields, these adminstrative fields show but are only one character in length.

If you want to view the config file (which is set to autogeneration) so far, check out http://www.retaillabs.com/listing.cfg .