Needs work
Project:
lm_paypal
Version:
5.x-1.0
Component:
Code
Priority:
Critical
Category:
Support request
Assigned:
Reporter:
Created:
29 Jan 2007 at 04:45 UTC
Updated:
21 Jun 2009 at 02:27 UTC
Jump to comment: Most recent file
Hi,
I have a list view that has a search bar at the top. How do I filter the view so that unpaid adverts don't get listed in the filtered results?
Cheers..
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | lm_paypal_subscribers_views-5.x-1.x-dev.tar_.gz | 1.17 KB | Triskelion |
| #14 | lm_paypal_subscribers_views-5.x-1.x-dev.tar_.gz | 1.21 KB | Triskelion |
| #11 | lm_paypal_subscribers_views-5.x-1.x-dev.tar.gz | 1.13 KB | Triskelion |
| #10 | lm_paypal_subscribers_views-5.x-1.x-dev.tar.gz | 1.12 KB | Triskelion |
| #3 | lm_paypal_views.tar.gz | 881 bytes | ivissani |
Comments
Comment #1
swms commentedI have the same problem. Unpaid adverts are shown in the "views" I use on my side. What can I do to show only paid adverts?
Comment #2
LeeMcL commentedWhen you say a "view" is this using the Views module (not CCK or something else similar)?
I've never used that module so I'll have to install it locally to test it out. Can you let me know which version of Drupal and which version of Views you are using so I can duplicate the setup here.
Lee
Comment #3
ivissani commentedProblem is that this module doesn't change the Published/Unpublished status of the node as one can expect on first sight. Instead it determines the internal paid/unpaid state independently of the Published/Unpublished status of the node.
One way to workaround this is to add views integration capability to the module.
I attach a first and rough approach to this which isn't in anyway finished but may solve the simple problem of unpaid nodes getting showed in views by implementing a very simple (and maybe bad coded) filter.
I hope this can help someone with more time than me to extend this module capabilities.
Comment #4
codenamerhubarb commentedThanks ivissani for your views filter module... it works great if you only want to show the node types that require a subscription but what I want to do is show a few other node types that do not require subscriptions as well as my 'paid_listing' node type (which have actually been paid for).
So in my views filters I have the filter Node:Type ... is one of ... (selection of 4 node types I want to show - one of them being paid_listing) as well as a couple of other filters like Node:Published ... equals ... Yes etc.
However, when I filter the results it only ever shows those where lm_paypal_subscribers.status = 1 ... so it completely disregards all the other node types and only shows those which are associated with a subscription.
Is there a way to alter the code in your views filter module so that only if the content type is 'paid_listing', or even better only if the content type requires a subscription the filter will apply?
I'm having a hard time understanding the code in your module but I have added an 'if' statement right near the end which is probably wrong but might help you understand what I want to acheive. I'm not sure if I can even use an 'if' statement for the filter because it throws an error and doesn't display in the 'add filter' drop down box...
Comment #5
codenamerhubarb commentedI managed to solved my problem, yay!
If anybody would like to how I did it I just edited the part near the bottom of ivissani's code so it looks like this
Note that "paid_content" is the name of my content that requires a subscription.
Thanks ivissani for your great code, I owe you a beer.
Comment #6
codenamerhubarb commentedI've got another question... Is it possible to add to this views filter the ability to also show only those adverts that are unpaid?
Comment #7
asak commentedNice! the code works!
I used the addon by codenamerhubarb - and that works too.
Very nice - thank you.
EDIT: And a quick question: How would i add more content types to that list? i know no php... should i use "xx", "xx" .. or add 'or' or..what?
Thanks!
Comment #8
codenamerhubarb commented@asak,
Basically what you need to know is '!=' means 'does not equal' and '&&' means 'and'.
Also, '%s' is a placeholder for the strings and %d is a placeholder for the decimal/integer values that come after the comma.
So you should be able to change this part of my code...
...to this...
Notice the addition of the brackets surrounding the new values, this separates all the node.type!=... clauses from the lm_paypal_subscribers.status clause. Alternatively you could do something like the following to include the free content types:
Comment #9
asak commented@codenamerhubarb - Thank you so very much for the detailed explanation!
I was trying various options but all seemed to give me sql errors and cause much trouble,
I'll test this and see how it goes...
Thanks again!
Comment #10
Triskelion commentedI was looking at this issue because I am struggling with the module and paid ads. The code in the module by
codenamerhubarb is a good start, but LM PayPal is translation-aware, and the hard-coding of user-configurable options is a recipe for disaster. It means that the module must be maintained each time a new content-type is added, or a new selection-option is required. I have made a few changes to try to make the module a little more flexible, including several insertions of the t() function.
The new filter definition permits filtering on either status, and the filter may be exposed as optional to give the user complete control.
The handler now creates a list of paid node-types for the query, using a code snippet from another LM PayPal module.
I look forward to feedback, and I think after testing, this functionality should be committed to the development version. Thank you to codenamerhubarb for getting this started.
Comment #11
Triskelion commentedOops, wrong copy of the file upoaded :( !
Please use this one.
Comment #12
lyricnz commentedIs it possible for you to create a simpletest for this code? I don't have much experience with writing views plugins, so won't be able to tell if we break it. The current D5/D6 branches are really in maintenance-only mode, but if you can provide a patch with a test, we'll be happy to put it in.
Comment #13
Triskelion commentedPart of the problem is that the dev branch is broken for paid advertisements. Playing with this new module has helped me to understand the way LM PayPal works, and I have found the problem (Will post another thread to explain).
I am already finding problems with this module code. The filter may return an array() in $filter['value'], so I have made adjustments. It also appears that add_where() escapes quoted lists when it does string substitution. Makes the queries fail. I have moved the string assembly out of the add_where() function. I will post a final version once I have completed my testing.
I am not familiar with simpletest, although it appears to be a good concept. I guess I'm just an old fashioned print_r() kinda guy.
The questions are simple. Does the view display the fields? Does the filter work? It is not mediating any other content types, and it is almost impossible to break t().
It would not be a patch. It would be a new .module and .info to commit to the cvs. Let me finish my testing, then let the users have a go. If it passes muster, commit it.
Comment #14
Triskelion commentedFinished initial testing, and the views integration works. The changes I mentioned in the previous post were in the handler code:
I have redone the attached file.
Comment #15
lyricnz commentedYes, much of the code in this module is... a little hairy. Which is why we're doing a significant refresh/refactor in the Druapal 6.x-2 branch. I'll look at your code when I get a chance. Thanks.
Comment #16
codenamerhubarb commentedThanks triskelion,
You've done a great job and your code works much better than my easy 'hack' solution.
Just one thing... you have an unnecessary opening quotation mark in your .info code which is screwing up the way it is presented on the /modules page. The .info code should look like this...
Cheers.
Comment #17
tomws commentedsubscribing
Comment #18
pounard@lyricnz
I think this module is defective by design.
We should force the $node->status = 0; in hook_nodeapi() insert and update operations until the node has not been paid for, it will help for all filters people would want to make, without having the need to implement a view filter.
Comment #19
lyricnz commented@pounard: perhaps, but I would rather add support for doing it *either* way, than break the current behavior. I have asked the original maintainer to comment on this issue.
There are reasons to provide better views integration, besides this particular issue. If we expose subscriptions and subscribers (for example), as View-able things, then we could replace some of our existing pages with views. *shrug*
Comment #20
pounardAs we are totally breaking things in 6--2 branch, this may be a 6--2 branch alteration. But I agree, for current supported version we can't break the API and behavior.
But yes, a view integration submodule would be a good thing, but I think we'll have a to think about what filter we would wan't to really implement.
I think existing admin pages should be views module independant, as views module is not part of drupal core, and is not really needed to use paypal API.
Comment #21
Triskelion commented@codenamerhubarb
Thanks for pointing out the .info problem. I have changed the file to a cvs blank format in case it is to be committed.
@pounard
I just made a comment on this in #360779: Paid Adverts implementation of hook nodeapi unexpected behaviour before I came here. If support for doing it 'either way' is really an option, count me in! It would make my current job much easier. If you can give me a starting point, and a little direction, I would be willing to have a go at it. I am a solid php coder, with little, but growing, experience with Drupal. J'attend votre reponse.
Comment #22
LeeMcL commentedI wrote LM_PayPal quite some time ago for Drupal 4 and just to handle user subscriptions and donations. After it had been in use for a while I was asked to add some sort paid advert system to it. I didn't want to break existing installations which limited my choices and explains the convoluted code.
From memory, and please bear in mind it has been a couple of years, Paid Ad's were designed to be a two stage process. Nodes would be created but not visible to anyone but the author, which made it easy for the author to find their adverts, see there status, pay for them.... Once paid for they would be visible to all. I did try a few options to implement this and stuck with the one that worked.
Lee
Comment #23
pounardThis codebase is really old. I think it needs some severe cleaning in the way it behave, has I see it (may be not for you), I see a mis-use of drupal hooks, and a really weird behavior.
Comment #24
lyricnz commentedThe old module doesn't really *use* hooks, it uses function names, and added hooks later! Hahaha. I think we will do lots better in 6.x-2
Comment #25
pounardSo, let's state right now how it should behave :)
Comment #26
Triskelion commentedDesign, then build. What a concept! :-)
Comment #27
pounardI opened a new bug for this: #362180: Paid Advert submodule redesign: make use of drupal hook system should be a start
Comment #28
codenamerhubarb commentedHow about when you are trying to show just those nodes which are published but not yet paid. There would be no value for lm_paypal_subscribers.status because it would not exist yet.
Is there some way to adjust triskelion's code (#14) or even make a new views filter which shows only those nodes which haven't been paid yet as well as those where lm_paypal_subscribers.status doesn't equal 1... maybe something along the lines of
"WHERE ( (node.nid NOT IN lm_paypal_subscribers.nid) or (lm_paypal_subscribers.status != 1) )"I've been trying myself for nearly an hour to add this functionality to the code but can't seem to get it right and I would really appreciate some help.
Comment #29
timb commentedAnyone thinking of going to drupal 6 with this?
Comment #30
lyricnz commentedtimb: not until someone submits a patch - both the current maintainers are really busy at the moment
Comment #31
publetariat commentedI posted a workaround in this issue:
http://drupal.org/node/496978