diff --git a/app/Http/Controllers/ContactTableController.php b/app/Http/Controllers/ContactTableController.php index c0111431..dbc71150 100644 --- a/app/Http/Controllers/ContactTableController.php +++ b/app/Http/Controllers/ContactTableController.php @@ -32,10 +32,10 @@ public function index(Request $request): View // Determine what site to pull profiles from $site_id = $this->profile->getSiteID($request->data['base']); - $profiles = $this->profile->getProfilesByGroupOrder($site_id, config('profile.profile_group_id')); + $profiles = $this->profile->getProfilesByGroupOrder($site_id, config('profile.group_id')); // show table of contents if custom field 'table_of_contents' is not set to 'hide' - if (isset($request->data['base']['data']['table_of_contents']) && $request->data['base']['data']['table_of_contents'] === 'hide') { + if (config('profile.table_of_contents') === 'hide') { $profiles['anchors'] = []; } diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php index 82fe82e1..455c7bf4 100644 --- a/app/Http/Controllers/DirectoryController.php +++ b/app/Http/Controllers/DirectoryController.php @@ -33,7 +33,7 @@ public function index(Request $request): View $site_id = $this->profile->getSiteID($request->data['base']); if (!empty($request->data['base']['data']['profile_group_id'])) { - $profiles = $this->profile->getProfilesByGroupOrder($site_id, config('profile.profile_group_id')); + $profiles = $this->profile->getProfilesByGroupOrder($site_id, config('profile.group_id')); } else { $profiles = $this->profile->getProfilesByGroup($site_id); } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index fb2ca5d0..63f68c0b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -33,7 +33,7 @@ public function index(Request $request): View $site_id = $this->profile->getSiteID($request->data['base']); // Determine if we are forcing the profiles from custom page data - $forced_profile_group_id = config('profile.profile_group_id'); + $forced_profile_group_id = config('profile.group_id'); // Get the groups for the dropdown $dropdown_groups = $this->profile->getDropdownOfGroups($site_id); diff --git a/app/Repositories/PeopleRepository.php b/app/Repositories/PeopleRepository.php index f78b22a8..510de73c 100644 --- a/app/Repositories/PeopleRepository.php +++ b/app/Repositories/PeopleRepository.php @@ -132,7 +132,7 @@ public function getProfilesByGroupOrder($site_id, $groups) { $profile_listing = $this->getProfiles($site_id); - $group_order = explode(',', $groups); + $group_order = preg_split('/[\s,|]+/', $groups); $profiles['profiles'] = []; @@ -193,7 +193,7 @@ public function getDropdownOfGroups(int $site_id): array // Filter down the groups based on the parent group from the config $profile_groups['data'] = collect($profile_groups['data']) ->filter(function ($item) { - return (int)$item['parent_id'] === config('profile.profile_parent_group_id'); + return (int)$item['parent_id'] === config('profile.parent_group_id'); }) ->toArray(); @@ -386,7 +386,7 @@ public function getBackToProfileListUrl($referer = null, $scheme = null, $host = || $referer == $scheme.'://'.$host.$uri || strpos($referer, $host) === false ) { - return config('profile.profile_default_back_url'); + return config('profile.default_back_url'); } return $referer; @@ -397,7 +397,7 @@ public function getBackToProfileListUrl($referer = null, $scheme = null, $host = */ public function getSiteID($data) { - return !empty(config('profile.profile_site_id')) ? config('profile.profile_site_id') : $data['site']['people']['site_id']; + return !empty(config('profile.site_id')) ? config('profile.site_id') : $data['site']['people']['site_id']; } /** @@ -418,32 +418,20 @@ public function parseProfileConfig(array $data): void if (Str::startsWith($value, '{')) { $profile_config = json_decode($value, true); - if (!empty($profile_config['site_id'])) { - Config::set('profile.profile_site_id', $profile_config['site_id']); - } - - if (!empty($profile_config['group_id'])) { - Config::set('profile.profile_group_id', $profile_config['group_id']); - } - - if (!empty($profile_config['parent_group_id'])) { - Config::set('profile.profile_parent_group_id', $profile_config['parent_group_id']); - } - - if (!empty($profile_config['default_back_url'])) { - Config::set('profile.profile_default_back_url', $profile_config['default_back_url']); + foreach ($profile_config as $key => $value) { + Config::set('profile.'.$key, $value); } } } // legacy support for profile_group_id if (!empty($data['data']['profile_group_id'])) { - Config::set('profile.profile_group_id', $data['data']['profile_group_id']); + Config::set('profile.group_id', $data['data']['profile_group_id']); } // legacy support for profile_site_id if (!empty($data['data']['profile_site_id'])) { - Config::set('profile.profile_site_id', $data['data']['profile_site_id']); + Config::set('profile.site_id', $data['data']['profile_site_id']); } } } diff --git a/app/Repositories/ProfileRepository.php b/app/Repositories/ProfileRepository.php index 310dd221..e43ceec1 100644 --- a/app/Repositories/ProfileRepository.php +++ b/app/Repositories/ProfileRepository.php @@ -124,7 +124,7 @@ public function getProfilesByGroupOrder($site_id, $groups) { $profile_listing = $this->getProfiles($site_id); - $group_order = explode('|', $groups); + $group_order = preg_split('/[\s,|]+/', $groups); $profiles = []; @@ -196,7 +196,7 @@ public function getDropdownOfGroups(int $site_id): array // Filter down the groups based on the parent group from the config $profile_groups['results'] = collect($profile_groups['results']) ->filter(function ($item) { - return (int) $item['parent_id'] === config('profile.profile_parent_group_id'); + return (int) $item['parent_id'] === config('profile.parent_group_id'); }) ->toArray(); @@ -368,7 +368,7 @@ public function getBackToProfileListUrl($referer = null, $scheme = null, $host = || $referer == $scheme.'://'.$host.$uri || strpos($referer, $host) === false ) { - return config('profile.profile_default_back_url'); + return config('profile.default_back_url'); } return $referer; @@ -379,7 +379,7 @@ public function getBackToProfileListUrl($referer = null, $scheme = null, $host = */ public function getSiteID($data) { - return !empty(config('profile.profile_site_id')) ? config('profile.profile_site_id') : $data['site']['id']; + return !empty(config('profile.site_id')) ? config('profile.site_id') : $data['site']['id']; } /** @@ -400,32 +400,20 @@ public function parseProfileConfig(array $data): void if (Str::startsWith($value, '{')) { $profile_config = json_decode($value, true); - if (!empty($profile_config['site_id'])) { - Config::set('profile.profile_site_id', $profile_config['site_id']); - } - - if (!empty($profile_config['group_id'])) { - Config::set('profile.profile_group_id', $profile_config['group_id']); - } - - if (!empty($profile_config['parent_group_id'])) { - Config::set('profile.profile_parent_group_id', $profile_config['parent_group_id']); - } - - if (!empty($profile_config['default_back_url'])) { - Config::set('profile.profile_default_back_url', $profile_config['default_back_url']); + foreach ($profile_config as $key => $value) { + Config::set('profile.'.$key, $value); } } } // legacy support for profile_group_id if (!empty($data['data']['profile_group_id'])) { - Config::set('profile.profile_group_id', $data['data']['profile_group_id']); + Config::set('profile.group_id', $data['data']['profile_group_id']); } // legacy support for profile_site_id if (!empty($data['data']['profile_site_id'])) { - Config::set('profile.profile_site_id', $data['data']['profile_site_id']); + Config::set('profile.site_id', $data['data']['profile_site_id']); } } } diff --git a/config/profile.php b/config/profile.php index 2c7ee80d..c02b71ed 100644 --- a/config/profile.php +++ b/config/profile.php @@ -10,7 +10,7 @@ | "Return to Listing" link. | */ - 'profile_default_back_url' => '/profiles', + 'default_back_url' => '/profiles', /* |-------------------------------------------------------------------------- @@ -22,7 +22,7 @@ | groups are added to the root then leave this value as 0. | */ - 'profile_parent_group_id' => 0, + 'parent_group_id' => 0, /* |-------------------------------------------------------------------------- @@ -47,7 +47,7 @@ | This value is a pipe delimited string of group ids. | */ - 'profile_group_id' => null, + 'group_id' => null, /* |-------------------------------------------------------------------------- @@ -59,7 +59,7 @@ | this value as null. | */ - 'profile_site_id' => null, + 'site_id' => null, /* |-------------------------------------------------------------------------- diff --git a/resources/views/profile-listing.blade.php b/resources/views/profile-listing.blade.php index 1cb9c451..26ac2a31 100644 --- a/resources/views/profile-listing.blade.php +++ b/resources/views/profile-listing.blade.php @@ -2,6 +2,10 @@ @section('content') @include('components.page-title', ['title' => $base['page']['title']]) + +