I just enabled Organic Groups Access Control and now, every time a user with create permissions logs in it creates another separate group that user. Before I enabled Organic Groups Access Control it mirrored the roles of the LMS (Canvas) and added all users to the same group. When I disable Organic Groups Access Control everything goes back to how it should be. I really need this groups to be private.
I don't know Organic Groups Access Control well enough to tell what it is breaking in the lti_tool_provider module. Any help from the community would be much appreciated.
I have looked at the code and see that following lti_tool_provider function creates the groups on launch:
function lti_tool_provider_og_lti_tool_provider_launch_alter(&$launch_info, $account) {
$selected_group_bundle = variable_get('lti_tool_provider_og_group_mapping_bundle');
if ($selected_group_bundle != 'none:None') {
// Grant Group Membership and Group Role.
$users_groups = og_get_entity_groups('user', $account->uid);
// Find the group that matches the lti context_label.
$course_found = FALSE;
list($group_entity, $group_bundle) = explode(':', $selected_group_bundle);
$saved_settings = variable_get('lti_tool_provider_og_group_mapping', array());
$mapping_field = $saved_settings['context_id'];
foreach (og_get_all_group($group_entity) as $key => $group_id) {
$group_wrapper = entity_metadata_wrapper($group_entity, $group_id);
$fields = $group_wrapper->getPropertyInfo();
if (isset($fields[$mapping_field]) && $group_wrapper->{$mapping_field}->value() == $launch_info['context_id']) {
// Found the group that matches the context_id.
$course_found = TRUE;
$launch_info['course_entity_type'] = $group_entity;
$launch_info['course_entity_eid'] = $group_id;
// Add the user to the group.
if (!array_key_exists($group_entity, $users_groups) || !in_array($group_id, $users_groups[$group_entity])) {
og_group($group_entity, $group_id, array(
'entity_type' => 'user',
'entity' => $account->uid,
'field_name' => FALSE,
'state' => OG_STATE_ACTIVE,
));
}
// Grant the group roles.
if (isset($launch_info['roles'])) {
$found_roles = lti_tool_provider_og_search_roles($launch_info['roles']);
foreach ($found_roles as $lti_role => $found_role) {
og_role_grant($group_entity, $group_id, $account->uid, $found_role);
}
}
}
}
// Provision group.
// FIX THIS does not cope with non-node group bundles.
if (!$course_found && ($launch_info['context_id'] != NULL) &&
(variable_get('lti_tool_provider_og_provision_groups') == 1) &&
((variable_get('lti_tool_provider_og_provision_groups_anon') == 1) || (user_access('create ' . $group_bundle . ' content', $account)))) {
$node = new stdClass();
$node->type = $group_bundle;
$node->language = LANGUAGE_NONE;
node_object_prepare($node);
if (variable_get('lti_tool_provider_og_provision_groups_anon') == 1) {
$node->uid = 0;
}
$saved_settings = variable_get('lti_tool_provider_og_group_mapping', array());
foreach ($saved_settings as $variable => $field) {
if (isset($launch_info[$variable])) {
if ($field != 'none') {
if ($field != 'title') {
foreach (field_info_instances($group_entity, $group_bundle) as $entity_field) {
if (($field == $entity_field['field_name']) && (strcasecmp($entity_field['widget']['module'], 'text') == 0)) {
$node->{$field}[LANGUAGE_NONE][0]['value'] = $launch_info[$variable];
}
}
}
else {
$node->$field = isset($launch_info['custom_course_title']) ? $launch_info['custom_course_title'] : $launch_info[$variable];
}
}
}
}
node_save($node);
drupal_set_message(t('Group created for context.'), 'info');
$group_nid = $node->nid;
$launch_info['course_entity_type'] = $group_entity;
$launch_info['course_entity_eid'] = $group_nid;
}
if (isset($launch_info['course_entity_eid'])) {
$launch_info['destination'] = $launch_info['course_entity_type'] . '/' . $launch_info['course_entity_eid'];
}
else {
drupal_set_message(t('No course corresponding to @label exists.', array('@label' => $launch_info['context_label'])));
}
}
}
Comments
Comment #2
nsuit commentedComment #3
nsuit commentedComment #4
nsuit commentedComment #5
nsuit commentedComment #6
nsuit commentedComment #7
nsuit commentedComment #8
kenianbei commentedClosing as 7.x is no longer supported.