Comments

I'd like to volunteer to do this with the previously mentioned adjustments/bug fixes as a new 7.x/2.x branch

Title:D7 portPort Taxonomy Term Permissions to Drupal 7
Category:feature» task
Issue tags:+d7 ports

subscribing

Subscribing.

Looking to migrate to Drupal 7 and I require this module

Thanks.

subscribing

Has anyone tried doing a rough upgrade via http://drupal.org/project/coder

Would be useful to get the ball rolling on this module in any case.

StatusFileSize
new5.17 KB

A start. Didn't test the user autocomplete yet as i only needed roles.
Only support for "taxonomy_term_reference" field type atm.

Any updates on the port? Module from Docc does not work with D7.8

StatusFileSize
new11.92 KB

updated port working on d7.10 using coder

It's great that both @Docc & @witchcraft have uploaded new modules as .zip files.

It's almost always easier to review changes if people use the latest version from the repository:
http://drupal.org/node/360339/git-instructions

and then build a patch based on that so it is easy to see what exactly has changed.

Terrific that it has been run through Coder!

StatusFileSize
new13.48 KB

i am a bit new to git , i have the generated patch by coder .
everyone wellcome to review changes

Great, I am really interested in get this into D7, I will look into the patch and see if everything works as it should.

StatusFileSize
new13.92 KB

Took a look on this, and now I almost have it working on D7 (applied the patch, but had some problems with choosing users on the permission page, fixed that).

Hopefully I will get some time later this week. Attached patch (this replaces patch in comment #10). Maybe we could collaborate on this witchcraft?

Status:Active» Needs review

Updated to need review (and version is for drupal 7.x - but that is not selectable due that the fact that the version does not exist yet :-)

I think that the only things that works now in the d7 patch is adding permissions on the term page

<?php
function term_permissions_autocomplete_multiple($string) {
 
// The user enters a comma-separated list of users.
  // We only autocomplete the last user.
 
$array = drupal_explode_tags($string);
 
// Fetch last user.
 
$last_string = trim(array_pop($array));
 
$matches = array();
 
$result = db_select('users')->fields('users', array('name'))->condition('name', db_like($last_string) . '%', 'LIKE')->range(0, 10)->execute();
 
$prefix = count($array) ? implode(', ', $array) . ', ' : '';
  foreach (
$result as $user) {
   
$matches[$prefix . $user->name] = check_plain($user->name);
  }
/* Why is this in module? Problem with devel in d6?
  if (module_exists('devel')) {
    $GLOBALS['devel_shutdown'] = FALSE;
  }
  */
 
exit(drupal_json_output($matches));
}
?>

StatusFileSize
new15.09 KB

A little update, but still a lot of work to do. Used some of Docc's code from comment #6 also.

StatusFileSize
new15.19 KB

Okay, could not let this go, so I did some more work on it, seems like it is almost fully functioning, it throws an error when you try to delete a term, maybe someone else could look on that?

i will be glad to help but i do not know any of code stuff :)
i barely know how to use coder module.
if you need some test to patch i can do so...

something else
i have also made a port with coder to this module Vocabulary Permissions Per Role there is a diffrence between the two,
but it will be the complete permissions to vocabulary and terms

good job b.t.w.

@MiSc I Have tested the patch in comment #16 ,
Clean drupal install ,User with role "editor" and permission to edit terms.
UID1 cannot delete term whan module enable .
i cannot see any error.
hope it was helpful .

Did some clean up and changed a word in the README because of different structure in d7. Still breaks when you try to delete a term. @witchcraft, thanks for testing it out.

Should be interesting to also get Vocabulary Permissions Per Role in d7, but first a fully functional Taxonomy Term Permissions :-).

StatusFileSize
new18.51 KB

And the patch...

can you guide me a bit ?
what is the git command for revert a patch .
i want to test the new patch and see the progress...
so how to unpatch the patch that i used in comment 16?

You could reverse a patch with git apply -R filename.patch or git reset --hard (if you have not committed your changes)

Thanks for git command that works like a charm .

i tested patch #20 .
here is the result
whan the "editor" user try to delete the term i got error from apache2 log and a white screen :

[error] [client 127.0.0.1] PHP Fatal error:  Cannot use object of type stdClass as array in /var/www/sandbox/sites/all/modules/term_permissions/term_permissions.module on line 74, referer: http://dev1.sandbox.loc/taxonomy/term/1/edit?render=overlay
[error] [client 127.0.0.1] PHP Fatal error:  Cannot use object of type stdClass as array in /var/www/sandbox/sites/all/modules/term_permissions/term_permissions.module on line 74, referer: http://dev1.sandbox.loc/taxonomy/term/1/edit

<?php
   
// Pull in any stored users in the database.
   
$allowed_users = array();
    if (!empty(
$form['tid']['#value'])) {
     
$result = db_select('term_permissions_user')
        ->
fields('term_permissions_user')
        ->
condition('tid', $form['#term']['tid'])
        ->
execute();
      foreach (
$result as $row) {
       
$u = user_load($row->uid);
       
$allowed_users[] = $u->name;
      }
    }
   
$allowed_users = drupal_implode_tags($allowed_users);
?>

line 74 is :

<?php
->condition('tid', $form['#term']['tid'])
?>

I'am trying my best to understand this but i canot figure that out .
its about the selection of permissions ?

Its an Honor to collaborate with you.
Thanks for you Patience with me, you very kind !

Status:Needs review» Needs work

I did a quick read through the patch in #20 and it looks pretty reasonable. Let's get this PHP error sorted out and we can commit this to a new branch and open up new issues for any specific bugs or changes.

Status:Needs work» Needs review
StatusFileSize
new28.78 KB

Here's a patch that fixes the error when deleting terms. I generated this with git format-patch, so if anyone wants to apply it use git am.

Some light testing and this looks OK. Two things I noticed:

  1. The permissions fieldset is above the term name. This might be a bug in the 6.x-1.x branch as well, but either way seems like it should have a higher weight.
  2. Deleting a term didn't delete the rows from the table storing role permissions.

These can probably be addressed in followup issues.

The commits are:

  • c33f619 Issue #908434 by witchcraft, MiSC: Port Term Permissions to Drupal 7.
  • 9ee033c Issue #908434: Remove old hook_install / hook_uninstall functions.
  • 1f301c0 Issue #908434: Implement coder style reviews.
  • 25281c7 Issue #908434: Always cast terms to an object.

StatusFileSize
new28.78 KB

Use this one instead, the one in #25 has a stray error_log() call in it.

StatusFileSize
new28.65 KB

Obviously must be Friday.

StatusFileSize
new18.82 KB

This is fun :-).
Removed weight, I could not decide where the permissions settings should be at all... What do you think?
Also fixed the deletion in the database.

Status:Needs review» Fixed

Isn't this fixed? I'll assume so since @MiSc is a maintainer and there's a D7 dev & beta release.

Status:Fixed» Closed (fixed)
Issue tags:-d7 ports

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