mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: Add always on for notifications
This commit is contained in:
parent
ee24867435
commit
1a98f25c92
@ -83,9 +83,6 @@ class NotificationsExtension extends DataExtension
|
|||||||
$items = $this->owner->Notifications();
|
$items = $this->owner->Notifications();
|
||||||
$time = time();
|
$time = time();
|
||||||
|
|
||||||
return $items->filter([
|
return $items->where("AlwaysOn='1' OR (DateOn <= '".date('Y-m-d', $time)."' AND DateOff >= '".date('Y-m-d', $time)."')");
|
||||||
'DateOn:LessThanOrEqual' => date('Y-m-d', $time),
|
|
||||||
'DateOff:GreaterThanOrEqual' => date('Y-m-d', $time),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ class Notification extends DataObject
|
|||||||
'Content' => 'Text',
|
'Content' => 'Text',
|
||||||
'DateOn' => 'Date',
|
'DateOn' => 'Date',
|
||||||
'DateOff' => 'Date',
|
'DateOff' => 'Date',
|
||||||
|
'AlwaysOn' => 'Boolean(0)',
|
||||||
'Area' => 'Enum("Site","Site")',
|
'Area' => 'Enum("Site","Site")',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ class Notification extends DataObject
|
|||||||
private static $summary_fields = [
|
private static $summary_fields = [
|
||||||
'Title' => 'Title',
|
'Title' => 'Title',
|
||||||
'Content' => 'Text',
|
'Content' => 'Text',
|
||||||
|
'AlwaysOn' => 'Always On',
|
||||||
'DateOn' => 'Turn on date',
|
'DateOn' => 'Turn on date',
|
||||||
'DateOff' => 'Turn off date',
|
'DateOff' => 'Turn off date',
|
||||||
];
|
];
|
||||||
@ -73,13 +75,6 @@ class Notification extends DataObject
|
|||||||
{
|
{
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
if (!$this->getField('DateOn') || !$this->getField('DateOff')) {
|
|
||||||
return $result->addError(
|
|
||||||
'Turn on and turn off dates are required.',
|
|
||||||
ValidationResult::TYPE_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->getField('Content')) {
|
if (!$this->getField('Content')) {
|
||||||
return $result->addError(
|
return $result->addError(
|
||||||
'Text field required.',
|
'Text field required.',
|
||||||
|
Loading…
Reference in New Issue
Block a user