Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,5 @@ build/
nbbuild/
dist/
nbdist/

_ide_helper.php
5 changes: 5 additions & 0 deletions CitadelManager/app/FilterList.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ public function group()
{
return $this->belongsToMany('App\Group');
}

public function getRelativeListPath()
{
return '/' . $this->namespace . '/' . $this->category . '/' . FilterRulesManager::TYPES[$this->type] . '.txt';
}
}
37 changes: 36 additions & 1 deletion CitadelManager/app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ private function mergeConfigurations($userGroup, $thisUser, $activation) {
if ($userGroup->config_cache == null || strlen($userGroup->config_cache) == 0) {
$userGroup->rebuildGroupData();
}

$groupConfiguration = json_decode($userGroup->config_cache, true) ?? [];

$userConfiguration = json_decode($thisUser->config_override, true) ?? [];
Expand All @@ -564,6 +563,42 @@ private function mergeConfigurations($userGroup, $thisUser, $activation) {

$configuration = array_merge($groupConfiguration, $userConfiguration, $activationConfiguration);

// Merge the category overrides
if (isset($activationConfiguration['CategoryOverrides']) || isset($userConfiguration['CategoryOverrides'])) {
$categoryOverrideArray = $mergedCategoryOverrides = array_merge($userConfiguration['CategoryOverrides'] ?? [], $activationConfiguration['CategoryOverrides'] ?? []);
$mergedCategoryOverrides = array_values(array_reduce($categoryOverrideArray, function($carry, $item) {
$carry[$item['categoryId']] = $item;
return $carry;
}, []));
foreach ($mergedCategoryOverrides as $categoryOverride) {
$category = FilterList::where('id', $categoryOverride['categoryId'])->first();
if ($category) {
$path = $category->getRelativeListPath();
// look for existing category in ConfiguredLists array
$matchIndex = array_search($path, array_column($configuration['ConfiguredLists'], 'RelativeListPath'));
if ($matchIndex !== false) {
if ($categoryOverride['override'] == 'Ignored') {
// remove the category from the ConfiguredLists array
unset($configuration['ConfiguredLists'][$matchIndex]);
$configuration['ConfiguredLists'] = array_values($configuration['ConfiguredLists']);
} else {
// merge the category override into the existing category
$configuration['ConfiguredLists'][$matchIndex]['ListType'] = $categoryOverride['override'];
}

} else {
// add the category override to the ConfiguredLists array if it's not ignored
if ($categoryOverride['override'] != 'Ignored') {
$configuration['ConfiguredLists'][] = [
'ListType' => $categoryOverride['override'],
'RelativeListPath' => $path
];
}
}
}
}
}

/* -------------------------------------------------------------- */
/* Merge the arrays for these keys */
/* -------------------------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion CitadelManager/public/js/bindings.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions CitadelManager/resources/assets/js/admin/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,7 @@ namespace Citadel {
};

this.m_tableFilterLists = $('#filter_table').DataTable(filterTableSettings);
console.log(this.m_tableFilterLists)

});

Expand Down Expand Up @@ -1684,7 +1685,7 @@ namespace Citadel {
this.ForceTableRedraw(this.m_tableUsers);
});

userRecord.StartEditing(this.m_allGroups, data);
userRecord.StartEditing(this.m_allGroups, this.m_allFilters, data);
}
break;

Expand Down Expand Up @@ -1754,7 +1755,7 @@ namespace Citadel {
appUserActivationRecord.StopEditing();
this.ForceTableRedraw(this.m_tableActivation);
});
appUserActivationRecord.StartEditing(this.m_allGroups, data);
appUserActivationRecord.StartEditing(this.m_allGroups, this.m_allFilters, data);
}
break;

Expand Down Expand Up @@ -1806,7 +1807,7 @@ namespace Citadel {
let newUser = new UserRecord();

var usergoup_data = this.m_tableGroups.data();
newUser.StartEditing(this.m_allGroups, this.m_tableUsers.data()['all_user_roles']);
newUser.StartEditing(this.m_allGroups, this.m_allFilters, this.m_tableUsers.data()['all_user_roles']);

newUser.ActionCompleteCallback = ((action: string): void => {
newUser.StopEditing();
Expand Down
Loading