RE: http://drupal.org/node/99927 and the patch submitted by Luca Lenardi

Based on this work, I have cobbled together a similar fix for v6.x:

In og_vocab.module, I added this menu item:

  $items['node/%node/og/vocab/edit/term/%'] = array(
    'title' => t('Edit term'),
    'page callback' => 'taxonomy_admin_term_edit',
    'page arguments' => array(6),
    'access callback' => '_og_term_determine_access',
    'access arguments' => array ('update', 1),
    'type' => MENU_CALLBACK,
    'file' => 'taxonomy.admin.inc',
    'file path' => drupal_get_path('module', 'taxonomy'),
  );

and the following code to determine access:

function _og_term_determine_access ( $action, $node ) {
  // if the user has access to the group node as above...
  if ( og_vocab_determine_access ( $action, $node ) ) {
    // then if the term belongs to the vocabulary...
    if ( _og_term_in_vocab ( arg(6) ) ) {
      return TRUE;
    }
  }
  return FALSE;
}

function _og_term_in_vocab ( $tid ) {
  $group_node = og_get_group_context();
  $gcid = $group_node->nid;
  $gnid = _og_get_gnode_id ( $tid );
  return ( $gcid && $gnid && ($gcid == $gnid) );
}

/**
 * -- retrieve the group node id for a term controlled by og_vocab
 */
function _og_get_gnode_id ( $tid ) {
  $sql = "SELECT nid from {og_vocab} ogv, {term_data} td "
       . "WHERE ogv.vid = td.vid "
       . "AND td.tid = %d";
  $nid = db_result ( db_query ( $sql, $tid ) );
  return $nid;
}

I call the existing og_vocab_determine_access() to determine node access, then I make sure that the term is actually controlled by the current og. This prevents a user from fiddling with the url to mess with another group's terms.

This still depends on custom_url_rewrite_outbound(), similar to custom_url_rewrite() in Mr Lenardi's v5.x patch.

Questions, comments, and especially suggestions are encouraged and welcome!

Comments

StevenWill’s picture

I added the new item in the og_vocab_menu function and added the new functions at the bottom of the og_vocab.module, but when I go to edit a term I am still receiving a blank page. Did I miss something in applying this bug fix?
Steve

jleonard’s picture

Steve,

Hmmmm... maybe *I* missed something. A blank page very often indicates a syntax error, not a logic error. What do your apache logs have to say?

jleonard’s picture

Steve,
Also, here's my custom_url_rewrite_outbound from settings.php:

function _custom_url_rewrite_outbound (&$path, $options, $original) {
  if (arg(0) =="node" && arg(2) == "og" && arg(4) == "terms") {
    // the system path to change or cloak
    $pattern = '!^admin/content/taxonomy/edit/term/(\d+)!';
    if ( preg_match ( $pattern, $original ) ) {
      // the new cloaked name
      $replacement = 'node/'. arg(1) .'/og/vocab/edit/term/\1';
      $path = preg_replace ( $pattern, $replacement, $original );
    }
  }
}

I think I may have done a little fine-tuning here too. Sorry I didn't include this in my original post.
Bill

amitaibu’s picture

Status: Needs review » Fixed

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

Status: Fixed » Closed (fixed)

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