function Notifications_Subscription::__construct in Notifications 6.4
Class constructor
Overrides Messaging_Object::__construct
File
- includes/
notifications_subscription.class.inc, line 76 - Drupal Notifications Framework - Default class file
Class
- Notifications_Subscription
- Message destination class
Code
function __construct($object = NULL) {
$this->status = self::STATUS_ACTIVE;
if ($object) {
$properties = (array) $object;
foreach ($properties as $key => $value) {
// Set old fields format (array of field => value)
if ($key == 'fields' || $key == 'destination') {
$this
->__set($key, $value);
}
else {
$this->{$key} = $value;
}
}
}
// Default values for new objects
if (empty($this->sid)) {
$this->created = time();
// Set some properties from subscription type
if (!empty($this->type) && ($defaults = notifications_subscription_types($this->type))) {
foreach (array(
'event_type',
'module',
'cron',
'conditions',
) as $field) {
$value = notifications_subscription_types($this->type, $field);
if (!isset($properties[$field]) && isset($defaults[$field])) {
$this->{$field} = $defaults[$field];
}
}
}
}
}