You are here

function Notifications_Subscription::get_conditions in Notifications 6.4

Same name and namespace in other branches
  1. 7 notifications.subscription.inc \Notifications_Subscription::get_conditions()

Get fields as array of field => value pairs

Duplicate fields are returned as field => array(value1, value2...)

Parameters

$type: Optional to just return the values for some field type

4 calls to Notifications_Subscription::get_conditions()
Notifications_Subscription::build_link in includes/notifications_subscription.class.inc
Build subscribe /unsubscribe link
Notifications_Subscription::has_condition in includes/notifications_subscription.class.inc
Check whether we have a given condition
Notifications_Subscription::serialize_fields in includes/notifications_subscription.class.inc
Order and serialize fields so we can get a unique signature for this subscription fields
Notifications_Subscription::__get in includes/notifications_subscription.class.inc
Magic method, get protected properties

File

includes/notifications_subscription.class.inc, line 443
Drupal Notifications Framework - Default class file

Class

Notifications_Subscription
Message destination class

Code

function get_conditions($type = NULL) {
  $list = array();
  foreach ($this
    ->get_fields() as $field) {

    // We cannot simply use isset() because the value may be NULL
    if (!array_key_exists($field->field, $list)) {
      $list[$field->field] = $field->value;
    }
    elseif (is_array($list[$field->field])) {
      $list[$field->field][] = $field->value;
    }
    else {
      $list[$field->field] = array(
        $list[$field->field],
        $field->value,
      );
    }
  }
  if (isset($type)) {
    return isset($list[$type]) ? $list[$type] : NULL;
  }
  else {
    return $list;
  }
}