Gossamer Forum
Home : Products : Gossamer Links : Discussions :

limit number of links added per user

Quote Reply
limit number of links added per user
Hi all!

I am looking to limit the number of link submissions to the database per user to 1. Is there an easy way of doing this through the templates alone, or am I going to need to write some sort of plugin? I am currently running Links SQL v 2.05

Hope someone can help.

Cheers.

Hannah
Quote Reply
Re: [hannahmackenzie] limit number of links added per user In reply to
You would need to write a plugin, or at least a global function, but the plugin has the advantages outlined below.

Ok, I'm assuming your users log in -- if they don't, the exercise is pointless from the start :)

The simplest idea would be to have the add.cgi run a plugin pre-hook to see what the date of the last successful submission was.

The add.cgi script would update this field upon successful exiting ie: post-hook.

If the date was within the past 24 hours, reject the submission.

I'd use 24 hours, rather than calendar days, for a number of logical, logistical and other reasons.

To use a global, you'd need to have the global check the date of last submission on the add.html form, and update this column on the add_success.html form. It's more tricky, and probably asking more of the template parser/globals than you would want -- or should want -- to make them do, but it could probably be done. add.html uses a global that checks the Users.last_sub field, and add_success.html has a global that sets the Users.last_sub field. I'm not sure how/when globals are processed, but it should be possible to make sure the update global only runs on the add_success.html form. Whether the other globals run all the time is trivial ... you can then show the user the date of their last submission :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] limit number of links added per user In reply to
But that won't limit someone to one submission. You could post 365 per year :)

How about a simple select for their username against the LinkOwner column. If their username is found in the links table it means they've previously added a link so reject the submission.

Last edited by:

RedRum: Jan 21, 2002, 9:11 AM
Quote Reply
Re: [RedRum] limit number of links added per user In reply to
Hm, I read it as one per day.

Again, the solution is pretty much the same, but if a date was in the submission column block the event. You could just make the 24 hours "forever" and it would work in general in all situations -- 1/day, 1/week, 1/month, 1/year, etc.

I'm sure there are reasons to do this, but unless you have a subscription board, where user names/ID's are doled out for cash or other considerations, what prevents a person from getting multiple ID's?

This is an issue/question that comes up regularly, and some boards have posted they want to make a person re-register for each link, so each link has only one userID. That may make sense in some circles, but it makes it really hard to maintain such a database, and the database gets stale with time. Unless accounts are aged at some specified interval -- 30 days -- (like in a classifieds). Even then, it would make more sense to have one user posting multiple ads, or sequential ads, with a record of the user's performance (validity?) than to have multiple one-use-only accounts.

I just see this sort of thing as a grey area between free-for-all posting, and user-registration. It might have some uses, but if thought through, 6 months, a year, down the road, a "better" solution would be in order.

The main use, I see, is if you have a directory, like the yellow pages, where each paid account (or verfied account) is allowed one listing as a perk of their registration. The disincentive to register multiple accounts is the cost and/or screening process.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] limit number of links added per user In reply to
>>Again, the solution is pretty much the same, <<

Im fairly sure my method would work. You just need to do one query.
Quote Reply
Re: [RedRum] limit number of links added per user In reply to
I thought about using the LinkOwner field, and you could do that, but the problem was presented as

a) "limiting the number of link submissions per user to 1"

_not_

b) "allowing each userID to only have one link attached to it".

Semantically and logically, these are different problems, and would be evidenced down the road, if changes were made to the Link record, or other methods of tracking links, or if your needs change, such as wanting to allow multiple Links per [upgraded] user, or even a time between modify. What if the admin wants to assign links to users, that don't count as the users upload? What if the admin now wants to allow 2 links per user? What if a user can buy more upload credits??

The "concept" is that the User is allowed to add one link to the database. That is an attribute of the User and User-table, not the link record, or the relation between the two tables.

An existing link in the database shouldn't preclude a user from "adding" a link -- necessarily.

While it could be made to function in a similar fashion in this case, by looking at the LinkOwner field, it really hasn't attacked the problem, or solved the problem in a database-normal type fashion.

I might be picking nits, but with the ability of LinkSQL to grow into a huge "community", addressing the stated issue, or the "real" issue, rather than a quick fix is important. It's easy for the database to become unmanageable, and for relation assumptions to exist between tables that are not truly valid.

1) If you want to limit each Username to one link in the database, then you can use the LinkOwner field, since each Link has an owner, and you want a 1<=>1 relationship between them. In that case, the Link table is the "dominant" table, and if a record exists in it, you block addition of another. I don't see this as an extremely valid, or useful relationship. It's got very limited application, and is hard to scale properly.

2) If you want to limit the number of SUBMISSIONS from each user ID, that requires tracking of the userID, and the number of submissions it's made, and perhaps the date of submission. In this case the USER table is dominant, and the info should be based on that (or a relation table). If you only want one submission, you can use the date of last submission to track that -- no date, no submission. If you want to allow multiple submissions per user, you would want to keep track of the number of submissions, and date of last submission (perhaps even a more complicated relationship, but that would then require information as stored in the link). It would - theoretically - be possible to reconstruct the "submissions" from the LinkOwner field, but not necessarily -- since an editor or admin can muck that up by assigning a non-submitted item to that Username. Multiple Link records with the same Username can exist, but the User is still allowed _one_ submission of his own.



Again, I'm trying to explain a subtlety, but the problem as presented was "allowing each user to submit one and only one link" (and I added per-unit-time on my own <G>), not the deviant converse of allowing only one link per Username.

One is easily, and logically scaleable, the other isn't.

Your solution may work for now, as desired, as a quick fix, but I see a "gotcha" in it down the road if scalability is needed.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Post deleted by RedRum In reply to

Last edited by:

RedRum: Jan 21, 2002, 10:52 AM
Quote Reply
Re: [RedRum] limit number of links added per user In reply to
The difference is in the "submitting".

A webmaster is attempting to limit the user to one submission -- ie: one pass through add.cgi, not to owning only one link in the database.

Maybe, in some cases, that is the "same" thing. But not always.

Your method is not scalable beyond the 1<=>1 relation between username_table<=>Link_table, reguardless of how or when that relationship was established.

By not using the LinkOwner field, the number of links "owned" by a userid is irrelevant. The issue, or problem, is limiting the number of [future] SUBMISSIONS by that username.

That can be scaled, easily, through a variety of methods, and can adapt to the changes a site will inevitably go through during it's lifespan.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] limit number of links added per user In reply to
Blimey! Thanks for all the info guys - you've both given me lots of food for thought.

Pugdog - i did mean 1 link per user. We are building a web directory of music related sites and have customised links sql to act as a kind of yellow pages system : users can have a "SmartClassified" or a standard listing.

Our site has a tiered membership system: standard users and premium users. At the moment, standard users can add a basic standard listing of about 6 fields whereas a premium user can add upto 20 (at last count) fields worth of information about their business/organisation - the so called "SmartClassified".

We've built in a signup procedure of our own which if they select premium membership sends them off to Worldpay to charge their credit card - on their return an entry is made into our own user database and then in the appropriate places in the links user table. If the credit card authorisation is successful they are entered as a premium user - if it fails or if they opted for the free membership option they are entered as a standard user.

Basically, we want to limit the number of listings that a standard user can add and maybe even limit the number of SmartClassified full listings that a paying member can add - we're bound to get some users who abuse the system!

Thanks for all the help - i guess i'd better crack on with the plugin!

Best wishes

Hannah
Quote Reply
Re: [hannahmackenzie] limit number of links added per user In reply to
Your situation is actually a subset of what I was addressing :)

Your standard user is limited to one listing, and your premium user is currently limited to one listing, but you might want to increase that number at some point.

In your case, most likely, the number of "LinkOwner" fields that show up for a user will be equal to that users number of submissions (but what if you want to give "special" listings?)

You would want to create your plugin such that it knows how many listings a user has, and whether that user is allowed to add any more. It would work with your standard/premium system.

You don't really need a date field in the User record, since you are not measuring per unit time. But, you would probably want to have an "Allowed_Submissions" field, which keeps track of the number of links this user is allowed to submit and maintain, and add a field to the Link record called "User_Submitted". This field defaults to "1" (for Yes), and can be set to '0' by an admin or editor if they add a record not counted in the users "quota".

You can use that flag field to do your searches, and even to allow the user to edit records with User_Submitted=1 but not 0.

Premium users can get 1 or 3 (or whatever) listings, and standard users can get 1.

Premium users also have more fields show up when their listing is displayed.

From a marketing point of view, I would make the "standard" members enter the same data, but mark the fields that will show up with a standard listing.

If you have a "preview" field, you might want to show them their "Standard" listing, and below that what their Premium listing would look like. Use two different form tags, to submit.

Filter the fields out if a user is standard ie: <%if Premium%> display tag <%end if%>, so that a user can see their "premium" listing at any time, and upgrade. If your users log in, you could make a button on a users link to show them what their premium link would look like if they chose to upgrade. No one else would see that button.

From your plugins point of view, it would need to know the User_submit_limit and a select ID from Links where LinkOwner=Username and User_Submitted=1

Match that to the User_submit_limit, and you'll know if a user can submit another link or not.

If you want to limit by time, you'd just need to add a date field to the User record, and the appropriate handling routines to the plugins.

Each Link maintains the date it was added and last modified, so you can even fine-tune by link as well. (ie: a user can add a link every week, but a link can only be modifed once per month).

Again, that could be refined by additional fields in the User record that give a user the ability to make more changes or more frequent changes by paid/premium status.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.