Our newly installed Taxonomy Term Permissions module does not seem to have any effect. I set all terms in a vocabulary to be accessible to only the administrator role. However a test user assigned only to a different test role can see and set any of the terms in that vocabulary when creating content for a content type that has that vocabulary assigned to it. I confirmed that the other role is not selected for any of the taxonomy terms; and I confirmed the test user is only in one test role (in addition to the default "authenticated" role).

The only other non-core taxonomy related module installed on our Drupal is Taxonomy Super Select 6.x-1.0. Could there be a conflict?

I must be missing something -- any ideas?

Our Drupal is 6.15

Thanks!

Jerry

Comments

jkdrupal’s picture

It occurred to me to disable Taxonomy Super Select and try again. After disabling TSS, the Taxonomy Term Permissions module worked as expected. So, this raises the question: can Taxonomy Term Permissions and Taxonomy Super Select work together?

Thanks!

Jerry

jkdrupal’s picture

Category: support » bug

To elaborate my previous comment: If only Taxonomy Permissions is enabled, it works correctly; if only Taxonomy Super Select is enabled, it works correctly; if both are enabled, then that is when there are problems.

I was hoping it would work to have Taxonomy Permissions function first, then have Taxonomy Super Select do its nice organization of the taxonomy terms that the user's role is permitted to access (from Taxonomy Permissions). But it does not work this way. I do not know if this is a bug with Taxonomy Permissions or Taxonomy Super Select.

It is also possible that those two modules will not work together in the way I thought they would -- but if this is the case, I am hoping that someone supporting either of those two modules could clarify this for me. Thanks!

sohail_arif’s picture

Permssions setting have no effect. The user names which have not given any permission for viewing forum, they can view,add,edit and delete forum.

davide1982’s picture

guys, I have the same issue with me but I don't have that Taxonomy Super Select module at all. But there is no effect again ((

smscotten’s picture

It looks as though the admin user sees everything no matter what. Logged in as a regular user, the permissions correctly restrict access to the terms. When I first tried it out I was logged in as admin and I couldn't make the terms disappear.

Hope that helps.

jkdrupal’s picture

Splicer: for the testing I have done, I test with both a user in the administrator role, and for a user not in the administrator role. In every case that I have tested so far, a non-administrator role user will see all taxonomy terms if that vocabulary is set to be displayed via Taxonomy Super Select. I have tried different adjustments of the weights of Taxonomy Term Permissions (TTP) and Taxonomy Super Select (TSS) . Nothing I have tried achieves the desired behavior in which TSS will display only those terms allowed by the permission settings in TTP.

-Mania-’s picture

The permissions do not work for me at all and I don't have Taxonomy Super Select. I'm trying to restrict Anonymous users from accessing a particular taxonomy term but the settings do not apply. I've tried all the other taxonomy permission modules as well but there seems to be no working solution at the moment. :(

JoelKleier’s picture

Just a note: I thought I had an issue where my terms were not reading permissions I had set correctly -- I had set permissions for specific terms within a vocabulary to only be visible to a certain group, but that group was still able to see all the other terms.

It appears to be because, by default, all terms are visible to all roles, unless they have permissions explicitly defined.

It was probably in the documentation, and I probably just over looked it. I thought I'd mention it here, though, just in case anyone has a similar "problem", and it is not caused by an actual bug that this issue is tracking.

jhuon’s picture

Same issue here. All my terms are assigned to a specific role, but restrictions have no effects. Any role has access to any term. And I don't have Taxonomy Super Select module.

thaddeusmt’s picture

The module was also apparently not working for me. I traced it to the fact that I am running this on an old PHP4 server. The unset() isn't working properly with the pass-by-reference variables in term_permissions_form_alter().

I fixed it by replacing:

unset($terms->option[$tid]); ( line 129 )

with:

unset($form['taxonomy'][$vid]['#options'][$termCount]->option[$tid]);
(and adding a $termCount counter to foreach($vocabulary['#options'] as $terms) loop)

Sort of crummy, wish they would upgrade this server to PHP5!

deviantintegral’s picture

O really...

If others can confirm that the fix in #10 fixes the issue, I'll roll a patch, unless there is consensus to make PHP 5.2 required for the module.

jkdrupal’s picture

I am almost 100% certain the server I am using is php 5.x -- so the problem I described at the beginning is not limited to php 4 implementations. I will check to confirm which version of php is on the server and post that here.

Jerry

jday’s picture

using php 5.2 and taxonomy super select, the permission settings are having no effect, excluded roles can still select forbidden terms.

t.feltl’s picture

In my case helped to increase the "weight" of the module. I set module weight to 10 and everything works as it should :-)

deviantintegral’s picture

Thanks for the info about weight. If someone else can confirm that weight makes it work, I can make an update to change it.

http://drupal.org/project/util can be used to change module weights for those who aren't comfortable doing it in the database directly.

davidbessler’s picture

I am using php 5.26

I do not have Taxonomy Super Select installed.

I have tried module weight 10, 1000 and -1000

I have rebuilt permissions after each change.

Still, my average users can see and select the taxonomy terms for which I have set permissions to only allow admins to select.

To be clear, I am using the taxonomy list as an exposed search term within a view. I am assuming that is supported.

louis_gaff’s picture

Same here. Taxonomy Permissions have no effect.

What I'd like to do is just make sure a specific taxonomy term can be seen only by two people: The person who the taxonomy is named after, and the admin. Taxonomy Permissions is totally not working... :(

marcinp’s picture

Just wanted to confirm that on my drupal installation weight had to be changed to make it work. With default settings $form['taxonomy'] is not set, setting weight to 10 didn't help either, changed it to 30 and taxonomy key was present. Could have something to do with installation of Hierarchical Select which has weight of 16, also removed (!variable_get('taxonomy_override_selector', FALSE)), probably also related to HS module. I'm using HS on different Vocabulary than Term Permissions and didn't notice any problems so far. Hope this helps someone.

groovedork’s picture

Same problem here.

WAMP PHP 5.2.11
Drupal 6.17

Content Taxonomy 6.x-1.0-rc2 (including Content Taxonomy Options)
Taxonomy Super Select 6.x-1.0
Taxonomy term Permissions 6.x-1.0
Taxonomy Image 6.x-1.6 (with every sub-module enabled except Image Attach)

Unfortunately using Util doesn't change anything. Tried at at -1,0,1,6, 10, 30...

tsmorty’s picture

Priority: Minor » Major

Wanted to use this module but after installing it and setting up permissions no go. I even used util to increase it's weight to 30. Still no fix, so I dropped it back down to 0.

I then headed marcinp comment. By using Notepad++ I opened the term_permissions.module file and on line 111 removed " && (!variable_get('taxonomy_override_selector', FALSE)) " after saving this and chucking it up to the server the problem was resolved.

This seems to be due to hierarchical select being installed on my installation setting that to TRUE even though I am telling that term not to use it. None the less it doesn't seem to have affected HS. Not sure by whom this should be fixed than.

You can see another issue that explains HS causing problems with another module. https://drupal.org/node/619726

sidharth_k’s picture

I can confirm that Hierarchical Select also interferes with term_permissions. Once I disable Hierarchical Select, Term Permissions work properly.

kapep’s picture

See #895542: Conflicts with i18ntaxonomy hook_form_alter(), it's also a module weight problem.

bramley’s picture

This would be really useful for me too. I'm using Content Taxonomy, so it would need to work with this too.

stewest’s picture

I'm also struggling (rather suddenly_ with Taxonomy Term Permissions it seems.)

I'm using: Drupal 6.19

Taxonomy Defaults 6.x-1.0 weight -1
Taxonomy hide 6.x-1.02 1 weight 0
Taxonomy Manager 6.x-2.2 weight 0
Taxonomy Role 6.x-1.0-beta1 weight 99
Taxonomy Term Permissions 6.x-1.0 weight 50 (also tried -10 and 110)

Via Term page Permissions:
When a user is given permission to a term, they still don't see Edit tab on node page.
When a role is given permissions on a term, they also don't see edit tab.

Via User Permissions:
Only if role is given permission to edit any of that node's content type, can they see the edit tab. But then all users of that role can edit nodes of that term.

I rebuilt permissions, cleared cache all and have run an update. Still isn't working.

This started happening (well, was first noticed) this week for first time when we created a new user and treid to give them access to edit the node / linked to that term?

Looking in the DB at term_permissions)user table, the UID is assigned to the tid. So it is writing to the db.

There must be something else happening or overriding this?

A side note, not sure if this would mess things up?
Menu Per Role (still 6.x-1.3) module may be acting up?
(As latest 6.x.1-8 broke my site - there is a bug in 1.8. Apparently 1.7 is better. I just stayed on 1.3 for now rather) Perhaps this is conflicting?

I wonder if I should change the weight so the module runs before after one of the others. Any thoughts?

tchurch’s picture

+1

Gordon_Holtslander’s picture

I am using term_permissions, with Taxonomy Menu, Taxonomy Menu Custom Path, Taxonomy Menu Hierarchy, Taxonomy Menu Vocabulary Path.

Taxonomy Term Positions, has no effect. An anonymous user can search for find and access content that should be restricted.

I have changed the weight of the module with no effect.

I have removed " (!variable_get('taxonomy_override_selector', FALSE)) " with no effect

jmrivero’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Found the problem, this patch should fix it.
Thing is that for the roles validation it was looking into $user->roles array keys insted of the array values.

Leiph’s picture

Patch doesn't work for me, I get this warning message:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user)' at line 1 query: SELECT rid FROM term_permissions_role WHERE tid = 343 AND rid IN (authenticated user) in /home/mydir/modules/term_permissions/term_permissions.module on line 215.

tid=343 is the taxonomy I try to block
valid for bot dev and official
MySQL 5.0.92
PHP 5.2.13
Drupal 6.20
Running TSS as well

jmrivero’s picture

Ok, this is weird.
I just checked the $user->roles array and in some contexts, like when creating a new php page and printing the content of the array, it shows the literal name of the roles and their rid as the array key, but in the support tickets submit page where im using it, the values in the roles array are the rids, not their name.

So, in a php content page preview, the print_r of the $user->roles array shows this:

Array ( [2] => authenticated user [3] => administrators ) 

But in the support tickets creation page where i display the taxonomy terms it looks like this:

Array ( [0] => 2 [1] => 6 ) 

Those values are the actual role IDs.

Camario39’s picture

This thing was driving me nuts.

The function comments state:
* Given a term ID, determine if a user has access to that term. UID 1 is
* always allowed access. If no permissions are set on the term, allow
* access by default.

Therefore, my user is able to see all terms that are yet to be assigned an owner/user. Once I created other users and gave them term permission. They disappeared from the first user.

Hope this helps somebody.

fricupy’s picture

I changed the function term_permissions_allowed (line 212) this way

function term_permissions_allowed($tid, $user) {
  if (($user->uid == 1) {
    return TRUE;
  }
  // Are permissions enabled on this term?
  if (!(db_result(db_query("SELECT COUNT(1) FROM {term_permissions_user} WHERE tid = %d", $tid)) || db_result(db_query("SELECT COUNT(1) FROM {term_permissions_role} WHERE tid = %d", $tid)))) {
    //No more 'return TRUE;' but
    return FALSE;
  }
  // Permissions are enabled, check to see if this user or one of their roles
  // is allowed.
  if (db_result(db_query("SELECT uid FROM {term_permissions_user} WHERE tid = %d AND uid = %d", $tid, $user->uid)) || db_result(db_query("SELECT rid FROM {term_permissions_role} WHERE tid = %d AND rid IN (" . implode(', ', array_keys($user->roles)) . ")", $tid))) {
    return TRUE;
  }
  return FALSE;
}

This did the trick for me :)

francescogiannico’s picture

Hi , Sorry but I don't know how to apply the patch... :(

francescogiannico’s picture

I'm not able to apply this patch... can you help me please?
francesco

jmrivero’s picture

francesco, just find the function inside the module, copy this code and replace the one in the module with this, this is not a patch, you have to do it by hand.

druvision’s picture

Version: 6.x-1.0 » 7.x-1.x-dev

The issue still exists in 7.x - disabling the hierarchical select module made it work again

Orangefox Web Developers’s picture

Wasnt working for me in drupal 7, changed the function 'term_permissions_allowed' to below and it works now, hope this helps someone.


function term_permissions_allowed($tid, $user) {
  if ($user->uid == 1) {
    return TRUE;
  }

  // Are permissions enabled on this term?
  if (!(db_query("SELECT COUNT(1) FROM {term_permissions_user} WHERE tid = :tid",
          array(':tid' => $tid))->fetchField() ||
        db_query("SELECT COUNT(1) FROM {term_permissions_role} WHERE tid = :tid",
          array(':tid' => $tid))->fetchField())) {
          return TRUE;
  }
  // We need to convert user->roles to be useful for us.
  $users_uid = implode(', ', array_keys($user->roles));
  // Permissions are enabled, check to see if this user or one of their roles
  // is allowed.(" . implode(', ', array_keys($user->roles)) . ")

  $user_roles = array_keys($user->roles);

  $i = 0;

  while (isset($user_roles[$i])) {

	  if (db_query("SELECT uid FROM {term_permissions_user} WHERE tid = :tid AND uid = :uid",
		  array(':tid' => $tid, ':uid' => $user->uid))->fetchField() ||
	      db_query("SELECT rid FROM {term_permissions_role} WHERE tid = :tid AND rid IN (:user_roles)",
		  array(':tid' => $tid, ':user_roles' => $user_roles[$i]))->fetchField()) {
	    return TRUE;
	  }

  $i++;

  }

  return FALSE;
}

ehanuise’s picture

Same pronblem here, no effet seen after install/config of taxonomy permissions.
Increasing the module weight in the 'system' table of the DB (from à to 10) solved the problem.

IWasBornToWin’s picture

I also had to change weight to 10 is system table, and then it worked.

Garvil’s picture

Where can i change the weight ? In the system table i can't find where to change the weight ...

IWasBornToWin’s picture

Yes, in system table, scroll to the right in the table...it's over there.

mgifford’s picture

Would be good to get a resolution to this set in code and into a stable release.

misc’s picture

Plaese make a patch and we get it into the module asap.

dshields’s picture

StatusFileSize
new1.22 KB

Here is a patch for what I found to be useful in #36

misc’s picture

StatusFileSize
new1.08 KB

Rewrote the patch so it could be applied in the module directory, also removed some out commented stuff.

misc’s picture

Priority: Major » Normal
Status: Needs review » Fixed

Added to latest dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

aniebel’s picture

Status: Closed (fixed) » Active

Reopening because I have installed the DEV version and disabled the Hierarchial Select module, cleared cache, etc. and still have the same problem. To be clear, I have a vocabulary with about 50-60 terms. I changed the permissions on only 5 of those terms to allow Admin and one other role access. As anonymouse user, I can still navigate to the term path and view all items using that term.

roborn’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

Not a bug.
Taxonomy Term Permissions only works on Create/Update/Delete operations by design.