--- /og/og.module	2012-07-01 16:09:22.000000000 -0400
+++ /sites/all/modules/og/og.module	2012-08-23 15:54:01.000000000 -0400
@@ -3207,3 +3207,62 @@
 
   return $files;
 }
+
+
+/**
+ * Retrieve an array of all roles.
+ *
+ * @return
+ *   An associative array with the role id as the key and the role name as
+ *   value.
+ */
+function og_get_all_roles() {
+
+  $query = db_select('og_role', 'ogr')
+    ->fields('ogr', array('rid', 'name'))
+    ->orderBy('rid', 'ASC');
+
+  $rids = $query
+    ->execute()
+    ->fetchAllkeyed();
+
+  return $rids;
+}
+
+/**
+ * Access callback for the views_plugin_access_role access plugin.
+
+ * Determine if the specified user has access to a view on the basis of any of
+ * the requested roles. If the $account argument is omitted, the current user
+ * is used.
+ */
+function og_user_check_roles($group_type, $group_id_arg = '', $rids, $account = NULL) {
+	//if the view is a block, there will be no $group_id_arg set.
+	if($group_id_arg == ''){
+		$group = og_context($group_type);
+	}
+	
+	//if the view is a page, use the $group_id_arg to get and set the og context.
+	else{
+		$group = og_context_views_page($group_type, $group_id_arg);
+	}
+	
+	//if the group context exists, check the og roles access
+	if($group) {
+		
+	  global $user;
+	  
+	  //if an account wasn't passed as a variable, use the current user.
+	  $account = isset($account) ? $account : $user;
+	  
+	  //get all of the roles for the user and the group
+	  $user_og_roles = og_get_user_roles($group['group_type'], $group['gid'], $account->uid);
+	  
+	  //get an array of the rids from the user's roles
+	  $roles = array_keys($user_og_roles);
+	  
+	  return user_access('access all views', $account) || array_intersect(array_filter($rids), $roles);
+	}
+	return FALSE;
+}
+
