--- og_user_roles.module.5.x-2.6.orig	2007-11-17 16:57:49.000000000 -0800
+++ og_user_roles.module	2007-12-12 12:17:21.000000000 -0800
@@ -1,5 +1,5 @@
 <?php
-// $Id: og_user_roles.module,v 1.1.2.10 2007/11/11 22:43:16 somebodysysop Exp $
+// $Id: og_user_roles.module,v 1.1.2.3 2007/07/08 19:50:44 somebodysysop Exp $
 
 /**
  * @file
@@ -18,9 +18,13 @@ function og_user_roles_help($section) {
 
 /**
  * Implementation of hook_perm().
+ * 
+ * Modification as per: http://drupal.org/node/192747
+ * Added 'administer og_user_roles'
+ *
  */
 function og_user_roles_perm() {
-  return array('configure member roles', 'create og_subgroups');
+  return array('administer og_user_roles', 'configure member roles', 'create og_subgroups');
 }
 
 /**
@@ -277,7 +281,11 @@ function og_user_roles_menu($may_cache) 
       'description' => t('Allows group administrators to add members into group roles.'),
       'callback' => 'drupal_get_form',
       'callback arguments' => 'og_user_roles_admin_settings',
-      'access' => user_access('administer site configuration'),
+/* 
+ * Modification as per: http://drupal.org/node/192747
+ * was: 'access' => user_access('administer site configuration'),
+ */
+      'access' => user_access('administer og_user_roles'),
       'type' => MENU_NORMAL_ITEM
     );
     $items[] = array(
@@ -817,7 +825,8 @@ function og_user_roles_init() {
       $tid = intval(arg(3));
       $gid = og_user_roles_gid_from_tid($tid);
       // Hijack only if there is a gid value;
-      if (!empty($gid)) {
+      // Modificaton as per http://drupal.org/node/194214
+      if (!empty($gid) && $gid != 0) { 
         $path = 'node/ognodeadd';
         $query = 'type='. $type .'&gids[]='. $gid .'&tid='. $tid;
         drupal_goto($path, $query);
@@ -1424,7 +1433,7 @@ function og_user_roles_all_roles($user) 
       $nid = $comment->nid;
       $gid = og_user_roles_getgid($nid, $uid);
     }
-
+
     //                           0      1    2
     // http://www.mysite.com/comment/reply/128#comment_form
     if (arg(0) == 'comment' && arg(1) == 'reply') {
@@ -2119,14 +2128,14 @@ function og_user_roles_user_manage() {
  * stolen from og_forum (had to in the case where og_user_roles user doesn't have latest
  * version of og_forum module which includes this)
  */
-function og_user_roles_gid_from_tid($tid = 0) {
+function og_user_roles_gid_from_tid($tid = 0) {
   // Modification as per: http://drupal.org/node/172923
   if (module_exists('og_forum')) {
-    $sql = "SELECT nid FROM {og_term} WHERE tid = %d";
-    $gid = db_result(db_query($sql, $tid));
-    return $gid;
-  }
-}
+    $sql = "SELECT nid FROM {og_term} WHERE tid = %d";
+    $gid = db_result(db_query($sql, $tid));
+  }
+  return empty($gid) ? 0 : $gid; // As per http://drupal.org/node/194214
+}
 
 /**
  * using the og_vocab tid, get the group id
@@ -2663,11 +2672,14 @@ function og_user_roles_theme() {
     $group_node = node_load($gid);
     $custom_theme = $group_node->og_theme;
   }
-  elseif (arg(0) == 'forum' && is_numeric(arg(1))) {
-    $tid = intval(arg(1));
-    $gid = og_user_roles_gid_from_tid($tid);
-    $group_node = node_load($gid);
-    $custom_theme = $group_node->og_theme;
+  // As per: http://drupal.org/node/194214
+  elseif (arg(0) == 'forum' && is_numeric(arg(1))) {
+    $tid = intval(arg(1));
+    $gid = og_user_roles_gid_from_tid($tid);
+    if (!empty($gid)) {
+      $group_node = node_load($gid);
+      $custom_theme = $group_node->og_theme;
+    }
   }
   elseif (arg(0) == 'og_calendar' && is_numeric(arg(1))) {
     $gid = intval(arg(1));
