From fa04cb406bb19c3a1904a1482beda1ff5f3f2a85 Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Mon, 17 Feb 2014 13:15:42 +1300 Subject: [PATCH] fixes #4675 Adding new config file setting: ; By default, users can create Segments which are to be processed in Real-time. ; Setting this to 0 will force all newly created Custom Segments to be "Pre-processed (faster, requires archive.php cron)" ; This can be useful if you want to prevent users from adding much load on the server. ; Note: any existing Segment set to "processed in Real time", will still be set to Real-time. ; this will only affect custom segments added or modified after this setting is changed. enable_create_realtime_segments = 1 --- config/global.ini.php | 7 +++++++ plugins/SegmentEditor/SegmentSelectorControl.php | 3 ++- plugins/SegmentEditor/templates/_segmentSelector.twig | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/global.ini.php b/config/global.ini.php index c8049e52f3..decf36869e 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -136,6 +136,13 @@ anonymous_user_enable_use_segments_API = 1 ; The only time that the browser will still trigger archiving is when requesting a custom date range that is not pre-processed yet browser_archiving_disabled_enforce = 0 +; By default, users can create Segments which are to be processed in Real-time. +; Setting this to 0 will force all newly created Custom Segments to be "Pre-processed (faster, requires archive.php cron)" +; This can be useful if you want to prevent users from adding much load on the server. +; Note: any existing Segment set to "processed in Real time", will still be set to Real-time. +; this will only affect custom segments added or modified after this setting is changed. +enable_create_realtime_segments = 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 diff --git a/plugins/SegmentEditor/SegmentSelectorControl.php b/plugins/SegmentEditor/SegmentSelectorControl.php index 1b28c7d89d..78638a6523 100644 --- a/plugins/SegmentEditor/SegmentSelectorControl.php +++ b/plugins/SegmentEditor/SegmentSelectorControl.php @@ -53,6 +53,7 @@ class SegmentSelectorControl extends UIControl } uksort($segmentsByCategory, array($this, 'sortSegmentCategories')); + $this->createRealTimeSegmentsIsEnabled = Config::getInstance()->General['enable_create_realtime_segments']; $this->segmentsByCategory = $segmentsByCategory; $this->nameOfCurrentSegment = ''; $this->clientSideProperties['isSegmentNotAppliedBecauseBrowserArchivingIsDisabled'] = 0; @@ -62,7 +63,7 @@ class SegmentSelectorControl extends UIControl $savedSegment['name'] = Common::sanitizeInputValue($savedSegment['name']); if (!empty($this->selectedSegment) && $this->selectedSegment == $savedSegment['definition']) { - $this->nameOfCurrentSegment = $savedSegment['name']; + $this->nameOfCurrentSegment = $savedSegment['name']; $this->clientSideProperties['isSegmentNotAppliedBecauseBrowserArchivingIsDisabled'] = $this->wouldApplySegment($savedSegment) ? 0 : 1; } diff --git a/plugins/SegmentEditor/templates/_segmentSelector.twig b/plugins/SegmentEditor/templates/_segmentSelector.twig index 9dfb59a7d5..de4509fa26 100644 --- a/plugins/SegmentEditor/templates/_segmentSelector.twig +++ b/plugins/SegmentEditor/templates/_segmentSelector.twig @@ -118,8 +118,10 @@ </strong></span> {{ 'General_And'|translate }} <span class="auto_archive"><strong> <select class="auto_archive_select"> + {% if createRealTimeSegmentsIsEnabled %} <option selected="1" value="0">{{ 'SegmentEditor_AutoArchiveRealTime'|translate }} {{ 'General_DefaultAppended'|translate }}</option> - <option value="1">{{ 'SegmentEditor_AutoArchivePreProcessed'|translate }} </option> + {% endif %} + <option {% if not createRealTimeSegmentsIsEnabled %}selected="1"{% endif %} value="1">{{ 'SegmentEditor_AutoArchivePreProcessed'|translate }} </option> </select> </strong></span> -- GitLab