Skip to content
Extraits de code Groupes Projets
Valider e79784e0 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fixes #5923, add INI config option allow_adding_segments_for_all_websites that...

Fixes #5923, add INI config option allow_adding_segments_for_all_websites that allows users to disable the ability to add segments affecting all websites.
parent ef61529d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -177,6 +177,11 @@ enable_segment_suggested_values = 1
; Possible values are "view", "admin", "superuser"
adding_segment_requires_access = "view"
; Whether it is allowed for users to add segments that affect all websites or not. If there are many websites
; this admin option can be used to prevent users from performing an action that will have a major impact
; on Piwik performance.
allow_adding_segments_for_all_websites = 1
; this action name is used when the URL ends with a slash /
; it is useful to have an actual string to write in the UI
action_default_name = index
......
......@@ -115,7 +115,13 @@ class API extends \Piwik\Plugin\API
protected function checkUserCanAddNewSegment($idSite)
{
if(!$this->isUserCanAddNewSegment($idSite)) {
if (empty($idSite)
&& !SegmentEditor::isAddingSegmentsForAllWebsitesEnabled()
) {
throw new Exception(Piwik::translate('SegmentEditor_AddingSegmentForAllWebsitesDisabled'));
}
if (!$this->isUserCanAddNewSegment($idSite)) {
throw new Exception(Piwik::translate('SegmentEditor_YouDontHaveAccessToCreateSegments'));
}
}
......
......@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\SegmentEditor;
use Piwik\Config;
use Piwik\Db;
use Piwik\DbHelper;
use Piwik\Version;
......@@ -98,4 +99,14 @@ class SegmentEditor extends \Piwik\Plugin
{
$stylesheets[] = "plugins/SegmentEditor/stylesheets/segmentation.less";
}
/**
* Returns whether adding segments for all websites is enabled or not.
*
* @return bool
*/
public static function isAddingSegmentsForAllWebsitesEnabled()
{
return Config::getInstance()->General['allow_adding_segments_for_all_websites'] == 1;
}
}
......@@ -37,6 +37,8 @@ class SegmentSelectorControl extends UIControl
$this->selectedSegment = Common::getRequestVar('segment', false, 'string');
$this->isAddingSegmentsForAllWebsitesEnabled = SegmentEditor::isAddingSegmentsForAllWebsitesEnabled();
$segments = APIMetadata::getInstance()->getSegmentsMetadata($this->idSite);
$segmentsByCategory = array();
......
......@@ -24,6 +24,7 @@
"VisibleToMe": "me",
"YouMayChangeSetting": "Alternatively you may change the setting in the config file (%s), or edit this Segment and choose '%s'.",
"YouMustBeLoggedInToCreateSegments": "You must be logged in to create and edit custom visitor segments.",
"YouDontHaveAccessToCreateSegments": "You don't have the required access level to create and edit segments."
"YouDontHaveAccessToCreateSegments": "You don't have the required access level to create and edit segments.",
"AddingSegmentForAllWebsitesDisabled": "Adding segments for all websites has been disabled."
}
}
\ No newline at end of file
......@@ -122,7 +122,7 @@
{{ 'SegmentEditor_SegmentIsDisplayedForWebsite'|translate }}<span class="visible_to_website"><strong>
<select class="visible_to_website_select">
<option selected="" value="{{ idSite }}">{{ 'SegmentEditor_SegmentDisplayedThisWebsiteOnly'|translate }}</option>
<option value="0">{{ 'SegmentEditor_SegmentDisplayedAllWebsites'|translate }}</option>
{% if isAddingSegmentsForAllWebsitesEnabled %}<option value="0">{{ 'SegmentEditor_SegmentDisplayedAllWebsites'|translate }}</option>{% endif %}
</select>
</strong></span>
{{ 'General_And'|translate }} <span class="auto_archive"><strong>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter