Closed (fixed)
Project:
Node Template
Version:
5.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
17 Aug 2007 at 13:28 UTC
Updated:
29 Nov 2012 at 09:43 UTC
Jump to comment: Most recent file
Comments
Comment #1
motou commentedHi WorldFallz,
are you using this module as an admin or a normal user? That's a question. =)
If you are an admin of the Drupal, you can clone a node template by clicking "duplicate" under "operations" in "my node templates". If you are a normal usre of the Drupal, please be sure that some options in the section "access control" such as "access node template", "delete node template of others", "share node template" are correctly checked.
Comment #2
WorldFallz commentedI tried it from superuser as well as other user roles with the node_templates permissions. No matter who creates the templates or who trys to list them, there are never any options under operations except for delete / share.
Comment #3
motou commentedHi WorldFallz,
I've reviewed the code recently. I guess you maybe marked a special type of node as a template? Because if the user has no right to create the special type of node, he cannot duplicate that node neither. Please confirm that what happens when you try to set a template with a normal node type such as "page" and what kind of node type you marked as a template.
Thanks!
Comment #4
WorldFallz commentedNo, it wasn't a special node type. Just a regular "Page" content type. I can't figure out what I'm doing wrong. I even installed it on a new installation of drupal, and I still don't get any options under "operations" except for delete and share. Its very weird, I feel like it must be a user error somewhere (that I'm not using the module properly) but I can't find anything else to test. I use a standard "page" will the same Input Format. The admin account has access to everything, and yet I still don't have any way of using the template that appears in the /nodetemplates list. I've attached a screenshot so you can see if it looks right. I really would love to get this working as I have a very strong need for it but I'm not sure where else to look.
Comment #5
WorldFallz commentedI've read through the code line by line, and I find where you set $can_duplicate but I can't see what the problem is. If i use user1, create a plain old page, set template, then goto "my node templates" duplicate does not appear (both with and without share enabled). The only way I can get "duplicate" to appear is to set $can_duplicate to "true" manually. I still don't know enough about drupal development to understand how you are setting $can_duplicate to spot the problem.
I can tell you that $function is being set to "page_access" on line 457 and that
does not get executed so the "function_exists('page_access')" is not true. I'm thinking it must be a permission check of some kind based on the content type, but I have no clue how to fix it. And I can't figure out why I'm having a problem that no one else is.
Any insights?
Comment #6
WorldFallz commentedI think there's more going on here with permissions. From issue http://drupal.org/node/154430 it seems like people should only be seeing templates they create or those marked shared. I set up a few test users, and they see all templates, whether or not they are shared. But i just installed this module into a fresh install, so I'm not sure what I could be doing that no one else is.
Comment #7
WorldFallz commentedthey are also seeing templates listed they don't have access to (that is, they get "access denied' when they click on the title to view the node set as a template). Anyway, i'm completely lost here as to 1) how this is supposed to work and 2) why it's not working that way.
Comment #8
motou commentedIt's really weird. I've looked after the function in php.net and got
So we can make sure that is not the problem with the php version.
Endly I find where the problem is: With the latest version of Drupal 5, the function "page_access" is disappeared and now I have to change the code to make it check "node_access".
It's really strange because every content type should have "hook_access" such as "book_access".
So I've update the dev version and please check it to see if it works.
Thanks for your patience to check the module line by line ;-)
Comment #9
motou commentedHi WorldFallz,
I intended to define the template showing rules as following:
1. Admin can see all the node templates.
2. Users can see all defined node templates in the drupal and shared templates.
3. Users can share their node templated if they are granted to the access rule "share node template".
4. Users can delete some templates if they are granted to the access rule "delete node template of others".
If you want the rule 2 to be changed to:
2. Users can only see all their own templates and shared templates.
the rule 4 should be eliminated then.
What is your opinion?
----
Joe's blog
Comment #10
motou commentedI made some modifications to the dev version of the module. If you want the users only see what they defined and shared node templates, just uncomment the line 477 in the nodetemplate.module.
Namely,
//if (($user->uid == $row->uid) || ($shared == 1) || ($user->uid == 0))
It should fit your requirement.
Comment #11
WorldFallz commentedHi motou---
thanks for taking a look and posting back. I've actually been working on this since posting last night, and I've got it working for my needs. I couldn't figure out how the existing nodetemplate_list was working, so I ended up doing some research and rewriting the WHILE loop that lists the nodes.
I'm pretty new to drupal and I have no experience with any version other than 5, so I don't know if my code will work for 4.x versions, but here's what I came up with:
To sum up the access rules:
1. if the user is the owner of the node or admin (uid = 1), access is granted
2. if the user is not the owner or admin, then it checks input format access, content type creation access, node view access, and if the template is shared. If any of those are false, then access is false and the node is not included in the list. This prevents users from receiving "access denied" messages when attempting to use a node template for a node they have no access to.
BTW node_access works with all content types in drupal 5 btw-- book, forum, custom types, etc. very nice. I just have to check it against my production site, which is using og and og_user_roles, to see if it will behave as expected there of if I have to do some additional access checks to pickup that access control as well. Hopefully it will.
The other changes I made were:
1. users can only share/unshare their own templates (except for user 1 which can share/unshare all templates). This prevents other users from unsharing a node shared by someone else.
2. don't need to check for $can_duplicate, if the node is listed, the duplicate operation is always there (since access permissions are checked before listing a node).
I've attached a patch to the 1.9 version but I'm developing on windows so I'm not sure I've figured out how to properly roll a patch yet-- let me know if it works. It would be great if you included the changes above into the module so I don't have to maintain it separately, but it's up to you of course.
I do have one remaining question-- do any of the access control checks I do in the WHILE loop need to be added to nodetemplate_menu somehow? In other words, can users still do unpermitted operations (especially sharing/unsharing someone else's template) by typing the URL directly into the browser? let me know...
thanks again for responding. and if there's anything else I can do to help, let me know.
Comment #12
WorldFallz commentedforgot... I left your rule #4 above in because I could imagine a scenario where perhaps everyone is permitted to share templates but maybe a certain group of "editors" or something have control on templates and need to be able to delete templates that are owned by others. That's probably how it will work in my application. Group owners will get the "delete templates of others" permission.
Comment #13
WorldFallz commentedactually, the more I think about this... I'm wondering if the permissions should be:
access node templates: list/duplicate "shared" templates and create/share/delete/duplicate your own node templates
and
administer node templates: create/share/delete/duplicate templates of your own AND others (all templates)
In both cases, abilities would always be subject to node_access permissions first and admin would always be able to do all.
what do you think?
Comment #14
(not verified) commentedComment #15
motou commentedI've reviewed your code. It's great. I will adapter it to the dev version.
Talking about the access rules:
Here the permission "administer node templates" might be: "share/delete templates of others", because the right to do with your own node templates are already enabled by the permission "access node templates".
In the module, there are now three permissions:
So we can see they are almost the same with your thought! :)
The problem is: should we divide the rights more fine or combine them in one "administer node templates"?
Comment #16
motou commentedA note to the patch:
with the code
$can_share = user_access('share node template') && ($row->uid == $user->uid);One cannot share a node template of others?
Comment #17
WorldFallz commentedone cannot share the template of others. The problem I ran into with my users was that they thought they should be the ones that control the sharing / unsharing of their templates. They didn't want someone else to be able to decide to share a node of theirs-- they wanted to be the one to decide if their node should be a shared template. They didn't like the idea of someone else sharing their template-- because they consider themselves the owner of their nodes.
Most of my site is organized based on "contributors" who can only create and edit their own content and "editors" who can create and edit anyone's content, so that's probably why I ran into this issue.
Is that something you don't think is a generally applicable perception?
Also, regarding the permissions-- mostly I was trying to figure a more intuitive way of separating them. But there again, I'm approaching it from my use case with contributors and editors, it may not be universally applicable.
Comment #18
motou commentedI think you are right. You code is already adapted in the latest dev version. Now one cannot share the node template from others. :)
So if one can only share his/her templates, your suggestion for permission are very reasonable and understandable. I will make the changes in the next release.
Comment #19
(not verified) commentedComment #20
kenorb commented