Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
6.x-1.x-dev
Component:
content.module
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
13 Mar 2006 at 09:37 UTC
Updated:
8 Nov 2006 at 19:15 UTC
Jump to comment: Most recent file
Comments
Comment #1
RayZ commentedLooks good to me. Here's a unified version of the identical patch if anybody cares.
Comment #2
moshe weitzman commentedDrupal core does not enable a module to properly define read/view permission. this is handled by node_access(). when displaying a node listiong, hook_access() is not called so node module can't influence here. see core modules for an example hook_access implementation.
Comment #3
karens commentedI'd like to resurrect this patch and get it applied. I need this capability and the patch seems to work perfectly. I see that moshe said drupal core does define view permission, but the hook_access documentation includes 'view' as one of its examples and it does seem to prevent an anonymous user from getting to the node.
Comment #4
jonbob commentedIt will prevent a viewing of the node on an individual page, yes, but has no effect on listings. Node listings strictly rely on the node_access table for access restriction. It is therefore dangerous to check for view permissions this way, because users will be under the impression their content is access-controlled when it is still accessible by other means.
Comment #5
sami_k commentedDoes there then need to be a patch to the core that would allow for full CRUD support, because I think it's necessary for quite a few situations? If so, KarenS or Ber, is it possible for you to submit such a patch? Perhaps JonBob or Moshe can give a few pointers as to how to make that happen? Just seems like the next logical step, I just thought I might as well as just say it :)
Comment #6
sami_k commentedComment #7
karens commentedThe whole topic of access control is going to get off-topic for cck, but I wanted to post a bit of info here for anyone else who is looking for the ability to control access to cck content since they may end up reading this thread. I am still getting all this figured out myself, so anyone who knows better, please correct me if I'm wrong.
Basically, the module can control everything but 'view' access, so we can set up control for edit, edit own, delete, etc. within the cck module itself (and I think we certainly should).
Completely controlling 'view' access requires one of the access control modules -- simple access, organic groups, taxonomy access, node privacy by role, etc.
I was trying to figure out which of them would most closely match what I wanted to do here -- control access based on the content type and user role, and it looks like node privacy by role is the best match for that purpose. You can enable it, then go to admin/settings/content types and select the cck content type to set up default access permissions for that type. You can then override the permissions on a node by node basis.
A *very* brief overview of the other modules, just to help point people in the right direction for more research into this issue, since I think there is nothing that cck can do itself to control 'view' permissions:
Simple access -- a very simple module that allows you to control access on a node by node basis. The default is to make everything public, you have to edit each node that you want to make private.
Taxonomy access -- links user role and taxonomy terms to control access. You have to apply the right taxonomy terms to your node and then access will follow the permissions settings for that term. If you don't set anything up, the default is to make content public, so it's public until you change it.
Organic groups -- allows you to create groups, then each node has an option whether or not to make it public. The default is to private unless you set it otherwise. Again, to set up any access other than the default you have to edit each node.
Node privacy by role is the only access control module I found that seems to have a means to set a default view access by the content type. It uses the default you set for that type when you create new content, but any content that already exists when you first enable the module defaults to being viewable by the public until you change it. This seems to be the module that most closely emulates what I was trying to do in this patch. I am trying this module out and it looks like there is no problem using it with cck content types (and of course there is no reason why cck content types would behave any differently than any other type).
Comment #8
jonbob commentedFor this issue, I think we need to wait until Drupal 4.7 ships. At the moment discussions on the developer list are focused on squashing critical bugs, and that can't be disrupted. After that we can open a general discussion on whether node modules should have "update" and "delete" permissions per content type. The core node types don't do this now, and since CCK is being designed as a core candidate we want to emulate the core approach as much as possible. If the community decides this should be done, then I will make the change.
Until then, node privacy by role not only allows for controlling view access, as Karen mentioned, but also update/delete. It is a fine solution for urgent needs, and scales well for other access schemes.
Comment #9
Bèr Kessels commentedI just tested the patch, and it still works.
The "view" issue is indeed a very tough one. And I beleive that it is just a bug in Core.
Getting it to work completely in cck, as expected, requires either cck to use the hook_node_grants, which adds a lot of complexity. Or it requires a core change.
In any case, I beleive we can still use this patch for providing basic CRUD permissions.
Comment #10
jonbob commentedRUD support, then? :-)
I am very willing to add the "update" and "delete" permissions if the community decides to add such permissions to core. The development philosophy is to prepare this module for core inclusion, so I'm hesitant to add any features that are not related to the task at hand (administratively-defined content types) unless those features are also being added to core.
Comment #11
Bèr Kessels commentedWell, CUUD would be better.
I will ping the lists and see what can be done in and for core. We might even add CUD for any node type in the node core.
Bèr
Comment #12
ninetwenty commentedI've been looking at this for Flexinode and I think it would be a good idea in CCK. View restrictions for lists can be done through the db_rewrite_sql hook but I'm not entirely sure how to do this as I can't get my head round the documentation. Sometimes I find the access modules a bit of overkill for what I need and simply having a permission for view on CCK would be great.
I'll let you know if I eventually get my head round this.
Comment #13
ninetwenty commentedGot something that seems to work. Haven't got diff installed so I'll just post the three functions:
The first two are per the original patch.
The db_rewrite_sql hook allows the sql to be modified with extra clauses to prevent unviewable entries showing up in lists. This is needed as hook_access is not called during a list for performance and other reasons.
Let me know if any problems show up and if this is of any use to anyone.
Comment #14
Bèr Kessels commentedninetwenty: this looks very usefull. Can you make this into a pathc? IF not, please report here, or contact me in private, so that I can help.
Comment #15
ninetwenty commentedHi Bèr,
Just downloaded diff and here it is in patch form. I've tested this patch with simple_access and so far there are no conflicts, everything works as expected.
Comment #16
Bèr Kessels commentedComment #17
ninetwenty commentedI've updated the patch so that a user isn't blocked from viewing their own content. Some issues need looking at such as the view permissions for the module override permissions given by other access modules.
Comment #18
Bèr Kessels commentedI personally feel that it should be possible to provide people viewing their own content. Like when they submitted something that gets deprecated after X weeks. Or when one uses CCK/nodes for a ticker/tracker system where a user is not allowed to view an issue in certain states.
In any case: there are enough cases where one wants to provide users access to their own content.
Comment #19
Bèr Kessels commentedHere is a revised version of the patch
I made the conditional logic in content_db_rewrite_sql a bit more optimised
I removed the hardcoded conditions for "view your own stuff". (see above for why)
Comment #20
forngren commentedI continue the discussion from http://drupal.org/node/62340#comment-109810 to http://drupal.org/node/62340#comment-111006
By patching them too ;)
Sounds like a great idea to me, but I think that we should implement this sooner or later.
Here's an example scenario:
I'm the admin of a small site for a soccer team.
It has two groups called coaches and players.
There are four kinds of roles:
Not the best example, but I hope that you got the idea
How often is node listenings used? There must be a way to not slow down pages that much
Puh, I'm exhausted :p
//Johan F
Comment #21
marcoBauli commentedCarefull:
This patch is NOT compatible with Views at the moment: it throws 'Unknown table 'n'' warnings for each view displayed, see here and screenshot attached.
Comment #22
gerd riesselmann commentedkiteatlas is right. See http://drupal.org/node/82513 for a patch to the patch :-)
Comment #23
karens commentedI added 'edit $name content' permission to match permissions used in 5.0 core. I didn't address the view permissions, and all permissions are handled in core starting in 5.0, so I don't know if this patch still is needed. You can re-open if there is still interest in doing something with view permissions.
Comment #24
seanberto commentedI'm sorry to reopen this. But I'm a bit of a newbie. I know how to use patches and have muddled through all the comments on this and the views patch.
Where does all this stand? Sorry, but what's the best combination of patches to give "edit all" permissions for specific node types - while not breaking views. module?
Thanks for the help.
I still don't understand why a patch like this hasn't been committed to content.module as a permanent fix. I've read the arguments for using node access, but it just seems simpler to add the access privilege to content.module. Again, I'm a newbie - so there's probably sound logic for the decision that just goes over my head.
Cheers,
Sean
Comment #25
karens commentedIt has been committed, it's just called 'edit' instead of 'edit all' for compatibility with the ways things work now in 5.0. So you should have 'edit own' and 'edit' (which is the same as edit all).
Comment #26
(not verified) commented