Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Need help with 2.2.0 changes for "isValidated"

Quote Reply
Need help with 2.2.0 changes for "isValidated"
Hey all,

I just upgraded and have been noticing a few differences with the way Links SQL uses "isValidated". I guess with the changes made to the way Links uses "isValidated" this is to be somewhat expected. Here's a snipit from the developer changes that were posted with the announcement of 2.2.0...
  • Previously, a link was "viewable" in Links SQL if it had the 'isValidated' column set to 'Yes'. Due to the addition of payment support, the way to determine whether or not a link is viewable has changed, and a subroutine VIEWABLE has been added to Links.pm (it can be imported via 'use Links qw/VIEWABLE/', or via 'use Links qw/:objects/', or used directly such as Links::VIEWABLE), which returns a Condition object that should be used, such as: $DB->table('Links')->select(VIEWABLE). See the comments above the VIEWABLE subroutine in Links.pm for more complex examples.



  • I don't completely understand those developer changes to "isValidated". Does this mean I need to change all my globals to use the new subroutine "VIEWABLE" for them to work properly???

    EX:

    $sth = $search_db->select ( { isNew => 'Yes', isValidated => 'Yes' });

    to

    $sth = $search_db->select ( { isNew => 'Yes' } , VIEWABLE );


    One other problem I'm having is that I can no longer call for all links in a category using my old method of:

    http://www.mysite.com/cgi-bin/search/search.cgi?isValidated=Yes&catid=12

    The example above just sends users to my advanced search page with no results. I did just happen to stumble across a quick fix for my site. Using the following does produce the desired result even though I have no idea why...

    http://www.mysite.com/cgi-bin/search/search.cgi?isValidated=0&catid=12

    Is it ok to use "isValidated=0" or is there a better way to make use of the new code? Why does using a value of "0" even work???


    Thanks so much for any help or explaination to any of my questions!

    [/url]
    Quote Reply
    Re: [Jonze] Need help with 2.2.0 changes for "isValidated" In reply to
    >> http://www.mysite.com/cgi-bin/search/search.cgi?isValidated=0&catid=12

    Do you get the same result if you leave off the isValidated=0 completely?

    Also, I would imagine you can use isValidated, as long as you are _not_ using the payment options. The changes are due to the payment module, and needing to decide not only if a link is _viewable_ (eg: approved) but is paid up as well. If paid up doesn't matter, than using isValidated _should_ work properly backwards compatible (eg: no use of payment features in the Links install).

    I may be wrong... I'm just working on my first all Links 2.2.0 site install now. I'll find out in short order though <G>


    PUGDOG� Enterprises, Inc.

    The best way to contact me is to NOT use Email.
    Please leave a PM here.
    Quote Reply
    Re: [Jonze] Need help with 2.2.0 changes for "isValidated" In reply to
    This is all I use;

    Code:
    my $cond = GT::SQL::Condition->new('isNew','=','Yes');
    $cond->add(VIEWABLE);

    ..instead of something like;

    Code:
    my $cond = GT::SQL::Condition->new('isNew','=','Yes','isValidated','=','Yes');

    That is the main difference I have noticed so far (one of my plugins stopped working because of it Frown).

    Hope that helps :)

    Cheers

    Andy (mod)
    andy@ultranerds.co.uk
    Want to give me something back for my help? Please see my Amazon Wish List
    GLinks ULTRA Package | GLinks ULTRA Package PRO
    Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
    Quote Reply
    Re: [Andy] Need help with 2.2.0 changes for "isValidated" In reply to
    Thanks for the help guys... Fortunately I think I may have found the problem and a solution.

    I found that isValidated=Yes was no working as a valid search field because of this code in the search.pm :

    # Remove search fields we aren't allowed to search on.
    my @bad = (@{$CFG->{search_blocked}}, qw/isValidated ExpiryDate/);


    You'll notice how isValidated is being blocked as a valid search. Guess that was added to work with the new payment modules. Althought it looks to me like there is really no reason it should have been blocked.

    Doesn't this code located a few lines below eliminate any search results that have expired???

    # Make sure we only search on validated links.
    $IN->param('isValidated', 'Yes');
    $IN->param('ExpiryDate', '>=' . time) if $CFG->{payment}->{enabled};


    Besides, even if you were not using "isValidated" as a search field you are still going to run into problems. Lets say you wanted to search on a certain field.... EX: http://www.mysite.com/cgi-bin/links/search.cgi?query=&isPopular=Yes

    Give it a try and you'll notice that the urls of the page spans are being created with isValided=Yes added in there. Since it is blocked in 2.2.0 those span pages will no longer work. EX: http://www.mysite.com/...lidated=Yes&nh=2

    Better check your sites people... I didn't notice this for weeks.

    Here's the line I changed in search.pm to my problem...

    my @bad = (@{$CFG->{search_blocked}}, qw/isValidated ExpiryDate/);

    to

    my @bad = (@{$CFG->{search_blocked}}, qw/ExpiryDate/);


    I'm not using the payment modules yet so this works fine for me. I'd would like to find that this has on adverse affect on them since I do plan on accepting payments in the future. Hopefully someone can confirm this and hopefully GT can make changes as well since there is a definate problem with the page spans.

    Later
    Quote Reply
    Re: [Jonze] Need help with 2.2.0 changes for "isValidated" In reply to
    You're right; they are superfluous on the template, and they'll be removed in 2.2.1. However, as they're being effectively ignored in the search code, they aren't actually _hurting_ anything, and the code you cited is simply provided as a protection against displaying unpaid and/or unvalidated links.

    In Reply To:
    Since it is blocked in 2.2.0 those span pages will no longer work.
    The code doesn't _block_ searches that contain isValidated or ExpiryDate, it just ignores the values if they are passed in, and sets its own. This is by design, to prevent people from being able to call up unpaid/expired or unvalidated through the search page.

    In Reply To:
    Doesn't this code located a few lines below eliminate any search results that have expired???
    It does, in most cases, but without the top code it could be worked around by passing in something like 'isValidated-ne=Yes', which is not eliminated by the second piece of code.

    In Reply To:
    Hopefully someone can confirm this and hopefully GT can make changes as well since there is a definate problem with the page spans.
    I've tried to reproduce this locally, both with and without payments enabled, and although the isValidated=Yes and ExpiryDate=>=xxxxx show up in the page span URL's, they do not appear to be affecting the search results.

    In Reply To:
    I found that isValidated=Yes was no working as a valid search field ...
    It isn't really a search at all, as it will always return all links. If you really want to return all links in a search result, I recommend using 'ID-ge=0', which should be the same thing you are expecting from isValidated=Yes.

    Jason Rhinelander
    Gossamer Threads
    jason@gossamer-threads.com
    Quote Reply
    Re: [Jagerman] Need help with 2.2.0 changes for "isValidated" In reply to
    Thanks a lot for taking the time and clearing all that up for me.

    Guess I had confused the fact that isValidated was being ignored as a way of returning all links instead of being blocked. Until now I didn't know any other way of returning all links, which I why it was causing me so much concern. I just updated my site using 'ID-ge=0' and everything works great. Wasn't aware you could format fields like that...Nice!

    Anyway, thanks again for your help. Wink