-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from jbrule/v3Compatibility
V3 compatibility
- Loading branch information
Showing
6 changed files
with
186 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\AdminNotification; | ||
|
||
use Piwik\Piwik; | ||
use Piwik\Notification; | ||
use Piwik\Settings\Setting; | ||
use Piwik\Settings\FieldConfig; | ||
|
||
/** | ||
* Defines Settings for AdminNotification. | ||
* | ||
* Usage like this: | ||
* $settings = new SystemSettings(); | ||
* $settings->metric->getValue(); | ||
* $settings->description->getValue(); | ||
*/ | ||
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings | ||
{ | ||
/** @var Setting */ | ||
public $enabled; | ||
|
||
/** @var Setting */ | ||
public $context; | ||
|
||
/** @var Setting */ | ||
public $messageTitle; | ||
|
||
/** @var Setting */ | ||
public $message; | ||
|
||
protected function init() | ||
{ | ||
|
||
$this->enabled = $this->createEnabledSetting(); | ||
|
||
$this->context = $this->createContextSetting(); | ||
|
||
$this->messageTitle = $this->createTitleSetting(); | ||
|
||
$this->message = $this->createMessageSetting(); | ||
|
||
} | ||
|
||
private function createEnabledSetting() | ||
{ | ||
return $this->makeSetting('enabled', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { | ||
$field->title = $this->t('EnabledSettingTitle'); | ||
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; | ||
$field->description = $this->t('EnabledSettingDescription'); | ||
$field->readableByCurrentUser = true; | ||
}); | ||
} | ||
|
||
private function createContextSetting() | ||
{ | ||
return $this->makeSetting('context', $default = "info", FieldConfig::TYPE_STRING, function (FieldConfig $field) { | ||
$field->title = $this->t('ContextSettingTitle'); | ||
$field->condition = 'enabled'; | ||
$field->uiControl = FieldConfig::UI_CONTROL_SINGLE_SELECT; | ||
$field->description = $this->t('ContextSettingDescription'); | ||
$field->availableValues = array(Notification::CONTEXT_INFO => Notification::CONTEXT_INFO, | ||
Notification::CONTEXT_ERROR => Notification::CONTEXT_ERROR, | ||
Notification::CONTEXT_SUCCESS => Notification::CONTEXT_SUCCESS, | ||
Notification::CONTEXT_WARNING => Notification::CONTEXT_WARNING); | ||
}); | ||
} | ||
|
||
private function createTitleSetting() | ||
{ | ||
return $this->makeSetting('title', $default = "Message from Piwik Administrator", FieldConfig::TYPE_STRING, function (FieldConfig $field) { | ||
$field->title = $this->t('TitleSettingTitle'); | ||
$field->condition = 'enabled'; | ||
$field->uiControl = FieldConfig::UI_CONTROL_TEXT; | ||
//$field->uiControlAttributes = array("size"=> 65); | ||
$field->description = $this->t('TitleSettingDescription'); | ||
}); | ||
} | ||
|
||
private function createMessageSetting() | ||
{ | ||
return $this->makeSetting('message', $default = "", FieldConfig::TYPE_STRING, function (FieldConfig $field) { | ||
$field->title = $this->t('MessageSettingTitle'); | ||
$field->condition = 'enabled'; | ||
$field->uiControl = FieldConfig::UI_CONTROL_TEXTAREA; | ||
$field->description = $this->t('MessageSettingDescription'); | ||
}); | ||
} | ||
|
||
private function t($translate_token){ | ||
return Piwik::translate("AdminNotification_".$translate_token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
{ | ||
"name": "AdminNotification", | ||
"version": "0.1.2", | ||
"description": "Adds the ability for Piwik administrators to include an informative message to all user's dashboards. This uses the built in Notification function.", | ||
"license": "GPL v3+", | ||
"keywords": ["admin message", "notification"], | ||
"homepage": "https://github.com/jbrule/piwikplugin-AdminNotification", | ||
"theme": false, | ||
"require": { | ||
"piwik": ">=2.12.0" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Josh Brule", | ||
"email": "", | ||
"homepage": "https://www.linkedin.com/pub/joshua-brule/15/326/9b9" | ||
} | ||
] | ||
} | ||
{ | ||
"name": "AdminNotification", | ||
"version": "3.0.0", | ||
"description": "Adds the ability for Piwik administrators to include an informative message to all user's dashboards. This uses the built in Notification function.", | ||
"license": "GPL v3+", | ||
"keywords": [ | ||
"admin message", | ||
"notification" | ||
], | ||
"homepage": "https:\/\/github.com\/jbrule\/piwikplugin-AdminNotification", | ||
"theme": false, | ||
"require": { | ||
"piwik": ">=2.12.0,<4.0.0-b1" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Josh Brule", | ||
"email": "", | ||
"homepage": "https:\/\/github.com\/jbrule" | ||
} | ||
] | ||
} |