PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
← All changes | app/Services/OptionService.php +100 -27 1.402.1.0 View file →
@@ -35,8 +35,28 @@
35 35 ->where('key', Constant::FLUENT_BOARD_ADMIN)
36 36 ->first();
37 37 }
38 38
39 + private function getDefaultGlobalNotificationSettings()
40 + {
41 + return [
42 + Constant::GLOBAL_EMAIL_NOTIFICATION_COMMENT => true,
43 + Constant::GLOBAL_EMAIL_NOTIFICATION_STAGE_CHANGE => true,
44 + Constant::GLOBAL_EMAIL_NOTIFICATION_TASK_ASSIGN => true,
45 + Constant::GLOBAL_EMAIL_NOTIFICATION_DUE_DATE => true,
46 + Constant::GLOBAL_EMAIL_NOTIFICATION_REMOVE_FROM_TASK => true,
47 + Constant::GLOBAL_EMAIL_NOTIFICATION_TASK_ARCHIVE => true,
48 + Constant::GLOBAL_EMAIL_NOTIFICATION_CREATING_TASK => true,
49 + Constant::GLOBAL_EMAIL_NOTIFICATION_COMMENTING => true,
50 + Constant::GLOBAL_EMAIL_NOTIFICATION_ASSIGNING => true
51 + ];
52 + }
53 +
54 + private function normalizeNotificationPreferenceValue($value)
55 + {
56 + return true === $value || 1 === $value || '1' === $value || 'true' === $value;
57 + }
58 +
39 59 public function updateGlobalNotificationSettings($newSettings)
40 60 {
41 61 $userId = get_current_user_id();
42 62
@@ -44,13 +64,17 @@
44 64 ->where('object_type', Constant::OBJECT_TYPE_USER)
45 65 ->where('key', Constant::USER_GLOBAL_NOTIFICATIONS)
46 66 ->first();
47 67
48 - foreach ($newSettings as $index => $setting)
49 - {
50 - $newSettings[$index] = $setting == 'true' ? true : false;
68 + $allowedSettings = $this->getDefaultGlobalNotificationSettings();
69 + $newSettings = array_intersect_key($newSettings, $allowedSettings);
70 + $filteredSettings = [];
71 + foreach ($newSettings as $index => $setting) {
72 + $filteredSettings[$index] = $this->normalizeNotificationPreferenceValue($setting);
51 73 }
52 74
75 + $newSettings = array_merge($allowedSettings, $filteredSettings);
76 +
53 77 $globalNotification->value = $newSettings;
54 78 $globalNotification->save();
55 79
56 80 //set this settings to all board
@@ -70,16 +94,9 @@
70 94 ->where('key', Constant::USER_GLOBAL_NOTIFICATIONS)
71 95 ->first();
72 96
73 97 //default notification settings
74 - $newSettingsArray = [
75 - Constant::GLOBAL_EMAIL_NOTIFICATION_COMMENT => true,
76 - Constant::GLOBAL_EMAIL_NOTIFICATION_STAGE_CHANGE => true,
77 - Constant::GLOBAL_EMAIL_NOTIFICATION_TASK_ASSIGN => true,
78 - Constant::GLOBAL_EMAIL_NOTIFICATION_DUE_DATE => true,
79 - Constant::GLOBAL_EMAIL_NOTIFICATION_REMOVE_FROM_TASK => true,
80 - Constant::GLOBAL_EMAIL_NOTIFICATION_TASK_ARCHIVE => true,
81 - ];
98 + $newSettingsArray = $this->getDefaultGlobalNotificationSettings();
82 99
83 100 //if no settings found of this user then store default
84 101 if(!$globalNotification) {
85 102 $meta = new Meta();
@@ -91,8 +108,23 @@
91 108
92 109 return $meta;
93 110 }
94 111
112 + $storedSettings = maybe_unserialize($globalNotification->value);
113 + if (is_array($storedSettings)) {
114 + $filteredSettings = array_merge($newSettingsArray, array_intersect_key($storedSettings, $newSettingsArray));
115 + foreach ($filteredSettings as $index => $setting) {
116 + $filteredSettings[$index] = $this->normalizeNotificationPreferenceValue($setting);
117 + }
118 +
119 + if ($filteredSettings !== $storedSettings) {
120 + $globalNotification->value = $filteredSettings;
121 + $globalNotification->save();
122 + } else {
123 + $globalNotification->value = $filteredSettings;
124 + }
125 + }
126 +
95 127 return $globalNotification;
96 128 }
97 129
98 130 public function getDashboardViewSettings()
@@ -104,24 +136,13 @@
104 136 ->first();
105 137
106 138 //if no settings found of this user then store default
107 139 if(!$dshboardViewSettings) {
108 - //default notification settings
109 - $newSettingsArray = [
110 - 'dashboard_view_label' => true,
111 - 'dashboard_view_priority' => true,
112 - 'dashboard_view_assignee' => true,
113 - 'dashboard_view_subtask' => true,
114 - 'dashboard_view_due_date' => true,
115 - 'dashboard_view_comment' => true,
116 - 'dashboard_view_notification' => true
117 - ];
118 -
119 140 $meta = new Meta();
120 141 $meta->object_id = $userId;
121 142 $meta->object_type = Constant::OBJECT_TYPE_USER;
122 143 $meta->key = Constant::USER_DASHBOARD_VIEW;
123 - $meta->value = $newSettingsArray;
144 + $meta->value = Constant::DEFAULT_DASHBOARD_VIEW_PREFERENCES;
124 145 $meta->save();
125 146
126 147 return $meta;
127 148 }
@@ -127,22 +148,74 @@
127 148 }
128 149
129 150 return $dshboardViewSettings;
130 151 }
131 - public function updateDashboardViewSettings($newSettings)
152 +
153 + public function getListViewPreferences()
132 154 {
133 155 $userId = get_current_user_id();
156 + $dshboardViewSettings = Meta::where('object_id', $userId)
157 + ->where('object_type', Constant::OBJECT_TYPE_USER)
158 + ->where('key', Constant::USER_LISTVIEW_PREFERENCES)
159 + ->first();
160 + //if no settings found of this user then store default
161 + if(!$dshboardViewSettings) {
162 + $meta = new Meta();
163 + $meta->object_id = $userId;
164 + $meta->object_type = Constant::OBJECT_TYPE_USER;
165 + $meta->key = Constant::USER_LISTVIEW_PREFERENCES;
166 + $meta->value = Constant::DEFAULT_DASHBOARD_VIEW_PREFERENCES;
167 + $meta->save();
134 168
169 + return $meta;
170 + }
171 +
172 + return $dshboardViewSettings;
173 + }
174 + public function updateDashboardViewSettings($newSettings, $view)
175 + {
176 + $userId = get_current_user_id();
177 +
178 + if ($view == 'listview') {
179 + $viewWiseKey = Constant::USER_LISTVIEW_PREFERENCES;
180 + } elseif ($view == 'tableview') {
181 + $viewWiseKey = Constant::USER_TABLEVIEW_PREFERENCES;
182 + } else {
183 + $viewWiseKey = Constant::USER_DASHBOARD_VIEW;
184 + }
185 +
135 186 $dshboardViewSettings = Meta::where('object_id', $userId)
136 187 ->where('object_type', Constant::OBJECT_TYPE_USER)
137 - ->where('key', Constant::USER_DASHBOARD_VIEW)
188 + ->where('key', $viewWiseKey)
138 189 ->first();
139 -
190 +
140 191 foreach ($newSettings as $index => $setting)
141 192 {
142 193 $newSettings[$index] = $setting == 'true' ? true : false;
143 194 }
144 -
195 +
145 196 $dshboardViewSettings->value = $newSettings;
146 197 $dshboardViewSettings->save();
198 + }
199 +
200 + // Add this new method
201 + public function getTableViewPreferences()
202 + {
203 + $userId = get_current_user_id();
204 + $tableViewSettings = Meta::where('object_id', $userId)
205 + ->where('object_type', Constant::OBJECT_TYPE_USER)
206 + ->where('key', Constant::USER_TABLEVIEW_PREFERENCES)
207 + ->first();
208 + if (!$tableViewSettings) {
209 + $meta = new Meta();
210 + $meta->object_id = $userId;
211 + $meta->object_type = Constant::OBJECT_TYPE_USER;
212 + $meta->key = Constant::USER_TABLEVIEW_PREFERENCES;
213 + $meta->value = Constant::DEFAULT_TABLEVIEW_VIEW_PREFERENCES;
214 + $meta->save();
215 +
216 + return $meta;
217 + }
218 +
219 + return $tableViewSettings;
147 220 }
148 221 }