Closed (fixed)
Project:
OG Vocabulary
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Dec 2008 at 19:37 UTC
Updated:
7 Jan 2009 at 15:30 UTC
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
Comment #1
StevenWill commentedI 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
Comment #2
jleonard commentedSteve,
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?
Comment #3
jleonard commentedSteve,
Also, here's my custom_url_rewrite_outbound from settings.php:
I think I may have done a little fine-tuning here too. Sorry I didn't include this in my original post.
Bill
Comment #4
amitaibuThis should be fixed in commit http://drupal.org/cvs?commit=160722