Skip to content

Commit

Permalink
Fix max levels defaulting to 0 on reset
Browse files Browse the repository at this point in the history
When resetting user settings, the maximum level of ancestors/descendants was defaulting to 0. Fixes #518
  • Loading branch information
Neriderc committed Nov 16, 2024
1 parent 9269163 commit 0273b04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions app/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Settings
/**
* Settings instance always starts with default settings
*/
public function __construct(){
public function __construct($tree = null){
// Load settings from config file
$this->defaultSettings = include dirname(__FILE__) . "/../config.php";
// Add options lists
Expand Down Expand Up @@ -78,8 +78,7 @@ public function __construct(){
$this->defaultSettings['sharednote_col_data'] = '[]';
$this->defaultSettings['updated_date'] = '';
$this->defaultSettings['highlight_custom_json'] = '{}';
$this->defaultSettings['limit_levels'] = '0';

$this->defaultSettings['limit_levels'] = ($tree ? $this->getLevelLimit($tree, $this->defaultSettings) : '0');
}

/**
Expand Down Expand Up @@ -836,7 +835,7 @@ public function getSettingsName($module, $tree, $settings_id)
* @param $settings
* @return string
*/
private function getLevelLimit($tree, $settings)
private function getLevelLimit($tree, $settings): string
{
if (Auth::isAdmin()) {
return '99';
Expand Down
4 changes: 2 additions & 2 deletions module.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public function getChartAction(ServerRequestInterface $request): ResponseInterfa
$xref = $tree->getUserPreference(Auth::user(), UserInterface::PREF_TREE_ACCOUNT_XREF);
}
$individual = $this->getIndividual($tree, $tree->significantIndividual(Auth::user(), $xref)->xref());
$userDefaultVars = (new Settings())->getAdminSettings($this);
$settings = new Settings();
$userDefaultVars = (new Settings($tree))->getAdminSettings($this);
$settings = new Settings($tree);
$userDefaultVars['first_render'] = true;
if (isset($_REQUEST['reset'])){
if (!$userDefaultVars['enable_graphviz'] && $userDefaultVars['graphviz_bin'] != "") {
Expand Down

0 comments on commit 0273b04

Please sign in to comment.