PDA

View Full Version : Adding (approving) Links via cron.


neverstop
11-23-2007, 12:08 AM
Hi,

This isn't quite a "How do I..." question because I am sure it isn't part of the default install but it seemed like the best forum.... This is more of a "Is this the best way to go about this...." question. I am not a coder so I will be contracting someone to help me out and I want to make sure I am not way off/missing something.


I want to be able to use a cron script to approve a link every hour.
I want the links to be "pre-approved" by an admin/moderator before the cron script can approve the link.

I was thinking one way to do this is to add a radio button custom field (yes/no).

The script looks for the link with the oldest timestamp and (cfield-pre-approved = yes) and then approves the link and updates the timestamp to the current time.


Any thoughts on this?
Cheers,
Ian

Brian
11-24-2007, 10:12 AM
I'm sure that would be possible, but would probably require adding a new column to the adv_links table and then re-working the default approval page so that it updates this new column instead of the 'valid' column. Just out of curiosity, what's the point of moderating the links and not displaying them until an hour later?

Our Sponsors
 

neverstop
11-24-2007, 10:31 AM
Just out of curiosity, what's the point of moderating the links and not displaying them until an hour later?

The idea is that I can "pre-approve" X links, and have the script run every hour and approve one link at a time, so it seems like the directory is being updated constantly (rather than adding a bunch of links all at once).

I'm sure that would be possible, but would probably require adding a new column to the adv_links table and then re-working the default approval page so that it updates this new column instead of the 'valid' column.

Hmmm, I was hoping I wouldn't have to alter any files or tables. You don't think it's possible using a custom field? This is how it works in my head:


User submits link to database.
Admin reviews submitted links. If the link is acceptable, admin selects "pre-approved" from a custom field radio button (If unaccaptable, admin deletes link (or does nothing)).
Admin does this for any/all submitted links.
Cron script runs once per hour.

It searches the database for links with the custom field from above set to "pre-approved".
It takes the link with the oldest timestamp and cfield = pre-approved and changes the the link to valid.



This way I can pre-approve like 20 links at a time and the script will "validate" one an hour.

Think I should look at altering the table, and the approval page?

Cheers,
Ian

Brian
11-24-2007, 10:57 AM
Hmmm, I was hoping I wouldn't have to alter any files or tables. You don't think it's possible using a custom field? This is how it works in my head:

Possibly... I would think you could add a new custom field, but would still need to hack the files a bit to hide that custom field in the showlink.php and addlink.php files. If you went that route though you could just leave the radio button set to 'Ignore' for each link when validating, change the custom field for those you want to validate, and then use your cron script to look for links that have that custom field updated and update those links to change the 'valid' column to 1.