diff --git a/AdminNotification.php b/AdminNotification.php index 1880478..3e60cef 100644 --- a/AdminNotification.php +++ b/AdminNotification.php @@ -43,7 +43,7 @@ public function setNotificationV3() $notification = new Notification($settings->message->getValue()); $notification->title = $settings->messageTitle->getValue(); $notification->context = $settings->context->getValue(); - $notification->type = Notification::TYPE_PERSISTENT; + $notification->type = $settings->type->getValue(); //$notification->priority = Notification::PRIORITY_MAX; //echo "NOTIFY"; diff --git a/SystemSettings.php b/SystemSettings.php index 295ce5c..ee705d0 100644 --- a/SystemSettings.php +++ b/SystemSettings.php @@ -36,6 +36,9 @@ class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings /** @var Setting */ public $message; + /** @var Setting */ + public $type; + protected function init() { @@ -46,6 +49,8 @@ protected function init() $this->messageTitle = $this->createTitleSetting(); $this->message = $this->createMessageSetting(); + + $this->type = $this->createTypeSetting(); } private function createEnabledSetting() @@ -103,6 +108,24 @@ private function createMessageSetting() }); } + private function createTypeSetting() + { + return $this->makeSetting( + 'type', + $default = "persistent", + FieldConfig::TYPE_STRING, + function (FieldConfig $field) { + $field->title = $this->t('TypeSettingTitle'); + $field->condition = 'enabled'; + $field->uiControl = FieldConfig::UI_CONTROL_SINGLE_SELECT; + $field->description = $this->t('TypeSettingDescription'); + $field->availableValues = array(Notification::TYPE_PERSISTENT => Notification::TYPE_PERSISTENT, + Notification::TYPE_TRANSIENT => Notification::TYPE_TRANSIENT, + Notification::TYPE_TOAST => Notification::TYPE_TOAST); + } + ); + } + private function t($translate_token) { return Piwik::translate("AdminNotification_" . $translate_token); diff --git a/lang/en.json b/lang/en.json index b904251..6b2547f 100644 --- a/lang/en.json +++ b/lang/en.json @@ -8,6 +8,9 @@ "ContextSettingTitle": "Context", "ContextSettingDescription": "Sets what type of message should be displayed (affects color).", "TitleSettingTitle": "Title", - "TitleSettingDescription": "Sets the title of the message. This will be dislayed in bold with the message." + "TitleSettingDescription": "Sets the title of the message. This will be dislayed in bold with the message.", + "TypeSettingTitle": "Type", + "TypeSettingDescription": "Persistent (display until user closes the notification), Transient (displays once, disappear on page reload) or Toast (displayed for a few seconds, and the fades out)" + } } \ No newline at end of file