From cf72c2ef8f4ffd758e7a0b5c4b2504889f2193bd Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 2 Mar 2021 11:33:52 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03649=20-=20Activity=20panel:=20Add=20con?= =?UTF-8?q?f.=20param.=20'activity=5Fpanel.entry=5Fform=5Fopened=5Fby=5Fde?= =?UTF-8?q?fault'=20as=20a=20default=20value=20for=20the=20user=20pref.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.class.inc.php | 10 +++++++++- pages/preferences.php | 7 ++++++- .../UI/Base/Layout/ActivityPanel/ActivityPanel.php | 11 ++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 7df22d9bf..2c5983d18 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1215,7 +1215,7 @@ class Config ], 'activity_panel.show_author_name_below_entries' => [ 'type' => 'bool', - 'description' => 'Whether or not to show the author friendlyname next to the date on the last entry', + 'description' => 'Whether or not to show the author friendlyname next to the date on the last entry.', 'default' => false, 'value' => '', 'source_of_value' => '', @@ -1229,6 +1229,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'activity_panel.entry_form_opened_by_default' => [ + 'type' => 'bool', + 'description' => 'Whether or not the new entry form will be automatically opened when viewing an object.', + 'default' => false, + 'value' => '', + 'source_of_value' => '', + 'show_in_conf_sample' => true, + ], 'obsolescence.show_obsolete_data' => [ 'type' => 'bool', 'description' => 'Default value for the user preference "show obsolete data"', diff --git a/pages/preferences.php b/pages/preferences.php index b223945c0..306d5e7f5 100644 --- a/pages/preferences.php +++ b/pages/preferences.php @@ -514,7 +514,12 @@ function GetRichTextToolbarExpandedFieldBlock(): iUIBlock */ function GetActivityPanelEntryFormOpenedFieldBlock(): iUIBlock { - $bOpened = appUserPreferences::GetPref('activity_panel.is_entry_form_opened', false); + // First check if user has a pref. + $bOpened = appUserPreferences::GetPref('activity_panel.is_entry_form_opened', null); + if (null === $bOpened) { + // Otherwise get the default config. param. + $bOpened = MetaModel::GetConfig()->Get('activity_panel.entry_form_opened_by_default'); + } $sCheckedForHtmlAttribute = $bOpened ? 'checked="checked"' : ''; $sLabel = Dict::S('UI:Preferences:ActivityPanel:EntryFormOpened'); diff --git a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php index cd1f0a539..b6d422bc9 100644 --- a/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php +++ b/sources/application/UI/Base/Layout/ActivityPanel/ActivityPanel.php @@ -667,16 +667,21 @@ class ActivityPanel extends UIBlock } /** - * @return bool True if the entry form shouldbe opened by default, false otherwise. Based on the user pref. or false by default. + * @return bool True if the entry form shouldbe opened by default, false otherwise. Based on the user pref. or the config. param. by default. * @throws \CoreException * @throws \CoreUnexpectedValue * @throws \MySQLException */ public function IsEntryFormOpened(): bool { - $bDefault = false; + // First check if user has a pref. + $bValue = appUserPreferences::GetPref('activity_panel.is_entry_form_opened', null); + if (null === $bValue) { + // Otherwise get the default config. param. + $bValue = MetaModel::GetConfig()->Get('activity_panel.entry_form_opened_by_default'); + } - return appUserPreferences::GetPref('activity_panel.is_entry_form_opened', $bDefault); + return $bValue; } /**