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.
This patch adds a hook_node_operations() function for modr8 and provides 3 operations:
- Mark for moderation
- Approve moderated nodes
- Delete moderated nodes
Pretty simple but immensely useful. Use with views bulk operations to create custom moderation views.
Comment | File | Size | Author |
---|---|---|---|
#15 | modr8_368124.patch | 5.8 KB | drewish |
#8 | modr8.nodeops.patch | 6.08 KB | zroger |
modr8.nodeops.patch | 2.56 KB | zroger |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedLooks useful indeed - however, it seems like at least for the approve/deny functions we ought to be able to re-use existing code? If not, we should refactor it.
Comment #2
pwolanin CreditAttribution: pwolanin commentedMore problems - the operations, such as "approve" may be applied to nodes that are not in moderation. Also, casting $node to an array does not fully recapitulate the expected values array.
Comment #3
zroger CreditAttribution: zroger commentedI definitely want to refactor, just didn't want to over-scope this issue.
Comment #4
zroger CreditAttribution: zroger commentedcreated an issue to refactor into reusable api functions. will re-roll this after that gets in.
marking postponed, waiting on #368782: Refactor: modr8 api functions
Comment #5
pwolanin CreditAttribution: pwolanin commentedLet's just do it here - the amount of code we are talking about doesn't really warrant multiple issues.
Comment #6
zroger CreditAttribution: zroger commentednew patch that creates new public API functions:
- modr8_moderate_node($node) - place a node into moderation
- modr8_approve_node($node) - approve and publish a node
- modr8_delete_node($node) - delete a node and notify user
These functions are now used by modr8_form_submit() and the hook_node_operations() callbacks.
Comment #7
pwolanin CreditAttribution: pwolanin commentedno patch
Comment #8
zroger CreditAttribution: zroger commentedoops.
Comment #9
pwolanin CreditAttribution: pwolanin commentedseems like we are building all the values twice, since we still have:
Comment #10
ilfelice CreditAttribution: ilfelice commentedSubscribe
Comment #11
alex_b CreditAttribution: alex_b commentedI see undefined $nid in query:
Further I would argue that there shouldn't be an 'approve moderated nodes' or a 'delete moderated nodes' because these steps can be implemented by exposing a filter on moderation plus bulk operations for moving into moderation queue and approving:
'select all nodes in moderation' + approve or delete.
Comment #12
EvanDonovan CreditAttribution: EvanDonovan commentedI just did this today, without seeing there was already an issue. I simply added the following, where node_mass_update() is the function in the node module that publish/unpublish, etc. uses.
Of course, doing it my way doesn't write to the moderation log. But in my case that isn't necessary, since we don't actually use the log messages.
Comment #13
Daniel A. Beilinson CreditAttribution: Daniel A. Beilinson commentedThere is no happen after i'm trying to do bulk opertions: aprove or remove from moderation queue.
Nodes staying there in moderation and have moderated status: No.
Comment #14
k3vin CreditAttribution: k3vin commentedI put EvanDonovan modr8_node_operations() function in the file /modules/node/node.admin.inc and the operations works for me in drupal 6.14.
Better the function would be implemented in the modr8 module. For me the feature is very important and very flexible to handle a lot of nodes.
Thanks btw for the snippet EvanDonovan :)
Comment #15
drewish CreditAttribution: drewish commentedre-rolled zroger's patch against the current version. fixed the issue that alex_b reported in #11.
some direction from the maintainer on this vs EvanDonovan's approach would be helpful.
Comment #16
EvanDonovan CreditAttribution: EvanDonovan commented@drewish: Your way is definitely more robust. I think it is the way that should be committed to the module; I just don't actually use modr8 anymore, only the {node}.moderate value.
Comment #17
pwolanin CreditAttribution: pwolanin commentedWhy is the patch doing a node load in cases where the operation to be performed only requires the NID?
Comment #18
CobraMP CreditAttribution: CobraMP commentedlooking at the latest patch I am gathering the the following php code will set the node into moderation
db_query('UPDATE {node} SET moderate = %d WHERE nid = %d', 1, $node->nid);
I am trying to make a rule where the action "execute custom php code" will set the node into moderation
*edit
I can verify that indeed that worked perfectly
Comment #19
mathankumarc CreditAttribution: mathankumarc commentedNew features are going into 7.x
Comment #20
mathankumarc CreditAttribution: mathankumarc commentedCommitted public API functions to 7.x.
As pwolanin stated in #2 , node operations will try to perform moderate actions on the contents which are not in moderation queue.
Is there any better way to achieve this? We can alter the node filter form, but query cannot be altered.