Closed (duplicate)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
6 Apr 2008 at 07:03 UTC
Updated:
3 Nov 2009 at 01:54 UTC
It would be nice if a user could have a page listing views of what he or she can edit (in the form of a custom workspace). Since the workspace module doesn't play nice with other access modules, I was hoping that a views filter might be developed that would filter and display only existing content that the current user can edit, delete, or otherwise change in some way (things that the user may not have authored but is given rights over through the access table and things like Taxonomy Access and Content Access). Someone has tried to create a views argument here, but I had trouble getting this to work: http://drupal.org/node/240345
Comments
Comment #1
merlinofchaos commentedThis is unfortunately kind of tough. Not impossible, I suppose, but the node_access query is kind of rough. Still, this is an interesting feature request.
Comment #2
bomarmonk commentedThanks for the response. I still hope someone will figure this one out (I know that you, Merlin, have been very busy creating the new version of views and it looks terrific-- I am testing it on several sites).
Comment #3
bomarmonk commentedI did request something similar from the workspace module and one person tried to create a patch that allowed this from the node_access side of things. I thought I should provide a link for that issue to see if the supplied path there might help create a filter for views: http://drupal.org/node/59924
Comment #4
moshe weitzman commentedYeah, core db_rewrite_sql() and node_db_rewrite_sql() do not help much here at all. They assume 'view' operation.
Comment #5
merlinofchaos commentedWhile Views does not handle this natively, it should be possible to create a filter that links into node_access similar to what db_rewrite_sql does and checks 'update' rather than 'view'. This may be a useful feature in the future.
Comment #6
catofcheshir commentedThis can be very useful feature especially in fusion with CCK's nodereference feature - using view to generate list of nodes that can be referenced.
I hope someone can code this...
Comment #7
chaloalvarezj commentedSubscribing... I really need this functionality.
Comment #8
thepanz commented+1 for this feature!
Anyone can point me to the Views2 API that could help developing this filter?
Comment #9
traviscarden commented+1 / subscribing
Comment #10
merlinofchaos commentedNow that the node_access filter is in, a relatively small patch to add an option to views_handler_filter_node_access.inc should allow checking for view, update or delete access quite easily.
Comment #11
traviscarden commentedShould we expect such a patch soon, or do you just mean it's theoretically possible to make one? I'm not quite at that place with Drupal yet, but I could really use this feature on a current project. Either way, thanks so much for all your work!
Comment #12
merlinofchaos commentedThis should be a relatively easy patch for someone to write.
Comment #13
lelizondo commentedsubscribing
Comment #14
hefox commentedAs most things, this is not as simple as it seems
1) user_access('edit any content')
2) The node_access filter doesn't work when a node access module is not in use since the sole content of the node_access table is...
+-----+-----+-------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-----+-----+-------+------------+--------------+--------------+
| 0 | 0 | all | 1 | 0 | 0 |
+-----+-----+-------+------------+--------------+--------------+
And it does a left join on nid = nid but there is no nid to join on in there.
This is what I have so far
(This is it's own seperate filter, not using the view access filter due. if I have the time I'll try and make a patch for views (it's in a separate module that contains various other filters and random code, I can link to it later). )
file views_handler_filter_node_edit_access.inc
file module name.views.inc
file module name.module
Comment #15
jacerider commentedsubscribing
Comment #16
jesss commentedI could really use this functionality on my current project. I've looked at a bunch of other modules (Workspace, Module Grants, UDashboard), but none of them offer the exposed filters provided by Views. If hefox (or someone else more skilled than I) could convert the code in #14 into a patch, I'd be happy to help test it.
Comment #17
hefox commentedThere's one more aspect I forgot about the checking edit permission is for custom module nodes type that implement ... hook_node_access? The above code does not take that into consideration. Oh, and also need to add in a 'edit own $type content' check.
ATM a bit busy, and frankly a bit 'I'm not worthy' to submit a patch to views .. XD
oh, idealy it should be joined with the view access filter as mentioned above instead of being independent.
Comment #18
scishop commentedsubscribing
Comment #19
ymmatt commentedI have been using a php snippet for a couple years now:
I just create a new page, put this in the body and set the input format as PHP, it should work on both 5.x and 6.x sites.
Comment #20
RoboPhred commentedMarking dup of #620392: Allow edit and delete access check in "Node Access: Access" filter per merlin.