Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-10-22 08:05:21 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-10-22 08:05:21 +0400
commitd4f2a75a40b6f4a015ae29e8c4ea5547e20d9f22 (patch)
tree10aeec8e35b7d4cf4c7933deccbdac8ad7998418 /core/Settings
parenta385e5450cdf181e5bb84eeff0820ab22cc42d8f (diff)
refs #4126 started to work on plugin settings
Diffstat (limited to 'core/Settings')
-rw-r--r--core/Settings/Manager.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/core/Settings/Manager.php b/core/Settings/Manager.php
new file mode 100644
index 0000000000..045ae4e49b
--- /dev/null
+++ b/core/Settings/Manager.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+
+namespace Piwik\Settings;
+
+use Piwik\Piwik;
+
+/**
+ * Settings manager
+ *
+ * @package Piwik
+ * @subpackage Manager
+ */
+class Manager
+{
+ private static $settings = array();
+
+ /**
+ * @return \Piwik\Plugin\Settings[]
+ */
+ public static function getAllPluginSettings()
+ {
+ if (empty(static::$settings)) {
+
+ $pluginSettings = array('Login' => 'Piwik\\Plugins\\Login\\Settings');
+ // TODO: document hook and think about better name
+
+ Piwik::postEvent('Plugin.addSettings', $pluginSettings);
+
+ $settings = array();
+ foreach ($pluginSettings as $pluginName => $pluginSetting) {
+ $settings[$pluginName] = new $pluginSetting($pluginName);
+ }
+
+ static::$settings = $settings;
+ }
+
+ return static::$settings;
+ }
+
+ /**
+ * @return bool
+ */
+ public static function hasPluginSettingsForCurrentUser()
+ {
+ $settings = static::getAllPluginSettings();
+
+ foreach ($settings as $setting) {
+ $forUser = $setting->getSettingsForCurrentUser();
+ if (!empty($forUser)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}