In order to avoid two+ modules that do the same thing, I want to try and incorporate as much of edkwh's draft module that make sense. My goal was to make something very light-weight and non-invasive so that it could potentially be "forward-ported" to work with HEAD to solve issue: http://drupal.org/node/48731.
Things his module has that this one doesn't:
1. Permissions on creating/editing 'drafts' (revisions). The revision moderation module just uses the default node permissions for this. Don't know if that should be considered a feature or a bug -- input welcome.
2. A separate tab for tracking drafts vs. revisions on a node. Since drafts ARE revisions, it made sense to me to keep them in the same place. But if people think that's more confusing, we can talk about it. :)
3. Keeping "drafts" separate from "revisions." The only way draft module can do this is by using the "log" field as a means of storing "meta" info about the revision in question. However, doing that prevents the log field from being used as an actual log. The only way to get around this is to add another table, and I would really rather not do that.
Things incorporated from draft module into revision moderation module:
1. Consolidating options. Not a direct port, but edkwh's idea of placing the options for saving a node as draft right in the node publishing options got me thinking that we don't actually need _any_ additional settings for this, really; simply trigger the behaviour when both "in moderation queue" and "create new revision" are checked.
2. Moving logic into hook_nodeapi. I had some stupidly complex hook_form_alter logic for awhile there and ewkwh's approach was much better. :)
3. Archiving of other original properties than the vid. Again, not a direct port, but edkwh's idea of versioning original/new properties led to revision moderation doing the same. Right now all that's versioned is vid and status, but more can easily be added if need be.
This module still needs testing; as uid 1 it seems to be working ok, but I need yet to test it thoroughly with 'peon' users and such.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | fix_zero_nid.patch | 1.03 KB | criznach |
Comments
Comment #1
yched commentedI'm giving the module a first round. Seems pretty clean :-)
Once again, thanks to both of you for the effort.
Here are a few remarks :
- On the revisions tab : the "revert" word seems odd when the revision is a draft - Back to the future ?
- It seems the "pending revisions" list only show the title of the first draft :
Say user_foo has "my node 1.0", and edits a new draft with the title "my node 2.0"
admin sees "my node 2.0" pending - OK
Before admin "commits", user_foo creates a new draft "my node 3.0"
admin still sees "my node 2.0" pending (though the list on the node's "revisions" tab correctly lists the two dratfs)
- Sort of related : It seems simpler to have drafts managed on the existing "revisions" tab - only problem is this currently does not display the title changes
- The publish revision ("revert") operation seems to have strange effects :
my node gets unpublished, and vid=0 in the {node} table. I currently have to manually correct this in the db.
- Is it necessary to copy the accepted draft as a new revision ? Why not simply turn the accepted draft into the node's current revision (and add a log message saying "Published by admin on (date)" ?
- BTW, the log message seems to display strangely on the node's page
if my node's body is "test", it displays "testLog:Copy of the revision from Wed, 27/09/2006 - 22:02."
(not sure this is really this module's fault, though...)
Here's for now. More thoughts later on :-)
Comment #2
webchickGreat! Thank you so much for the review!! I'll see what can be done about those issues as I work more on this tonight. :) That vid=0 thing looks particularly bothersome. :P
Comment #3
criznach commentedI think this helps maintain the concept of a logical "stack" of history under the current vid, including drafts that didn't get published. Similar the current behavior if you revert to an old vid. It copies the revision to the top of the stack and logs what's happened.
Another idea... What if there was a "Create New Draft" tab next to edit, which automatically flagged "in moderation" and "create new revision". This would automate the steps and make this a bit more end-user friendly.
Comment #4
criznach commentedHere's a patch for the zero and status vid problem. Please review before trying it :) After stepping through the revert code, I found that revert calls the module's nodeapi "update" event, which was attempting to set vid and status to the values saved in "submit". So I added a test that they've been set before updating the node. Other than that, it was working as expected. The concept still looks solid after digging into the node module. At some point, it would be nice to have some tighter integration into the nodeapi.
Comment #5
yched commentedComment #6
criznach commentedI think one case where it makes sense to not copy is when the topmost draft gets published. Then it is somewhat of a duplicate state. But since the copy happens in the node module, I could live with it.
I'm getting caught up on the various threads regarding drafts, so I should be able to stop posting duplicate information real soon now. :)
Comment #7
webchick(attempting to stop quote-o-rama ;))
Thanks a lot for the input, guys!
The "back to the future" comment is valid; however because the revisions page is not a form, I can't edit what those links say. There are two options around this:
1. Override the node/#/revisions path with a custom menu that displays the links differently.
2. Put pending revisions on their own tab, like draft module does; then we can modify this page to say whatever we want.
@criznach: It might be because my caffeine and sugar high is wearing off, but I can't really see a difference between the two hunks in the patch, apart from indentation. Am I missing something..?
Comment #8
criznach commentedMy patch foo just isn't up to snuff... In fact, I think I ran the diff tool backwards. Oops.
I changed this (lines 66-68)...
To this...
Comment #9
webchickAh! Yes, that makes total sense, and probably has a lot to do with why the vid is becoming 0. :P The trickiest part of testing this module is there are approximately a gabillion different possible configurations of options. ;) So I appreciate your guys' help!
I've added that to the module now, although I'm wondering if isset() is the proper check here? It seems these would be set either way in the nodeapi op submit case. But I guess we'll find out. ;)
I also like your idea of making a "create draft" link, however, that's more than a 2-second change so will need to wait until next week or so. :) If someone gets to it before me though, feel free to post a patch!
Could you elaborate on what you mean by "more integrated with nodeapi"?
Comment #10
criznach commentedhook_nodeapi "submit" isn't necessarily called in every case. I'm looking at line 1303 of node.module, and it says that "update" is triggered via node_save when a revision is reverted. Then, at line 489 in node_save, it calls hook_nodeapi with "insert" or "update", but not submit. So in the case of revert, "update" is called but not "submit". So neither original_vid or original_status have been set and they end up being zero in the query.
By more integrated into the node api, I mean that some of us view this as something that could or should be part of the core revision mechanism. I think that if revisions are in core, then drafts should be too, since they often go hand in hand. For example, I would have no use for CVS or Subversion if I had to commit changes every time I saved. If it were eventually integrated into core, some distinction between the draft and history states would be useful and more intuitive. For example, the "copy on revert" behavior could be slightly different when "reverting to" a draft. It just so happens that node.module's copy behavior works for us. In the future, there could be a clear distinction in node.module between "reverting" to a history state and "publishing" a draft state. It wouldn't change the database schema, but more just clarification in the source of what's happening.
I showed this to a client today, so I guess I've committed to helping out. Clicking the revision and moderation check boxes was the only part where she looked confused...
I'll look into the "Create Draft" feature. I need to study up on hooking the forms, etc... There are a ton of potential features related to this, but a "Create Draft" link would make my clients 99% happy.
Comment #11
webchickJust quickly, I'm 100% with you on "this is really how core ought to do things" ... my idea was to get it working as a contrib module first to get all the "kinks" worked out (and also so 4.7 users aren't stranded) and then look at porting it to HEAD as a bug fix.
Thanks for looking into the nodeapi madness. That's strange that submit isn't called sometimes; it should be each time a node form is submitted. I'll have to look more into it...
Comment #12
criznach commentedBut when you revert you're not really submitting a form. The parameters come in from the the URL as it's built on line 1289.
Comment #13
yched commentedSorry for the earlier blockquote mess. Not my first time :-)
About the "create draft" tab / link / whatever ..., well, UI.
What I've been trying to achieve so far with the "moderated revision" feature (until now I used the patch in http://drupal.org/node/48731) is this :
IMO this should kept as simple as possible for the user (especially the one whose edits go through moderation, since he is supposedly "less involved" with the site and the admin interface).
'edit' tab / 'submit' button / 'thanks, edits submitted for moderation' message : My user is happy.
No checkboxes to mess with, he does the same as for every other (unmoderated) content he could edit, he is just informed at the right moment of what is going to happen with his contribution.
What happens when the user hits 'Submit' should be decided by his access rights.
When the user has a choice (he has the rights to save as a draft OR as a plain new revision), then maybe the best thing would be to expose him a "Submit as draft" button next to the regular "Submit".
I think this is kind of related to the "access rights" question webchick evoked : default core access rights, or additional rights. I'm still uncertain about that, too...
Comment #14
criznach commentedI'm filing bugs, etc here...
http://drupal.org/project/issues/revision_moderation?categories=bug
Comment #15
webchickJust to follow-up, criznach: thanks for catching that isset bug. I totally get what you mean now, was having a "blonde" day that day I guess. ;)
Sure, makes sense. The question is, which access rights?
I might use revisions in the form of a wiki. In that case, I want all new revisions to be published immediately, regardless of by whom.
Or, I might use revisions as a way of "screening" edits before they apply to a node. In this case I want all revisions (except possibly node administrators) to stay unpublished until i get a chance to approve them.
Handling this at the node content type level (so create new revisions + in moderation queue == checked) was the only way I could think of to handle this. And while that's a bit awkward, at least you only have to do it once if you make it the default for that content type.
Comment #16
webchickNew update tonight includes ability to edit revisions (uses hook_link when viewing a node revision) and uses a slightly different way of storing the original values. Still working on #86596.
Comment #17
webchickI think I'm going to mark this closed... this module's being successfully used "in the field" on a few different sites.