Skip to content

Commit

Permalink
Marketplace improvements (#10737)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur authored and mattab committed Oct 22, 2016
1 parent 5366603 commit d099e40
Show file tree
Hide file tree
Showing 202 changed files with 15,647 additions and 1,332 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -49,6 +49,11 @@ The folder containing expected screenshots was renamed from `expected-ui-screens
* Tracking API: by default, when tracking a Page URL, Piwik will now remove the URL query string parameter `sid` if it is found.
* In the JavaScript tracker, the function `setDomains` will not anymore attempt to set a cookie path. Learn more about [configuring the tracker correctly](http://developer.piwik.org/guides/tracking-javascript-guide#tracking-one-domain) when tracking one or several domains and/or paths.

## Piwik 2.16.1

### Internal change
* The setting `[General]enable_marketplace=0/1` was removed, instead the new plugin Marketplace can be disabled/enabled. The updater should automatically migrate an existing setting.

## Piwik 2.16.0

### New features
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -44,7 +44,8 @@
"piwik/referrer-spam-blacklist": "~1.0",
"piwik/searchengine-and-social-list": "~1.0",
"tecnickcom/tcpdf": "~6.0",
"piwik/piwik-php-tracker": "^1.0"
"piwik/piwik-php-tracker": "^1.0",
"composer/semver": "~1.3.0"
},
"require-dev": {
"aws/aws-sdk-php": "2.7.1",
Expand Down
68 changes: 65 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions config/global.ini.php
Expand Up @@ -442,6 +442,12 @@
; set the HTTPS environment variable.
assume_secure_protocol = 0

; Set to 1 if you're using more than one server for your Piwik installation. For example if you are using Piwik in a
; load balanced environment, if you have configured failover or if you're just using multiple servers in general.
; By enabling this flag we will for example not allow the installation of a plugin via the UI as a plugin would be only
; installed on one server or a config one change would be only made on one server instead of all servers.
multi_server_environment = 0

; List of proxy headers for client IP addresses
;
; CloudFlare (CF-Connecting-IP)
Expand Down Expand Up @@ -526,14 +532,9 @@
; This may for example be useful when doing Mysql AWS replication
enable_load_data_infile = 1

; By setting this option to 0, you can disable the Piwik marketplace. This is useful to prevent giving the Super user
; the access to disk and install custom PHP code (Piwik plugins).
enable_marketplace = 1

; By setting this option to 0:
; - links to Enable/Disable/Uninstall plugins will be hidden and disabled
; - links to Uninstall themes will be disabled (but user can still enable/disable themes)
; - as well as disabling plugins admin actions (such as "Upload new plugin"), setting this to 1 will have same effect as setting enable_marketplace=1
enable_plugins_admin = 1

; By setting this option to 0, you can prevent Super User from editing the Geolocation settings.
Expand Down Expand Up @@ -805,6 +806,7 @@
Plugins[] = DevicePlugins
Plugins[] = Heartbeat
Plugins[] = Intl
Plugins[] = Marketplace
Plugins[] = ProfessionalServices
Plugins[] = UserId
Plugins[] = CustomPiwikJs
Expand Down
2 changes: 2 additions & 0 deletions core/API/DocumentationGenerator.php
Expand Up @@ -249,6 +249,8 @@ public function getExampleUrl($class, $methodName, $parametersToSet = array())
'addGoal',
'updateGoal',
'deleteGoal',
//Marketplace
'deleteLicenseKey'
);

if (in_array($methodName, $doNotPrintExampleForTheseMethods)) {
Expand Down
15 changes: 11 additions & 4 deletions core/Http.php
Expand Up @@ -94,17 +94,24 @@ public static function sendHttpRequest($aUrl,
$httpPassword = null)
{
// create output file
$file = null;
$file = self::ensureDestinationDirectoryExists($destinationPath);

$acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : '';
return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod, $httpUsername, $httpPassword);
}

public static function ensureDestinationDirectoryExists($destinationPath)
{
if ($destinationPath) {
// Ensure destination directory exists
Filesystem::mkdir(dirname($destinationPath));
if (($file = @fopen($destinationPath, 'wb')) === false || !is_resource($file)) {
throw new Exception('Error while creating the file: ' . $destinationPath);
}

return $file;
}

$acceptLanguage = $acceptLanguage ? 'Accept-Language: ' . $acceptLanguage : '';
return self::sendHttpRequestBy(self::getTransportMethod(), $aUrl, $timeout, $userAgent, $destinationPath, $file, $followDepth, $acceptLanguage, $acceptInvalidSslCertificate = false, $byteRange, $getExtendedInfo, $httpMethod, $httpUsername, $httpPassword);
return null;
}

/**
Expand Down
7 changes: 7 additions & 0 deletions core/Notification.php
Expand Up @@ -80,6 +80,13 @@ class Notification
*/
const FLAG_NO_CLEAR = 1;

/**
* If this flag is applied, a close icon will be displayed.
*
* See {@link $flags}.
*/
const FLAG_CLEAR = 0;

/**
* Notifications of this type will be displayed for a few seconds and then faded out.
*/
Expand Down
2 changes: 1 addition & 1 deletion core/Notification/Manager.php
Expand Up @@ -132,7 +132,7 @@ private static function removeOldestNotificationsIfThereAreTooMany()
if (!self::isSessionEnabled()) {
return;
}

$maxNotificationsInSession = 30;

$session = static::getSession();
Expand Down
47 changes: 47 additions & 0 deletions core/Plugin/ControllerAdmin.php
Expand Up @@ -10,13 +10,15 @@

use Piwik\Config as PiwikConfig;
use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Development;
use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuTop;
use Piwik\Menu\MenuUser;
use Piwik\Notification;
use Piwik\Notification\Manager as NotificationManager;
use Piwik\Piwik;
use Piwik\Plugins\Marketplace\Marketplace;
use Piwik\Tracker\TrackerConfig;
use Piwik\Url;
use Piwik\Version;
Expand All @@ -41,6 +43,50 @@ private static function notifyWhenTrackingStatisticsDisabled()
}
}

private static function notifyAnyInvalidLicense()
{
if (!Marketplace::isMarketplaceEnabled()) {
return;
}

if (Piwik::isUserIsAnonymous()) {
return;
}

if (!Piwik::isUserHasSomeAdminAccess()) {
return;
}

$expired = StaticContainer::get('Piwik\Plugins\Marketplace\Plugins\InvalidLicenses');

$messageLicenseMissing = $expired->getMessageNoLicense();
if (!empty($messageLicenseMissing)) {
$notification = new Notification($messageLicenseMissing);
$notification->raw = true;
$notification->context = Notification::CONTEXT_ERROR;
$notification->title = Piwik::translate('Marketplace_LicenseMissing');
Notification\Manager::notify('ControllerAdmin_LicenseMissingWarning', $notification);
}

$messageExceeded = $expired->getMessageExceededLicenses();
if (!empty($messageExceeded)) {
$notification = new Notification($messageExceeded);
$notification->raw = true;
$notification->context = Notification::CONTEXT_WARNING;
$notification->title = Piwik::translate('Marketplace_LicenseExceeded');
Notification\Manager::notify('ControllerAdmin_LicenseExceededWarning', $notification);
}

$messageExpired = $expired->getMessageExpiredLicenses();
if (!empty($messageExpired)) {
$notification = new Notification($messageExpired);
$notification->raw = true;
$notification->context = Notification::CONTEXT_WARNING;
$notification->title = Piwik::translate('Marketplace_LicenseExpired');
Notification\Manager::notify('ControllerAdmin_LicenseExpiredWarning', $notification);
}
}

private static function notifyAnyInvalidPlugin()
{
$missingPlugins = \Piwik\Plugin\Manager::getInstance()->getMissingPlugins();
Expand Down Expand Up @@ -276,6 +322,7 @@ public static function setBasicVariablesAdminView(View $view)

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

self::notifyAnyInvalidLicense();
self::notifyAnyInvalidPlugin();
self::notifyWhenPhpVersionIsEOL();
self::notifyWhenPhpVersionIsNotCompatibleWithNextMajorPiwik();
Expand Down

0 comments on commit d099e40

Please sign in to comment.