Moshe,

Not sure if this counts as a bug but it's certainly making my day less fun. Users are unable to edit terms on my intranet. I can see that this is because the list terms page is generated by taxonomy.module and this inserts edit links that og_vocab has no control over. These links require 'adminster taxonomy' to access and so no editing gets done.

Not sure how to work around this short of copying 'taxonomy_overview_terms' into og_vocab and making alterations.

Any suggestions?

Thanks
Adam

Comments

moshe weitzman’s picture

Title: Can't edit terms » Can't edit terms - taxonomy.module controls links

Ouch. I don't know how i missed that.

This is not going to be easy to solve. i suggest hacking your core Drupal. Sometimes, thats the best way.

Longer term, I'd like regular old read only tables to be rendered through drupal_render like nodes are. Then we would have a point for altering the array ... Another possible approach is to use hook_link_alter() in drupal5 but these links don't go through there, and i'm not sure they should.

I'd be happy to discuss approaches on this so we have a good solution for drupal6

cooperaj’s picture

StatusFileSize
new1.23 KB

The attached path will, with changes to taxonomy.module :-/, allow editing of group terms.

Like you said it is a nasty hack but I'm leaving my job on Friday so I'm not sweating it. :-)

cooperaj’s picture

StatusFileSize
new1.12 KB

This patch will change 4.7.3 taxonomy in the correct way. eww.

I agree that hook_link_alter is probably not the way to go though I'm a bit stumped as to what can be done. It'd be nice to alter the permissions system to do this. Make it more fine grained to allow a sort of node access table for other things. Menus and blocks spring to mind. I'd see it as a sort of authmap for module permissions

How about a hook_permission_veto($permission="administer taxonomy", $module_checking_permission="taxonomy", $context=array("task"=>"edit", "type"=>"vid", "subject"=>"12"))

It's one of the weaknesses I see in the drupal permissions system. It's very difficult to get fine grained enough. For instance, to allow a group member the ability to post stories in one group also allows them to post in any that they are a member of. Even if the intention of that membership is just to view private posts.

I've altered content_moderator to work with groups. It has the exact same problem. A person with the permission 'moderate content' can moderate in all groups of which they are a member. To fix it other wise would require building the functionality right into og.

I've had to put a disclaimer on the group member page that says 'be sure to find out what a users permissions in other groups are before adding them to your group'.

But I digress. Sorry. ;-)

moshe weitzman’s picture

occurs to me know that this might be solvable by defining a custom_url_rewrite() function to rewrite outbound links, specifically these taxo links when they appear on an og page.

custom_url_rewrite() is very powerful function - grep for it in path.inc. ... i can't explore this right now.

Luca Lenardi’s picture

Ok. This hack works on Drupal 5.

Add a menu item on og_vocab.module to skip permissions:

<?php
$items[] = array('path' => "node/$gid/og/vocab/edit/term",
'title' => t('Edit term'),
'callback' => 'taxonomy_admin_term_edit',
'type' => MENU_CALLBACK);
?>

Add the custom_url_rewirte() function on setting.php:

<?php
function custom_url_rewrite($type, $path, $original) {
  // This path was already aliased, skip rewriting it
  if ($path != $original) {
    return $path;
  }
  if (arg(0) =="node" && arg(2) == "og" && arg(4) == "terms") {
    // the system path to change or cloak
    $patterns[0] = '!^admin/content/taxonomy/edit/term/(\d+)$!';
    // the new cloaked name
    $replacements[0] = 'node/'. arg(1) .'/og/vocab/edit/term/\1';
    return preg_replace($patterns, $replacements, $path);
  }
  if ($type == 'source') { // URL coming from a client
    $result = $path;
    return $result;
  }
  elseif ($type == 'alias') { // URL going out to a client
    $result = $path;
    return $result;
  }
}
?>
Luca Lenardi’s picture

The same technique used to list vocabulary on a per-group logic must be used for terms.
To let users edit only terms for og vocabulary, change:

<?php
$items[] = array('path' => "node/$gid/og/vocab/edit/term",
'title' => t('Edit term'),
'callback' => 'taxonomy_admin_term_edit',
'type' => MENU_CALLBACK);
?>

to:

<?php
$terms = taxonomy_get_tree($vid);
$items[] = array('path' => "node/$gid/og/vocab/edit/term/".$terms[0]->tid,
'title' => t('Edit term'),
'callback' => 'taxonomy_admin_term_edit',
'callback arguments' => $terms[0]->tid,
'type' => MENU_CALLBACK);
?>
Luca Lenardi’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new991 bytes

This small patch to allow users to edit terms, skipping taxonomy access control.
This patch needs also the function custom_url_rewrite() as showed in #5.

moshe weitzman’s picture

@Luca - great work in this issue. Thanks for your patches. Are you interested in co-maintaining this module? I will grant you CVS access and you can make the needed changes. I'm a bit unavailable these days.

Christefano-oldaccount’s picture

Thanks, folks. Subscribing.

moshe weitzman’s picture

Version: 4.7.x-1.x-dev » master
Status: Reviewed & tested by the community » Fixed

very nice patch. i committed this and the custom_url_rewrite() function to this module since few sites use a rewrite function. those that do will need to copy the code in this module and then comment out our comment_url_rewrite().

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

jackbravo’s picture

Version: master » 5.x-1.0
Status: Closed (fixed) » Needs review
StatusFileSize
new1.78 KB

I have some sites that use custom_url_rewrite and some that don't (most don't). So if I delete the function on the module I have to write it on every settings.php I have.

I made a change where the function is defined only if its not already defined using:

if (!function_exists('custom_url_rewrite'))

This allows users to extend this function only when necessary without deleting the function from the module.

moshe weitzman’s picture

Thats an iffy solution - Site owners will just install this module and if they have a custom_url_rewrite then this module will simply not work. I almost rather throw a duplicate function error like today.

jackbravo’s picture

what about providing an error or a notice on the else clause. To inform site owners about the change they must make?

moshe weitzman’s picture

And how can they get rid of the error/notice? we have to build a checkbox or something. thats boring code.

moshe weitzman’s picture

Status: Needs review » Needs work
Leeteq’s picture

subscribing

sethcohn’s picture

Currently looking at a good/better answer for having og_vocab and context_prefix running at the same time. (context_prefix is weighted at -20, and despite a check for the pre-existence of custom_url_rewrite similar to #12's attempt, it fails to work and errors once og_vocab attempts to "redefine", because og_vocab's definition hasn't yet occurred at the time of the check (later weighting than the check itself))
[note - "better" than editing both modules manually (making upgrades a pain), or losing functionality of either.]

jleonard’s picture

This problem appears to persist in 6.x -- correct? Workarounds similar to those mentioned above?

Cheers!

amitaibu’s picture

Version: 5.x-1.0 » 6.x-1.x-dev
Status: Needs work » Fixed

This should be fixed in commit http://drupal.org/cvs?commit=160722 for the D6 version.

likewhoa’s picture

Status: Fixed » Needs work

I'm still getting the wrong linkage with latest -dev version. links for editing terms turn out like this.

http://localhost/node/%252Fog/vocab/terms/edit/705

Using drupal 6.8
Organic groups 6.x-1.0 & OG Vocabulary 6.x-1.x-dev (2008-Dec-30)

reopening bug since this is still an issue it seems.

amitaibu’s picture

Status: Needs work » Postponed (maintainer needs more info)

@likewhoa,
Did you run update.php? or try to menu_rebuild().

likewhoa’s picture

yes I tried both as I normally do and running hook_uninstall() and hook_install() didn't help it, links are still broken.

likewhoa’s picture

Priority: Normal » Critical

ok I see where the bug is triggered, the thing is that vocabulary term editing works only when a vocabulary is associated with a group and term editing only works the group's node/%/og/vocab link, but then all term edit links in admin/content/taxonomy break. so this is a conflict with og_vocabulary & terms in admin/content/taxonomy that are not assigned to a group.

amitaibu’s picture

Status: Postponed (maintainer needs more info) » Fixed

Fixed, thanks likewhoa!

Status: Fixed » Closed (fixed)

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