You are here

function party_hat_party_data_sets_alter in Party 7

Same name and namespace in other branches
  1. 8.2 modules/party_hat/party_hat.module \party_hat_party_data_sets_alter()

Implements hook_party_data_sets_alter().

File

modules/party_hat/party_hat.module, line 228
party_hat.module Provides an extensible access system for parties.

Code

function party_hat_party_data_sets_alter(&$party_data_sets, $party) {

  // Get the party_hats off this party.
  $party_hats = party_hat_get_hats($party);
  $hats_sets = array();

  // Collect all the data sets this party should have.
  foreach ($party_hats as $hat) {
    $hats_sets = array_merge($hats_sets, party_hat_get_hat_data_sets($hat));
  }

  // Remove data sets from party_data_sets that are not in the hats_sets array.
  foreach ($party_data_sets as $key => $data_set) {
    if (!in_array($data_set, $hats_sets)) {
      unset($party_data_sets[$key]);
    }
  }
}