--- og_user_roles.module.6.x-1.0.orig	2008-12-03 01:01:16.000000000 -0800
+++ og_user_roles.module	2008-12-24 00:32:07.000000000 -0800
@@ -1,5 +1,5 @@
 <?php
-// $Id: og_user_roles.module,v 1.1.2.15.2.2 2008/11/24 19:03:28 somebodysysop Exp $
+// $Id: og_user_roles.module,v 1.1.2.4 2008/07/03 19:50:44 somebodysysop Exp $
 
 /**
  * @file
@@ -1771,7 +1771,7 @@ function og_user_roles_nodeapi(&$node, $
 		  if (module_exists('og_forum')) {
 		    if ($node->type == 'forum') {
               // Get the forum vocabulary ID
-              $vid = _forum_get_vid();
+              $vid = og_forum_get_vid(); // http://drupal.org/node/346717
               $ok = FALSE;
    			  // Get all forums for this group
      		  $sql = "SELECT tid FROM {og_term} WHERE nid = %d";
@@ -1977,7 +1977,10 @@ function og_user_roles_all_roles($user) 
     // Modified 2007-12-20 for "revisions": http://drupal.org/node/202196
     // Modified 2008-01-10 for "workflow": http://drupal.org/node/208363
     // Modified 2008-03-21 for "feedapi": http://drupal.org/node/237258
-    if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'outline' || arg(2) == 'track' || arg(2) == 'results' || arg(2) == 'access' || arg(2) == 'modr8' || arg(2) == 'ogmodr8' || arg(2) == 'delete' || arg(2) == 'galleries' || arg(2) == 'email' || arg(2) == 'revisions' || arg(2) == 'signups' || arg(2) == 'agenda' || arg(2) == 'workflow' || arg(2) == 'votes' || arg(2) == 'refresh' || arg(2) == 'purge')) {
+	// Modified 2008-12-24: How about just looking for nid in /node/<nid> instead of trying to
+	//                      anticipate each and every module.
+    // if (arg(0) == 'node' && is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'outline' || arg(2) == 'track' || arg(2) == 'results' || arg(2) == 'access' || arg(2) == 'modr8' || arg(2) == 'ogmodr8' || arg(2) == 'delete' || arg(2) == 'galleries' || arg(2) == 'email' || arg(2) == 'revisions' || arg(2) == 'signups' || arg(2) == 'agenda' || arg(2) == 'workflow' || arg(2) == 'votes' || arg(2) == 'refresh' || arg(2) == 'purge')) {
+    if (arg(0) == 'node' && is_numeric(arg(1))) {
       $location = 2;
       $nid = (int)arg(1);	
       $gid = og_user_roles_getgid($nid, $uid);
@@ -2504,16 +2507,35 @@ function og_user_roles_getgid($nid, $uid
     }
   }
 
-  // If $gid still equals 0 then try searching node_access table
-  /* Sample:
-   * SELECT node_access.gid from node_access INNER JOIN og_uid ON node_access.gid = og_uid.nid WHERE node_access.realm = 'og_subscriber' AND og_uid.uid = 2 AND (node_access.nid = 194 OR node_access.gid = 194)
-   */
-  if ($gid == 0) {
-    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND ogu.uid = %d AND (na.nid = %d OR na.gid = %d)", $uid, $nid, $nid); // modified to check for either the node or group ID in node_access
-    while ($t = db_fetch_object($result)) {
-      $gid = $t->gid;
-    }
-  }  
+/** 
+ * If $gid still equals 0 then try searching node_access table
+ * Modified as per: http://drupal.org/node/347277
+ */
+  if ($gid == 0) {
+    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND ogu.uid = %d AND (na.nid = %d)", $uid, $nid, $nid); // modified to check for either the node ID in node_access
+    while ($t = db_fetch_object($result)) {
+      $gid = $t->gid;
+    }
+  } 
+
+  if ($gid == 0) {
+    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND ogu.uid = %d AND (na.gid = %d)", $uid, $nid, $nid); // modified to check for group ID in node_access
+    while ($t = db_fetch_object($result)) {
+      $gid = $t->gid;
+    }
+  } 
+
+/** 
+ * Old code. Query too slow:
+ * SELECT node_access.gid from node_access INNER JOIN og_uid ON node_access.gid = og_uid.nid WHERE node_access.realm = 'og_subscriber' AND og_uid.uid = 2 AND (node_access.nid = 194 OR node_access.gid = 194)
+ * 
+ */
+//  if ($gid == 0) {
+//    $result = db_query("SELECT na.gid from {node_access} na INNER JOIN {og_uid} ogu ON na.gid = ogu.nid WHERE na.realm = 'og_subscriber' AND ogu.uid = %d AND (na.nid = %d OR na.gid = %d)", $uid, $nid, $nid); // modified to check for either the node or group ID in node_access
+//    while ($t = db_fetch_object($result)) {
+//      $gid = $t->gid;
+//    }
+//  }  
 
   // If $gid still equals 0 then try searching og_term table (if it exists)
   // og forums will typically be listed here
@@ -2610,6 +2632,8 @@ function og_user_roles_ognodeadd() {
   $type = $_GET['type'];
 
   if ($type) {
+    // Convert the dashes in the URL back to underscores. http://drupal.org/node/349648
+    $type = str_replace('-', '_' , $type);
     // Got this from node.module (node_access)
     // No matter the type, this should return us the create permission.
     $module = node_get_types('module', $type);
@@ -2678,6 +2702,8 @@ function og_user_roles_ognodeadd() {
  * Format: http://www.scbbs.com/node/ogtermedit?destination=node%2F29%2Fog%2Fvocab%2Fterms%2F26&gids[]=29&tid=116
  */
 function og_user_roles_ogtermedit() {
+  require_once drupal_get_path('module', 'taxonomy'). '/taxonomy.admin.inc';
+
   global $user;
 
   $roles = og_user_roles_all_roles($user); // This returns normal $user->roles and includes OG roles if any
@@ -3482,7 +3508,7 @@ function og_user_roles_determine_context
  */
 function og_user_roles_og_create_links($group) {
   if (variable_get('og_user_roles_links_content_' . $group->nid, 0) == 1) {
-    $links[] = l(t('Create content'), "node/ognodeadd", array('title' => t('Add new content in this group.')), "gids[]=$group->nid");
+    $links[] = l(t('Create content'), "node/ognodeadd", array('title' => t('Add new content in this group.'), 'query' => 'gids[]=' . $group->nid));
     return $links;
   }
 }
@@ -3493,7 +3519,13 @@ function og_user_roles_og_create_links($
  * Modification as per: http://drupal.org/node/2517905
  * Optionally remove create_ links.
  */
-function og_user_roles_og_link_alter(&$links, $group_node) {
+function og_user_roles_og_links_alter(&$links, $group_node) {
+
+  // Convert the dashes in the URL back to underscores.
+  foreach($links as $key => $value) {
+    $links[$key] = str_replace('-', '_' , $value);
+  }
+
   if (variable_get('og_user_roles_links_remove_' . $group_node->nid, 0) == 1) {
     foreach($links as $key => $value) {
       if(substr($key,0,7) == 'create_') {
