Gossamer Forum
Home : Products : DBMan : Customization :

Q&A: 'deactivate' records & neat tricks

Quote Reply
Q&A: 'deactivate' records & neat tricks
I'm converting DBman into a fairly groovy multi-user property listing system. The tricks I used wound up being useful enough that I thought I'd share some details before asking my question:

First: I modified the output with JPDeni's 'listing style' mod - list of results, click on one and it displays the unique record.

Then I set up DBman to auto generate the forms but NOT the output - allowing the admin to see the Userid and ID fields in the forms, without displaying them in forms for other users. From the admin login you can assign and reassign records to and from any user. Add a field to the flatfile and you don't have to mess with updating the forms, but you still have tight control over the record display. Easy to administer + easy to modify = cool.

Then I whacked in an upload photo feature by setting up a photo upload script and attaching it's link to the ADD permission in the script - if you can add, you can upload. Not tightly integrated, or really secure, but it works. Wish I could figure out a way to write the filename to the Photo field in my flatfile...

NOW: Since they're rental property managers, they always have the same properties to list, but these properties are obviously not available all the time, and therefore don't need to be listed all the time. However, reentering the same record over and over is a pain - if they could just deactivate and reactivate the records it'd be real snazzy.

I'm thinkg about adding a yes/no field to the database and the user input forms called 'active'. If the value is yes, the record is active in the database and is displayed as a search result. If the value is no - the record is not displayed in the search results.

How would I modify the search to exclude/include records based on the value of a field?

I had also thought about having a checkbox that appends a letter (a) to the record ID - and limiting the search to records that have
the a in them, but that sounds kinda scary...

If anyone's got any thoughts on this I'd love to hear 'em!

------------------
Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
Nifty!

Regarding your limiting viewing on the basis of a field entry -- you can do it one of two ways. The first way is to add a hidden field to your search form.

<input type="hidden" name="field" value="yes">

or something similar.

If you're using the same form to search and to enter, this could be a problem, though. So, you could some lines within sub view_records (db.cgi) --

before

my ($status, @hits) = &query("view");

add

unless ($per_admin) {
$in{'field'} = "yes";
}

replacing, of course, "field" with your field name. This allows you (as admin) to view all the records, but everyone else only sees the ones that are okayed for viewing.


------------------
JPD





Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
Shucks - I been messing with this all afternoon, and nothing I do seems to work!

I'm using both an HTML form and the script generated search form - but I removed the record_form line from the search form so you just get the search options.

Since I need users to be able to activate and deactivate listings, I thought I'd just go with the hidden input tag based on a database field. So I added a new field to my database: Status. It's values are Active|Inactive.

Then I added <input type="hidden" name="Status" value="Active"> to the HTML search form.

Went in and switched several records to Inactive, then searched the database. Nothing changed; every listing was displayed.
Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
whoops! stumbled and hit the submit reply button before I finished...

Anyway - what am I doing wrong here?
Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
Your choice of options was unfortunate. Since "active" is part of "inactive," it won't give you what you want without a little more work. You'll need to add another hidden field -- name="ww" value="1" -- that will make it look for whole words.


------------------
JPD





Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
Totally Wierd: I went back and set the whole thing up again. I called the field in the database 'Active' and it's values are 'Yes|No'. Tagged my input forms with <input type="hidden" name="Active" value="Yes">

As simple as possible, as close to your example as possible. I even understand WHY it should work - but in total disregard for the fact that you and I are right, it refuses to work. I still see all the listings, all the time, no matter what I change. I tried the view_records mod - but that didna seem to work either.(???)

To make sure the hidden value was passing from the form correctly - I screwed up the hidden input tag (value=red instead of yes).
As I expected, it screwed up the search (no matching records). The script is getting the field & value passed to it okay - it just don't care. It displays all of my records, regardless of the value of the 'Active' field.

I done think I screwed something up somewhere during the various mods. But I've not a clue what at the moment...hmmph.
Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
I think it's time for me to look at your database, if you would be willing to give me the URL. If you'd rather not post it publicly, you can send it to me at hall@drizzle.com .


------------------
JPD





Quote Reply
Re: Q&A: 'deactivate' records & neat tricks In reply to
The saga continues: Sorry bout the delay - Easter & whatnot, you know how it is.

I would most certainly appreciate it if you'd log in and have a look - but this weekend, the folks who host this site decided to move it from a commercial hosting service's unix box onto their own NT box this week. I'll email you once things get settled a bit with a login and such.

Thanks!!