You are here

function og_context_negotiation_set in Organic groups 7.2

Same name and namespace in other branches
  1. 7 og_context/og_context.module \og_context_negotiation_set()

Save a list of language providers.

Parameters

$type: The language negotiation type.

$language_providers: An array of language provider ids.

1 call to og_context_negotiation_set()
og_context_configure_form_submit in og_context/og_context.admin.inc
Submit handler for og_context negotiation settings.

File

og_context/og_context.module, line 345
Get a group from a viewed page.

Code

function og_context_negotiation_set($group_context_providers) {
  $type = 'group_context';

  // Save only the necessary fields.
  $provider_fields = array(
    'callbacks',
  );
  $negotiation = array();
  $providers_weight = array();
  $defined_providers = og_context_negotiation_info();

  // Initialize the providers weight list.
  foreach ($group_context_providers as $id => $provider) {
    $providers_weight[$id] = og_context_provider_weight($provider);
  }

  // Order providers list by weight.
  asort($providers_weight);
  foreach ($providers_weight as $id => $weight) {
    if (isset($defined_providers[$id])) {
      $provider = $defined_providers[$id];
      $provider_data = array();
      foreach ($provider_fields as $field) {
        if (isset($provider[$field])) {
          $provider_data[$field] = $provider[$field];
        }
      }
      $negotiation[$id] = $provider_data;
    }
  }
  variable_set("og_context_negotiation_{$type}", $negotiation);
}