Commit 268da5a5 authored by rbayliss's avatar rbayliss Committed by amitaibu

Issue #2380967 by rbayliss, criznach: Edit Group membership of a user and changing the status

parent 2261c4e6
......@@ -3074,7 +3074,7 @@ function og_role_grant($group_type, $gid, $uid, $rid) {
// Get the existing user roles.
$user_roles = og_get_user_roles($group_type, $gid, $uid);
$user_roles = og_get_user_roles($group_type, $gid, $uid, TRUE, FALSE);
if (empty($user_roles[$rid])) {
$role = new stdClass();
$role->uid = $uid;
......@@ -768,6 +768,29 @@ class OgPermissionsTestCase extends DrupalWebTestCase {
$this->assertEqual($roles, array(), 'Blocked member has no roles.');
$this->assertFalse(og_user_access('entity_test', $entity->pid, 'update group', $user2), 'Blocked member has no access.');
function testGrantRolesTwiceForPendingUsers() {
// Create user.
$user1 = $this->drupalCreateUser();
// Create an entity.
$entity = entity_create('entity_test', array('name' => 'main', 'uid' => $user1->uid));
$wrapper = entity_metadata_wrapper('entity_test', $entity);
$og_roles = og_roles('entity_test', 'main');
//Add the user to the group.
$values = array('entity_type' => 'user', 'entity' => $user1, 'state' => OG_STATE_PENDING);
$rid = array_search(OG_ADMINISTRATOR_ROLE, $og_roles);
og_group('entity_test', $entity->pid, $values);
// Try granting the admin role to a pending user twice.
og_role_grant('entity_test', $entity->pid, $user1->uid, $rid);
og_role_grant('entity_test', $entity->pid, $user1->uid, $rid);
$this->pass('Granting a role twice should not throw an exception.');
class OgDefaultAccessFieldTestCase extends DrupalWebTestCase {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment