Gossamer Forum
Home : Products : DBMan : Customization :

archive Mod

Quote Reply
archive Mod
I have a archive in place but I wonder if there is a way to prevent users from adding new record if the record is Archived 4 Example
user add record admin archive's it after 30 days
when this users signup again and want's to add the same record need's to get autorization from admin
Quote Reply
Re: [classic] archive Mod In reply to
Well, there's two tasks in there, no?

(1) Mark a record as "archived" after 30 days (automatically or with approval?). I don't quite get the purpose of this, though.
(2) Prevent users from adding records which already exist as "archived".

(1) If you want automatic archiving, you could add a field to the database with the date when the record was added. You could then let dbman automatically check all record dates and replace the date with the string "archive" if the date is 30 days or more in the past.

(2) When a user wants to add a record, you'd check the record against all records which are "archived" - or against all? Then you'd inform the user that they need admin approval if they really want to add the record. If so, mail the record proposed to be added to the admin and notify the user.
You'd have to set definite criteria for checking new records against existing ones: Define one, two or more fields where records should not be identical.

Is this what you want? I don't quite understand it, as I said, and if you really want to automatically archive records after 30 days and compare new records only against *archived* ones, users might add duplicate records which are NOT yet archived.

kellner
Quote Reply
Re: [kellner] archive Mod In reply to
Ok How do i put it . Sorry ESL
i have database that user adds it's company
to db and has 30 days to decide if he want's to keep it in db or not .
If it does he pays the members fee and that's fine if it's not than i was thinking of putting it to Archive if he decide's to keep it i just unarchive .
But if he decides not to keep it but add it again
i do not want him to .
So the new addition checks against archived, i do no want to all the new recors go to Archived only the one I approve .
Does That make sense ?
If you have any other suggestions .
Thanks A LOT



Quote Reply
Re: [classic] archive Mod In reply to
Let me see if I understand this correctly:
1) A user adds a record to the database
2) After 30 days, the user is asked whether they want to keep the record in the database - if so, they have to pay a membership fee and the record stays as is
3) If the user decides not to pay, then the record is "archived".
4) If the same user decides to add the same record again, it is refused. (What if someone else adds the same record? Would that be OK?)
kellner
Quote Reply
Re: [kellner] archive Mod In reply to
Yes that's it
No one else can add this record with :
the same userid;email ;or state

Quote Reply
Re: [classic] archive Mod In reply to
I know you are wanting to use the archive mod, but have you looked at the Auto Delete mod?

You could set that mod up to automatically delete records after a certain period time. There are several variations of how this can be used, and may provide other ideas or options.


Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [classic] archive Mod In reply to
I haven't looked at the mod, but here are my thoughts anyway.
There are basically two approaches you could choose: 1) Write the "archived" entries to the same database file than the other ones, but mark them (e.g. by adding a select field "archived" with "yes", "no", "pending" and "disabled"), 2) use a different database file.
I'll start out with the first approach.

I would suggest adding two fields to the database, if they aren't there already, and then performing actions depending on what they contain: First, a field for the date when the record was added, second, a field called "archived" with values "yes", "no", "pending" and "disabled". "Disabled" means these are regular database entries, "yes" means they are the ones that users already tried to add in the past, "no" means they're added recently and the user hasn't paid yet, "pending" means you already sent a warning email "pay or the record will not be added" to the user, but they haven't replied yet.

I'm assuming users login with a username, and not as "default", and I also assume that the database contains a field with a user id.

So you'd have to do the following things:
1) If a user adds a record: Check whether the database contains records where "archive" = "yes" where the field "userid" (or whatever it's called) = current user id, and whether it is significantly similar to the one the user tries to add. By "significantly similar", I mean you'd have to decide based on what fields you check a new record against existing ones - you'd probably want to use fields which are obligatory and where chances of variation are next to zero (postal codes, names of towns, countries, people - comment fields would be a bad idea). Full identity in all fields might be a problem, because simply throwing in a typo here and there would result in the record not being rejected. This is perhaps the trickiest part of the whole routine. Are you sure that "userid", "mail" and "state" are specific enough?

Anyway, if your standards for significant similarity are met, then the record is not added: The user gets an error screen saying "You have already tried to add a record with the values X, Y and Z in the fields A, B, and C. Please report to the administrator if the record you're presently trying to add is indeed different from that one." (for politeness - it might turn out not to be the same record after all.)
I'd code this as a separate subroutine, called from add_record in db.cgi.

2) Whenever dbman starts up: Check all records where "archive" = "no". If their "date added" field has a date more than 30 days back, send a message to the user that contains the record (I reckon their mail address is in the database as well) and asks them whether they'd like to pay the membership fee.
At the same time, set "archive" to "pending" and update the "file added" date to the current one. That way you make sure dbman doesn't send warning messages to users more than once, and you can also check how long it takes until users reply.
In the same routine, you can check: If there's a record with "archive" = "pending" for longer than XX days, set "archive" to "yes". This has the benefit that you'd only have to "de-archive" records manually - like, when the user pays their fees and sends you a mail, you'd have to change the value of "archive" to "disabled" (you can code a link to that routine in your admin interface to make that easier). When they don't, the record will automatically be moved from "pending" to "yes" after a certain amount of time.
This would be a separate subroutine, checked whenever dbman starts up (e.g right after auth_cleanup in db.cgi).

How does that sound?
kellner