Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Change Add Date to Current Date

Quote Reply
Change Add Date to Current Date
Hi,

I'm using Links SQL version 2.12

I always have a large number of site awaiting validation. I like to list the new sites as those which are validated during that specific day. How can I change the "Add Date" to reflect the current day instead of the day the link was submitted?

thanks!

marc
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
You can just change the Add_Date to current date when you validate ...

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Change Add Date to Current Date In reply to
Yes,

That's what I've been doing, but needless to say it's sort of a pain to manually edit the date each time. We add over 75 sites per day.

marc
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
We also add a lot of links everyday (that often were submitted a week or two prior) and also would love to be able to have Links SQL do this automatically, if it is possible somehow.

--Frank
Quote Reply
Re: [FrankM] Change Add Date to Current Date In reply to
Well, a small global/plugin could do it, adding a button to the admin, but try:

update Links set Add_Date = Now() where Add_Date <= '0000-00-00' And (Validated eq 'No' or Validated = 0)

The *key* here is limiting the scope of the update to only UNVALIDATED links OLDER than a certain date.

If you want to update *ALL* unvalidated links, you can simplify it to:

update Links set Add_Date = Now() where Validated eq 'No' or Validated = 0

*BEFORE* using any update/delete code, use a select to make sure it's only picking the links you want:

select * from Links set Add_Date = Now() where Validated eq 'No' or Validated = 0


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Change Add Date to Current Date In reply to
isValidated Tongue
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
For ease of use this would be best done as a plugin.

There is likely to be a hook for admin link validation and so you'd just add a hook onto it - probably PRE, and change the dates before the links are validated.
Quote Reply
Re: [pugdog] Change Add Date to Current Date In reply to
Thanks very much pugdog for the SQL commands to simply update the Add_Date for links where isValidated = 'No'. Should have thought of that. Now before I validate a large group, I can just run that through SQL monitor once, rather than changing the date individually on each link being validated.

--Frank
Quote Reply
Re: [pugdog] Change Add Date to Current Date In reply to
Strange, but when I place:

update lsql_Links set Add_Date = Now() where isValidated eq 'No' or isValidated = 0

in SQL monitor, I get this error:

Error: Query Error: Failed to execute query: 'update lsql_Links set Add_Date = Now() where isValidated eq 'No' or isValidated = 0' Reason: You have an error in your SQL syntax near 'eq 'No' or isValidated = 0' at line 1

Please note that I use the prefix "lsql" on my tables in the sql database.

Also, I wonder if there is a way to run this query during build so that the links are already changed when I wake up in the morning for my update. I run a cron that builds once an hour to rotate my links :-)

marc
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
Try changing eq to = Wink
Quote Reply
Re: [Paul] Change Add Date to Current Date In reply to
Paul:

Yes, that made it work, however, the order of submissions is affected. It almost seems to randomly sort the links awaiting validation.

The first ten link IDs for example (in order of listing) 21414, 21415, 21413, 21411, 21412, 21409, 21410, 21408, 21521, 21537

marc
Quote Reply
Re: [Paul] Change Add Date to Current Date In reply to
Hi,

Again, I should reiterate that the above method completely randomizes the validation order of your links. I could have someone that submitted a week ago get their submission after someone who submitted today.

Anyone else have any input on a cleaner way of doing this? I think it is very important for most webmasters to be able to show new links added "today".

thanks,

marc
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
I think that you will need to follow Paul's advice and write a short plugin that changes the date on validating the links. If you change the dates before validating then Links has nothing to sort them on when it comes to validating them.

Laura.

Edit: Alternatively, you could change the sort order for the validation page to sort by ID number of course - but if you modify the core code, you'll have to redo this for every update.

Last edited by:

afinlr: Apr 2, 2003, 10:49 AM
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
Add "order by ID DESC" to the query, and it will sort newer links first, since the ID is an autoincrement, new links will always have a higher number than older links.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [hcom] Change Add Date to Current Date In reply to
Hi,

I just did this the other day, actually. If you don't mind hacking the Links SQL files a bit, here's what I did:

In admin/Links/Tools.pm, look for this block of code:

Code:
my $type = $link->{_mode};
my $db = $DB->table ('Links');
delete $link->{Timestmp} if ($type eq 'modify');
$link->{isValidated} = 'Yes';


(It's in the validate_record subroutine. In my file, it starts on line 914, but mine has been modified somewhat.)

Directly below that, add:

Code:
# hack
Links::init_date();
$link->{Add_Date} = GT::Date::date_get() if ($type ne 'modify');


So the end result is:

Code:
my $type = $link->{_mode};
my $db = $DB->table ('Links');
delete $link->{Timestmp} if ($type eq 'modify');
$link->{isValidated} = 'Yes';
# hack
Links::init_date();
$link->{Add_Date} = GT::Date::date_get() if ($type ne 'modify');


Worked for me, anyhow. Smile

~~~~~~~~~~~~~~~~~~~~~~
Jamie Marie
BuffyGuide.com
Quote Reply
Re: [nemesis] Change Add Date to Current Date In reply to
Hi Jamie,

Thanks very much for posting the modification. I tried it, and it works great!

--Frank