N°3649 - Activity panel: Add conf. param. 'activity_panel.entry_form_opened_by_default' as a default value for the user pref.

This commit is contained in:
Molkobain
2021-03-02 11:33:52 +01:00
parent 3b40728701
commit cf72c2ef8f
3 changed files with 23 additions and 5 deletions

View File

@@ -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"',

View File

@@ -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');

View File

@@ -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;
}
/**