From 84db18c2c1b30717ac83861c4cb96d84514e9b2b Mon Sep 17 00:00:00 2001 From: krueschi Date: Mon, 19 Sep 2016 13:01:31 +0200 Subject: [PATCH 01/16] Fixed: og_help function in og.module refers now README.md. The module help refered an old README.txt file that does not exist any more. Help function now refers the correct markdown file README.md. --- og.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/og.module b/og.module index 812707e6b..186dc0c84 100755 --- a/og.module +++ b/og.module @@ -81,8 +81,8 @@ function og_help($path, $arg) { switch ($path) { case 'admin/help#og': $path = drupal_get_path('module', 'og'); - $output = '

' . t("Read the README.txt file in the Organic groups module directory.", array('@url' => "/$path/README.txt")) . '

'; - $output .= '

' . t("Information about Organic Groups can also be found on the module'sdocumentation page.", array('@og' => 'http://drupal.org/documentation/modules/og')) . '

'; + $output = '

' . t("Read the README.md file in the Organic groups module directory.", array('@url' => "/$path/README.md")) . '

'; + $output .= '

' . t("Information about Organic Groups can also be found on the module's documentation page.", array('@og' => 'http://drupal.org/documentation/modules/og')) . '

'; return $output; } } From eb5776af9a492f96870dbbc850ea7a7dd4252821 Mon Sep 17 00:00:00 2001 From: sasovucic Date: Fri, 13 Oct 2017 15:57:55 +0200 Subject: [PATCH 02/16] og_ui edit_membership_form disable checkboxes if member is not active. --- og_ui/og_ui.admin.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/og_ui/og_ui.admin.inc b/og_ui/og_ui.admin.inc index ca02148a5..5da7c38bc 100644 --- a/og_ui/og_ui.admin.inc +++ b/og_ui/og_ui.admin.inc @@ -311,6 +311,7 @@ function og_ui_edit_membership($form, &$form_state, $group_type, $gid, $og_membe '#options' => $og_roles, '#title' => t('Roles'), '#default_value' => array_keys(og_get_user_roles($group_type, $gid, $account->uid)), + '#disabled' => $og_membership->state != OG_STATE_ACTIVE, ); } From 18dc4922a3481c30c53f9f2f92b0bde76b3beea2 Mon Sep 17 00:00:00 2001 From: willzyx Date: Sat, 14 Oct 2017 18:08:11 +0200 Subject: [PATCH 03/16] Group owner membership is activated on every group save --- og.module | 2 +- og.test | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/og.module b/og.module index 23af037dd..463548621 100755 --- a/og.module +++ b/og.module @@ -874,7 +874,7 @@ function og_entity_update($entity, $entity_type) { } 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. og_group($entity_type, $id, array('entity' => $entity->uid)); // Assign roles to group manager. diff --git a/og.test b/og.test index 5bd5deb6e..b0f38fb7f 100644 --- a/og.test +++ b/og.test @@ -649,6 +649,41 @@ class OgGroupAndUngroup extends DrupalWebTestCase { $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.')); } + + /** + * 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 { From 86038a91d63d9621fe53c550816e12e6f86fbdcb Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Wed, 31 May 2017 10:00:45 +0200 Subject: [PATCH 04/16] Remove duplicate checks in og_ui_user_access_group It is not necessary to check if `$group_type` is a valid entity type when `entity_load_single()` was successful. Also, `og_is_group()` was invoked twice. --- og_ui/og_ui.module | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/og_ui/og_ui.module b/og_ui/og_ui.module index bac58c127..879480c7e 100644 --- a/og_ui/og_ui.module +++ b/og_ui/og_ui.module @@ -328,12 +328,7 @@ function og_ui_user_access_group($perm, $group_type, $gid) { return FALSE; } - $entity_info = entity_get_info($group_type); - if (!$group_type || !$entity_info) { - // Not a valid entity type. - return FALSE; - } - return og_is_group($group_type, $group) && og_user_access($group_type, $gid, $perm); + return og_user_access($group_type, $gid, $perm); } /** From 28c2d66e2f286f854a47e876efd109e5a287890e Mon Sep 17 00:00:00 2001 From: "jacob.embree" Date: Tue, 13 Feb 2018 14:11:32 -0500 Subject: [PATCH 05/16] Issue #2569471 by robertom, jacob.embree: og_get_groups_by_user don't respect @return documentation --- og.module | 8 ++++---- .../selection/OgSelectionHandler.class.php | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/og.module b/og.module index 23af037dd..b798ea1b2 100755 --- a/og.module +++ b/og.module @@ -3561,18 +3561,18 @@ function og_get_groups_by_user($account = NULL, $group_type = NULL) { $account = $user; } + $gids = array(); + if (!og_get_group_audience_fields()) { // User entity doesn't have group audience fields. - return; + return $gids; } - $gids = array(); - // Get all active OG membership that belong to the user. $wrapper = entity_metadata_wrapper('user', $account->uid); $og_memberships = $wrapper->{'og_membership__' . OG_STATE_ACTIVE}->value(); if (!$og_memberships) { - return; + return $gids; } foreach ($og_memberships as $og_membership) { diff --git a/plugins/entityreference/selection/OgSelectionHandler.class.php b/plugins/entityreference/selection/OgSelectionHandler.class.php index d66bad3b1..cebdf6579 100644 --- a/plugins/entityreference/selection/OgSelectionHandler.class.php +++ b/plugins/entityreference/selection/OgSelectionHandler.class.php @@ -105,7 +105,6 @@ public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS $field_mode = $this->instance['field_mode']; $user_groups = og_get_groups_by_user(NULL, $group_type); - $user_groups = $user_groups ? $user_groups : array(); $user_groups = array_merge($user_groups, $this->getGidsForCreate()); From fb4c95eb1c38bd4f1d19498bedf346d19c2e3726 Mon Sep 17 00:00:00 2001 From: Jacob Embree Date: Wed, 21 Feb 2018 07:55:12 -0500 Subject: [PATCH 06/16] Fix return value of og_get_groups_by_user() when $group_type is provided and results are empty --- og.module | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/og.module b/og.module index b798ea1b2..13112f1ed 100755 --- a/og.module +++ b/og.module @@ -3553,7 +3553,10 @@ function og_node_create_links($group_type, $gid, $field_name, $destination = NUL * types will be fetched. * * @return - * An array with the group IDs or an empty array. + * If $group_type is provided then an array of group IDs matching the + * specified group type. If $group_type is not provided then an associative + * array is returned containing arrays of group IDs keyed by group type. If + * no results are found an empty array is returned. */ function og_get_groups_by_user($account = NULL, $group_type = NULL) { if (empty($account)) { @@ -3581,12 +3584,10 @@ function og_get_groups_by_user($account = NULL, $group_type = NULL) { } } - if (empty($group_type)) { - return $gids; - } - elseif (!empty($gids[$group_type])) { - return $gids[$group_type]; + if (isset($group_type)) { + return isset($gids[$group_type]) ? $gids[$group_type] : array(); } + return $gids; } /** From 712765b192ffab521b1c015419493ff50ba25b8d Mon Sep 17 00:00:00 2001 From: Jacob Embree Date: Wed, 21 Feb 2018 09:50:47 -0500 Subject: [PATCH 07/16] Fix tests: core-quick-drupal not available in Drush 9 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b156c4072..6a0436078 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_script: - cd ../.. # Install Drush - - composer global require drush/drush + - composer global require drush/drush:8 - export PATH=$PATH:~/.composer/vendor/bin # Install php packages required for running Drupal From 4a968a894bf256955924e7cea1d1fb81b44bd0b2 Mon Sep 17 00:00:00 2001 From: "jacob.embree" Date: Tue, 19 Jun 2018 12:53:16 +0200 Subject: [PATCH 08/16] #2158477 hook_og_permission() does not document its @return. --- og.api.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/og.api.php b/og.api.php index e776cf5df..4f58d71bb 100644 --- a/og.api.php +++ b/og.api.php @@ -12,7 +12,28 @@ */ /** - * Add group permissions. + * Define permissions specific to organic groups. + * + * This hook can supply permissions that the module defines, so that they can be + * selected on the group permissions page and used to grant or restrict access + * to actions pertaining to groups. + * + * Permissions are checked using og_user_access(). + * + * @return array + * An array whose keys are permission names and whose corresponding values are + * arrays containg the following key-value pairs: + * - title: The human-readable name of the permission, to be shown on group + * permissions pages. This should be wrapped in the t() function so it can + * be translated. + * - description: (optional) A description of what the permission does. This + * should be wrapped in the t() function so it can be translated. + * - roles: (optional) An array of OG roles to which it is possible to assign + * this permission. The default value is an array containg OG_ANONYMOUS_ROLE + * and OG_AUTHENTICATED_ROLE. + * - default role: (optional) An array of OG roles that should be assigned + * this permission by default. If omitted then no role will receive the + * permission by default. */ function hook_og_permission() { return array( From fad3becd4b53136a4a7969ed74a470d7d803ddb9 Mon Sep 17 00:00:00 2001 From: "jacob.embree" Date: Tue, 19 Jun 2018 13:26:46 +0200 Subject: [PATCH 09/16] #1865860 Issues with multiple entity types as groups. --- og.module | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/og.module b/og.module index 23af037dd..549487fe5 100755 --- a/og.module +++ b/og.module @@ -671,7 +671,15 @@ function og_field_create_instance($instance) { $og_field = og_fields_info(OG_AUDIENCE_FIELD); $og_field['field']['settings']['target_type'] = $entity_type; - $og_field['instance']['label'] = t('Group membership'); + if ($entity_type == 'node') { + $og_field['instance']['label'] = t('Group membership'); + } + else { + $entity_info = entity_get_info($entity_type); + $og_field['instance']['label'] = t('@label group membership', array( + '@label' => $entity_info['label'], + )); + } // If the user entity type has multiple bundles, make sure to attach a field // instance to all of them. From 78da0725c82667fdd1b87308dd419101cb21077e Mon Sep 17 00:00:00 2001 From: "jacob.embree" Date: Tue, 19 Jun 2018 13:33:22 +0200 Subject: [PATCH 10/16] #1997274 Return docs for og_get_entity_groups() unclear. --- og.module | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/og.module b/og.module index 23af037dd..1027b6306 100755 --- a/og.module +++ b/og.module @@ -2305,9 +2305,9 @@ function og_user_access_entity($perm, $entity_type, $entity, $account = NULL, $s * (optional) The field name associated with the group. * * @return - * An array with the group's entity type as the key, and array - keyed by - * the OG membership ID and the group ID as the value. If nothing found, - * then an empty array. + * An associative array keyed by the group's entity type. Each value is itself + * an array, where each item has for its key the OG membership ID and for its + * value the group ID. */ function og_get_entity_groups($entity_type = 'user', $entity = NULL, $states = array(OG_STATE_ACTIVE), $field_name = NULL) { $cache = &drupal_static(__FUNCTION__, array()); From dcc92cfaf71c64aabb4d6fe272e675775a6dd05e Mon Sep 17 00:00:00 2001 From: markpavlitski Date: Tue, 19 Jun 2018 13:49:56 +0200 Subject: [PATCH 11/16] #2575833 OG entityreference field breaks Views when the field is attached to multiple entity types.. --- .../behavior/OgBehaviorHandler.class.php | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/plugins/entityreference/behavior/OgBehaviorHandler.class.php b/plugins/entityreference/behavior/OgBehaviorHandler.class.php index 65d2eabe3..d17a8e262 100644 --- a/plugins/entityreference/behavior/OgBehaviorHandler.class.php +++ b/plugins/entityreference/behavior/OgBehaviorHandler.class.php @@ -203,26 +203,20 @@ public function views_data_alter(&$data, $field) { // that this field is attached to. foreach ($entity_types as $entity_type) { $entity_info = entity_get_info($entity_type); - $data['og_membership'] = array( - 'table' => array( - 'join' => array( - $entity_info['base table'] => array( - // Join entity base table on its id field with left_field. - 'left_field' => $entity_info['entity keys']['id'], - 'field' => 'etid', - 'extra' => array( - 0 => array( - 'field' => 'entity_type', - 'value' => $entity_type, - ), - ), - ), + $data['og_membership']['table']['join'][$entity_info['base table']] = array( + // Join entity base table on its id field with left_field. + 'left_field' => $entity_info['entity keys']['id'], + 'field' => 'etid', + 'extra' => array( + 0 => array( + 'field' => 'entity_type', + 'value' => $entity_type, ), ), - // Copy the original config from the table definition. - $field['field_name'] => $data['field_data_' . $field['field_name']][$field['field_name']], - $field['field_name'] . '_target_id' => $data['field_data_' . $field['field_name']][$field['field_name'] . '_target_id'], ); + // Copy the original config from the table definition. + $data['og_membership'][$field['field_name']] = $data['field_data_' . $field['field_name']][$field['field_name']]; + $data['og_membership'][$field['field_name'] . '_target_id'] = $data['field_data_' . $field['field_name']][$field['field_name'] . '_target_id']; // Change config with settings from og_membership table. foreach (array('filter', 'argument', 'sort', 'relationship') as $op) { From 16606d5a5b63cbaf1688cb2485f3eb9320607340 Mon Sep 17 00:00:00 2001 From: marcoscano Date: Tue, 19 Jun 2018 14:08:56 +0200 Subject: [PATCH 12/16] #2542856 og_is_member() documentation incorrectly inform about parameter. --- og.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/og.module b/og.module index 23af037dd..15e5dc0a4 100755 --- a/og.module +++ b/og.module @@ -2572,8 +2572,8 @@ function og_get_all_group_content_bundle() { * @param $entity * The entity object. If empty the current user will be used. * @param $states - * (optional) Array with the state to return. If empty groups of all state will - * return. + * (optional) Array with the membership states to check against. If omitted + * then only active (OG_STATE_ACTIVE) memberships will be checked. * * @return * TRUE if the entity (e.g. the user) belongs to a group and is not pending or From f0b92215398d1493e3d58a2af175d78e8e8e0817 Mon Sep 17 00:00:00 2001 From: JulienD Date: Tue, 19 Jun 2018 14:16:47 +0200 Subject: [PATCH 13/16] #2338665 Remove unnecessary files[] from .info file. --- og.info | 1 - og_access/og_access.info | 2 -- og_context/og_context.info | 2 -- og_field_access/og_field_access.info | 1 - og_register/og_register.info | 2 -- 5 files changed, 8 deletions(-) diff --git a/og.info b/og.info index 9fcdc8675..3985df0f0 100644 --- a/og.info +++ b/og.info @@ -24,7 +24,6 @@ files[] = includes/views/handlers/og_plugin_argument_validate_group.inc files[] = includes/views/handlers/og_plugin_argument_default_user_groups.inc ; Views fields -files[] = includes/views/handlers/og_handler_field_group_member_count.inc files[] = includes/views/handlers/og_handler_field_group_audience_state.inc files[] = includes/views/handlers/og_handler_field_prerender_list.inc files[] = includes/views/handlers/og_handler_field_user_roles.inc diff --git a/og_access/og_access.info b/og_access/og_access.info index 3656ff2fd..af3abfa9a 100644 --- a/og_access/og_access.info +++ b/og_access/og_access.info @@ -4,8 +4,6 @@ package = "Organic groups" dependencies[] = og core = 7.x version = VERSION -files[] = og_access.module -files[] = og_access.install ; Tests files[] = og_access.test \ No newline at end of file diff --git a/og_context/og_context.info b/og_context/og_context.info index 5e4e792c1..442f2e68f 100644 --- a/og_context/og_context.info +++ b/og_context/og_context.info @@ -3,8 +3,6 @@ description = "Get a group from a viewed page." package = "Organic groups" dependencies[] = og core = 7.x -files[] = og_context.module -files[] = og_context.install ; Views default arguments files[] = includes/views/handlers/og_context_plugin_argument_default_group_context.inc diff --git a/og_field_access/og_field_access.info b/og_field_access/og_field_access.info index 8dae4521d..1f009e39e 100644 --- a/og_field_access/og_field_access.info +++ b/og_field_access/og_field_access.info @@ -3,7 +3,6 @@ description = "Provide field access based on group." package = "Organic groups" dependencies[] = og core = 7.x -files[] = og_field_access.module ; Tests files[] = og_field_access.test diff --git a/og_register/og_register.info b/og_register/og_register.info index 85bdd6e0c..36cfa0168 100644 --- a/og_register/og_register.info +++ b/og_register/og_register.info @@ -4,5 +4,3 @@ description = "Allow subscribing to groups during the user registration." package = "Organic groups" dependencies[] = og core = 7.x -files[] = og_register.module -files[] = og_register.install \ No newline at end of file From 2377e42bfda9a61256fa7a38816d214e70553bac Mon Sep 17 00:00:00 2001 From: idebr Date: Tue, 19 Jun 2018 14:34:10 +0200 Subject: [PATCH 14/16] #2831715 Unsubscribe confirm firm uses 'Remove' as button text. --- og_ui/og_ui.pages.inc | 2 +- og_ui/og_ui.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/og_ui/og_ui.pages.inc b/og_ui/og_ui.pages.inc index 36d0f3460..7d63f7cac 100644 --- a/og_ui/og_ui.pages.inc +++ b/og_ui/og_ui.pages.inc @@ -237,7 +237,7 @@ function og_ui_confirm_unsubscribe($form, &$form_state, $group_type, $group) { $label = entity_label($group_type, $group); $url = entity_uri($group_type, $group); - return confirm_form($form, t('Are you sure you want to unsubscribe from the group %title?', array('%title' => $label)), $url, NULL, t('Remove'), t('Cancel')); + return confirm_form($form, t('Are you sure you want to unsubscribe from the group %title?', array('%title' => $label)), $url, NULL, t('Unsubscribe'), t('Cancel')); } /** diff --git a/og_ui/og_ui.test b/og_ui/og_ui.test index e729a1a3d..7beb30cc6 100644 --- a/og_ui/og_ui.test +++ b/og_ui/og_ui.test @@ -199,7 +199,7 @@ class OgUiSubscribeTestCase extends DrupalWebTestCase { $this->drupalGet('node/' . $node->nid); $this->assertText(t('Unsubscribe from group'), t('Member gets correct unsubscribe text.')); $this->clickLink(t('Unsubscribe from group')); - $this->drupalPost(NULL, array() , t('Remove')); + $this->drupalPost(NULL, array() , t('Unsubscribe')); $this->assertFalse(og_is_member('node', $node->nid, 'user', $user2, array(OG_STATE_ACTIVE, OG_STATE_PENDING)), t('User unsubscribed from group.')); From 0a45dbdf3a34ef264593b5d569c97804dc5b6deb Mon Sep 17 00:00:00 2001 From: minorOffense Date: Tue, 19 Jun 2018 14:39:45 +0200 Subject: [PATCH 15/16] #1865852 og_form_group_manager_validate() assumes the entity form has a language. --- og.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/og.module b/og.module index 23af037dd..b5f6bf553 100755 --- a/og.module +++ b/og.module @@ -786,7 +786,7 @@ function og_form_group_manager_validate($form, &$form_state) { return; } $entity = $form_state[$entity_type]; - $langcode = $form_state['values']['language']; + $langcode = isset($form_state['values']['language']) ? $form_state['values']['language'] : LANGUAGE_NONE; if (!isset($form_state['values']['uid']) || !isset($entity->uid)) { // There is no user ID property on the entity. From d4f40264a21882977fe5bdfd449c34c6d2661725 Mon Sep 17 00:00:00 2001 From: "axel.rutz" Date: Tue, 19 Jun 2018 14:47:28 +0200 Subject: [PATCH 16/16] #2057025 OG subscribe / join page not working with field permissions on group field. --- og_ui/og_ui.pages.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/og_ui/og_ui.pages.inc b/og_ui/og_ui.pages.inc index 36d0f3460..cfe61ced2 100644 --- a/og_ui/og_ui.pages.inc +++ b/og_ui/og_ui.pages.inc @@ -36,7 +36,7 @@ function og_ui_subscribe($entity_type, $etid, $field_name = NULL) { $account = user_load($user->uid); if (empty($field_name)) { - $field_name = og_get_best_group_audience_field('user', $account, $entity_type, $bundle); + $field_name = og_get_best_group_audience_field('user', $account, $entity_type, $bundle, TRUE); if (empty($field_name)) { // User entity has no group audience field. drupal_not_found();