update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
9abe039dc8
commit
47263617c5
92 changed files with 418860 additions and 226988 deletions
|
|
@ -0,0 +1,44 @@
|
|||
<?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\Commands;
|
||||
|
||||
use Piwik\Plugin\ConsoleCommand;
|
||||
use Piwik\Plugin\Manager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* plugin:activate console command.
|
||||
*/
|
||||
class ActivatePlugin extends ConsoleCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('plugin:activate');
|
||||
$this->setDescription('Activate a plugin.');
|
||||
$this->addArgument('plugin', InputArgument::REQUIRED, 'The plugin name.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$pluginManager = Manager::getInstance();
|
||||
|
||||
$plugin = $input->getArgument('plugin');
|
||||
|
||||
if ($pluginManager->isPluginActivated($plugin)) {
|
||||
$output->writeln('<comment>The plugin is already activated.</comment>');
|
||||
return;
|
||||
}
|
||||
|
||||
$pluginManager->activatePlugin($plugin);
|
||||
|
||||
$output->writeln("Activated plugin <info>$plugin</info>");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?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\Commands;
|
||||
|
||||
use Piwik\Plugin\ConsoleCommand;
|
||||
use Piwik\Plugin\Manager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* plugin:deactivate console command.
|
||||
*/
|
||||
class DeactivatePlugin extends ConsoleCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('plugin:deactivate');
|
||||
$this->setDescription('Deactivate a plugin.');
|
||||
$this->addArgument('plugin', InputArgument::REQUIRED, 'The plugin name.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$pluginManager = Manager::getInstance();
|
||||
|
||||
$plugin = $input->getArgument('plugin');
|
||||
|
||||
if (!$pluginManager->isPluginActivated($plugin)) {
|
||||
$output->writeln('<comment>The plugin is already deactivated.</comment>');
|
||||
return;
|
||||
}
|
||||
|
||||
$pluginManager->deactivatePlugin($plugin);
|
||||
|
||||
$output->writeln("Deactivated plugin <info>$plugin</info>");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?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\Commands;
|
||||
|
||||
use Piwik\Plugin\ConsoleCommand;
|
||||
use Piwik\Plugin\Manager;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* plugin:list console command.
|
||||
*/
|
||||
class ListPlugins extends ConsoleCommand
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('plugin:list');
|
||||
$this->setDescription('List installed plugins.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$pluginManager = Manager::getInstance();
|
||||
|
||||
$plugins = $pluginManager->getInstalledPluginsName();
|
||||
|
||||
$plugins = array_map(function ($plugin) use ($pluginManager) {
|
||||
return array(
|
||||
'<info>' . $plugin . '</info>',
|
||||
$pluginManager->isPluginBundledWithCore($plugin) ? 'Core' : 'Optional',
|
||||
$pluginManager->isPluginActivated($plugin) ? 'Activated' : '<comment>Not activated</comment>',
|
||||
);
|
||||
}, $plugins);
|
||||
|
||||
// Sort Core plugins first
|
||||
usort($plugins, function ($a, $b) {
|
||||
return strcmp($a[1], $b[1]);
|
||||
});
|
||||
|
||||
$table = new Table($output);
|
||||
$table
|
||||
->setHeaders(array('Plugin', 'Core or optional?', 'Status'))
|
||||
->setRows($plugins)
|
||||
;
|
||||
$table->render();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,8 +8,10 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\CorePluginsAdmin;
|
||||
|
||||
use Exception;
|
||||
use Piwik\API\Request;
|
||||
use Piwik\Common;
|
||||
use Piwik\Exception\MissingFilePermissionException;
|
||||
use Piwik\Filechecks;
|
||||
use Piwik\Filesystem;
|
||||
use Piwik\Nonce;
|
||||
|
|
@ -17,13 +19,11 @@ use Piwik\Notification;
|
|||
use Piwik\Piwik;
|
||||
use Piwik\Plugin;
|
||||
use Piwik\Settings\Manager as SettingsManager;
|
||||
use Piwik\Translation\Translator;
|
||||
use Piwik\Url;
|
||||
use Piwik\View;
|
||||
use Piwik\Version;
|
||||
use Exception;
|
||||
use Piwik\View;
|
||||
|
||||
/**
|
||||
*/
|
||||
class Controller extends Plugin\ControllerAdmin
|
||||
{
|
||||
const UPDATE_NONCE = 'CorePluginsAdmin.updatePlugin';
|
||||
|
|
@ -35,6 +35,50 @@ class Controller extends Plugin\ControllerAdmin
|
|||
private $validSortMethods = array('popular', 'newest', 'alpha');
|
||||
private $defaultSortMethod = 'popular';
|
||||
|
||||
/**
|
||||
* @var Translator
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
public function __construct(Translator $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function marketplace()
|
||||
{
|
||||
self::dieIfMarketplaceIsDisabled();
|
||||
|
||||
$show = Common::getRequestVar('show', 'plugins', 'string');
|
||||
$query = Common::getRequestVar('query', '', 'string', $_POST);
|
||||
$sort = Common::getRequestVar('sort', $this->defaultSortMethod, 'string');
|
||||
if (!in_array($sort, $this->validSortMethods)) {
|
||||
$sort = $this->defaultSortMethod;
|
||||
}
|
||||
$mode = Common::getRequestVar('mode', 'admin', 'string');
|
||||
if (!in_array($mode, array('user', 'admin'))) {
|
||||
$mode = 'admin';
|
||||
}
|
||||
|
||||
$view = $this->configureView('@CorePluginsAdmin/marketplace');
|
||||
|
||||
$marketplace = new Marketplace();
|
||||
|
||||
$showThemes = ($show === 'themes');
|
||||
$view->plugins = $marketplace->searchPlugins($query, $sort, $showThemes);
|
||||
$view->showThemes = $showThemes;
|
||||
$view->mode = $mode;
|
||||
$view->query = $query;
|
||||
$view->sort = $sort;
|
||||
$view->installNonce = Nonce::getNonce(static::INSTALL_NONCE);
|
||||
$view->updateNonce = Nonce::getNonce(static::UPDATE_NONCE);
|
||||
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
private function createUpdateOrInstallView($template, $nonceName)
|
||||
{
|
||||
static::dieIfMarketplaceIsDisabled();
|
||||
|
|
@ -88,7 +132,7 @@ class Controller extends Plugin\ControllerAdmin
|
|||
$nonce = Common::getRequestVar('nonce', null, 'string');
|
||||
|
||||
if (!Nonce::verifyNonce(static::INSTALL_NONCE, $nonce)) {
|
||||
throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch'));
|
||||
throw new \Exception($this->translator->translate('General_ExceptionNonceMismatch'));
|
||||
}
|
||||
|
||||
Nonce::discardNonce(static::INSTALL_NONCE);
|
||||
|
|
@ -148,6 +192,30 @@ class Controller extends Plugin\ControllerAdmin
|
|||
return $view->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function browsePlugins()
|
||||
{
|
||||
$this->redirectToIndex('CorePluginsAdmin', 'marketplace');
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function browseThemes()
|
||||
{
|
||||
$this->redirectToIndex('CorePluginsAdmin', 'marketplace', null, null, null, array('show' => 'themes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function userBrowsePlugins()
|
||||
{
|
||||
$this->redirectToIndex('CorePluginsAdmin', 'marketplace', null, null, null, array('mode' => 'user'));
|
||||
}
|
||||
|
||||
private function dieIfMarketplaceIsDisabled()
|
||||
{
|
||||
if (!CorePluginsAdmin::isMarketplaceEnabled()) {
|
||||
|
|
@ -167,54 +235,6 @@ class Controller extends Plugin\ControllerAdmin
|
|||
}
|
||||
}
|
||||
|
||||
private function createBrowsePluginsOrThemesView($template, $themesOnly)
|
||||
{
|
||||
static::dieIfMarketplaceIsDisabled();
|
||||
|
||||
$query = Common::getRequestVar('query', '', 'string', $_POST);
|
||||
$sort = Common::getRequestVar('sort', $this->defaultSortMethod, 'string');
|
||||
|
||||
if (!in_array($sort, $this->validSortMethods)) {
|
||||
$sort = $this->defaultSortMethod;
|
||||
}
|
||||
|
||||
$view = $this->configureView('@CorePluginsAdmin/' . $template);
|
||||
|
||||
$marketplace = new Marketplace();
|
||||
$view->plugins = $marketplace->searchPlugins($query, $sort, $themesOnly);
|
||||
|
||||
$view->query = $query;
|
||||
$view->sort = $sort;
|
||||
$view->installNonce = Nonce::getNonce(static::INSTALL_NONCE);
|
||||
$view->updateNonce = Nonce::getNonce(static::UPDATE_NONCE);
|
||||
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
public function browsePlugins()
|
||||
{
|
||||
$view = $this->createBrowsePluginsOrThemesView('browsePlugins', $themesOnly = false);
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function browseThemes()
|
||||
{
|
||||
$view = $this->createBrowsePluginsOrThemesView('browseThemes', $themesOnly = true);
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
static::dieIfMarketplaceIsDisabled();
|
||||
|
||||
$view = $this->configureView('@CorePluginsAdmin/extend');
|
||||
$view->installNonce = Nonce::getNonce(static::INSTALL_NONCE);
|
||||
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
private function createPluginsOrThemesView($template, $themesOnly)
|
||||
{
|
||||
Piwik::checkUserHasSuperUserAccess();
|
||||
|
|
@ -227,7 +247,7 @@ class Controller extends Plugin\ControllerAdmin
|
|||
$view->deactivateNonce = Nonce::getNonce(static::DEACTIVATE_NONCE);
|
||||
$view->pluginsInfo = $this->getPluginsInfo($themesOnly);
|
||||
|
||||
$users = \Piwik\Plugins\UsersManager\API::getInstance()->getUsers();
|
||||
$users = Request::processRequest('UsersManager.getUsers');
|
||||
$view->otherUsersCount = count($users) - 1;
|
||||
$view->themeEnabled = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled()->getPluginName();
|
||||
|
||||
|
|
@ -242,7 +262,10 @@ class Controller extends Plugin\ControllerAdmin
|
|||
try {
|
||||
$marketplace = new Marketplace();
|
||||
$view->marketplacePluginNames = $marketplace->getAvailablePluginNames($themesOnly);
|
||||
$view->pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly);
|
||||
|
||||
$pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate(true);
|
||||
$themesHavingUpdate = $marketplace->getPluginsHavingUpdate(false);
|
||||
$view->pluginsHavingUpdate = $pluginsHavingUpdate + $themesHavingUpdate;
|
||||
} catch(Exception $e) {
|
||||
// curl exec connection error (ie. server not connected to internet)
|
||||
}
|
||||
|
|
@ -283,28 +306,33 @@ class Controller extends Plugin\ControllerAdmin
|
|||
protected function getPluginsInfo($themesOnly = false)
|
||||
{
|
||||
$pluginManager = \Piwik\Plugin\Manager::getInstance();
|
||||
$plugins = $pluginManager->returnLoadedPluginsInfo();
|
||||
$plugins = $pluginManager->loadAllPluginsAndGetTheirInfo();
|
||||
|
||||
foreach ($plugins as $pluginName => &$plugin) {
|
||||
|
||||
$plugin['isCorePlugin'] = $pluginManager->isPluginBundledWithCore($pluginName);
|
||||
|
||||
if (!empty($plugin['info']['description'])) {
|
||||
$plugin['info']['description'] = $this->translator->translate($plugin['info']['description']);
|
||||
}
|
||||
|
||||
if (!isset($plugin['info'])) {
|
||||
|
||||
$suffix = Piwik::translate('CorePluginsAdmin_PluginNotWorkingAlternative');
|
||||
$suffix = $this->translator->translate('CorePluginsAdmin_PluginNotWorkingAlternative');
|
||||
// If the plugin has been renamed, we do not show message to ask user to update plugin
|
||||
if($pluginName != Request::renameModule($pluginName)) {
|
||||
list($pluginNameRenamed, $methodName) = Request::getRenamedModuleAndAction($pluginName, 'index');
|
||||
if ($pluginName != $pluginNameRenamed) {
|
||||
$suffix = "You may uninstall the plugin or manually delete the files in piwik/plugins/$pluginName/";
|
||||
}
|
||||
|
||||
$description = '<strong><em>'
|
||||
. Piwik::translate('CorePluginsAdmin_PluginNotCompatibleWith', array($pluginName, self::getPiwikVersion()))
|
||||
. $this->translator->translate('CorePluginsAdmin_PluginNotCompatibleWith', array($pluginName, self::getPiwikVersion()))
|
||||
. '</strong><br/>'
|
||||
. $suffix
|
||||
. '</em>';
|
||||
$plugin['info'] = array(
|
||||
'description' => $description,
|
||||
'version' => Piwik::translate('General_Unknown'),
|
||||
'version' => $this->translator->translate('General_Unknown'),
|
||||
'theme' => false,
|
||||
);
|
||||
}
|
||||
|
|
@ -334,6 +362,8 @@ class Controller extends Plugin\ControllerAdmin
|
|||
|
||||
public function safemode($lastError = array())
|
||||
{
|
||||
$this->tryToRepairPiwik();
|
||||
|
||||
if (empty($lastError)) {
|
||||
$lastError = array(
|
||||
'message' => Common::getRequestVar('error_message', null, 'string'),
|
||||
|
|
@ -359,15 +389,15 @@ class Controller extends Plugin\ControllerAdmin
|
|||
return $message;
|
||||
}
|
||||
|
||||
if(Common::isPhpCliMode()) {
|
||||
Piwik_ExitWithMessage("Error:" . var_export($lastError, true));
|
||||
if (Common::isPhpCliMode()) { // TODO: I can't find how this will ever get called / safeMode is never set for Console
|
||||
throw new Exception("Error: " . var_export($lastError, true));
|
||||
}
|
||||
|
||||
$view = new View('@CorePluginsAdmin/safemode');
|
||||
$view->lastError = $lastError;
|
||||
$view->isSuperUser = Piwik::hasUserSuperUserAccess();
|
||||
$view->isAnonymousUser = Piwik::isUserIsAnonymous();
|
||||
$view->plugins = Plugin\Manager::getInstance()->returnLoadedPluginsInfo();
|
||||
$view->plugins = Plugin\Manager::getInstance()->loadAllPluginsAndGetTheirInfo();
|
||||
$view->deactivateNonce = Nonce::getNonce(static::DEACTIVATE_NONCE);
|
||||
$view->uninstallNonce = Nonce::getNonce(static::UNINSTALL_NONCE);
|
||||
$view->emailSuperUser = implode(',', Piwik::getAllSuperUserAccessEmailAddresses());
|
||||
|
|
@ -401,17 +431,17 @@ class Controller extends Plugin\ControllerAdmin
|
|||
$actionToRedirect = 'themes';
|
||||
}
|
||||
|
||||
$message = Piwik::translate('CorePluginsAdmin_SuccessfullyActicated', array($pluginName));
|
||||
if (SettingsManager::hasPluginSettingsForCurrentUser($pluginName)) {
|
||||
$message = $this->translator->translate('CorePluginsAdmin_SuccessfullyActicated', array($pluginName));
|
||||
if (SettingsManager::hasSystemPluginSettingsForCurrentUser($pluginName)) {
|
||||
$target = sprintf('<a href="index.php%s#%s">',
|
||||
Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'pluginSettings')),
|
||||
Url::getCurrentQueryStringWithParametersModified(array('module' => 'CoreAdminHome', 'action' => 'adminPluginSettings')),
|
||||
$pluginName);
|
||||
$message .= ' ' . Piwik::translate('CorePluginsAdmin_ChangeSettingsPossible', array($target, '</a>'));
|
||||
$message .= ' ' . $this->translator->translate('CorePluginsAdmin_ChangeSettingsPossible', array($target, '</a>'));
|
||||
}
|
||||
|
||||
$notification = new Notification($message);
|
||||
$notification->raw = true;
|
||||
$notification->title = Piwik::translate('General_WellDone');
|
||||
$notification->title = $this->translator->translate('General_WellDone');
|
||||
$notification->context = Notification::CONTEXT_SUCCESS;
|
||||
Notification\Manager::notify('CorePluginsAdmin_PluginActivated', $notification);
|
||||
|
||||
|
|
@ -439,11 +469,15 @@ class Controller extends Plugin\ControllerAdmin
|
|||
$path = Filesystem::getPathToPiwikRoot() . '/plugins/' . $pluginName . '/';
|
||||
$messagePermissions = Filechecks::getErrorMessageMissingPermissions($path);
|
||||
|
||||
$messageIntro = Piwik::translate("Warning: \"%s\" could not be uninstalled. Piwik did not have enough permission to delete the files in $path. ",
|
||||
$messageIntro = $this->translator->translate("Warning: \"%s\" could not be uninstalled. Piwik did not have enough permission to delete the files in $path. ",
|
||||
$pluginName);
|
||||
$exitMessage = $messageIntro . "<br/><br/>" . $messagePermissions;
|
||||
$exitMessage = $messageIntro . "<br/><br/>" . $messagePermissions;
|
||||
$exitMessage .= "<br> Or manually delete this directory (using FTP or SSH access)";
|
||||
Piwik_ExitWithMessage($exitMessage, $optionalTrace = false, $optionalLinks = false, $optionalLinkBack = true);
|
||||
|
||||
$ex = new MissingFilePermissionException($exitMessage);
|
||||
$ex->setIsHtmlMessage();
|
||||
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$this->redirectAfterModification($redirectAfter);
|
||||
|
|
@ -456,7 +490,7 @@ class Controller extends Plugin\ControllerAdmin
|
|||
$nonce = Common::getRequestVar('nonce', null, 'string');
|
||||
|
||||
if (!Nonce::verifyNonce($nonceName, $nonce)) {
|
||||
throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch'));
|
||||
throw new \Exception($this->translator->translate('General_ExceptionNonceMismatch'));
|
||||
}
|
||||
|
||||
Nonce::discardNonce($nonceName);
|
||||
|
|
@ -475,7 +509,16 @@ class Controller extends Plugin\ControllerAdmin
|
|||
|
||||
private function getPluginNamesHavingSettingsForCurrentUser()
|
||||
{
|
||||
return array_keys(SettingsManager::getPluginSettingsForCurrentUser());
|
||||
return SettingsManager::getPluginNamesHavingSystemSettings();
|
||||
}
|
||||
|
||||
private function tryToRepairPiwik()
|
||||
{
|
||||
// in case any opcaches etc were not cleared after an update for instance. Might prevent from getting the
|
||||
// error again
|
||||
try {
|
||||
Filesystem::deleteAllCacheOnUpdate();
|
||||
} catch (Exception $e) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,105 +9,27 @@
|
|||
namespace Piwik\Plugins\CorePluginsAdmin;
|
||||
|
||||
use Piwik\Config;
|
||||
use Piwik\Menu\MenuAdmin;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin;
|
||||
use Piwik\ScheduledTask;
|
||||
use Piwik\ScheduledTime;
|
||||
use Piwik\Plugin\Manager as PluginManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class CorePluginsAdmin extends \Piwik\Plugin
|
||||
{
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
* @see Piwik\Plugin::registerEvents
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
public function registerEvents()
|
||||
{
|
||||
return array(
|
||||
'Menu.Admin.addItems' => 'addMenu',
|
||||
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
|
||||
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
|
||||
'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
|
||||
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all scheduled tasks executed by this plugin.
|
||||
*/
|
||||
public function getScheduledTasks(&$tasks)
|
||||
{
|
||||
$tasks[] = new ScheduledTask(
|
||||
'Piwik\Plugins\CorePluginsAdmin\MarketplaceApiClient',
|
||||
'clearAllCacheEntries',
|
||||
null,
|
||||
ScheduledTime::factory('daily'),
|
||||
ScheduledTask::LOWEST_PRIORITY
|
||||
);
|
||||
|
||||
if (self::isMarketplaceEnabled()) {
|
||||
$sendUpdateNotification = new ScheduledTask ($this,
|
||||
'sendNotificationIfUpdatesAvailable',
|
||||
null,
|
||||
ScheduledTime::factory('daily'),
|
||||
ScheduledTask::LOWEST_PRIORITY);
|
||||
$tasks[] = $sendUpdateNotification;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendNotificationIfUpdatesAvailable()
|
||||
{
|
||||
$updateCommunication = new UpdateCommunication();
|
||||
if ($updateCommunication->isEnabled()) {
|
||||
$updateCommunication->sendNotificationIfUpdatesAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
public function getStylesheetFiles(&$stylesheets)
|
||||
{
|
||||
$stylesheets[] = "plugins/CorePluginsAdmin/stylesheets/marketplace.less";
|
||||
$stylesheets[] = "plugins/CorePluginsAdmin/stylesheets/plugins_admin.less";
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
$pluginsUpdateMessage = '';
|
||||
$themesUpdateMessage = '';
|
||||
|
||||
if (Piwik::hasUserSuperUserAccess() && static::isMarketplaceEnabled()) {
|
||||
$marketplace = new Marketplace();
|
||||
$pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
|
||||
$themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
|
||||
|
||||
if (!empty($pluginsHavingUpdate)) {
|
||||
$pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
|
||||
}
|
||||
if (!empty($themesHavingUpdate)) {
|
||||
$themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
|
||||
}
|
||||
}
|
||||
|
||||
MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', null, "", !Piwik::isUserIsAnonymous(), $order = 7);
|
||||
MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage,
|
||||
array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''),
|
||||
Piwik::hasUserSuperUserAccess(),
|
||||
$order = 1);
|
||||
MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage,
|
||||
array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''),
|
||||
Piwik::hasUserSuperUserAccess(),
|
||||
$order = 3);
|
||||
|
||||
if (static::isMarketplaceEnabled()) {
|
||||
|
||||
MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace',
|
||||
array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''),
|
||||
!Piwik::isUserIsAnonymous(),
|
||||
$order = 5);
|
||||
|
||||
}
|
||||
$stylesheets[] = "plugins/CorePluginsAdmin/stylesheets/plugin-details.less";
|
||||
}
|
||||
|
||||
public static function isMarketplaceEnabled()
|
||||
|
|
@ -122,8 +44,9 @@ class CorePluginsAdmin extends \Piwik\Plugin
|
|||
|
||||
public function getJsFiles(&$jsFiles)
|
||||
{
|
||||
$jsFiles[] = "libs/bower_components/jQuery.dotdotdot/src/js/jquery.dotdotdot.min.js";
|
||||
$jsFiles[] = "plugins/CoreHome/javascripts/popover.js";
|
||||
$jsFiles[] = "plugins/CorePluginsAdmin/javascripts/pluginDetail.js";
|
||||
$jsFiles[] = "plugins/CorePluginsAdmin/javascripts/marketplace.js";
|
||||
$jsFiles[] = "plugins/CorePluginsAdmin/javascripts/pluginOverview.js";
|
||||
$jsFiles[] = "plugins/CorePluginsAdmin/javascripts/pluginExtend.js";
|
||||
$jsFiles[] = "plugins/CorePluginsAdmin/javascripts/plugins.js";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
namespace Piwik\Plugins\CorePluginsAdmin;
|
||||
|
||||
use Piwik\Date;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Dependency as PluginDependency;
|
||||
|
||||
/**
|
||||
|
|
@ -105,41 +104,43 @@ class Marketplace
|
|||
public function getPluginsHavingUpdate($themesOnly)
|
||||
{
|
||||
$pluginManager = \Piwik\Plugin\Manager::getInstance();
|
||||
$pluginManager->returnLoadedPluginsInfo();
|
||||
$pluginManager->loadAllPluginsAndGetTheirInfo();
|
||||
$loadedPlugins = $pluginManager->getLoadedPlugins();
|
||||
|
||||
try {
|
||||
$pluginsHavingUpdate = $this->client->getInfoOfPluginsHavingUpdate($loadedPlugins, $themesOnly);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$pluginsHavingUpdate = array();
|
||||
}
|
||||
|
||||
foreach ($pluginsHavingUpdate as &$updatePlugin) {
|
||||
foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
|
||||
foreach ($loadedPlugins as $loadedPlugin) {
|
||||
|
||||
if (!empty($updatePlugin['name'])
|
||||
&& $loadedPlugin->getPluginName() == $updatePlugin['name']
|
||||
) {
|
||||
|
||||
$updatePlugin['currentVersion'] = $loadedPlugin->getVersion();
|
||||
$updatePlugin['isActivated'] = $pluginManager->isPluginActivated($updatePlugin['name']);
|
||||
$updatePlugin = $this->addMissingRequirements($updatePlugin);
|
||||
$pluginsHavingUpdate[$key] = $this->addMissingRequirements($updatePlugin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// remove plugins that have updates but for some reason are not loaded
|
||||
foreach ($pluginsHavingUpdate as $key => $updatePlugin) {
|
||||
if (empty($updatePlugin['currentVersion'])) {
|
||||
unset($pluginsHavingUpdate[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $pluginsHavingUpdate;
|
||||
}
|
||||
|
||||
private function enrichPluginInformation($plugin)
|
||||
{
|
||||
$dateFormat = Piwik::translate('CoreHome_ShortDateFormatWithYear');
|
||||
|
||||
$plugin['canBeUpdated'] = $this->hasPluginUpdate($plugin);
|
||||
$plugin['isInstalled'] = \Piwik\Plugin\Manager::getInstance()->isPluginLoaded($plugin['name']);
|
||||
$plugin['lastUpdated'] = Date::factory($plugin['lastUpdated'])->getLocalized($dateFormat);
|
||||
$plugin['canBeUpdated'] = $plugin['isInstalled'] && $this->hasPluginUpdate($plugin);
|
||||
$plugin['lastUpdated'] = Date::factory($plugin['lastUpdated'])->getLocalized(Date::DATE_FORMAT_SHORT);
|
||||
|
||||
if ($plugin['canBeUpdated']) {
|
||||
$pluginUpdate = $this->getPluginUpdateInformation($plugin);
|
||||
|
|
@ -150,18 +151,15 @@ class Marketplace
|
|||
if (!empty($plugin['activity']['lastCommitDate'])
|
||||
&& false === strpos($plugin['activity']['lastCommitDate'], '0000')) {
|
||||
|
||||
$dateFormat = Piwik::translate('CoreHome_DateFormat');
|
||||
$plugin['activity']['lastCommitDate'] = Date::factory($plugin['activity']['lastCommitDate'])->getLocalized($dateFormat);
|
||||
$plugin['activity']['lastCommitDate'] = Date::factory($plugin['activity']['lastCommitDate'])->getLocalized(Date::DATE_FORMAT_LONG);
|
||||
} else {
|
||||
$plugin['activity']['lastCommitDate'] = null;
|
||||
}
|
||||
|
||||
if (!empty($plugin['versions'])) {
|
||||
|
||||
$dateFormat = Piwik::translate('CoreHome_DateFormat');
|
||||
|
||||
foreach ($plugin['versions'] as $index => $version) {
|
||||
$plugin['versions'][$index]['release'] = Date::factory($version['release'])->getLocalized($dateFormat);
|
||||
$plugin['versions'][$index]['release'] = Date::factory($version['release'])->getLocalized(Date::DATE_FORMAT_LONG);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\CorePluginsAdmin;
|
||||
|
||||
use Piwik\CacheFile;
|
||||
use Piwik\Cache;
|
||||
use Piwik\Http;
|
||||
use Piwik\Version;
|
||||
|
||||
|
|
@ -18,24 +18,14 @@ use Piwik\Version;
|
|||
class MarketplaceApiClient
|
||||
{
|
||||
const CACHE_TIMEOUT_IN_SECONDS = 1200;
|
||||
const HTTP_REQUEST_TIMEOUT = 3;
|
||||
const HTTP_REQUEST_TIMEOUT = 60;
|
||||
|
||||
private $domain = 'http://plugins.piwik.org';
|
||||
|
||||
/**
|
||||
* @var CacheFile
|
||||
*/
|
||||
private $cache = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache = new CacheFile('marketplace', self::CACHE_TIMEOUT_IN_SECONDS);
|
||||
}
|
||||
|
||||
public static function clearAllCacheEntries()
|
||||
{
|
||||
$cache = new CacheFile('marketplace');
|
||||
$cache->deleteAll();
|
||||
$cache = Cache::getLazyCache();
|
||||
$cache->flushAll();
|
||||
}
|
||||
|
||||
public function getPluginInfo($name)
|
||||
|
|
@ -137,7 +127,10 @@ class MarketplaceApiClient
|
|||
{
|
||||
ksort($params);
|
||||
$query = http_build_query($params);
|
||||
$result = $this->getCachedResult($action, $query);
|
||||
|
||||
$cacheId = $this->getCacheKey($action, $query);
|
||||
$cache = $this->buildCache();
|
||||
$result = $cache->fetch($cacheId);
|
||||
|
||||
if (false === $result) {
|
||||
$endpoint = $this->domain . '/api/1.0/';
|
||||
|
|
@ -155,29 +148,20 @@ class MarketplaceApiClient
|
|||
throw new MarketplaceApiException($result['error']);
|
||||
}
|
||||
|
||||
$this->cacheResult($action, $query, $result);
|
||||
$cache->save($cacheId, $result, self::CACHE_TIMEOUT_IN_SECONDS);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getCachedResult($action, $query)
|
||||
private function buildCache()
|
||||
{
|
||||
$cacheKey = $this->getCacheKey($action, $query);
|
||||
|
||||
return $this->cache->get($cacheKey);
|
||||
}
|
||||
|
||||
private function cacheResult($action, $query, $result)
|
||||
{
|
||||
$cacheKey = $this->getCacheKey($action, $query);
|
||||
|
||||
$this->cache->set($cacheKey, $result);
|
||||
return Cache::getLazyCache();
|
||||
}
|
||||
|
||||
private function getCacheKey($action, $query)
|
||||
{
|
||||
return sprintf('api.1.0.%s.%s', str_replace('/', '.', $action), md5($query));
|
||||
return sprintf('marketplace.api.1.0.%s.%s', str_replace('/', '.', $action), md5($query));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
|
|||
73
www/analytics/plugins/CorePluginsAdmin/Menu.php
Normal file
73
www/analytics/plugins/CorePluginsAdmin/Menu.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?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\Menu\MenuUser;
|
||||
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 = 4);
|
||||
}
|
||||
|
||||
|
||||
if (Piwik::hasUserSuperUserAccess() && CorePluginsAdmin::isMarketplaceEnabled()) {
|
||||
$menu->addManageItem('CorePluginsAdmin_Marketplace',
|
||||
$this->urlForAction('marketplace', array('activated' => '', 'mode' => 'admin')),
|
||||
$order = 12);
|
||||
}
|
||||
}
|
||||
|
||||
private function isAllowedToSeeMarketPlace()
|
||||
{
|
||||
$isAnonymous = Piwik::isUserIsAnonymous();
|
||||
$isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
|
||||
|
||||
return $isMarketplaceEnabled && !$isAnonymous;
|
||||
}
|
||||
|
||||
public function configureUserMenu(MenuUser $menu)
|
||||
{
|
||||
if ($this->isAllowedToSeeMarketPlace()) {
|
||||
$menu->addPlatformItem('CorePluginsAdmin_Marketplace',
|
||||
$this->urlForAction('marketplace', array('activated' => '', 'mode' => 'user')),
|
||||
$order = 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,19 +8,19 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\CorePluginsAdmin;
|
||||
|
||||
use Piwik\Container\StaticContainer;
|
||||
use Piwik\Filechecks;
|
||||
use Piwik\Filesystem;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\SettingsPiwik;
|
||||
use Piwik\Unzip;
|
||||
use Piwik\Plugin\Dependency as PluginDependency;
|
||||
use Piwik\Unzip;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class PluginInstaller
|
||||
{
|
||||
const PATH_TO_DOWNLOAD = '/tmp/latest/plugins/';
|
||||
const PATH_TO_DOWNLOAD = '/latest/plugins/';
|
||||
const PATH_TO_EXTRACT = '/plugins/';
|
||||
|
||||
private $pluginName;
|
||||
|
|
@ -32,11 +32,10 @@ class PluginInstaller
|
|||
|
||||
public function installOrUpdatePluginFromMarketplace()
|
||||
{
|
||||
$tmpPluginZip = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName . '.zip';
|
||||
$tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
|
||||
$tmpPluginPath = StaticContainer::get('path.tmp') . '/latest/plugins/';
|
||||
|
||||
$tmpPluginZip = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginZip);
|
||||
$tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginFolder);
|
||||
$tmpPluginZip = $tmpPluginPath . $this->pluginName . '.zip';
|
||||
$tmpPluginFolder = $tmpPluginPath . $this->pluginName;
|
||||
|
||||
try {
|
||||
$this->makeSureFoldersAreWritable();
|
||||
|
|
@ -48,6 +47,8 @@ class PluginInstaller
|
|||
$this->makeSureThereAreNoMissingRequirements($metadata);
|
||||
$this->copyPluginToDestination($tmpPluginFolder);
|
||||
|
||||
Filesystem::deleteAllCacheOnUpdate($this->pluginName);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->removeFileIfExists($tmpPluginZip);
|
||||
|
|
@ -62,8 +63,7 @@ class PluginInstaller
|
|||
|
||||
public function installOrUpdatePluginFromFile($pathToZip)
|
||||
{
|
||||
$tmpPluginFolder = PIWIK_USER_PATH . self::PATH_TO_DOWNLOAD . $this->pluginName;
|
||||
$tmpPluginFolder = SettingsPiwik::rewriteTmpPathWithHostname($tmpPluginFolder);
|
||||
$tmpPluginFolder = StaticContainer::get('path.tmp') . self::PATH_TO_DOWNLOAD . $this->pluginName;
|
||||
|
||||
try {
|
||||
$this->makeSureFoldersAreWritable();
|
||||
|
|
@ -78,6 +78,8 @@ class PluginInstaller
|
|||
$this->fixPluginFolderIfNeeded($tmpPluginFolder);
|
||||
$this->copyPluginToDestination($tmpPluginFolder);
|
||||
|
||||
Filesystem::deleteAllCacheOnUpdate($this->pluginName);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->removeFileIfExists($pathToZip);
|
||||
|
|
@ -94,7 +96,10 @@ class PluginInstaller
|
|||
|
||||
private function makeSureFoldersAreWritable()
|
||||
{
|
||||
Filechecks::dieIfDirectoriesNotWritable(array(self::PATH_TO_DOWNLOAD, self::PATH_TO_EXTRACT));
|
||||
Filechecks::dieIfDirectoriesNotWritable(array(
|
||||
StaticContainer::get('path.tmp') . self::PATH_TO_DOWNLOAD,
|
||||
self::PATH_TO_EXTRACT
|
||||
));
|
||||
}
|
||||
|
||||
private function downloadPluginFromMarketplace($pluginZipTargetFile)
|
||||
|
|
@ -151,7 +156,7 @@ class PluginInstaller
|
|||
private function makeSureThereAreNoMissingRequirements($metadata)
|
||||
{
|
||||
$requires = array();
|
||||
if(!empty($metadata->require)) {
|
||||
if (!empty($metadata->require)) {
|
||||
$requires = (array) $metadata->require;
|
||||
}
|
||||
|
||||
|
|
@ -161,8 +166,14 @@ class PluginInstaller
|
|||
if (!empty($missingDependencies)) {
|
||||
$message = '';
|
||||
foreach ($missingDependencies as $dep) {
|
||||
$params = array(ucfirst($dep['requirement']), $dep['actualVersion'], $dep['requiredVersion']);
|
||||
$message .= Piwik::translate('CorePluginsAdmin_MissingRequirementsNotice', $params);
|
||||
if (empty($dep['actualVersion'])) {
|
||||
$params = array(ucfirst($dep['requirement']), $dep['requiredVersion'], $metadata->name);
|
||||
$message .= Piwik::translate('CorePluginsAdmin_MissingRequirementsPleaseInstallNotice', $params);
|
||||
} else {
|
||||
$params = array(ucfirst($dep['requirement']), $dep['actualVersion'], $dep['requiredVersion']);
|
||||
$message .= Piwik::translate('CorePluginsAdmin_MissingRequirementsNotice', $params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
throw new PluginInstallerException($message);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
|
|||
36
www/analytics/plugins/CorePluginsAdmin/Tasks.php
Normal file
36
www/analytics/plugins/CorePluginsAdmin/Tasks.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?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;
|
||||
|
||||
class Tasks extends \Piwik\Plugin\Tasks
|
||||
{
|
||||
public function schedule()
|
||||
{
|
||||
$this->daily('clearAllCacheEntries', null, self::LOWEST_PRIORITY);
|
||||
|
||||
if (CorePluginsAdmin::isMarketplaceEnabled()) {
|
||||
$this->daily('sendNotificationIfUpdatesAvailable', null, self::LOWEST_PRIORITY);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearAllCacheEntries()
|
||||
{
|
||||
$marketplace = new MarketplaceApiClient();
|
||||
$marketplace->clearAllCacheEntries();
|
||||
}
|
||||
|
||||
public function sendNotificationIfUpdatesAvailable()
|
||||
{
|
||||
$updateCommunication = new UpdateCommunication();
|
||||
if ($updateCommunication->isEnabled()) {
|
||||
$updateCommunication->sendNotificationIfUpdatesAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -109,34 +109,8 @@ class UpdateCommunication
|
|||
$hasPluginUpdate = $hasPluginUpdate || !$plugin['isTheme'];
|
||||
}
|
||||
|
||||
$subject = Piwik::translate('CoreUpdater_NotificationSubjectAvailablePluginUpdate');
|
||||
$message = Piwik::translate('ScheduledReports_EmailHello');
|
||||
$message .= "\n\n";
|
||||
$message .= Piwik::translate('CoreUpdater_ThereIsNewPluginVersionAvailableForUpdate');
|
||||
$message .= "\n\n";
|
||||
|
||||
foreach ($pluginsToBeNotified as $plugin) {
|
||||
$message .= sprintf(' * %s %s', $plugin['name'], $plugin['latestVersion']);
|
||||
$message .= "\n";
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
|
||||
$host = SettingsPiwik::getPiwikUrl();
|
||||
if ($hasThemeUpdate) {
|
||||
$message .= Piwik::translate('CoreUpdater_NotificationClickToUpdateThemes') . "\n";
|
||||
$message .= $host. 'index.php?module=CorePluginsAdmin&action=themes';
|
||||
}
|
||||
if ($hasPluginUpdate) {
|
||||
if ($hasThemeUpdate) {
|
||||
$message .= "\n\n";
|
||||
}
|
||||
$message .= Piwik::translate('CoreUpdater_NotificationClickToUpdatePlugins') . "\n";
|
||||
$message .= $host. 'index.php?module=CorePluginsAdmin&action=plugins';
|
||||
}
|
||||
|
||||
$message .= "\n\n";
|
||||
$message .= Piwik::translate('Installation_HappyAnalysing');
|
||||
$subject = Piwik::translate('CoreUpdater_NotificationSubjectAvailablePluginUpdate');
|
||||
$message = $this->buildNotificationMessage($pluginsToBeNotified, $hasThemeUpdate, $hasPluginUpdate);
|
||||
|
||||
$this->sendEmailNotification($subject, $message);
|
||||
}
|
||||
|
|
@ -161,24 +135,24 @@ class UpdateCommunication
|
|||
}
|
||||
}
|
||||
|
||||
private function setHasLatestUpdateNotificationReceived($plugin)
|
||||
protected function setHasLatestUpdateNotificationReceived($plugin)
|
||||
{
|
||||
$latestVersion = $this->getLatestVersion($plugin);
|
||||
|
||||
Option::set($this->getNotificationSentOptionName($plugin), $latestVersion);
|
||||
}
|
||||
|
||||
private function getLatestVersionSent($plugin)
|
||||
protected function getLatestVersionSent($plugin)
|
||||
{
|
||||
return Option::get($this->getNotificationSentOptionName($plugin));
|
||||
}
|
||||
|
||||
private function getLatestVersion($plugin)
|
||||
protected function getLatestVersion($plugin)
|
||||
{
|
||||
return $plugin['latestVersion'];
|
||||
}
|
||||
|
||||
private function hasNotificationAlreadyReceived($plugin)
|
||||
protected function hasNotificationAlreadyReceived($plugin)
|
||||
{
|
||||
$latestVersion = $this->getLatestVersion($plugin);
|
||||
$lastVersionSent = $this->getLatestVersionSent($plugin);
|
||||
|
|
@ -192,7 +166,7 @@ class UpdateCommunication
|
|||
return false;
|
||||
}
|
||||
|
||||
private function getNotificationSentOptionName($plugin)
|
||||
protected function getNotificationSentOptionName($plugin)
|
||||
{
|
||||
return 'last_update_communication_sent_plugin_' . $plugin['name'];
|
||||
}
|
||||
|
|
@ -207,4 +181,39 @@ class UpdateCommunication
|
|||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
protected function buildNotificationMessage($pluginsToBeNotified, $hasThemeUpdate, $hasPluginUpdate)
|
||||
{
|
||||
$message = Piwik::translate('ScheduledReports_EmailHello');
|
||||
$message .= "\n\n";
|
||||
$message .= Piwik::translate('CoreUpdater_ThereIsNewPluginVersionAvailableForUpdate');
|
||||
$message .= "\n\n";
|
||||
|
||||
foreach ($pluginsToBeNotified as $plugin) {
|
||||
$message .= sprintf(' * %s %s', $plugin['name'], $plugin['latestVersion']);
|
||||
$message .= "\n";
|
||||
}
|
||||
|
||||
$message .= "\n";
|
||||
|
||||
$host = SettingsPiwik::getPiwikUrl();
|
||||
|
||||
if ($hasThemeUpdate) {
|
||||
$message .= Piwik::translate('CoreUpdater_NotificationClickToUpdateThemes') . "\n";
|
||||
$message .= $host . 'index.php?module=CorePluginsAdmin&action=themes';
|
||||
}
|
||||
|
||||
if ($hasPluginUpdate) {
|
||||
if ($hasThemeUpdate) {
|
||||
$message .= "\n\n";
|
||||
}
|
||||
$message .= Piwik::translate('CoreUpdater_NotificationClickToUpdatePlugins') . "\n";
|
||||
$message .= $host . 'index.php?module=CorePluginsAdmin&action=plugins';
|
||||
}
|
||||
|
||||
$message .= "\n\n";
|
||||
$message .= Piwik::translate('Installation_HappyAnalysing');
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
www/analytics/plugins/CorePluginsAdmin/images/flattr.png
Normal file
BIN
www/analytics/plugins/CorePluginsAdmin/images/flattr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
www/analytics/plugins/CorePluginsAdmin/images/paypal_donate.jpg
Normal file
BIN
www/analytics/plugins/CorePluginsAdmin/images/paypal_donate.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
50
www/analytics/plugins/CorePluginsAdmin/javascripts/marketplace.js
Executable file
50
www/analytics/plugins/CorePluginsAdmin/javascripts/marketplace.js
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*!
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Keeps the plugin descriptions the same height
|
||||
$('.marketplace .plugin .description').dotdotdot({
|
||||
after: 'a.more',
|
||||
watch: 'window'
|
||||
});
|
||||
|
||||
$('a.plugin-details[data-pluginName]').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var pluginName = $(this).attr('data-pluginName');
|
||||
if (!pluginName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var activeTab = $(this).attr('data-activePluginTab');
|
||||
if (activeTab) {
|
||||
pluginName += '!' + activeTab;
|
||||
}
|
||||
|
||||
broadcast.propagateNewPopoverParameter('browsePluginDetail', pluginName);
|
||||
});
|
||||
|
||||
broadcast.addPopoverHandler('browsePluginDetail', function (value) {
|
||||
var pluginName = value;
|
||||
var activeTab = null;
|
||||
|
||||
if (-1 !== value.indexOf('!')) {
|
||||
activeTab = value.substr(value.indexOf('!') + 1);
|
||||
pluginName = value.substr(0, value.indexOf('!'));
|
||||
}
|
||||
|
||||
var url = 'module=CorePluginsAdmin&action=pluginDetails&pluginName=' + encodeURIComponent(pluginName);
|
||||
|
||||
if (activeTab) {
|
||||
url += '&activeTab=' + encodeURIComponent(activeTab);
|
||||
}
|
||||
|
||||
Piwik_Popover.createPopupAndLoadUrl(url, 'details');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
/*!
|
||||
* Piwik - Web Analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*/
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
function syncMaxHeight (selector) {
|
||||
|
||||
if (!selector) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $nodes = $(selector);
|
||||
|
||||
if (!$nodes) {
|
||||
return;
|
||||
}
|
||||
|
||||
var max = {};
|
||||
$nodes.each(function (index, node) {
|
||||
var $node = $(node);
|
||||
var top = $node.position().top;
|
||||
|
||||
var height = $node.height();
|
||||
|
||||
if (!max[top]) {
|
||||
max[top] = height;
|
||||
} else if (max[top] < height) {
|
||||
max[top] = height;
|
||||
} else {
|
||||
$node.height(max[top] + 'px');
|
||||
}
|
||||
});
|
||||
|
||||
$nodes.each(function (index, node) {
|
||||
var $node = $(node);
|
||||
var top = $node.position().top;
|
||||
|
||||
$node.height(max[top] + 'px');
|
||||
});
|
||||
}
|
||||
|
||||
syncMaxHeight('.pluginslist .plugin');
|
||||
syncMaxHeight('.themeslist .plugin');
|
||||
|
||||
$('.pluginslist, #plugins, .themeslist').on('click', '[data-pluginName]', function (event) {
|
||||
if ($(event.target).hasClass('install') || $(event.target).hasClass('uninstall')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pluginName = $(this).attr('data-pluginName');
|
||||
|
||||
if (!pluginName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var activeTab = $(event.target).attr('data-activePluginTab');
|
||||
if (activeTab) {
|
||||
pluginName += '!' + activeTab;
|
||||
}
|
||||
|
||||
broadcast.propagateNewPopoverParameter('browsePluginDetail', pluginName);
|
||||
});
|
||||
|
||||
var showPopover = function (value) {
|
||||
var pluginName = value;
|
||||
var activeTab = null;
|
||||
|
||||
if (-1 !== value.indexOf('!')) {
|
||||
activeTab = value.substr(value.indexOf('!') + 1);
|
||||
pluginName = value.substr(0, value.indexOf('!'));
|
||||
}
|
||||
|
||||
var url = 'module=CorePluginsAdmin&action=pluginDetails&pluginName=' + encodeURIComponent(pluginName);
|
||||
|
||||
if (activeTab) {
|
||||
url += '&activeTab=' + encodeURIComponent(activeTab);
|
||||
}
|
||||
|
||||
Piwik_Popover.createPopupAndLoadUrl(url, 'details');
|
||||
};
|
||||
|
||||
broadcast.addPopoverHandler('browsePluginDetail', showPopover);
|
||||
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Piwik - Web Analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
$(document).ready(function () {
|
||||
|
||||
$('.extendPlatform .uploadPlugin').click(function (event) {
|
||||
$('.uploadPlugin').click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
piwikHelper.modalConfirm('#installPluginByUpload', {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Piwik - Web Analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -34,4 +34,12 @@ $(document).ready(function () {
|
|||
});
|
||||
});
|
||||
|
||||
$('.plugin-donation-link').click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var overlayId = $(this).data('overlay-id');
|
||||
|
||||
piwikHelper.modalConfirm('#'+overlayId, {});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Piwik - Web Analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue