You are here

function notifications_option_array_get in Notifications 7

Get an array of options indexed by type

Example: If we want to get the 'enabled' property for all subscription types

  • $name = 'subscription_types'
  • $types = array('type1', 'type2'...)

We will iterate over all the 'notifications_option_subscription_type_$type' array variables and get the $property we want for them

File

./notifications.module, line 1160
Notifications module

Code

function notifications_option_array_get($name, $type_list, $property, $default = NULL) {
  $type_values = array();
  foreach ($type_list as $type) {

    // Example 'notifications_option_subscription_types_thread' => array()
    $value = notifications_option_get($name . '_' . $type, array());
    if (isset($value[$property])) {
      $type_values[$type] = $value[$property];
    }
    elseif (isset($default)) {
      $type_values[$type] = $default;
    }
  }
  return $type_values;
}