Gossamer Forum
Home : Products : Gossamer Links : Discussions :

displaying unpaid links

Quote Reply
displaying unpaid links
I want to make it so unpaid links are displayed in a category listing even when they are not paid for (if they don't pay initially, I'll require them to pay later when they want to modify their link). Except for the fact the link doesn't appear in the category page Crazy it works perfectly, and don't want payments to be optional (or, at least, appear optional) during submission.

In Build.pm I commented out the following lines (which separates out free and paid links) but still get the unpaid links removed. It seems to me this last bit could be edited to do what I want, but I'm not sure:

$cond->add(ExpiryDate => '>=' => time);

I wish there were control of the link display at the template level, but understand the concept of paid vs. unpaid is deeply rooted into the code.

best,
squillo

# Load payment info if payment is enabled. Change sort order by paid links
# first then free links if payment for this category is optional. If payment
# is required, we need to remove unpaid links

# hack as described gossamer-threads.com/perl/gforum/gforum.cgi?post=292632
# if ($CFG->{payment}->{enabled}) {
# require Links::Payment;
# my $payment_info = Links::Payment::cat_payment_info($opts->{id});
#
# if ($payment_info->{mode} == OPTIONAL) {
# my $paycond = GT::SQL::Condition->new($cond);
# $paycond->add(ExpiryDate => '>=' => time, ExpiryDate => '<=' => UNLIMITED);
#
# my $offset = ($opts->{nh} - 1) * $opts->{mh};
# $catlink_db->select_options(@select_options);
# $catlink_db->select_options("LIMIT $opts->{mh} OFFSET $offset");
# $optional_sth = $catlink_db->select('Links.*', $paycond);
#
# $cond->add(ExpiryDate => '=' => FREE);
# }
# else {
# 1) This is an else (instead of elsif ($payment_info->{mode} == REQUIRED)) because the
# run-time count updating code cannot efficiently take category settings into account
# as doing so requires either subselects (which older MySQL doesn't support), or a fair
# bit of Perl code; a single fast count to determine whether the check is necessary
# won't work. The end result is that counts would be off.
# 2) Even if this was an elsif, we can't include ExpiryDate <= UNLIMITED (to exclude
# free links) because links being free is the default for imported, upgraded, and
# admin-added links, which we don't want to exclude from REQUIRED categories.
# $cond->add(ExpiryDate => '>=' => time);
# }
# }

Quote Reply
Re: [squillo] displaying unpaid links In reply to
I'm halfway there, perhaps. Farther up in Build.pm, I commented out line 105 and it now displays unpaid links in the Category listing (though there are probably unintended consequences elsewhere).

Code:
# Should not select unpaid and expired links if payment is enabled
# $filter{ExpiryDate} = '>=' . time if $CFG->{payment}->{enabled};


The only problem now is the detailed page still won't show an unpaid listing. Anyone know where the link comes from in the default detailed page template?

squillo
Quote Reply
Re: [squillo] displaying unpaid links In reply to
Okay, my readership, forget everything I wrote above. Tongue

I've now got unpaid links displaying in the Category listing, and Detailed unpaid link pages showing by commenting out two places in Build.pm (around line 511 and 649-as above). However, the Next and Previous links for the unpaid Detailed page are still not working. I think the answer is around line 525 in Build.pm, but not sure.

squillo
Quote Reply
Re: [squillo] displaying unpaid links In reply to
It seem to work. The key piece was finding and modifying the VIEWABLE condition in Links.pm, then turning it off in Modify.pm under the modify_passed_in subroutine.