Closed (fixed)
Project:
Userpoints Node Access
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
1 Aug 2010 at 23:40 UTC
Updated:
7 Oct 2010 at 18:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
berdirImportant:: The 6.x-1.x version has multiple security issues (see the issues I created), is only like 50% implemented and has several design flaws. This is not a port, this is a complete rewrite of the module, using several features which only exist in Drupal 7.
Once this is working, we can think about backporting this to Drupal 6, that is probably easier than fixing the bugs in the existing code.
Features:
- Support for vertical fieldset on node edit (including summary)
- Does not actually use the node access system to deny access but instead replaces the content with a form that allows to buy the content. Not only does the node access system simply not allow this kind of feature (allow users to buy a node because a node for which they don't have access to is completely hidden but this will also allow advanced follow-up features like allowing access to the teaser only).
- Integrates settings into the userpoints settings page instead of a separate page
- Removes unprotected menu callbacks to empty database tables (doesn't belong into a productive module imho. If you want to do that, reinstall the module or use phpmyadmin)
- Support for bypass content access permission
- Allows access for the author
- More which I've forgotten :)
Comment #2
BenK commentedHey Berdir,
All of your work on this module is very cool! I tried out the patch and I'm getting the following error message when enabling the module, emptying the cache, or saving Userpoints settings page:
Warning: include_once(/Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess/userpoints_nodeaccess.theme.inc): failed to open stream: No such file or directory in _theme_process_registry() (line 381 of /Users/benkaplan/git/drupal/includes/theme.inc).
Warning: include_once(): Failed opening '/Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess/userpoints_nodeaccess.theme.inc' for inclusion (include_path='.:/Applications/MAMP/bin/php5.2/lib/php') in _theme_process_registry() (line 381 of /Users/benkaplan/git/drupal/includes/theme.inc).
Also, I can't find any administrative controls for assigning how many points are needed to "buy" a node. I'm assuming these individual node settings should be available on the node/add and node/edit pages (in the vertical tabs section), as well as the content type defaults pages. But they aren't showing up at all (even after I tried clearing the cache).
Could the above error be related to why these node settings are missing? So far, I can only see the general settings on the Userpoints settings page and the one added permission on the site permission page.
Thanks,
Ben
Comment #3
BenK commentedComment #4
berdirYeah, sorry, my fault, the new files are missing from the patch file. (I hate CVS :p)
Comment #5
berdirTry this patch.
Comment #6
BenK commentedBerdir,
I tried the patch in #5 and the error message has gone away. Yay!
But I still can't find any administrative controls for assigning how many points are needed to "buy" a node. I'm assuming these individual node settings should be available on the node/add and node/edit pages (in the vertical tabs section), as well as on the content type defaults pages. But they aren't showing up at all (even after I tried clearing the cache).
At the moment, the only settings I can see are two settings at admin/config/people/userpoints/settings and the one added permission on the site permission page (admin/people/permissions). I don't see any place else to configure the points required to view a node.
Thanks,
Ben
Comment #7
berdirUhm. Tried the patch on another laptop and it works fine for me. Applied the patch, enabled the module and the "Userpoints Nodeaccess Options" vertical tab shows up.
Is your drupal 7 version up to date?
Comment #8
BenK commentedHmmm.... My Drupal 7 is maybe 1 day old... I'll try to update and report back.
--Ben
Comment #9
BenK commentedHmmm.... My Drupal 7 is maybe 1 day old... I'll try to update and report back.
--Ben
Comment #10
BenK commentedIn an IRC chat with Berdir, we determined that there was a missing "administer userpoints nodeaccess" permission. As a result, the vertical tab was only showing up for User #1. He's working on a fix for this....
Comment #11
BenK commentedBerdir and I also discussed changing some of the permission names and displayed messages. Here's a summary of what we discussed:
* Change "Buy access to a node" permission to: "Trade Userpoints for node access". Make the description read "Allows a user to gain access to a node by trading in Userpoints that the user has accumulated."
* Change "Administer userpoints nodeaccess" to: "Set required Userpoints for any node". Make the description read: "Allows a user (usually a site administrator) to determine the number and category of Userpoints required to access a node."
* Add a new permission: "Set required Userpoints for own node". Make the description read: "Allows the author of a node to determine the number and category of Userpoints required to access that node."
* Change submit button that currently reads "Buy Access" to: "Get Access". Another option is to use: "Trade @price !Points" (example: "Trade 15 Points") as the submit button. Which do you prefer?
--Ben
Comment #12
BenK commentedWe also discussed changing the message that is currently printed to users who don't have access to a node. The message currently reads:
"You need to buy access to view this content. You have to pay 10 points from category Access Points. You currently have 3 points in that category."
Based on Berdir's suggestions, I recommend changing this to:
'To access this content, you must trade in @price "[categoryname]" !points. You currently have [numberofpoints] !points in the "[categoryname]" category.'
Thus, a message would read something like (for the "Participation" category):
'To access this content, you must trade in 15 "Participation" points. You currently have 20 points in the "Participation" category.'
--Ben
Comment #13
BenK commentedI've been doing more testing and noticed two things:
i) It would be great if we could change the default message that is displayed when points are traded in for node access. Currently, the default Userpoints "lost points" message is used: "User authenticated lost 10 points Total now is 8 kudos." But modules like userpoints_no_negative seem to be able to set their own custom message.
So when 10 points are traded in for node access, would it would be possible to display a message like: 'You have successfully traded in @price "[categoryname]" !points and now can access the content. You currently have [numberofpoints] !points remaining in the "[categoryname]" category.'
Thus, it would read something like: 'You have successfully traded in 10 "Participation" points and now can access the content. You currently have 8 points remaining in the "Participation" category.'
ii) It doesn't appear that the "Show a message when the user already bought access to the node and tries to buy it again" setting is currently working properly or actually doing anything. I'm not seeing any message. This might be because we now just hide the form if the user has access (so there is no way anymore to try to "buy" it again). But ideally, I'd love to see a message displayed when viewing the content each time that says something like:
'By trading in @price "[categoryname]" !points, you now have full access to this content. Enjoy!'
This would read as:
'By trading in 10 "Participation" points, you now have full access to this content. Enjoy!'
--Ben
Comment #14
BenK commentedBerdir,
Sorry for all the separate comments. I figured I'd stick with testing so that you can deal with bugs in one fell swoop. I'm posting them as I find them. Here are two new ones I found:
a) PHP fatal error when user creates new content (but doesn't have permission to set required userpoints): I had a regular authenticated user who can't set required Userpoints create some new content (a basic page). Upon trying to submit the new content, I got a white screen of death. Here was the message in my logs:
PHP Fatal error: Call to undefined method DeleteQuery::fields() in /Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess-DRUPAL-6--1/userpoints_nodeaccess.module on line 133
b) "Bypass content access control" is not recognized. I've got a user with the administrator role (but not User #1) who has all permissions, including the "Bypass content access control" permission. But on a node with 10 Userpoints required to access, this admin user is still being shown the "Get Access" message (and he can't access because he doesn't have enough points to see the "Get Access" button). I previously thought this was working, but I might have been fooled before because this admin user was also the node author. Automatically granting access to the node author seems to be working properly.
--Ben
Comment #15
BenK commentedWe should probably also update the language on the node/edit page to reflect our change from buy/sell terminology. Currently, the points description reads:
"Optionally set a price in points that this node costs to get access to. When leaving empty, the standard drupal node access decides who can access the node or not."
We should change this to:
"Set a price in !points that is required to access this node. If this field is left empty, then the standard Drupal node access system is used instead."
And currently, the category description reads:
"Choose a Points category from which this node can be bought."
We should change this to:
"Choose the !Points category that shall be used when users trade in their !points."
--Ben
Comment #16
berdirNice list ;)
Changes/answers:
#10/11: Permissions changed
#12: Strings changed. I few minor modifications, for example, I'm not sure if something like "@price @category !points" works with branding, other languages etc. Feel free to provide more suggestions if you don't like what I've done.
#13:
i) That is currently not possible. Not without #668284: hook_userpoints pass $params by reference, because hook implementations can not change $params so they can not hide the default message. userpoints_no_negative is a special case because it denies to change the points so the default "points changed" message is not shown.
ii) Yep, that setting was actually for something slightly different. It was displayed when you tried to access the page for gaining access to a node. That page is gone now, so it makes sense change the meaning of that setting. Done.
#14:
a) Yeah, saw that myself too and fixed that already.
b) Fixed, I used the wrong permission name (again ;))
#15: Done. Changed the part about the node access reference because this module doesn't really use the node access system anymore, so that is always active (Meaning, a node that has a price is not displayed if a user does not have access to that node).
- After thinking and actually implementing the teaser setting we discussed yesterday, It occurred to me that this setting is so Drupal 6 and not really the way to go in Drupal 7. Instead, the module now defines a separate build mode, which you can configure as you wish. For example, you can add a textfield that is only visible when the user has not yet bought the node. This also solves the issues with translation and stuff because fields can be translated or be language specific. Not our problem any more :)
Please test the attached patch, I just hacked the view mode stuff together, it might not yet work correctly.
Comment #17
berdirForgot to remove a teaser reference in one of the queries...
Comment #18
BenK commentedBerdir,
I've completed testing of your latest patch. Here are the results. I'm starting first with the bugs I previously mentioned:
#10 + #11: The new permissions are working great. This is totally fixed!
#12: The "no access" message currently reads:
"To access this content, you must trade in @price !points of the category @category. You currently have @points !points in the @category category."
Upon further reflection, I think it would be better to change this to:
"Trade in @price !points to access this content. You have @points !points available. Only !points in the @category category may be used."
So this would read:
"Trade in 15 points to access this content. You have 20 points available. Only points in the participation category may be used."
I think it's shorter and more clear.
#13i: Thanks for explaining. Let's not worry about this.
#13ii: It's nice to have this message displayed in the message area at the moment when the points trade goes through (as confirmation that the trade went through). But I don't think we necessarily need to show it every time the node is displayed (because we can deal with that better using view modes as discussed below). Plus, if we only display it immediately after the points trade itself (in addition to the regular Userpoints "points lost" message that we can't delete), we won't have to deal with duplicates in the message area when multiple nodes are listed.
Also, I think we should shorten my original message a bit (since I realized we don't really need to mention the category here). We also should make it better match instances where multiple nodes are on one page. The message currently reads:
"By trading in @price !points in category @category, you now have full access to this content. Enjoy!"
Let's change this to:
"By trading in @price !points, you now may access the requested content."
Also, if we're changing the nature of when this setting is displayed, we should probably change the language of the label itself. Currently, it reads:
"Show a message when the user already bought access to the node and tries to buy it again"
What if we changed it to:
"Show a confirmation message when a user is granted node access"
#14a: This is fixed!
#14b: This is fixed!
#15: This looks good. I did, however, notice one small typo. The field title "Points Category" is not using proper branding (the word "Points" is hardcoded). You could just delete "Points" and let the field title simply be "Category".
ADDITIONAL ITEMS STILL TO DO (as discussed on IRC):
A. Determine if it is possible to change the view mode before rendering to avoid building it twice.
B. Explore the possibility of a second view mode (for users who do have access). The new view mode could be named "Userpoints node access granted". The existing view mode would still be called "Userpoints node access denied".
C. We need to determine if it is possible to only include a view build mode conditionally for certain content types. This isn't critical and might not be possible.
D. Per your suggestion in IRC, we need a new message for the case of a user who does have "Trade Userpoints for node access" permission, but doesn't have enough points to trade . Here's my suggestion for a message:
"@price !points are required to access this content. You currently have @points !points available and need more !points. Only !points in the @category category may be used."
E. Per your suggestion, at "admin/config/people/userpoints/settings", we need to add checkboxes for each content type so that the admin can specify which content types are enabled for Userpoints Nodeaccess functionality.
It's open for debate whether we should also provide a link to the view mode page for each content type. That seems like too many links for sites with a lot of content types. Maybe we should just provide a short note that says check out the "Manage Display" tab for each content type to configure special custom displays. (Also, perhaps we should hold off on default points amounts and categories for each content type since it seems complex to manage from a UI perspective.)
F. The Userpoints Nodeaccess Views sub-module still needs to be ported.
G. Explore the possibility of integrating more of the modules messages/buttons/forms into the view build modes (on the "Manage Display" tab) so that site admins can better control the order and placement of items on the page, including re-ordering and hiding them as needed. We seem to have two basic "fields" (may not be the precise term) with four options each:
1. Access Message:
a) No permission, no access
b) Permission, not enough points
c) Permission, enough points
d) Permission and access granted
2. Access Button:
a) "No access" button/icon (red)
b) "Need more points" button/icon (yellow)
c) "Get access" form submit button (the button that currently exists)
d) "You have access" button/icon (green)
Obviously, I sort of invented 2a, 2b, and 2d above. I wanted to see what you thought. I was thinking we could do something simple with CSS for these other buttons/icons (maybe a css background color and border for each). I was also thinking it would be handy to have all of these options in one "field" because then when you output the field as part of Views integration then all of those options would be shown (as appropriate) in that one field. And if the Access Message was also part of the Views Integration, it would sort of explain each button/icon, too.
But anyway, just an idea... eager to hear your thoughts.
--Ben
Comment #19
BenK commentedComment #20
BenK commentedIf "G" above is too expansive/difficult right now, we could move on the other stuff first....
--Ben
Comment #21
berdirChanged #12.
#13i: What I said is not really correct, it's just a bug that should be fixed by #872238: Improve Message Syntax When Points Are Awarded. That issue also provides better way to define that message (pass it to the userpoints transaction instead of using dsm(), that allows other modules to change the message or hide it. But for now, if the above patch is applied, only the "By trading in 50 points in category Uncategorized, you now have full access to this content. Enjoy!" message should be displayed.
A: Still Open, but I don't think that's possible.
B: Don't get why this is needed? What would it allow that's not already possible with the full content view mode?
C: Still Open.
D: Changed.
E: Actually, I had a better idea. I moved the content type settings to the place where they belong, the content type edit form. It's a vertical fieldset there, and has a enabled checkbox (there is also a global default checkbox, so you either enable it by default and disable it for the content types you don't want it or the other way round). It also allows to define default points and category per content type if enabled. It's even using the fancy new #states system to hide the settings if it's not enabled ;) Also provides a summary but the wording needs to be improved I think. Also, with this, it should even work to enable userpoints node access with a default without giving authors access to changing these settings. Yet another use case :)
F: I made an initial port but there isn't much to see yet. You can make a view of all nodes that have points assigned and each node that you don't yet have access to display the "Get access" button. That's what the 6.x version does, you're welcome to provide ideas on how to improve id (what to display for the following conditions for example: user is author, user has by-pass access permission, userpoints_na is not enabled for that content type, user already has gained access) and additional conditions.
G: nothing done yet, interesting ideas but problematic :) For example, while the color-thing idea is great, that's really theme-dependented (for example, a theme might use images for buttons, some have light other dark background...). What we *could* do is add classes to the button so that it can be themed differently based on that.
- I just had an additional idea: What about an option that allows to actually *pay* the author? So that he would get the points the user has to pay to get access to a node? Similiar to user2userpoints.module....
Comment #22
BenK commentedHey Berdir,
I tried out your patch in #21 and things are looking good. The new content type settings are really nice!
Here are the bugs/issues that I noticed. All of these issues are numbered from scratch and don't refer to prior comments (since it was getting a little bit hard to follow):
a. If you leave the "Points" field blank on a node or type in a "0" (because you now want all users to have access even though it required points before), then the setting is being overwritten by the default points value and category for the content type. Note that upon saving initially, everything works fine: All users are granted access. But if you visit the content type settings page again, the defaults will be filled in (even though you last left the points field empty) and will go into effect if you don't notice this and re-save the content type settings page.
b. Change this: "Set a price in points that is required to access this content. All users have access if this field is left empty." To this: "Set a price in points that is required to access this content. All users will have access if you enter "0" or this field is left empty."
c. Change this message: "By trading in 50 points in category Uncategorized, you now have full access to this content. Enjoy!" To this: "By trading in 50 points in the Uncategorized category, you now have full access to this content."
d. If you're creating a new content type, the Manage display screen link doesn't work until the content type is saved. Basically, the link doesn't have the content type machine name included yet. I'm not sure if there is a way around this.
e. Change this: "You can control how the content looks for a user that does not have access by going to the Manage display screen." To this: "You can control how the content appears to users who do not have access by going to the Manage display screen."
f. Change this: "Set a default price in points that is required to access content with this type." To this: "Set a default price in points that is required to access content of this type. I changed "with" to "of".
g. Change this: "Points can be assigned to content with this type if checked." To this: "If checked, a price in !points can be set to access content of this type."
h. At admin/config/people/userpoints/settings, there are two typos: "overriden" should be spelled "overridden" in the description of both settings.
i. Per your question, I just wanted to explain why I brought up the possibility of a second view mode for users who do have access ("Userpoints node access granted"). The purpose of this was to display certain fields in the teaser that only users with access would see. As I understand it, there's no other way to do this in the teaser. However, now I'm thinking this is probably overkill. But just thought I'd explain.
j. I'm seeing an error message at the top of a view when including the "Buy Access Button" field in the view. Here's the error that I'm getting:
Notice: Undefined property: stdClass::$nid in userpoints_nodeaccess_handler_field_buyaccess->render() (line 28 of /Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess-DRUPAL-6--1/userpoints_nodeaccess_views/userpoints_nodeaccess_handler_field_buyaccess.inc).
k. Per your question about what to conditionally display in a view, here are my suggestions:
* user doesn't have enough points: "Need more points"
* user is author: "Author access granted"
* user has by-pass access permission: "Unlimited access"
* user does not have permission to trade points but points are required: "Access denied"
* user is anonymous: "Register or login to get access"
* Points not set for the node: "No points required"
* userpoints_na is not enabled for that content type: "No points required"
* user already has gained access: "Access granted"
We should also give a different CSS class to each of these so that they can be styled as needed.
l. Add specific CSS classes to the "Get Access" button so that it can be styled as needed.
m. I'm wondering about the default message that is displayed to anonymous users: "You do not have access to this content." This is because anonymous users obviously can't trade in points. But this could be confusing to a lot of users who are visiting a site for the first time or traded in points for access but just aren't logged in. Could we add a special case for anonymous users? The text for anonymous users could be something like: "This content requires @points !points to access. You must login or register to earn or use !points." The words "login" and "register" would be links to the Drupal pages to do this. What do you think?
n. I love your idea to add an option that allows to the node author to be "paid" in points when a user trades in points to get access to a node. I hadn't thought of that. That's really, really cool. I think it would be great if the amount of points to be paid to the node author were configurable.... so that you could pay just some of the traded in points, all of the traded in points, or an amount more than the traded in points to the node author. Also, the category of the points awarded to the node author should be configurable because you might want to award points to the node author in a different category than the category used when the points were traded in (imagine a category called "Author Rewards").
Do you think this should be done natively within the module or using Rules integration? For instance, I could imagine a Rules event called "!Points traded in for access". To award points to the node author in response, we could use the "Grant points" action supplied by the main Userpoints module. The drawback to this approach would be that it would be very cumbersome to do this via Rules on a per node basis (because you'd need a massive Rules configuration to account for every node). For this reason, it might be easier to do this within the module itself. We'd just need a new "Set Userpoints award for node author" permission. However, the "!Points traded in for access" Rules event could still be useful, too.
o. All this talk of Rules made me thing of something else: How hard would it be to allow a site to programatically give someone access to a node (either via a simple API or via Rules)? Here's the use case: In addition to allowing users to trade points for access, you also might want to let them buy access with actual money. So let's say you're using Drupal Commerce, Ubercart, or something else... It would be great to have a simple way upon completion of a sale to add a user and a node programatically to the userpoints_nodeaccess table. This could be done with a very simple API to add access or else there could be a Rules "Grant access without points trade" action. What do you think?
Berdir, so sorry for the long message here! I just wanted to get everything down that was running through my mind. This turned into quite the brain dump. Hope you don't mind... ;-)
--Ben
Comment #23
BenK commentedOne idea I wanted to mention just so I don't forget: There really should be a way to see who has access to a node without having to go into phpmyadmin. As I test the module, I've forgotten on several occasions who has been added to which node. I usually need to guess and check by logging in as the user or else manually translating the uid's and nid's in the userpoints_nodeaccess table. This could be accomplished with a simple table that only displays on the node if a user has a "View who can access any node" permission.
Once we did that, it would probably be useful to add a simple way for a site admin to manually add a user to this userpoints_nodeaccess table. This could be based on the same permission as above or else we could have a separate "Grant a user node access" permission. But this is less important than the first feature.
What would this table look like? I actually think it would look and function pretty much the same as Private Message's messages/blocked page (except that this would appear at the bottom of a node instead of on a separate page).
Per our conversation in IRC, we could postpone this for a later issue, but I just wanted to make sure I didn't lose track of it.
--Ben
Comment #24
berdirOk, trying to get back to this :)
a. Fixed. Nice catch...
b+c: Changed.
d: Fix is simple :) Hide the the link when creating a new content type. We don't want them to click on the link and loose the information they entered anyway.
e-h: Changed.
i: If I understood you right, that's not necessary. The access denied view mode is used both for teaser and default display (actually, it is used *always*). Fields added to both Teaser and Normal view mode are *only* visible when the user does have access.
j: Fixed
k: Added except the anon special case. I know that comment.module is doing something like that as well AFAIK, but I don't like it because it is not guaranteed that the user will have permission after logging in. Need to think about it, maybe in combination with yet another check that checks if auth user would have access. No CSS classes yet.
l: ToDo
m: Same as above, I'm not sure if I like that, but I can probably be convinced if done correctly. I'm just not sure what's better:
"Always simply showing access denied, confusing users who forgot that they are logged out" vs. "You are not logged in, log in to use points. -> user logs in (or even registers) -> "Oh well, but you still don't have access." :)
n: Where would that configuration happen? per node? with defaults per node type and everything? Sounds like quite a thing to handle... Maybe implement that after the initial module is done?
m: Same here, rules integration would be great but should probably wait until we have the basics figured out.
#23: You can do that with Views already, there is even a default view available, called "userpoints_nodeaccess_node_buys". Obviously without the ability to add grant users access, but it's a start. Together with views_attach (that's probably not yet available for D7), you can display that list below the node...
Comment #25
berdirComment #26
BenK commentedHey Berdir,
I took me awhile to do all of the testing on views integration, but here is the full report. My notes below are limited to the views integration sub-module and incorporates the conclusions of our great discussion in IRC:
i. Rename the "Userpoints Nodeaccess: Buy Access Button" field to "Userpoints Nodeaccess: Access Status". Change the default title of the field from "Buy Access Button" field to "Access Status". Make this field sortable (it is currently missing the sortable option). Change the field description from "Shows a buy access button." to "Shows whether the current user can access each node."
ii. Streamline the "Access Status" possibilities to the following:
* user has enough points to trade: "Get access" (button)
* user is author: "Granted"
* user has by-pass access permission: "Granted"
* user already has bought access: "Granted"
* user does not have permission to trade points but points are required: "Denied"
* Points not set for the node (null) or set to "0": "Unlimited Access"
* userpoints_na is not enabled for that content type: "Unlimited Access"
* user doesn't have enough points: "Need [@points - currentpoints] more !points" (i.e. Need 25 more points)
* user is anonymous: "Login to view status" ("Login" should be a link to Drupal login page)
iii. Add a css class to each of the above "Access Status" view states:
a) "Get access" button -- Class: .view-access-getbutton (CSS: background-color: yellow; color: black;)
b) "Granted" -- Class: .view-access-granted (CSS: background-color: green; color: white;)
c) "Denied" -- Class: .view-access-denied (CSS: background-color: red; color: white;)
d) "Unlimited Access" -- Class: .view-access-unlimited (CSS: background-color: green; color: white;)
e) "Need more points" -- Class: .view-access-needmore (CSS: background-color: red; color: white;)
f) "Login to view status" -- Class: .view-access-anonymous (CSS: color: black;)
In my testing with Firebug, I applied the above background colors to the entire table cell of each status and it actually looked pretty good.
iv. Make an "Access Status" filter. Filter name: "Userpoints Nodeaccess: Access Status." Filter description: "Shows whether a user can access each node." If possible, filter options should include:
a) Show nodes with 'Get access' button status
b) Show nodes with 'Granted' status
c) Show nodes with 'Unlimited access' status
d) Show nodes with 'Need more points' status
e) Show nodes with 'Get access' or 'Need more points' status
f) Show nodes with 'Get access' or 'Need more points' or 'Granted' status
g) Show nodes with 'Unlimited access' or 'Granted' status
v. When modifying the "Userpoints Nodeaccess: Points" filter so that it has a value different than "0" (say, greater than or equal to 10 points), I'm getting the following error message after saving the view:
Warning: Invalid argument supplied for foreach() in views_plugin_display->get_handlers() (line 672 of /Users/benkaplan/git/drupal/sites/all/modules/views/plugins/views_plugin_display.inc).
vi. The "Userpoints Nodeaccess: Points" filter needs special case handling the account for NULL or O. Basically, we need to create a filter that can show all nodes with either a "0" or NULL value for the point total.
vii. Make "Category" an available field (that is sortable). Field name: "Userpoints Nodeaccess: Points Category". Field description: "The category of points that is used when gaining access to a node."
viii. Make "Category" an available filter. Filter name: "Userpoints Nodeaccess: Points Category". Filter description: "The category of points that is used when gaining access to a node." The available categories should be selectable via a select list or checkboxes.
ix. In the "userpoints_nodeaccess_node_buys" view, add "Userpoints Nodeaccess: Points" as a field. Make this field sortable. Make the order of the fields from left to right: Name, title, points, timestamp. Add a default sort criteria using "Userpoints Nodeaccess: Timestamp" and sort it descending.
x. In the "userpoints_nodeaccess_node_buys" view, if I click the "Name" header to sort by name, I get the following error:
I get the same error if I click the "Title" header to sort by title.
xi. In the "userpoints_nodeaccess_node_buys" view, the "no results" message is set to: "No userpoints nodeaccess bought yet." Change this to: "No users have traded in points to access content."
xii. In the "userpoints_nodeaccess_node_list" view, add a default sort criteria using "Node: Post Date" and sort it descending. Add a field for the "Points Category" to this table. Make it sortable and the fourth column. Enable the "Sortable" option for the "title" and "points" fields. Make the "Access Status" field (formerly "Buy Access Button" field) sortable, too.
This will be a great module when we are done! :-)
Cheers,
Ben
Comment #27
jrivelli commentedAl lthe hunks failed for
Any thoughts?
Comment #28
berdirThe patch only works if you have a CVS checkout.
Comment #29
jrivelli commentedOh gotcha. My bad! :)
Do you guys have a rough timeline of when the next release would be out for this module then? I am in dire need of something like this because on my site currently users can buy points, but I need the option for authors of nodes to set a point value and other users buy that node_access from them :)
Comment #30
BenK commented@jrivelli: If you need instructions on how to do a CVS checkout for this module, visit this link: http://drupal.org/project/userpoints_nodeaccess/cvs-instructions
Comment #31
jrivelli commented@BenK, Thank you for that. That seems to popssibly be over my head at this time as I have never attempted checking any CVS anything out. I think I shall wait till this is released in some form or a patch I can use. Thanks guys!
Comment #32
jrivelli commentedI got the CVS and then patched it, however now I have no permission options to give to roles about who can use this now.
I don't have the option to add points to a node either. hmm I must've done something improperly. Everything has given me successful messages so far though.
ALSO, I know the title says Drupal 7 port. I thought this was being tested on drupal 6 and then being ported to drupal 7 because I have this error.
"This version is incompatible with the 6.19 version of Drupal core."
Comment #33
BenK commented@jrivelli: No, we're working exclusively on Drupal 7 on this thread. To use or test the latest patch, you must have the latest -dev version of Drupal 7 core. Because there is no 7.x-1.x-dev branch yet of this module, you apply the patch to a CVS checkout of the 6.x-1.x-dev branch.
--Ben
Comment #34
jrivelli commentedAh that's what confused me then! Ah I had a feeling all my work would be in vain. Thats ok.Well, I'll have to wait til the version 6 comes out :) Do you know approximately when a version for D6 will come out?
Comment #35
BenK commentedBoth Berdir and myself are just working on the D7 version. We don't use this module in D6. So you may want to check with the module maintainer for questions about D6.
--Ben
Comment #36
BenK commentedHey Berdir,
In follow up to my views integration testing in #26, I've now tested the latest patch with the rest of the module. Here are the issues I noticed and suggested string changes (item letters refer to the original bug report in comment #22):
a. If you leave the points field blank on a node and try to save, you get this error:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'points' at row 1: UPDATE {userpoints_nodeaccess_points} SET points=:db_update_placeholder_0, tid=:db_update_placeholder_1 WHERE (nid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => [:db_update_placeholder_1] => 0 [:db_condition_placeholder_0] => 40 ) in userpoints_nodeaccess_update_node() (line 210 of /Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess-DRUPAL-6--1/userpoints_nodeaccess.module).
c. There is small typo here. It currently reads: "By trading in 50 points in Uncategorized category, you now have full access to this content." The word "the" is missing. It should be: "By trading in 50 points in the Uncategorized category, you now have full access to this content."
l. We still need to add CSS classes to the "Get access" button and the other printed messages. Ideally, it would be great to add an umbrella CSS class for all messages and an additional CSS class depending on which message is printed (not enough points, get access, anonymous, etc.) This way, the site admin could style these messages all the same or make certain ones highlighted differently. For the messages, I'd probably make the umbrella CSS class italic by default. It just seems like the messages would look good in italic.
m. For anonymous users, what if we just simplify this to: "Requires @points !points in the @category category." We simply state the facts to anonymous users and don't make a judgement on whether they will be able to gain access once they login. It's a more informative message than just access denied. A login or register message could always be specified by the site admin in a field attached to the "Userpoints node access denied" view mode. See dd) below for a possible variation to this message if only one userpoints category is configured.
o. I've thought about this some more and I can really see the benefits of a simple "Grant access to a node" Rules action. That might be all that we really need for now (no immediate need for a rules event or conditions). That one action could largely replace the need for an entire API. The primary use case for me would be to use Userpoints Nodeaccess in conjunction with Drupal Commerce. Because Drupal Commerce is entirely rules-based, if a user bought access to a node (instead of trading in points) this rules action would allow them to be added to the access list upon purchase. So if possible, it would be great to add this rules action to our list of priorities.
ADDITIONAL ISSUES:
aa) If a user does not have "Trade Userpoints for node access" permission, then we should print "Access denied: You do not have permission to trade in !points." as the message. This way it's clear why access is denied.
bb) On the Points settings page (admin/config/people/userpoints/settings), the description for "Enabled by default" currently reads: "This can be overridden for each content type." Change this to: "If checked, Userpoints Nodeaccess functionality is activated by default for each content type. This can be overridden on the content type edit page."
cc) Also on the points settings page: Change: "Default Category" to "Global Default Category". I thought this change might be good because "Default Category" is the label used on the content type edit page. So this one on the settings page is the "global" version.
dd) As briefly discussed in IRC, after seeing the new message strings I wrote displayed on the page, the text strings for each case (not enough points, get access, anonymous) seemed overly long. So I recently had some ideas on how to streamline it. I also was wondering if it is possible to check whether the site admin has any userpoints categories configured and to display different messages in the case of one default category or multiple categories (since we don't need to mention categories if only one is configured).
So here are my new suggestions....
>> 'Not enough points' message (multiple categories):
"Requires @points !points in the @category category. You only have @points !points available."
>> 'Not enough points' message (only one default category):
"Requires @points !points. You only have @points !points available."
>> 'Get access' message (multiple categories):
"Requires @points !points in the @category category. You have @points !points available."
["Get access" button goes here]
>> 'Get access' message (only one default category):
"Requires @points !points. You have @points !points available."
["Get access" button goes here]
>> 'Anonymous user' message (multiple categories):
"Requires @points !points in the @category category."
>> 'Anonymous user' message (only one default category):
"Requires @points !points."
If it is not possible to display different messages based on category configuration, we could simply go with the "multiple categories" strings shown above.
That's all I've got! We're not too far away here. Just a reminder that I've included views-related notes in comment #26.
--Ben
Comment #37
berdirNote: I have the problem with the broken condition now again. But I've confirmed that it happens with all numerical conditions, so it's a views bug. After all, views is not even alpha yet :)
Note 2: I've done some refactoring that allows to kill the node_load() call in the view and load all necessary information directly in the views query.
i. Changed label/description. Only something that is in the database can be sorted. This is a virtual/computed field, so you can't sort it because you'd have to check every single node and then sort on what has been generated. Note that you can "sort" this field for some specific use cases. For example, you could make a view that only shows nodes a user could buy if he had enough points and then sort by the number of points required. You then have all nodes first (or last) that the user can buy and that do show a get access button :)
ii. Done.
iii. I don't think we have any way to add classes to the table cell. Because this could also be a grid, or a semantic view or whatever. What I did is adding a span tag around each error message with something like this "userpoints-nodeaccess userpoints-nodeaccess-needmore" as classes and added similiar classes to the submit button of the form. Adding color/background-color is the responsibility of the theme. Maybe we can add specific theming for bartik at a later point but not now. also, background-color on a span doesn't really work :)
iv. Hm.. not everything of this work. Similiar to sorting, a filter is imho supposed to check something in the database and not permissions or configurations. Because of that, we can't use the same labels/strings as we do for the output. Explanation:
a) This is tricky, but valid and I think I can get this working.
b) You can get the list of nodes bought by the user already by adding a relationship or by choosing the correct view type. By-pass is a permission and site-wide, there is no point in checking that in a filter imho and you can easily exclude nodes the user is author of with a separate condition.
c) we probably want an option to show "free nodes", meaning, nodes that have no or 0 points (not the same thing). Unlimited access can also mean that it's not enabled for a node type and you can do that with a node type condition filter.
d) This is similiar to a), basically a reversed a. Instead of showing nodes where the user does have enough points, we show nodes where a user has more points.
e-f) These are just combinations of the things above.
So here's my proposal. A filter with each of the following as a checkbox (so you can freely combine them):
- Show nodes the current user can buy.
- Show nodes the current user could buy but misses !points.
- Show nodes that don't require !points.
(Not yet implemented)
v. The conditions seems to be totally broken for me anyway. Also, there is nothing userpoints_nodeaccess specific, I just specified that it should use the default numeric filter provided by views.module
vi. Ok, we could also add this as a special case to this filter and just have 2 checkboxes in the access status filter. What do you prefer?
vii. & viii. & xi. Let's postpone that on the userpoints.module views issue, that adds the necessary handler classes for the category.
ix. Done
x. I've seen similiar issues, but it works for me right now. Can you retry with this patch?
----
a) Fixed.
c) Fixed.
l) Added classes to the div. Already added classes to the button while working on the views stuff.
m) / aa) I'm not convinced that we should differentiate between these two cases (no permission and not logged in). I can probably be convinced but the current page only does m) for both anon and those without permission.
o) Agree, but let's do that later.
bb) changed
cc) changed
dd) Not so easy. because we would have to load all content types (slow operation!) and check the category of every single of them. And also check if they're enabled, or if they're enabled by default and what not...
Attaching a new patch, not everything is resolved yet, see the the single responses. Also, like discussed in IRC, we're getting to point where it is getting messy to deal with the remaining issues/feature requests in a single patch, will think on how to continue with this :)
Comment #38
BenK commentedHey Berdir,
I've begun testing the patch in #37, but one new error has popped up that makes it a bit difficult to test. So I'm hoping that we can fix this before I continue with more testing.
Basically, if I visit a node page that requires points (and the user has enough points to buy the node), I'm now getting the following fatal error:
Recoverable fatal error: Object of class stdClass could not be converted to string in userpoints_nodeaccess_trade_access_form() (line 302 of /Users/benkaplan/git/drupal/sites/all/modules/userpoints_nodeaccess-DRUPAL-6--1/userpoints_nodeaccess.module).
I'm also getting this fatal error if visiting a list page (like the front page) with the node's teaser on it. And I've confirmed that the error goes away (and everything works fine) if the user does not have enough points to buy the node.
Can you take a look? And if you feel this patch is getting too large to deal with, we could definitely move our work to github if you would like.
Thanks,
Ben
Comment #39
berdirOk, then lets do that :)
Git repo is at http://github.com/Berdir/userpoints_nodeaccess
Note that it's actually a CVS checkout that has been added to a git repository as well, so it also contains the CVS directory and the patches that have been uploaded here yet.
The bug you reported should be fixed, so happy testing :)
Comment #40
BenK commentedHey Berdir,
I created my own github fork based on your repository. First, I can confirm that the bug reported in comment #38 has been fixed. Thanks!
Here is a report on the various outstanding issues related to the main module. I'll tackle the views integration stuff in a subsequent comment:
a) Confirmed this is fixed.
c) Confirmed this is fixed.
l) Most of the CSS classes look great. However, if the printed message is "Requires 50 kudos in the Uncategorized category", I'm not seeing any CSS class in Firebug. (The only classes I see on the div are "content" and "clearfix".) Can we get a CSS class for this? We would want this message to be styled the same as the other messages.
Also, if a user has "granted" access to a node, is it possible to add a CSS class somewhere so that we can tell at a glance that access has already been granted? Currently, the drupal_set_message is great, but that only is visible immediately after access is granted. How about adding a class to the entire node similar to how the ".node-unpublished" class is handled in Bartik for unpublished content (so you can change the color of the entire background of the node). Ideally, this class should be present both for the teaser and full node view. But I'm not sure how feasible this type of class insertion would be. Other ideas?
m) / aa) I agree that we don't need to differentiate between these two cases (no permission and not logged in). The message we have now looks good! :-)
o) Sounds good.
bb) Confirmed this is fixed.
cc) Confirmed this is fixed.
dd) Thanks for the explanation. I agree that the drawbacks of the category check outweigh the benefits. So let's not worry about that. However, to make the messages a bit shorter and simpler, let's change them to:
>> 'Not enough points' message:
"Requires @points !points in the @category category. You only have @points !points available."
>> 'Get access' message:
"Requires @points !points in the @category category. You have @points !points available."
["Get access" button goes here]
The sentences shown above should now fit nicely on a single line. And because the sentences don't mention "access" directly anymore, I think they can be used in more use cases (such as when the node is a page for a physical product that is shipped to the user).
ee) NEW: Is there any way to allow the text of the "Get access" button to be configured by the site administrator at the global, content type, and (possibly) node levels? This would be similar to how the points category is configured now. This issue came up when I started thinking about my actual use case: We'll likely be using the module not only for nodes with written content, but also for node pages that describe physical products that are actually shipped to the user. For such instances, we might want the button to say "Get this prize". Likewise, for nodes that play videos or audio tracks, we might want to change the button to say "Watch this video" or "Listen to interview". So would this be difficult to implement? It would be great if it's configurable at the global, content type, and node levels, but if that's too difficult, just a setting on the content type edit page could work (with "Get access" being the default button text if it is not overridden at the content type level). What do you think?
That's it for the main module. I'll test views integration next and attach my notes to a subsequent comment.
--Ben
Comment #41
berdirl) added a span around that message, used the denied class that's already used by the views handler. If you need/want something else, please suggest a different name. But you can also depend on the hierarchy (for example, the views denied message is inside a td if you use a table etc.) to address them separately.
Also added a access (by-pass permission, author or bought access) and a no-access only if the node has points. Do you need some additional classes to differentiate between the different access conditions?
dd) Changed.
ee) I guess you know what's coming now: Translation handling :) The main problem is that I'm not sure what's the best way to handle stuff like that in D7. I see that this would be a useful feature, however. So what about this for now: We add the node type to the form that displays the get access button. That gives another (custom) module enough context to easily change the button text. It doesn't require more then ~10 lines of code and you avoid the problem with multiple languages because you can simply use t() in the code. I can give you the necessary code for this once you need it. We can also create an issue to handle this in a better way.
Pushed everything to github. Note that you only need a fork if you plan to work on it yourself :)
Comment #42
BenK commentedHey Berdir,
I tested your latest changes documented in #41. Here's what I found:
l) * Thanks for the span class around that message... using the denied class is fine.
* Yes, some additional classes to differentiate between the different access conditions would be great. Specifically, I need two no-access sub-classes (one for "have enough points" and another for "not enough points") and one access sub-class (bought access). I think that would be enough to target what I need.
* If a node does not require any points to access, it is getting the "userpoints-nodeaccess-node-no-access" class. Is this the intended behavior? I would have thought that content with unlimited access would get the "userpoints-nodeaccess-node-access" class.
* On a list of node teasers like the front page, any teaser with a message printed in it (a message such as "Requires 100 kudos in the Access Points category") is not getting the "node-teaser" class. As a result the teaser area is not being styled the same as other teasers. I noticed this using the Bartik theme because teasers in Bartik have a line (border) at the bottom of the teaser area. But because the .node-teaser class is not being applied on teasers with a message in it, the border line is not being displayed (plus the message text is the wrong size compared to other teasers). Note that any nodes in which access has been granted do not have this problem (the .node-teaser class is displaying properly). This is probably because no message is printed for nodes in which access is granted.
dd) There's a problem with both of the changed messages. It may have resulted from the fact that I originally typed @points for both point tokens in the message (I was just using it as a generic placeholder), when in the first case it's the "price" of the node and in the second case it's the "points" of the user. Currently, for a node that costs 10 points (when a user has 7 points), the message currently reads:
'Requires 7 kudos in the Access Points category. You have 7 kudos available.'
So the message is repeating the user point total twice instead of using the "price" in the first instance.
Second, I think you may have mixed up the two messages that I changed (one in which the user doesn't have enough points and another in which the user does have enough points). In the case where the user doesn't have enough points, the word "only" should appear in the sentence. Conversely, in the case where the user does have enough points, the word "only" shouldn't appear. This is because "only" is meant to signify that "it's not quite enough." But currently, it's backwards... the word "only" is appearing in the wrong message.
Sorry for the confusion about all of this. If any of this is unclear, let me know. :-)
ee) Sounds good. Let's add the node type to the form as you suggest.
That's it for all of the non-views related issues. I'll attach my views testing results to a subsequent comment...
--Ben
Comment #43
BenK commentedComment #44
berdirl) * Added the classes for enough and not enough
* no points has the access class now
* Well, that's pretty much by design because you are not viewing the teaser $view_mode anymore :) You are viewing the access denied view mode. But I get what you mean. Added a special case that if the original view mode was teaser, we add the node-teaser class ourself. Note that the read more / log in to comment links are still gone (and all else probably too, not sure if we want that or not.
dd) Upsie. Fixed.
ee) Already done :)
Comment #45
BenK commentedHey Berdir,
I just tested your latest changes. Here are the bugs I found:
l)
* In cases where the user does have enough points to purchase access, the "userpoints-nodeaccess-node-no-access-notenough" class is still being applied to the node. This is occurring on both the teaser and node view. Instead, a "userpoints-nodeaccess-node-no-access-enough" (or whatever the "enough points" or "trade in" class name should be) should be applying.
* If the user does not have enough points to purchase a node and that node appears in a list of teasers, then something very strange is happening: The
* Thanks for the explanation about the view mode and for adding .node-teaser. Actually, the "login to comment" links are currently being added to this view mode (which is good). Only the "read more" links are missing. My vote would probably be to include the "read more" links (so that everything matches) unless it is difficult from a coding perspective.
dd) The "only" logic is fixed, but the current point total of the user is still displaying instead of the "points price" to buy the node. More specifically, the incorrect points price is still displaying for both the "enough" and "not enough" cases. (Note that the points price is displaying properly in the access denied case.) Did you maybe forget to commit this change? ;-) I didn't see it in the commit log.
--Ben
Comment #46
BenK commentedHey Berdir,
At long last, here are my latest testing results related to views integration:
i. Confirmed this is fixed. (And thanks for the explanation about sortability.)
ii. This looks good. Only one fix: On a node that requires points, an anonymous user is seeing a "Denied" message instead of the following:
"Login to view status" (Note: If possible, "Login" should be a link to Drupal login page)
iii. The CSS span classes look great. We'll just need to add one for "Login to view status" once we fix ii (above).
iv. I love your proposal. It's much simpler yet it still accomplishes a lot. Let's do it! :-) For the checkboxes, I just have the following updates to the language of the labels to be a little more clear:
- Show nodes the current user can buy immediately.
- Show nodes the current user could buy if he had more !points.
- Show nodes that don't require !points.
v. OK, let's not worry about it. Probably a views bug.
vi. Let's not worry about this. I like your proposal better. ;-)
vii. and viii. Okay, sounds good. Do we have an existing issue thread in userpoints.module for that?
ix. Confirmed this is fixed.
x. Unfortunately, I'm still getting this error with the latest patch.
xi. I don't think this item was completed yet: In the "userpoints_nodeaccess_node_buys" view, the "no results" message is set to: "No userpoints nodeaccess bought yet." Change this to: "No users have have been granted access yet."
xii. I don't think this item was completed yet. I've simplified it based on your prior comments about category and sortability. :-) So only this needs to be done: In the "userpoints_nodeaccess_node_list" view, add a default sort criteria using "Node: Post Date" and sort it descending. Enable the "Sortable" option for the "title" and "points" fields.
As you can see, not too much left to do. We're very close to being done, I think. :-)
--Ben
Comment #47
berdirl)
* Typo, fixed the css class name
* There was a missing closing div tag. Fixed. Nice catch.
* All existing links are re-added. This will break once #878092: Regression from D7 alpha: themes are unable to render one group of node links separately from another is in and will need some changes.
dd) Fixed. Really this time :)
Comment #48
BenK commentedI tested your changes in #47 and everything is working great. Both l) and dd) are fixed!
Just a quick question: In the case of "All existing links are re-added," you said this will break once that patch is committed to core. How will it break? Will the links just stop appearing or we will we actually get an error message on the page?
So the only thing we have left is the views related stuff documented in #46! Yay! We're very close....
--Ben
Comment #49
berdirii. Added. As discussed, we are going to improve the default views to show a separate view instead for anon users.
iii. I added the same denied classes to the log in link, but directly on the a tag. so you can differentiate them or not, as you want.
iv: Added. This took me a while but I learned a lot about views filters ;) Seems to be working great... Note that not selecting any of the two first options is the same as selecting both of them: All nodes are shown (exception: nodes without points aren't shown when the third option is not checked).
vii: Yes, we do: #871126: Fix Bugs in Views Integration
x: Do you have the latest views version? Are you using the default view? (I guess you are, because of the following points). Anyway, I don't know what the problem could be here, let's wait until views is a bit more stable. Something with those relationships is totally strange anyway.
xi: Added the empty text. Also added the administer userpoints permission restriction.
xii: Added the default order and made the columns sortable. I also added the trade userpoints permission restriction and am now using the Access status filter to hide nodes without points, as this one actually works :)
Pushed the changes...
We're close, I can feel it :)
Comment #50
BenK commentedBerdir,
I tested the latest views changes and things are working quite well... the new filters are very cool. I've just noticed a little odd behavior and an edge case we may need to address. Here's my list:
1. The "Show nodes that don't require points" filter is working very well. And the other two filters do filter out what they are intended to filter out. But I'm not sure the logic is totally right on those two filters because extra nodes are still showing up. For instance, both the "can buy immediately" and "could buy if more points" filters are still displaying nodes that the user has bought in the past. Interestingly, checking or unchecking each of those filters results in different "bought" nodes being displayed. I think what is going on is that even though the user has already bought the node, we are still comparing his current point total to the price of the node. So if an "already bought" node costs more than the number of points the user has, it shows up if "Show nodes the current user could buy if he had more points" is checked. Conversely, if an "already bought" node costs less than the number of points the user has, it shows up if "Show nodes the current user can buy immediately" is checked. So the bottom line, I think, is that we should be filtering out already bought nodes if the Access Status filter is in use.
A similar thing is happening for nodes that the user has access to because of authorship or the bypass access permission. Such nodes are showing up based on a comparison of the price to the number of points the user has. So if a user has authored a node and the node costs more than the number of points the user has, it will show up if "Show nodes the current user could buy if he had more points" is checked. So I think we need to filter out nodes that the user has authored if the Access Status filter is in use.
But what should we do for users who have the bypass access permission? Would we display no nodes (since he can't technically "buy" any)? Or would we display all nodes available for purchase if "Show nodes the current user can buy immediately" is checked (because he can technically see all of them even if he can't really buy them). From an admin perspective, it seems he would want to see all nodes available for purchase instead of seeing a view with no nodes. But I'm interested to hear your thoughts. (I guess "Show nodes that don't require points" should still work for a user with the bypass access permission.)
2. Okay, this next one is an edge case. I'm not sure if we should deal with it or just not worry about it. Basically, it's possible to have a node with "Unlimited Access" that still has a "points" price listed. This type of node is showing up in the view no matter which access filter is set. How can this type of node be created? If you set a point price for a node and then later disable "Userpoints Nodeaccess Options" on the content type edit page, the result is a node with a price that still has unlimited access. What should we do in this case? When it is listed in a view, it shows the price in the price column, but Unlimited Access in the status column.
One option would be to show the point price as "0" for the node if the content type is disabled... but I'm not sure of the added performance costs of this extra check (since it is going against the actual point value listed in the database). And I don't think we want to delete the point price of the node from the database when the content type is disabled... a site admin may disable the content type temporarily but doesn't want to have to re-enter a price when the content type is re-enabled. What do you think? Again, this is an edge case so I don't want it to slow us down. The added complication, of course, is that this type of node is showing up even when the "Show nodes that don't require points" filter is unchecked.
3. If "Show nodes that don't require points" is checked, two types of nodes are added to the view--nodes that have a price of 0 points or nodes of a content type that don't require points. This, of course, is exactly what we want. But a possible issue is in the "Points" column... nodes of a content type that don't require points has a blank points field. Conversely, nodes that have a price of 0 points show an actual "0". Neither of these is confusing on their own, but when you combine them the result is that some points field show 0 and some are blank. I like being able to differentiate between the two cases, but should something be entered in the blank field? Maybe a "None required" (this could still be confusing)? Maybe just a "0"? But the problem with that is that the "0" would have to be computed and that would ruin the ability to sort (I think).
Anyway, I'm not sure this is a big deal (the site admin could always remove the points column for certain types of views), but I thought I would bring it up in case there was an easy fix.
4. If "Show nodes that don't require kudos" is the only Access Status filter option that is checked, some "Need x more points" nodes are still showing up in the view.
5. One small typo on the "no results" message for the "userpoints_nodeaccess_node_buys" view. The word "have" is repeated twice in a row in the current displayed message.
Anyway, I'm interested to hear your thoughts... a little logic cleanup and I think we're done!
--Ben
Comment #51
BenK commentedP.S. If I didn't mention an issue in my prior comment above, then that means that I tested it and confirmed that it is now fixed. Thanks! :-)
Comment #52
berdirAs discussed:
- Nodes the user already bought are excluded now.
- Nodes he is the author can be excluded with an additional filter
- We don't want to check the by-pass permission because it could be confusing for administrators when creating the view.
- Node types can be limited with an addtional filter
- To show "free" nodes, use the points filter and use < 1 (once it's working again)
- Uses "0" as the empty value for the default view
Comment #53
BenK commentedHey Berdir,
Everything is working great! Only one problem: I can't seem to change any of the Access Status filter settings. If I try to check or uncheck one of the boxes and click update, it's not retaining the changes. So I know that the default filter options work great ("buy immediately" and "could buy if more points" are both checked), but I can't actually change these options in the userpoints_nodeaccess_node_list view.
I also tried adding the Access Status filter to the "buys" view, but I couldn't save the filter options there either. I also got the following error message when adding and saving the Access Status filter (with all options unchecked since I couldn't change them):
Also, one small thing: I don't think the following typo was fixed:
The empty message still incorrectly currently reads: "No users have have been granted access yet."
--Ben
P.S. I tried to filter out nodes authored by the current user by using the "User: Current" filter set to "No", but I got a PDO error. I think I'm doing this correctly, right? Maybe Views is having problems with this filter at the moment.
Comment #54
BenK commentedOne bit of good news: I can confirm that my error described in "x." above (error when sorting columns) is now fixed after updating to the latest version of views! :-)
Comment #55
berdir- I can confirm the issue with the broken form, working on it.
- About the current user filter, see #906440: Filters: Current User: Yes causes an sql error
Comment #56
berdirFixed a bug on my side in the validation form that caused it to not save the submitted values.
However, there is also a views bug involved, if there is a validation error, the form just goes away and doesn't display the validation errors. Issue is #788950: Clicking Override Closes Options.
Fixed the wrong empty message. Is there anything left?
Comment #57
BenK commentedBerdir,
I almost marked this RTBC... and you could still treat it as such. I tested the two views a multitude of ways and only noticed two small things:
1. If 'Show nodes the current user could buy if he had more points' and 'Show nodes that don't require points' are both checked (and nothing else), then "free" nodes (those without a price) are not actually displaying. The bug is limited to this particular configuration and I'm not sure why.
2. If you try to only check 'Show nodes that don't require points', then the setting won't be retained upon clicking update. This doesn't really matter because if you are trying to list "free" nodes it is better to use the points filter (and choose a points value < 1). But I thought I would mention it because some users may be confused why this setting won't save.
That's it. There's nothing else. Very minor stuff. I think we're ready to open the 7.x branch. :-)
--Ben
Comment #58
berdir1. Kinda makes sense if you think about it :) Because it will only show nodes with more points than you have. I added a fix for it although I don't think it's a combination that makes much sense :)
2. That is the views bug I talked about in #56. Once that one is fix, this should work (as in, give you an validation error).
Will start a D7 branch in CVS and commit what we have later today.
Comment #59
BenK commentedAwesome! Great work on this. :-)
Comment #60
berdirCommited to HEAD and made a 7.x-1.x-dev release which will show up within the next 12h.
Thanks for all your testing on this. I assume that you will create follow-up issues for the remaining things that we postponed?
Comment #61
BenK commentedThanks to you, Berdir! Yes, I'll create the follow-up issues for postponed items. I'll plan on doing that later today or tomorrow.
--Ben