Unverified Commit 731d5b8e authored by alesr's avatar alesr Committed by GitHub

Merge pull request #322 from willzyx-dev/7.x-2.x

Group owner membership is activated on every group save
parents 983ce450 eb6ca6a9
...@@ -882,7 +882,7 @@ function og_entity_update($entity, $entity_type) { ...@@ -882,7 +882,7 @@ function og_entity_update($entity, $entity_type) {
} }
list($id, , $bundle) = entity_extract_ids($entity_type, $entity); list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
if (!empty($entity->uid) && !og_is_member($entity_type, $id, 'user', $entity->uid)) { if (!empty($entity->uid) && !og_is_member($entity_type, $id, 'user', $entity->uid, array())) {
// Subscribe the group manager, in case the owner changed. // Subscribe the group manager, in case the owner changed.
og_group($entity_type, $id, array('entity' => $entity->uid)); og_group($entity_type, $id, array('entity' => $entity->uid));
// Assign roles to group manager. // Assign roles to group manager.
......
...@@ -649,6 +649,41 @@ class OgGroupAndUngroup extends DrupalWebTestCase { ...@@ -649,6 +649,41 @@ class OgGroupAndUngroup extends DrupalWebTestCase {
$user_roles = og_get_user_roles('entity_test', $entity1->pid, $user1->uid, FALSE); $user_roles = og_get_user_roles('entity_test', $entity1->pid, $user1->uid, FALSE);
$this->assertEqual($og_roles, $user_roles, t('Group manager was granted default role.')); $this->assertEqual($og_roles, $user_roles, t('Group manager was granted default role.'));
} }
/**
* Test group behaviour when the group owner is not active.
*/
public function testGroupManagerNotActive() {
// Create the user.
$user1 = $this->drupalCreateUser();
// Create the group; the group owner is the previously created user.
$entity1 = entity_create('entity_test', array('name' => 'main', 'uid' => $user1->uid));
$wrapper = entity_metadata_wrapper('entity_test', $entity1);
$wrapper->{OG_GROUP_FIELD}->set(1);
$wrapper->save();
// Ensure that the user owner membership for the group has active status.
$og_membership = og_get_membership('entity_test', $entity1->pid, 'user', $user1->uid);
$this->assertEqual($og_membership->state, OG_STATE_ACTIVE, 'Owner Membership status is Active');
// Move the user owner membership to blocked.
$og_membership->state = OG_STATE_BLOCKED;
$og_membership->save();
$og_membership = og_membership_load($og_membership->identifier());
$this->assertEqual($og_membership->state, OG_STATE_BLOCKED, 'Owner Membership status is Blocked');
// Save the group entity.
$wrapper = entity_metadata_wrapper('entity_test', $entity1);
$wrapper->save();
// Ensure that the user owner membership for the group still has blocked
// status.
$og_membership = og_membership_load($og_membership->identifier());
$this->assertEqual($og_membership->state, OG_STATE_BLOCKED, 'Owner Membership status is Blocked');
}
} }
class OgPermissionsTestCase extends DrupalWebTestCase { class OgPermissionsTestCase 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