Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taxonomy_term_edit_access() doesn't exist #1

Closed
herbdool opened this issue Feb 5, 2019 · 4 comments
Closed

taxonomy_term_edit_access() doesn't exist #1

herbdool opened this issue Feb 5, 2019 · 4 comments

Comments

@herbdool
Copy link
Contributor

herbdool commented Feb 5, 2019

Looks like taxonomy_term_edit_access() was removed after Drupal 7. In line

if (isset($entity) && $op == 'update' && !isset($account) && taxonomy_term_edit_access($entity)) {

Not clear why it was removed but perhaps can just add directly: user_access("edit terms in {$term->vid}")

@aaronbowwwls
Copy link

I think taxonomy_term_access() can be used in its place.

index 7826aa7..13792c3 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -799,7 +799,7 @@ function entity_plus_metadata_taxonomy_access($op, $entity = NULL, $account = NU
   if ($entity_plus_type == 'taxonomy_vocabulary') {
     return user_access('administer taxonomy', $account);
   }
-  if (isset($entity) && $op == 'update' && !isset($account) && taxonomy_term_edit_access($entity)) {
+  if (isset($entity) && $op == 'update' && !isset($account) && taxonomy_term_access($entity, $op)) {
     return TRUE;
   }
   if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') {```

@herbdool
Copy link
Contributor Author

@aaronlphillips the only problem is that for some reason taxonomy_term_access only checks $op for "edit" and "delete". Perhaps we need to just hardcode "edit" into it

@aaronbowwwls
Copy link

@herbdool good point. I also just noticed that I had my parameters flipped for taxonomy_term_access.
I found an issue for the taxonomy module to addresses your point about $op, but the fix hasn't made it into core yet.
backdrop/backdrop-issues#3011

Once these changes make it into core, then it might be safe to rely on the taxonomy module to determine access.

@aaronbowwwls
Copy link

I think this will work:

diff --git a/modules/callbacks.inc b/modules/callbacks.inc
index 7826aa7..f32ad23 100644
--- a/modules/callbacks.inc
+++ b/modules/callbacks.inc
@@ -799,7 +799,7 @@ function entity_plus_metadata_taxonomy_access($op, $entity = NULL, $account = NU
   if ($entity_plus_type == 'taxonomy_vocabulary') {
     return user_access('administer taxonomy', $account);
   }
-  if (isset($entity) && $op == 'update' && !isset($account) && taxonomy_term_edit_access($entity)) {
+  if (isset($entity) && $op == 'update' && !isset($account) && user_access("edit terms in {$entity->vocabulary}")) {
     return TRUE;
   }
   if (user_access('administer taxonomy', $account) || user_access('access content', $account) && $op == 'view') {```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants