PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Http/Controllers/ProfileController.php +30 -29 2.9.02.10.0 View file →
@@ -4,9 +4,8 @@
4 4
5 5 use FluentCommunity\App\Functions\Utility;
6 6 use FluentCommunity\App\Models\Comment;
7 7 use FluentCommunity\App\Models\Feed;
8 -use FluentCommunity\App\Models\NotificationSubscription;
9 8 use FluentCommunity\App\Models\Space;
10 9 use FluentCommunity\App\Models\SpaceGroup;
11 10 use FluentCommunity\App\Models\SpaceUserPivot;
12 11 use FluentCommunity\App\Models\XProfile;
@@ -76,9 +75,9 @@
76 75 $isAdmin = Helper::isSiteAdmin($currentUserId);
77 76
78 77 if ($isOwn || $isAdmin) {
79 78 $enableUserSync = Utility::getPrivacySetting('enable_user_sync') === 'yes';
80 - $nameArray = explode(' ', trim($xprofile->display_name));
79 + $nameArray = explode(' ', trim((string) $xprofile->display_name));
81 80 $xprofileFirstName = array_shift($nameArray);
82 81 $xprofileLastName = implode(' ', $nameArray);
83 82
84 83 $profile['email'] = $user->user_email;
@@ -206,9 +205,9 @@
206 205
207 206 if (isset($updateData['avatar'])) {
208 207
209 208 if ($xprofile->hasCustomAvatar()) {
210 - $deletedMedias[] = $xprofile->attributes['avatar'];
209 + $deletedMedias[] = Arr::get($xprofile->getAttributes(), 'avatar');
211 210 }
212 211
213 212 $xprofile->avatar = $updateData['avatar'];
214 213
@@ -356,10 +355,10 @@
356 355 }
357 356
358 357 $updateData['display_name'] = trim(sanitize_text_field(Arr::get($data, 'first_name') . ' ' . Arr::get($data, 'last_name')));
359 358
360 - $updateData['short_description'] = CustomSanitizer::unslashMarkdown(sanitize_textarea_field(trim(Arr::get($data, 'short_description'))));
361 - $meta['website'] = sanitize_url(Arr::get($data, 'website'));
359 + $updateData['short_description'] = CustomSanitizer::unslashMarkdown(sanitize_textarea_field(trim((string) Arr::get($data, 'short_description', ''))));
360 + $meta['website'] = sanitize_url((string) Arr::get($data, 'website', ''));
362 361 $meta['headline'] = sanitize_text_field(trim(Arr::get($data, 'headline', '')));
363 362 $socialLinks = Arr::get($data, 'social_links', []);
364 363
365 364 $maxDescriptionLength = apply_filters('fluent_community/max_profile_description_length', 5000);
@@ -725,38 +724,40 @@
725 724 $xProfile = $this->verifyAndGetProfile($userName);
726 725
727 726 $globalPreferances = NotificationPref::getGlobalPrefs();
728 727
729 - $userPrefs = NotificationSubscription::where('user_id', $xProfile->user_id)
730 - ->select(['notification_type', 'is_read', 'object_id'])
731 - ->get();
728 + // Read through the same service the save path writes through. These rows
729 + // live in fcom_notification_prefs, keyed by flat keys - space-scoped ones
730 + // carry an '_<space id>' suffix.
731 + $userPrefs = NotificationPref::getUserPrefs($xProfile->user_id);
732 732
733 + $frequencyMaps = [
734 + 0 => 'disabled',
735 + 1 => 'hourly',
736 + 2 => 'daily',
737 + 3 => 'weekly'
738 + ];
739 +
733 740 $userGlobalPrefs = [];
734 741 $spaceWisePrefs = [];
735 - foreach ($userPrefs as $pref) {
736 - if (!$pref->object_id) {
737 - if ($pref->notification_type === 'message_email_frequency') {
738 - $maps = [
739 - 0 => 'disabled',
740 - 1 => 'hourly',
741 - 2 => 'daily',
742 - 3 => 'weekly'
743 - ];
742 + foreach ($userPrefs as $prefKey => $prefValue) {
743 + if ($prefKey === 'message_email_frequency') {
744 + $userGlobalPrefs[$prefKey] = isset($frequencyMaps[$prefValue]) ? $frequencyMaps[$prefValue] : 'default';
745 + continue;
746 + }
744 747
745 - if (isset($maps[$pref->is_read])) {
746 - $userGlobalPrefs[$pref->notification_type] = $maps[$pref->is_read];
747 - } else {
748 - $userGlobalPrefs[$pref->notification_type] = 'default';
749 - }
750 - continue;
748 + if (preg_match('/^(np_by_(?:member|admin)_mail)_(\d+)$/', $prefKey, $matches)) {
749 + $spaceId = (int)$matches[2];
750 +
751 + if (empty($spaceWisePrefs[$spaceId])) {
752 + $spaceWisePrefs[$spaceId] = [];
751 753 }
752 - $userGlobalPrefs[$pref->notification_type] = $pref->is_read ? 'yes' : 'no';
753 - } else {
754 - if (empty($spaceWisePrefs[$pref->object_id])) {
755 - $spaceWisePrefs[$pref->object_id] = [];
756 - }
757 - $spaceWisePrefs[$pref->object_id][$pref->notification_type] = $pref->is_read;
754 +
755 + $spaceWisePrefs[$spaceId][$matches[1]] = $prefValue;
756 + continue;
758 757 }
758 +
759 + $userGlobalPrefs[$prefKey] = $prefValue ? 'yes' : 'no';
759 760 }
760 761
761 762 $messagingConfig = Utility::getOption('_messaging_settings', []);
762 763 $isGlobalPerUser = Arr::get($messagingConfig, 'messaging_email_frequency') == 'disabled';