Closed (fixed)
Project:
Library
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
1 Jun 2010 at 15:07 UTC
Updated:
13 Nov 2010 at 03:36 UTC
Jump to comment: Most recent file
Remove 'patron' content type and use Drupal user module for all transactions instead. Related to the following feature requests:
http://drupal.org/node/323657
http://drupal.org/node/319021
http://drupal.org/node/295341
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | patron-removed4.patch | 69.7 KB | jastraat |
| #29 | patron-removed_v3.patch | 68.91 KB | jastraat |
| #27 | patron-removed.patch | 65.83 KB | jastraat |
| #26 | patron-autocomplete-v2.patch | 1.08 KB | grahl |
| #24 | patron-removed.patch | 64.8 KB | jastraat |
Comments
Comment #1
grahlAttached is my first attempt at this. My local installation is functioning as expected with it. Not really included is library.actions.inc, it has not been fully reviewed regarding send_email and renew. Also, I was unsure how to properly let the conditions in the install file fail for update_6201.
To accommodate being able to specify fields other than the user name to search for during transactions I added support for the profile and content_profile module. You can now select textfield fields from those modules (when enabled) under admin/settings/library and they will be searched and shown by the autocomplete function in addition to the user name.
The attached patch also includes numerous small suggestions from the coder module as well as a rules event on library actions. I tried splitting the patches for this up but ran into several conflicts. Please let me know if that's a problem. (Taking out the rules events should be trivial, the coding style issues, not quite, after all the other changes.)
Comment #2
jastraat commentedHey Grahl - thank you for working on this! It would probably be a good idea to try to reduce this patch to just the things related to this issue.
Comment #3
grahlA shortened version is attached, in a few instances a coder module suggestion was close to a modified region and I left them in, I hope those aren't too distracting.
Comment #4
grahlForgot to hit attach...
Comment #5
jastraat commentedThis seems to be a great start - but I really don't feel that we can just leave folks with no upgrade path here. A couple of comments:
We can't leave library patrons in the database except as a vestigial, unattached to anything, table. I understand not wanting to lose data for folks that have been using the module, but you can't have a join on the transactions table to a table that won't exist for people who are installing this module for the first time. I think we should get rid of the table entirely however - addressed in my next point:
We can put in the upgrade notes that if a user wishes to upgrade, a Drupal user will be generated for every existing patron that doesn't have one already associated with it. Also in the notes, if an individual wishes to retain patron first and last name, they must enable either the core profile module or content_profile module. On upgrade, check to see if each patron has an associated uid. If not, create a user for that patron. Then, check to see if the profile or content profile module is enabled and create fields for first and last name and insert the data from the library patrons table.
I really don't agree with adding the 'search library patrons' permission. I think we should just use Drupal's default 'access user profiles' since these are users. Not using that permission would be considered a security problem anyway since it would expose user information to users who should not have permission to see it. Check if a user has 'access user profiles' and if they don't, check if the patron user they are viewing is themselves.
Comment #6
rsevero commentedPlease remember you can make a 6.x-.1.0 release with patrons and finish the non-patrons support in a new 6.x-2.0 branch.
Comment #7
jastraat commentedI'm afraid I don't want to have to support two official releases that are that different. My plan is to only release an official version once the patron sub-module has been eliminated and actions are based on rules instead of the current convoluted custom code. (Gotta love alliteration)
Comment #8
rsevero commentedWell, this is obviously you decision but remember that you don't have to really support two different versions.
You can release the current version with patrons (and support it as far as it seems reasonable to you, maybe even taking the radical position of marking all 6.x-1.0 patron related bugs as "by design" or "won't fix") while developing the new patron-free version.
When you get to the point of releasing the new version you can deprecate the previous version. This way you won't have to support two versions at any time.
I'm mentioning (and insisting) on this topic just because I know of at least one module that doesn't use Library because of the lack of any proper release (phpMailer it is but I bet there are others) and I didn't suggest Library module for the Messaging module maintainers for the same reason.
It gets rather prohibitive for other module developers to adopt your module without a proper release they can relate to and I'm sure this is slowing Library's adoption which is a loss to all:
* Library maintainers that don't see their work adding as much value as it could to the community and
* other module developers and users that have to deal with the problems that Library module could already be solving had it a proper release.
But, again, the final decision is yours. I won't rant anymore.
Comment #9
pixelsweatshop commentedGreat module. I definitely like the transition from patron to drupal user. Do you have an idea when you might have this rolled into the next release? We have a nice testing environment for this module, but the use of the patron module does not work for our needs, but will be great when it allows for drupal users. :)
Comment #10
jastraat commentedNigel,
I'm afraid I have no idea. I don't have time to work on new development of this module myself. grahl volunteered to give it a shot, but he hasn't posted any updated patches since June.
Comment #11
pixelsweatshop commentedNo problem. I wish I was a developer so I could help it out. I can definitely help with testing though. Looking forward to any future developments :)
Comment #12
grahlSorry about not responding earlier, I got a bit buried under my master's thesis. I have recently made good progress for an improved upgrade path which moves the patron fields into profile or content_profile fields.
My progress is attached, the profile module seems to work so far, the primary remaining issue I'm running into with this is that I have not yet found a good way of adding cck fields automatically to a content type.
Comment #13
jastraat commentedI haven't had a chance yet to look at the patch you attached - it's on my todo list. However, maybe this forum discussion might help with the adding cck fields programmatically? http://drewish.com/node/118 It looks like we'd have to add CCK as a required module. (Which honestly it kinda is anyway if you want to get full functionality.)
Comment #14
Dartoxian commentedHi - appreciate the patch. It was EXACTLY the improvement I was looking for. Took a little while to configure though. Just being picky but I think the dependencies need to become:
dependencies[] = profile
dependencies[] = rules
Or at least I had to enable those modules to get the patch working.
Comment #15
grahlAttached is the complete patch including a complete importing routine, which should work reasonably well with either profile or content_profile.
The only thing I didn't change yet is the 'search library patrons' permission. My motivation behind this was to make it possible to let a user (say, a part-time staffer) have a permission set that allows him or her to perform a transaction, but not necessarily access the profiles in their entirety. If you think this is ultimately a bad idea, feel free to change that line or let me know if there is a dimension to that issue which the module does not yet consider.
--
@Dartoxian, I think you might have used the first patch, not the later one which included a call to the rules module (rules is postponed for now). The profile module should not have been necessary, as far is I remember, though you'd probably want to have either content_profile or profile turned on to search for users to check things out for by criteria other than user name. So, a strict dependency in that case would be difficult.
Comment #16
jastraat commentedSince viewing patrons is viewing user information, being able to search patrons must also require that 'access users' is checked before allowing user content to be accessed.
Comment #17
leducdubleuet commentedThanks, this module is really getting somewhere really interesting!
I would like to help to test it out without the patrons but I'm having a hard time installing the patch in #15...
Pardon me for asking but which version does it apply to?
Also, is it a normal patch we apply with "patch -p0 < ..."?
Thx for your time!
Comment #18
grahlChanged permission to access user profiles, patch attached.
For the commenter above: I'm not too well versed in the details of the patch command but trying out "patch -p0 <" has not worked for me while "patch -p1 <" has worked fine.
Omitting -p1 is not possible since plain "patch <" does not parse subdirectories properly for some reason and thus the file in the includes directory would go into the root and the patron directory is not found.
Comment #19
daengo commentedFor this module it seems like you get a strange response either way.
1st try...............
patch -p0 < 814986-complete_4.patch
patching file b/includes/library.cck_fields.inc
can't find file to patch at input line 299
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/library.admin.inc b/library.admin.inc
|index ceab47f..b3d7095 100644
|--- a/library.admin.inc
|+++ b/library.admin.inc
--------------------------
File to patch:
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
2nd try .....................
patch -p1 < 814986-complete_4.patch
patching file includes/library.cck_fields.inc
patching file library.admin.inc
patching file library.info
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file library.info.rej
patching file library.install
patching file library.module
patching file library.pages.inc
patching file patron/patron.info
Reversed (or previously applied) patch detected! Assume -R? [n]
Comment #20
grahlI can reproduce your bug with 6.x-1.x-dev. The patch applies cleanly with -p1 to library-HEAD from CVS. Just tried the patch again on a clean copy of both of them and HEAD worked, dev didn't.
Comment #21
daengo commentedSWEEEEEEEEETTTTTTTTTTT! This is cool!!!!! would you say that it is just as stable as the dev version that is listed on the main library module page? It worked just like I expected it to but I haven't tested it with any of our actions and triggers for email messages.--I assume there would be no issue.
Comment #22
grahl@daengo As far as diff shows, CVS currently differs from dev only in terms of file headers, the packaging information in library.info and the latest patch from 319676. Apart from that it's the same.
Comment #23
jastraat commentedHey grahl,
I'm finally going through the code in the last patch, and I have a couple of comments:
Since patrons will now be users, there's really no way to create profiles or use content profile unless a patron was already associated with a user (or unless hook_update created Drupal user accounts for all patrons without one). Not entirely comfortable with having an update batch create a ton of users, so I think it'll just be a prereq that if someone wants to upgrade to this version, they need to be using 'patrons as users'. Folks should be able to do this even after using the module without it by checking the option, creating user accounts with the same email addresses as their patrons, and then saving the patron nodes.
I'm leaning towards making the resulting module as simple as possible, so I would like to only support the core profile module. The profile module made it into Drupal 7, and I'd prefer to reduce the number of contrib module dependencies. If the profile module isn't enabled, I'll enable it during upgrade. I'm working on re-rolling the patch with some of these changes, and I'll upload it when I get done.
Comment #24
jastraat commentedHere's an updated patch. Major differences between this and grahl's patch:
No support for content profile. Users can use the core profile module if they want to.
All patrons must have an associated user before the update will run.
There is now a history tab for users and a history tab for nodes.
There's a little more checking to make sure that the active user has access to user profiles before displaying patron info.
No additional changes unrelated to the removal of patron. (no rules, no formatting - want to keep testing to a minimum)
Would like to take more advantage of the profile module (if it exists) for patron autocomplete. Anyone want to take a stab?
Comment #25
grahlThanks for all your work in reviewing and moving this patch along jastraat!
I looked into the patron autocomplete for profile a bit more just now and have a partial solution to querying the profile_fields properly and avoiding duplicates. Did you have any preference in how the results would be outputted, e.g.: username ( Field1, Field2, ...) or something different?
I'm wondering if it's worth the effort to make the field order configurable in the admin interface.
Comment #26
grahlThe attached patron autocomplete patch works well for me, please indicate if you had other things in mind as well and I'll try to ammend it.
--
Edit: Just after uploading I noticed I still had users AS u instead of {users} u, sorry about that.
Comment #27
jastraat commentedPatch updated to remove outstanding bugs and installation errors
Still would like to take more advantage of the profile module (if it exists) for patron autocomplete
Comment #28
jastraat commentedoo! Thanks grahl. I'll check this out tomorrow.
(sorry - had the next comment screen up for a couple hours while troubleshooting some of the bugs in the first patch)
Comment #29
jastraat commentedGrahl,
I spent 4 hours trying to make autocomplete work with profile values. Man. Sadly, your patch didn't quite work. Worked in my SQL editor - didn't work when called by db_query. Finally figured out what was up. Check out omerida's comment on http://api.drupal.org/api/drupal/includes--database.pgsql.inc/function/d...
"If your second argument to the function is an array, all following arguments are ignored and not used as expected in the query"
Which meant that $fids could not be an array. This was absolutely terrible to troubleshoot though.
I also added an option to turn off autocomplete for the patron input in case folks are scanning an ID card with a string (like a barcode). However - it will only work with the Drupal username because it's not possible to guarantee uniqueness in a profile field.
Finally, killed a few more bugs related to overdue notification.
Newest combined patch attached.
Note: I'm feeling pretty good about this one, but I want some independent tests of the upgrade before committing it to HEAD. So please test!
Comment #30
daengo commentedJust to clarify...if you already had "Associate Library Patrons with Drupal Users" enabled, there should be no issue with any of these recent patches, however, for jaastrat's most recent patch you need to have profile enabled? Can the profile module still be disabled and these newest patches still work? I ask because I had a conflict with the webserver_auth module last time I enabled profile. So I was hoping that would be optional. I like the way this is moving the last few weeks and really hope for a non-developer version for 6.x sometime in the near future. DOes that look likely?
Comment #31
jastraat commentedHey daengo,
For the most part, you shouldn't have a problem if you had 'associate library patrons with Drupal users' selected. Cases that could be troublesome are if not ALL your patrons are associated with users. For example, if you deleted a user that was associated with a patron. The upgrade process for this enables the profile module automatically so that the first name, last name, and (possibly) barcode info from the patron type can be stored somewhere. If you don't want to use profile, you can disable and uninstall it after the upgrade, but you will lose all patron info that isn't part of a user (username/email). Username is the only unique identifier supported anyway since profile fields don't have a unique option. So for example - if you were using barcodes with patrons, you will need to change the patron usernames to be the barcodes. Enabling the profile module, even temporarily, gives folks using this module a way to not lose data about their patrons.
I'm attaching another patch that makes sure that all the update code surrounding the removal of patron only occurs if folks had an earlier version of this module installed. I've tested it against a clean Drupal installation, and I think it makes using the module much, much easier. I'm about to apply these changes to HEAD in hopes that more folks will test if they don't need to apply a patch. Please make sure to test in a development environment and have backups.
Thanks!
Comment #32
jastraat commentedThese changes have been applied to HEAD, so you can also download them there.
Comment #33
jastraat commentedI've created a new release branch for this version. Please test!
Comment #34
grahlThank you for all your work on that branch, I plan to test it with a staging system extensively this weekend.
Comment #35
jastraat commentedHey grahl - thank you for all YOUR work! :)
Let me know how the testing goes.
Comment #36
tutumlum commentedNice work. Subscribing...