Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there a way to include role expiration date into a view? I need a membership list for admins with expiration dates, but the only way I could do this is hardcoding database query into the template, and them I guess I need to do a lot of extra coding if I want sorting and filtering by expiration date. Is there an easier way, and if not, can this be a feature request?
Comment | File | Size | Author |
---|---|---|---|
#78 | 419700-78.patch | 4.4 KB | TR |
| |||
#77 | 419700-77.patch | 4.19 KB | TR |
| |||
#74 | uc_role_views-419700-74.patch | 4.19 KB | TR |
#71 | uc_role_views-419700-71.patch | 4.19 KB | aniebel |
#47 | uc_role_views-419700.patch | 4.19 KB | dzepol |
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedThat's a great idea for Views integration, but we won't be adding in any more of that until we start work on the next version unfortunately.
Comment #2
julia_g CreditAttribution: julia_g commentedSo do you think you'll be able to do this within a few months? If not, I'll try to put something together myself.
Comment #3
neopoet CreditAttribution: neopoet commentedDid you managed to solve this?
Comment #4
Liliplanet CreditAttribution: Liliplanet commentedDefinitely subscribe, thx!
Comment #5
mariuss CreditAttribution: mariuss commentedImplemented the feature as a separate module. In Views it provides a new field group called "Role Expirations" and for each role that is expired by uc_role there are two fields in this group: the expiry date and a flag that tells if the notification was sent already. Until this code makes it into uc_role just use the attached module.
It can easily be added into uc_role module:
uc_role
instead ofuc_role_views
uc_role_views_views_api
function from uc_role_views.module to uc_role.module (and rename, see above)Did not create a patch because it is easier to use like this and based on first comment it may take a while. I can create a patch as well if that helps, let me know.
Comment #6
mariuss CreditAttribution: mariuss commentedForgot to mention that the inspiration for this module/patch came from:
http://www.gregeisenman.info/blogs/greg/views-2-and-drupal-adding-custom...
Comment #7
tjjacobsen CreditAttribution: tjjacobsen commentedMariuss' little module works well...thank you.
Unfortunately it doesnt really meet our needs. We simply want a view that lists the user name and their current expiration date.
Does anyone have a simple way to do this? Im not afraid of coding if necessary, but Im not an expert and it would take me awhile to complete.
Any help?
Comment #8
Chad_Dupuis CreditAttribution: Chad_Dupuis commentedsub
Comment #9
tjjacobsen CreditAttribution: tjjacobsen commentedGot it working!
With a few modifications to mariuss' code and some lessons from Greg Eisenman's posted link above, it was actually pretty simple and gave me just what my project needed.
I simply cloned mariuss' module, renamed it 'uc_role_admin', updated the .info and .module files to reflect this new name, and then modified the uc_role_admin.views.inc file with the attached function.
Hopefully this will help others out there. (and, of course, if anyone catches any errors, please let me know!)
Comment #10
hefox CreditAttribution: hefox commented(Note: uc_role_admin causes duplicates in views if a user has more than one role expiration; first should not cause this because each join to the table is different whereas uc_role_admin shares the join)
Comment #11
BenK CreditAttribution: BenK commentedSubscribing....
Comment #12
darsic CreditAttribution: darsic commentedHi,
Can someone tell me how can i make this module work, posted by mariuss.
I followed instructions, but nothing happens ... i can`t see Role Expiration fields in View.
Thank you.
Comment #13
darsic CreditAttribution: darsic commentedI followed your instructions, bur i can`t see role fields in my view. :(
Comment #14
TR CreditAttribution: TR commented@darsic: Please read http://drupal.org/node/314328 to what the issue "Priority" and "Assigned" fields mean.
If someone wants to roll a patch from #5, taking into account #9 and #10, I think this can be put into the uc_roles module.
Comment #15
TR CreditAttribution: TR commentedTagging
Comment #16
fidlertom CreditAttribution: fidlertom commentedHas anyone else gotten #5 or #9 to work? I've tried both options as well as reading the link in #6 and for some reason it's still not showing in views. I'm using d6.16 and uc6.x-2.4.
Comment #17
Rhino CreditAttribution: Rhino commentedSubscribing!
Comment #18
hawkdrupal CreditAttribution: hawkdrupal commented+1
There's a huge need to have a module and/or view -- especially for sites that sell subscriptions. Users need to readily see the status of the subscription -- that is, the particular role that IS the subscription, and the role/subscription expiration date.
The view should be able to show ONLY the desired SUBSCRIPTION role and expiration, and not other roles such as "authenticated user"; that will just be confusing.
Also, this view must be available in a block so it can be displayed whenever the user is signed-in. It should not require the user to dig to find, but should be up-front so the user does not forget to renew.
Comment #19
Liliplanet CreditAttribution: Liliplanet commentedHere is a block to show the user their current role status and when it's due to expire ..
http://drupal.org/project/uc_expiry
Comment #20
gpiersol CreditAttribution: gpiersol commentedI'm also very keen on being able to use the role expiration dates in views, and I've also been unable to successfully get the included custom module(s) in this thread to work for me.
I recently came across this helpful snippet of code : Drupal: Expose a Custom Field to Views 2.
I'd love to be able to create a custom module that does what the above link describes with a user's role expiration date, but I'm not sure where to start.
Comment #21
scotwith1tThanks for this. It works beautifully and was absolutely essential to my project. Hope to see this essential functionality committed to the dev and ultimately the next UC release, so I'm updating version to maybe draw some attention to it. If not, this module works great. mariuss++
Comment #22
Liliplanet CreditAttribution: Liliplanet commentedWith the http://drupal.org/project/role_expire In a view select filter 'Operator is greater or equal to' +365 days to see the newest members by role ..
Comment #23
dafederFolks - #9 works for me. Make sure you are using a user view, not a node view. If you need a view of profile nodes, make a user view and use relationships to pull in the profile fields.
Comment #24
interestingaftermath CreditAttribution: interestingaftermath commentedsubscribing
Comment #25
RedBob62 CreditAttribution: RedBob62 commentedA small idea for those who struggled to get this to work.
When I first downloaded the file in #5 I noticed that it saved to my PC as 'uc_roles_.tar_'. I uploaded this and unpacked it but could not find the new module in the modules list.
I went pack to my PC and renamed the tar file to remove the final _ making the name 'uc_roles_.tar'. I then uploaded this and unpacked it. This time the module appeared and now works perfectly.
It might be an obvious fix but it worked for me :-)
Cheers
Bob
Comment #26
eric.chenchao CreditAttribution: eric.chenchao commentedThanks - #9 works for me.
Comment #27
francismacomber CreditAttribution: francismacomber commentedHere's a modified version that works for me with UC 3 Beta 3 in Drupal 7.
Comment #28
TR CreditAttribution: TR commentedThere is still no patch here to review.
Comment #29
clr123 CreditAttribution: clr123 commentedsubscribing
Comment #30
Liliplanet CreditAttribution: Liliplanet commentedHi, #27 from francismacomber works perfectly and Role Expirations TJ: Expiration is available as a field.
is there perhaps any chance of being able to have the TJ: Expiration field as a 'sort by' in sort criteria please?
Would like to create a view of the user expirations by date.
Comment #31
odisey CreditAttribution: odisey commentedTHANKS THANKS THANKS!!!
Comment #32
TR CreditAttribution: TR commentedNew features should go into 7.x-3.x first.
Still no patch here to review ...
Comment #33
webservant316 CreditAttribution: webservant316 commentedsubscribe - looking for a patch for 6.x-2.x
Comment #34
clr123 CreditAttribution: clr123 commentedsubscribe
Comment #35
clr123 CreditAttribution: clr123 commentedsubscribe
Comment #36
scotwith1tjust putting this back towards the top of my queue so i can remember to try and put this patch together...can't promise anything but i've managed to do one for uc_varprice, so i'm sure i can manage...we'll see.
Comment #37
timb CreditAttribution: timb commentedwould love to see this in 7
Comment #38
jukka792 CreditAttribution: jukka792 commentedIs this coming to d7 ? Or is it possible to create the expiration date just using views ?
Comment #39
hejeva CreditAttribution: hejeva commentedHere is version D7 using parts of this module and roles_expire/role_expire.views as guidelines.
Comment #40
TR CreditAttribution: TR commentedPlease MAKE A PATCH. Posting a zip is not helpful. If you want to publish your own standalone module then open a sandbox project, don't post the code here. If you want to help improve Ubercart, then we need a PATCH.
Comment #41
scotwith1tNot sure if this is right, but the gist is there. It's a patch file, it adds the 3 files hejeva was trying to add as the contribution (thanks for that!) as a sub-module uc_role_views. I haven't looked at or tried this, just trying to help hejeva out by providing the patch for TR.
Comment #42
TR CreditAttribution: TR commentedChanging status so the testbot can try out the patch.
Comment #43
jsibley CreditAttribution: jsibley commentedAm I correct that the patch passed testing? If so, might we see a release soon? Thanks.
Comment #44
jsibley CreditAttribution: jsibley commentedDoes this need additional testing or can it be committed now?
Thanks.
Comment #45
TR CreditAttribution: TR commentedNo one has tested the patch in #41 yet. No one. Not even the guy who posted the patch. That's why the status is still "Needs review".
@jsibley: It sounds like this feature is of interest to you. If you would like to see this get into Ubercart, then please help. Try the patch, then post here in this issue what you tried and how you tested it and whether it worked as you expected or not. That is how progress is made in Drupal.
Comment #46
dzepol CreditAttribution: dzepol commentedI downloaded this and tested the patch. This patch creates a new sub-module as @scotself said and applied without error.
When I added the new views fields (expire and expire role) there was a problem. The expire role name caused an error as it was pointing to an invalid rid reference. I've fixed this to point to the correct reference.
@scotself had noted in the patch at the same line "TODO: Should I be using this->get_value() here?". Unfortunately, I don't know enough to be able to answer that question, but after making the change I mentioned, I found no other problems. I've updated it and attached it below.
Comment #47
dzepol CreditAttribution: dzepol commentedI thought about it a little bit, but I didn't think it made sense to have a completely new module created for this.
Anyways, I created a new patch with the same functions, against dev, which updates the existing uc_roles module. (This is my first attempt at creating a patch so bare with me!)
Comment #48
ydahiTested patch from #47 on:
UC 7.x-3.6
Views 7.x-3.8
Contents of uc_roles/uc_roles.info.rej
I am able to use both new fields in views. The patch does what it's supposed to do - wish I could help with the error...
Comment #49
TR CreditAttribution: TR commentedPatch applies fine for me. And it applies fine in the testbot in #47. So I suspect the problem is on your end ...
Comment #50
jsibley CreditAttribution: jsibley commentedI am also getting:
Hunk #1 FAILED at 2.
uc_roles.views.inc is created but the changes are not made to uc_roles.info as indicated in the reject file above.
Unfortunately, I don't know enough to know why it isn't working.
Comment #51
Anonymous (not verified) CreditAttribution: Anonymous commentedsubscribe
Comment #52
TR CreditAttribution: TR commented@ankos79: You do not have to / should not post just to subscribe to an issue on drupal.org. Instead, use the big green "Follow" button at the top of the page.
If this issue is important to you then please help out - test the proposed patch in #47 and report how it worked for you.
Comment #53
BenIPAQ CreditAttribution: BenIPAQ commentedApplied the patch. Seems to work ok! Still there is a problem with the expiration date within a view. It looks like it's tied to the wrong content. Also I get this error:
Comment #54
jsibley CreditAttribution: jsibley commentedUbercart is now version 3.8.
Does the patch need to be re-rolled or was it ever incorporated into a release?
Comment #59
TR CreditAttribution: TR commentedTestbot is currently broken: #2375345: Dependency on core module results in PHP Fatal error: Cannot redeclare system_requirements()
If you want to see if it still applies, you will have to try it yourself. It won't be committed until it has been tested and someone fixes the errors reported in #53.
Comment #61
aniebel CreditAttribution: aniebel commentedDisregard this comment
Comment #62
aniebel CreditAttribution: aniebel commentedUpdate: My white screen was an urelated issue.
However, I am not seeing the fields available in Views.
Comment #63
aniebel CreditAttribution: aniebel commentedUpdate #2: This does, in fact, work.
Comment #64
aniebel CreditAttribution: aniebel commentedComment #65
TR CreditAttribution: TR commented@aniebel: Did you try to reproduce the problem described in #53? What do you mean by "it works"? Can you be little more specific about what you tested...
Comment #66
aniebel CreditAttribution: aniebel commentedSorry about that. I do not get the error in #53 when using the Ubercart Role Expiration in a View at all. I am able to see and successfully use the field when creating Views with this field involved in them. Please let me know if you need more information.
Comment #67
aniebel CreditAttribution: aniebel commentedAn additional note: as a future feature request, the date widget is an input field as opposed to other date fields that provide a pop-up calendar widget and more relative date options. I'm only mentioning this as my viewpoint from testing it and being transparent on what I found and, again, this seems more of an additional feature request.
Comment #68
aniebel CreditAttribution: aniebel commentedUPDATE: I just migrated to a new hosting company and am now getting an error when visiting any page similar to #53.
Strict warning: Declaration of uc_role_views_handler_field_rid::pre_render() should be compatible with views_handler_field::pre_render(&$values) in ctools_plugin_api_include() (line 160 of /var/www/vhtdocs/userweb63850/html/sites/all/modules/ctools/includes/plugins.inc).
Comment #69
bachbach CreditAttribution: bachbach commentedHi,
patch #47 ran partially well for me with UC 7.x-3.8, it failled with uc_roles.info
i made it manually and it does the job, i can display and sort a view with role expiration date.
Comment #70
aniebel CreditAttribution: aniebel commentedWOW, I think I may have fixed the error but I need to figure out how to write a patch. In the meantime, line 75 of uc_roles.views:
function pre_render($values) {
should be:
function pre_render(&$values) {
Comment #71
aniebel CreditAttribution: aniebel commentedOk, not sure if this is the proper way. Please advise but this has fixed the error being thrown for me.
Comment #72
texas-bronius CreditAttribution: texas-bronius commentedThe patch being applied could be either a simple stand-alone module and made ready for download or as a patch against the ubercart project. The patch in #71 (only one I tried) appears to work for me in D7 Views 7.x-3.11 with uc_roles 7.x-3.8. I had some personal trouble wrangling in the patch, but that was likely just me..
Comment #74
TR CreditAttribution: TR commentedPatch format was bad - missing end-of-line character at the end of the file.
Re-rolled with no changes other than that. Please test.
Comment #75
aniebel CreditAttribution: aniebel commentedAdditional feedback: I noticed that I'm not able to use relative dates as a filter in Views. Perhaps this is related to the limitations of granularity and date format picker I mentioned in #67.
Comment #76
SeanA CreditAttribution: SeanA commentedIt works! Nothing broke, no complaints. Thanks guys.
Comment #77
TR CreditAttribution: TR commentedUploading the patch again so the new CI testbot will look at it.
Comment #78
TR CreditAttribution: TR commentedOK, it passed. I made a bunch of changes, mostly for coding standards. I separated the hook_views_data() and field handler into separate files and moved them into the views subdirectory. I removed the dependency on Views, since this module works fine without Views enabled. I also switched the Views api version from 3.0 to 2.0.
@SeanA: Can you give this new patch a try and make sure this still works for you? You will have to revert the old patch then apply the new patch. You will probably have to disable uc_roles then re-enable it to get Drupal to read the .info file. Don't forget to clear your caches!
Comment #79
SeanA CreditAttribution: SeanA commentedNo problems, looks good.
Comment #81
TR CreditAttribution: TR commentedThank you for testing that SeanA.
Committed to 7.x-3.x. Moving to 8.x-4.x for porting.
Comment #82
bisonbleu CreditAttribution: bisonbleu as a volunteer commentedI'm using the role expiration date in a view. I can see the list of roles that will expire in the future. But the view returns no result (null) when I search for roles that have recently expired e.g. last month.
Am I doing something wrong or is it that it's just not possible? In theory, expiration dates remain available in the uc_roles_expirations table, doesn't matter whether they are past or future.
Use case - having access to the recently expired roles in Views would make it easier to send out custom reminder emails.
Comment #83
TR CreditAttribution: TR commented@bisonbleu: I assume you're doing that in 7.x-3.x? Since that code has been in Ubercart for a year, if it doesn't work correctly it's a bug. Please open a separate issue for that bug (you can add a link back to this issue for reference).
This issue is now for porting the patch in #78 from D7 to D8.
Comment #84
bisonbleu CreditAttribution: bisonbleu as a volunteer commentedSorry for the noise.
Not a bug. I created a separate issue where I'm suggesting how this can be done. Cheers!
Comment #85
TR CreditAttribution: TR commentedThanks for the related issue - I'm sure that will help someone.