function _notifications_fields in Notifications 6.3
Same name and namespace in other branches
- 6.2 notifications.module \_notifications_fields()
Normalize field format
Converts notifications field into an array with known structure which will be an array containing objects with key, type, value pairs
In some parts, fields are a key => value array They can be also an array of arrays or objects
2 calls to _notifications_fields()
- notifications_format_subscription in ./
notifications.module - Format subscription for display
- notifications_get_subscriptions in ./
notifications.module - Get subscriptions that fit a set of conditions.
File
- ./
notifications.module, line 1556 - Notifications module
Code
function _notifications_fields($source) {
$result = array();
if ($source) {
foreach ($source as $key => $data) {
if (is_object($data)) {
$field = $data;
}
elseif (is_array($data)) {
$field = (object) $data;
$field->key = $key;
}
else {
$field = new Stdclass();
$field->key = $key;
$field->type = $key;
$field->value = $data;
}
$result[] = $field;
}
}
return $result;
}