User Rights for tagnodes
andre_ - February 26, 2006 - 09:21
| Project: | Tagnode |
| Version: | 4.6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | andre_ |
| Status: | closed |
Jump to:
Description
Hello!
I don't know whether this is a support request or a new feature request, so I put it for the moment in the support request.
On my site I use tagnode to link the node "courses" with the node "schools". Schools can offer courses. A user can create schools and courses.
The problem: When the user creates a course he can choose from the list of schools all schools. But I want that he can choose only his school(s), since he can edit only his schools/courses, this would make sense.
Question: Is it possible that the list of schools (tagnode) holds only items, where the current user is owner of?
Is this change maybe possible with a small change in the code?
Thanks,
Andre

#1
Andre,
Thanks for the suggestion. The selector to link nodes to tagnodes is just a taxonomy selector. So I wonder if you could find a suitable module, which allows you assign permissions to taxonomy terms.
To test modules, you could create a test vocabulary, and put a few terms in it. Now try using a taxonomy permissions module to restrict a user from selecting some terms (if any exists; i think they do). If you can identify a version 4.7 module which suits your functional needs, then we could procede with either
(a) You handle assigning ownership to tagnodes through that module's interface (in which case no change needed to tagnode module), or
(b) You identify the access rules you would like tagnode to apply to tagnodes, and I can look into adding calls into that module at the apporpriate places. Hopefully the module you identify would have appropriate API-like hooks.
Am I off base? Do you recommend an alternate approach?
dado
#2
Hi Dado
Thanks for your information and suggestions. Yes, I searched for modules to manage permissions to taxonomy terms and I found "taxonomy access" which seems maybe to fulfill what I am looking for. I will install and test it this week and write about the results.
Andre
#3
I don't think taxonomy access will do the trick, because everytime a new term is created, admin needs to set permissions. I have a different ideas for doing this.
Idea #1: If a user who created a tagnode is viewing their node, they would see a menu, in this case, "add courses to ", when the user clicks the link their node/add form would display only a term with the name matching the name of the tagnode. I guess ideally the user wouldn't even see the taxonomy selector and it would be a hidden field. I think a call could be made to the db looking for a taxonomy term that has the same name as the tagnode. Creating the form could be tougher.
Idea #2: This might be simpler. When a tagnode displays it's tagged nodes, only display the nodes in the proper category (as is done now) and filter by user id to only display those from the owner of the tagnode. A little more complex would be, when a user first creates a new tagnode they have a choise of "open" or "closed." If they choose open, then anybody's related nodes are displayed on view of their tagnode. If they choose closed, only their related nodes are displayed.
Others could still add to the category, but they wouldn't display on the tagnode at least. It would be nice if tagnode could use the same feature as forum and project module that allows for direct links to post into a forum with the forum preselected in the taxonomy selector when someone chooses "post to this forum," etc.
That gives me another idea? Doesn't the project module use some functions to restrict which terms can be posted into for each project? There might be some logic and code in that module that could help.
#4
Jason & Andre,
Good ideas, thanks. Most doable. I probably would have done some similar things if I had not run into this issue: since "tagnode" comes alphabetically before "taxonomy", then tagnode.module functions are executed before taxonomy.module functions. So unless/until i rename tagnode to something that comes after "taxonomy", I cannot alter taxonomy output.
I had contemplated rechristening tagnode as "taxonomy_tagnode" or something, w/ some new features like this, but I keep thinking a node relationships API & module are coming. Not much activity in this area recently that I've seen however.
Any impressions as to when a full fledged relations API is coming? If nothing soon I might well go ahead and do some of this stuff. Any desire to help? Definitely would like to have link to
"Add new [taggee] for [tagnode]", with tagnode's term either preselected in the form or as a fixed, hidden form parameter. I suppose I could add permissions to "tag with own tagnodes" and/or "tag with any tagnodes", which would restrict what subset of taxonomy terms appear in the select box. Any such enhancements require new module name? Perhaps should add views module support & enable more robust listing of tagnodes & taggees.
David
#5
Jason & David
I like idea #2 of Jason, I was thinking initally about this but thought after the answer from David that it is not possible this way and we need an API of another module. I have to say I am not a coder, it is 15 years ago I was writing my last line of code :-). I guess it depends whether you can easily access user information in the page where the list with tagnodes is displayed in order to filter by user-id or not.
It would be very good to control this with an option like "tag with own tagnodes" and/or "tag with any tagnodes" as you both propose.
I was searching quite a lot about relations ca. 3 weeks ago and there is/was a lot of discussion, but I have no idea if such a full relations API is coming soon, I did not find any announcement.
Do you think such a filtering by user-id could be easily done?
André
#6
not super easy but doable. i have been thinking perhaps there is a more generic module we could make. Basically this module would permit other modules to override default form generation of taxonomy elements to:
(a) preselect 1 or more taxonomy terms from 1 or more vocabs
(b) make hidden selection of 1 or more taxonomy terms from 1 or more vocabs (not rendering a selector for the vocabs in question)
tagnode & other modules could use this to alter the taxonomy form selector elements as desired
#7
I understand a), but not b), could you say it in other words? Thanks.
and: Would we here not have again the problem, that the selection is not done automatically on the user_id?
In other words we want these options:
a) Show from a defined node type *all* content
b) Show from a defined node type *only the own* content.
This is analogue to the permissions of the page/story/flexinode module, where the admin can define whether users can edit their own content or not.
#8
andre,
agreed. once my proposed taxonomy alteration module were in place, other modules (like tagnode) could use it to construct forms with modified taxonomy form elements.
tagnode could use the module to render a form with a taxonomy select box with only the current user's tagnodes as options.
the other thing you could achieve is that tagnode or other modules could create a link like "create a new CD of type JAZZ" where CD is the node type and JAZZ is the category. When the form is rendered, the "music type" taxonomy selector is not shown, but instead a hidden form field is present, with "JAZZ" the selected in that hidden form field. This is what I meant under my "(b)". This is not your requirement but it seems useful to me and I am unaware of another way to do it.
#9
indeed, this (b) would be a nice feature as well.
So, since I am not a programmer I can only offer you that I would test such a module and write a user documentation. I can test it in at least 2 sites I am building with drupal 4.7 and I am pretty sure that a friend of mine would test it too, because he has the same problem.
#10