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

Admin.php « Controller « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6c58b46a6a9339f1aea905c13acf0c4adc4b490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?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
 */
use Piwik\Config;
use Piwik\Piwik;

/**
 * Parent class of all plugins Controllers with admin functions
 *
 * @package Piwik
 */
abstract class Piwik_Controller_Admin extends Piwik_Controller
{
    /**
     * Set the minimal variables in the view object
     * Extended by some admin view specific variables
     *
     * @param Piwik_View $view
     */
    protected function setBasicVariablesView($view)
    {
        parent::setBasicVariablesView($view);

        self::setBasicVariablesAdminView($view);
    }

    static public function displayWarningIfConfigFileNotWritable(Piwik_View $view )
    {
        $view->configFileNotWritable = !Config::getInstance()->isFileWritable();
    }

    static public function setBasicVariablesAdminView(Piwik_View $view)
    {
        $statsEnabled = Config::getInstance()->Tracker['record_statistics'];
        if ($statsEnabled == "0") {
            $view->statisticsNotRecorded = true;
        }

        $view->topMenu = Piwik_GetTopMenu();
        $view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName();

        $view->enableFrames = Config::getInstance()->General['enable_framed_settings'];
        if (!$view->enableFrames) {
            $view->setXFrameOptions('sameorigin');
        }

        $view->isSuperUser = Piwik::isUserIsSuperUser();

        // for old geoip plugin warning
        $view->usingOldGeoIPPlugin = \Piwik\PluginsManager::getInstance()->isPluginActivated('GeoIP');

        // for cannot find installed plugin warning
        $missingPlugins = \Piwik\PluginsManager::getInstance()->getMissingPlugins();
        if (!empty($missingPlugins)) {
            $pluginsLink = Piwik_Url::getCurrentQueryStringWithParametersModified(array(
                                                                                       'module' => 'CorePluginsAdmin', 'action' => 'index'
                                                                                  ));
            $view->missingPluginsWarning = Piwik_Translate('CoreAdminHome_MissingPluginsWarning', array(
                                                                                                       '<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>',
                                                                                                       '<a href="' . $pluginsLink . '"/>',
                                                                                                       '</a>'
                                                                                                  ));
        }
        
        self::checkPhpVersion($view);

        $view->menu = Piwik_GetAdminMenu();
    }
    
    /**
     * Check if the current PHP version is >= 5.3. If not, a warning is displayed
     * to the user.
     */
    private static function checkPhpVersion($view)
    {
        $view->phpVersion = PHP_VERSION;
        $view->phpIsNewEnough = version_compare($view->phpVersion, '5.3.0', '>=');
    }
}