blob: 7ad8af935e4e1afbc03aa424c6c1287b449e2b77 (
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
|
<?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\CorePluginsAdmin;
use Piwik\Db;
use Piwik\Menu\MenuAdmin;
use Piwik\Piwik;
/**
*/
class Menu extends \Piwik\Plugin\Menu
{
public function configureAdminMenu(MenuAdmin $menu)
{
$hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
$isAnonymous = Piwik::isUserIsAnonymous();
$isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
$pluginsUpdateMessage = '';
if ($hasSuperUserAcess && $isMarketplaceEnabled) {
$marketplace = new Marketplace();
$pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
$themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
if (!empty($pluginsHavingUpdate)) {
$pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate) + count($themesHavingUpdate));
}
}
if (!$isAnonymous) {
$menu->addPlatformItem(null, "", $order = 7);
}
if ($hasSuperUserAcess) {
$menu->addManageItem(Piwik::translate('General_Plugins') . $pluginsUpdateMessage,
$this->urlForAction('plugins', array('activated' => '')),
$order = 20);
}
if ($this->isAllowedToSeeMarketPlace()) {
$menu->addPlatformItem('CorePluginsAdmin_Marketplace',
$this->urlForAction('marketplace', array('activated' => '', 'mode' => 'user')),
$order = 5);
}
}
private function isAllowedToSeeMarketPlace()
{
$isAnonymous = Piwik::isUserIsAnonymous();
$isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
return $isMarketplaceEnabled && !$isAnonymous;
}
}
|