Index: og_user_roles.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_user_roles/og_user_roles.info,v
retrieving revision 1.4
diff -u -p -r1.4 og_user_roles.info
--- og_user_roles.info	23 May 2009 04:12:36 -0000	1.4
+++ og_user_roles.info	24 May 2009 04:10:34 -0000
@@ -2,6 +2,7 @@
 name = Organic groups user roles
 description = Dynamically assign user roles to members of organic groups.
 dependencies[] = og
+dependencies[] = og_views
 package = Organic groups
 core = 6.x
 php = 4.3.9 
Index: og_user_roles.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_user_roles/og_user_roles.module,v
retrieving revision 1.7
diff -u -p -r1.7 og_user_roles.module
--- og_user_roles.module	23 May 2009 07:56:29 -0000	1.7
+++ og_user_roles.module	24 May 2009 05:43:22 -0000
@@ -36,15 +36,6 @@ function og_user_roles_perm() {
 }
 
 /**
- * Implementation of hook_access().
- */
-function og_user_roles_access($op, $node, $account) {
-  if ($op == 'create') {
-    return user_access('create og_subgroups');
-  }
-}
-
-/**
  * Implementation of hook_settings().
  */
 function og_user_roles_admin_settings() {
@@ -582,7 +573,6 @@ function og_user_roles_menu() {
     'description' => 'Allows group administrators to add members into group roles.   Also edit multinode access configuration.',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('og_user_roles_admin_settings'),
-    'access callback' => 'user_access',
     'access arguments' => array('administer og_user_roles'),
   );
   $items['admin/og/og_user_roles/settings'] = array(
@@ -594,7 +584,6 @@ function og_user_roles_menu() {
     'title' => t('Configure multinode UI'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('og_user_roles_multinode'),
-    'access callback' => 'user_access',
     'access arguments' => array('administer site configuration'),
     'weight' => 10,
     'type' => MENU_LOCAL_TASK,
@@ -635,7 +624,6 @@ function og_user_roles_menu() {
     'title' => 'Enter registration code',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('og_user_roles_register'),
-    'access callback' => 'user_access',
     'access arguments' => array('use registration codes'),
     'weight' => 10,
     'type' => MENU_LOCAL_TASK,
@@ -644,7 +632,6 @@ function og_user_roles_menu() {
     'title' => 'Confirm registration code',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('og_user_roles_register_confirm'),
-    'access callback' => 'user_access',
     'access arguments' => array('use registration codes'),
     'weight' => 10,
     'type' => MENU_LOCAL_TASK,
@@ -654,7 +641,6 @@ function og_user_roles_menu() {
     'title' => 'Group Logo',
     'page callback' => 'og_user_roles_oglogo',
     'callback arguments' => array($user->uid),
-    'access callback' => 'user_access',
     'access arguments' => array('access print'),
     'type' => MENU_CALLBACK,
   );
@@ -704,7 +690,6 @@ function og_user_roles_menu() {
     'title' => 'Manage users',
     'page callback' => 'og_user_roles_user_manage',
     'page arguments' => array(2),
-    'access callback' => 'user_access',
     'access arguments' => array('administer users'),
     'weight' => 6,
     'type' => MENU_LOCAL_TASK,
@@ -1471,12 +1456,30 @@ function og_user_roles_checkview($viewna
 }
 
 /**
- * Implementation of hook_boot().
+ * Implementation of hook_menu_alter().
+ */
+function og_user_roles_menu_alter(&$menu) {
+  // Override OG's node edit access callback.
+  $menu['node/%node/edit']['access callback'] = 'og_user_roles_menu_access_node_edit';
+  $menu['node/%node/edit']['access arguments'] = array(1);
+}
+
+/**
+ * Menu access callback; Determine access to node edit page.
+ */
+function og_user_roles_menu_access_node_edit($node) {
+  // Perform regular access check first.
+  $access = og_menu_access_node_edit($node);
+  return $access;
+}
+
+/**
+ * Implementation of hook_init().
  *
  * Got the idea of re-directing if this is a add group node request
  * from here: http://drupal.org/project/globalredirect
  */
-function og_user_roles_boot() {
+function og_user_roles_init() {
   global $user;
 
   // Let's try getting og roles here, just to see what happens
@@ -1489,7 +1492,7 @@ function og_user_roles_boot() {
     if (variable_get('og_user_roles_clear_cache_value', 0) == 1) {
       cache_clear_all($user->uid, 'cache_menu', TRUE);
       // Clear the user_access $perm cache
-      user_access('', NULL, TRUE);
+      user_access(NULL, NULL, TRUE);
     }
   }
 
@@ -1939,6 +1942,8 @@ function og_user_roles_user($op, &$edit,
     // This returns normal $user->roles and includes OG roles if any
     $roles = og_user_roles_all_roles($user);
     $user->roles = $roles;
+    // Reload user permissions.
+    user_access(NULL, NULL, TRUE);
   }
 
   // Remove user info from og_users_roles table
@@ -2003,7 +2008,7 @@ function og_user_roles_og($op, $nid, $ui
 
       // --- Modification - 2008-01-10 - as per: http://drupal.org/node/197489
       // Places all new group administrators into default group administrator role.
-      $admin = $args['is_admin'];
+      $admin = (isset($args['is_admin']) ? $args['is_admin'] : 0);
       if (variable_get('og_user_roles_assign_admingrouprole', 0) == 1 && $admin == 1) {
         $rid = variable_get('og_user_roles_admingrouprole_value', 0);
         // assign user to group role in that group
@@ -4271,9 +4276,6 @@ function og_user_roles_og_status($node) 
  *   Boolean true or false
  */
 function og_user_roles_modr8_access($nid, $access) {
-  // ToDo: Use og_user_roles_access to determine access.
-  //  og_user_roles_user_access($access, $gid, $uid)
-
   // This code doesn't work because it gives 'access denied' once node is approved:
   //  $node = node_load($nid);
   //  return $node->moderate && user_access($access);
