| @@ -2,11 +2,15 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentCommunity\App\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use FluentCommunity\App\Functions\Utility; |
| 6 | -use FluentCommunity\App\Models\User; | |
| 6 | +use FluentCommunity\App\Models\BaseSpace; | |
| 7 | +use FluentCommunity\App\Services\AuthenticationService; | |
| 7 | 8 | use FluentCommunity\App\Services\CustomSanitizer; |
| 8 | 9 | use FluentCommunity\App\Services\FeedsHelper; |
| 10 | +use FluentCommunity\App\Services\ProfileHelper; | |
| 11 | +use FluentCommunity\Modules\Auth\AuthHelper; | |
| 12 | +use FluentCommunity\Modules\PushNotification\PushNotificationModule; | |
| 9 | 13 | use FluentCommunity\App\Services\Helper; |
| 10 | 14 | use FluentCommunity\App\Services\OnboardingService; |
| 11 | 15 | use FluentCommunity\Framework\Http\Request\Request; |
| 12 | 16 | use FluentCommunity\Framework\Support\Arr; |
| @@ -25,12 +29,15 @@ | ||
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | unset($formatedRoles['administrator']); |
| 28 | 32 | |
| 29 | - return [ | |
| 30 | - 'settings' => $settings, | |
| 31 | - 'user_roles' => $formatedRoles | |
| 33 | + $data = [ | |
| 34 | + 'settings' => $settings, | |
| 35 | + 'user_roles' => $formatedRoles, | |
| 36 | + 'users_can_register' => !!get_option('users_can_register'), | |
| 37 | + 'user_registration_enable_url' => admin_url('options-general.php') | |
| 32 | 38 | ]; |
| 39 | + return apply_filters('fluent_community/general_settings_api_response', $data, $request->all()); | |
| 33 | 40 | } |
| 34 | 41 | |
| 35 | 42 | public function saveGeneralSettings(Request $request) |
| 36 | 43 | { |
| @@ -35,8 +42,9 @@ | ||
| 35 | 42 | public function saveGeneralSettings(Request $request) |
| 36 | 43 | { |
| 37 | 44 | $inputs = $request->get('settings', []); |
| 38 | 45 | $settings = Helper::generalSettings(false); |
| 46 | + $storedSettings = $settings; | |
| 39 | 47 | $inputs = Arr::only($inputs, array_keys($settings)); |
| 40 | 48 | |
| 41 | 49 | $settings['logo'] = Arr::get($inputs, 'logo', ''); |
| 42 | 50 | $settings['white_logo'] = Arr::get($inputs, 'white_logo', ''); |
| @@ -62,14 +70,35 @@ | ||
| 62 | 70 | $settings['access'] = Arr::get($inputs, 'access', []); |
| 63 | 71 | $settings['auth_content'] = wp_kses_post(Arr::get($inputs, 'auth_content', '')); |
| 64 | 72 | $settings['auth_redirect'] = sanitize_url(Arr::get($inputs, 'auth_redirect', '')); |
| 65 | 73 | $settings['restricted_role_content'] = wp_kses_post(Arr::get($inputs, 'restricted_role_content', '')); |
| 74 | + $settings['logo_permalink'] = sanitize_url(Arr::get($inputs, 'logo_permalink', '')); | |
| 75 | + $settings['logo_permalink_type'] = sanitize_text_field(Arr::get($inputs, 'logo_permalink_type', 'default')); | |
| 66 | 76 | $settings['auth_url'] = sanitize_url(Arr::get($inputs, 'auth_url', '')); |
| 67 | 77 | $media = Helper::getMediaFromUrl($settings['logo']); |
| 68 | 78 | $whiteMedia = Helper::getMediaFromUrl($settings['white_logo']); |
| 79 | + $featuredMedia = Helper::getMediaFromUrl($settings['featured_image']); | |
| 80 | + $settings['cutsom_auth_url'] = sanitize_url(Arr::get($inputs, 'cutsom_auth_url', '')); | |
| 81 | + $settings['auth_form_type'] = sanitize_text_field(Arr::get($inputs, 'auth_form_type', '')); | |
| 82 | + $settings['explicit_registration'] = sanitize_text_field(Arr::get($inputs, 'explicit_registration', 'no')); | |
| 69 | 83 | |
| 70 | - $featuredMedia = Helper::getMediaFromUrl($settings['featured_image']); | |
| 84 | + $isCustomSignupPage = $settings['auth_form_type'] === 'default' && Arr::get($inputs, 'use_custom_signup_page', 'no') == 'yes'; | |
| 85 | + if (!$isCustomSignupPage) { | |
| 86 | + $settings['custom_signup_url'] = ''; | |
| 87 | + $settings['use_custom_signup_page'] = 'no'; | |
| 88 | + } else { | |
| 89 | + $settings['use_custom_signup_page'] = 'yes'; | |
| 71 | 90 | |
| 91 | + $url = Arr::get($inputs, 'custom_signup_url', ''); | |
| 92 | + | |
| 93 | + if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) { | |
| 94 | + return $this->sendError([ | |
| 95 | + 'message' => __('Please provide a valid signup URL', 'fluent-community') | |
| 96 | + ]); | |
| 97 | + } | |
| 98 | + $settings['custom_signup_url'] = $url; | |
| 99 | + } | |
| 100 | + | |
| 72 | 101 | if ($media) { |
| 73 | 102 | $settings['logo'] = $media->public_url; |
| 74 | 103 | $media->update([ |
| 75 | 104 | 'is_active' => true, |
| @@ -96,13 +125,24 @@ | ||
| 96 | 125 | ]); |
| 97 | 126 | } |
| 98 | 127 | |
| 99 | 128 | $slugChanged = false; |
| 100 | - if ($settings['slugs'] != $inputs['slugs'] && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { | |
| 101 | - $settings['slugs'] = $inputs['slugs']; | |
| 129 | + $newSlug = sanitize_title($inputs['slug'] ?? ''); | |
| 130 | + if ($newSlug && $settings['slug'] != $newSlug && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { | |
| 131 | + $settings['slug'] = $newSlug; | |
| 102 | 132 | $slugChanged = true; |
| 103 | 133 | } |
| 104 | 134 | |
| 135 | + if (!Helper::isSuperAdmin()) { | |
| 136 | + foreach (['auth_url', 'cutsom_auth_url', 'auth_form_type', 'auth_redirect', 'custom_signup_url', 'use_custom_signup_page', 'explicit_registration'] as $restrictedKey) { | |
| 137 | + if ($settings[$restrictedKey] != Arr::get($storedSettings, $restrictedKey, '')) { | |
| 138 | + return $this->sendError([ | |
| 139 | + 'message' => __('You do not have permission to change the authentication and login settings', 'fluent-community') | |
| 140 | + ]); | |
| 141 | + } | |
| 142 | + } | |
| 143 | + } | |
| 144 | + | |
| 105 | 145 | update_option('fluent_community_settings', $settings); |
| 106 | 146 | |
| 107 | 147 | $redirectUrl = ''; |
| 108 | 148 | |
| @@ -113,9 +153,9 @@ | ||
| 113 | 153 | $redirectUrl = Helper::baseUrl('admin/settings/general'); |
| 114 | 154 | } |
| 115 | 155 | |
| 116 | 156 | return [ |
| 117 | - 'message' => __('Settings has been saved successfully', 'fluent-community'), | |
| 157 | + 'message' => __('Settings have been saved successfully.', 'fluent-community'), | |
| 118 | 158 | 'redirect_url' => $redirectUrl |
| 119 | 159 | ]; |
| 120 | 160 | } |
| 121 | 161 | |
| @@ -120,11 +160,18 @@ | ||
| 120 | 160 | } |
| 121 | 161 | |
| 122 | 162 | public function getEmailSettings(Request $request) |
| 123 | 163 | { |
| 124 | - return [ | |
| 125 | - 'email_settings' => Utility::getEmailNotificationSettings() | |
| 164 | + $emailSettings = Utility::getEmailNotificationSettings(); | |
| 165 | + $globalSettings = Helper::generalSettings(false); | |
| 166 | + if (empty($emailSettings['logo'])) { | |
| 167 | + $emailSettings['global_logo'] = $globalSettings['logo']; | |
| 168 | + } | |
| 169 | + | |
| 170 | + $data = [ | |
| 171 | + 'email_settings' => $emailSettings | |
| 126 | 172 | ]; |
| 173 | + return apply_filters('fluent_community/email_settings_api_response', $data, $request->all()); | |
| 127 | 174 | } |
| 128 | 175 | |
| 129 | 176 | public function saveEmailSettings(Request $request) |
| 130 | 177 | { |
| @@ -130,8 +177,22 @@ | ||
| 130 | 177 | { |
| 131 | 178 | $prevSettings = Utility::getEmailNotificationSettings(); |
| 132 | 179 | $newSettings = $request->get('email_settings', []); |
| 133 | 180 | |
| 181 | + $logo = Arr::get($newSettings, 'logo', ''); | |
| 182 | + | |
| 183 | + if ($logo) { | |
| 184 | + $logoMedia = Helper::getMediaFromUrl($logo); | |
| 185 | + if ($logoMedia) { | |
| 186 | + $newSettings['logo'] = $logoMedia->public_url; | |
| 187 | + $logoMedia->update([ | |
| 188 | + 'is_active' => true, | |
| 189 | + 'user_id' => get_current_user_id(), | |
| 190 | + 'object_source' => 'general' | |
| 191 | + ]); | |
| 192 | + } | |
| 193 | + } | |
| 194 | + | |
| 134 | 195 | $newSettings = wp_parse_args($newSettings, $prevSettings); |
| 135 | 196 | $newSettings = CustomSanitizer::santizeEmailSettings($newSettings); |
| 136 | 197 | |
| 137 | 198 | Utility::updateOption('global_email_settings', $newSettings); |
| @@ -147,12 +208,56 @@ | ||
| 147 | 208 | } |
| 148 | 209 | |
| 149 | 210 | return [ |
| 150 | 211 | 'email_settings' => $newSettings, |
| 151 | - 'message' => __('Email notification settings has been updated', 'fluent-community') | |
| 212 | + 'message' => __('Email notification settings have been updated', 'fluent-community') | |
| 152 | 213 | ]; |
| 153 | 214 | } |
| 154 | 215 | |
| 216 | + public function getPushSettings(Request $request) | |
| 217 | + { | |
| 218 | + $data = [ | |
| 219 | + 'push_settings' => Utility::getPushNotificationSettings(), | |
| 220 | + 'push_available' => PushNotificationModule::isFluentNotifyActive(), | |
| 221 | + 'push_setup' => [ | |
| 222 | + 'state' => PushNotificationModule::getSetupState(), | |
| 223 | + 'settings_url' => PushNotificationModule::getSettingsUrl(), | |
| 224 | + 'can_install' => current_user_can('install_plugins'), | |
| 225 | + 'can_activate' => current_user_can('activate_plugins'), | |
| 226 | + 'has_installer' => (bool)has_action('fluent_community/install_fluent_notify_plugin'), | |
| 227 | + 'learn_more_url' => 'https://fluentnotify.com' | |
| 228 | + ] | |
| 229 | + ]; | |
| 230 | + | |
| 231 | + return apply_filters('fluent_community/push_settings_api_response', $data, $request->all()); | |
| 232 | + } | |
| 233 | + | |
| 234 | + public function savePushSettings(Request $request) | |
| 235 | + { | |
| 236 | + $prevSettings = Utility::getPushNotificationSettings(); | |
| 237 | + | |
| 238 | + $settings = Arr::only((array)$request->get('settings', []), array_keys($prevSettings)); | |
| 239 | + $settings = wp_parse_args($settings, $prevSettings); | |
| 240 | + | |
| 241 | + foreach ($settings as $key => $value) { | |
| 242 | + if ($key === 'prompt_placements') { | |
| 243 | + $settings[$key] = array_values(array_intersect( | |
| 244 | + array_map('sanitize_text_field', (array)$value), | |
| 245 | + PushNotificationModule::PROMPT_PLACEMENTS | |
| 246 | + )); | |
| 247 | + } else { | |
| 248 | + $settings[$key] = $value === 'yes' ? 'yes' : 'no'; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + | |
| 252 | + Utility::updateOption('global_push_settings', $settings); | |
| 253 | + | |
| 254 | + return [ | |
| 255 | + 'push_settings' => $settings, | |
| 256 | + 'message' => __('Push notification settings have been updated', 'fluent-community') | |
| 257 | + ]; | |
| 258 | + } | |
| 259 | + | |
| 155 | 260 | public function getStorageSettings(Request $request) |
| 156 | 261 | { |
| 157 | 262 | if (!defined('FLUENT_COMMUNITY_PRO')) { |
| 158 | 263 | $config = [ |
| @@ -163,9 +268,9 @@ | ||
| 163 | 268 | } |
| 164 | 269 | |
| 165 | 270 | return apply_filters('fluent_community/storage_settings_response', [ |
| 166 | 271 | 'config' => $config |
| 167 | - ]); | |
| 272 | + ], $request->all()); | |
| 168 | 273 | } |
| 169 | 274 | |
| 170 | 275 | public function updateStorageSettings(Request $request) |
| 171 | 276 | { |
| @@ -170,19 +275,19 @@ | ||
| 170 | 275 | public function updateStorageSettings(Request $request) |
| 171 | 276 | { |
| 172 | 277 | if (!defined('FLUENT_COMMUNITY_PRO')) { |
| 173 | 278 | return $this->sendError([ |
| 174 | - 'message' => 'Sorry, you can not update this config. Please activate pro' | |
| 279 | + 'message' => __('Sorry, you cannot update this config. Please activate pro', 'fluent-community') | |
| 175 | 280 | ]); |
| 176 | 281 | } |
| 177 | 282 | |
| 178 | 283 | if (defined('FLUENT_COMMUNITY_CLOUD_STORAGE') && FLUENT_COMMUNITY_CLOUD_STORAGE) { |
| 179 | 284 | return $this->sendError([ |
| 180 | - 'message' => 'You can not update the storage settings as it is defined in the config file' | |
| 285 | + 'message' => __('You cannot update the storage settings as it is defined in the config file', 'fluent-community') | |
| 181 | 286 | ]); |
| 182 | 287 | } |
| 183 | 288 | |
| 184 | - $config = $request->get('config', []); | |
| 289 | + $config = (array)$request->get('config', []); | |
| 185 | 290 | |
| 186 | 291 | $driver = Arr::get($config, 'driver', 'local'); |
| 187 | 292 | |
| 188 | 293 | $validation = [ |
| @@ -188,16 +293,17 @@ | ||
| 188 | 293 | $validation = [ |
| 189 | 294 | 'driver' => 'required' |
| 190 | 295 | ]; |
| 191 | 296 | |
| 297 | + $isRemote = in_array($driver, ['amazon_s3', 'bunny_cdn', 'cloudflare_r2']); | |
| 298 | + | |
| 192 | 299 | if ($driver == 'cloudflare_r2') { |
| 193 | 300 | $validation = [ |
| 194 | - 'driver' => 'required', | |
| 195 | - 'access_key' => 'required', | |
| 196 | - 'secret_key' => 'required', | |
| 197 | - 'bucket' => 'required', | |
| 198 | - 'public_url' => 'required|url', | |
| 199 | - 'account_id' => 'required', | |
| 301 | + 'driver' => 'required', | |
| 302 | + 'access_key' => 'required', | |
| 303 | + 'secret_key' => 'required', | |
| 304 | + 'public_url' => 'required|url', | |
| 305 | + 'endpoint_url' => 'required|url', | |
| 200 | 306 | ]; |
| 201 | 307 | } else if ($driver == 'amazon_s3') { |
| 202 | 308 | $validation = [ |
| 203 | 309 | 'driver' => 'required', |
| @@ -204,14 +310,21 @@ | ||
| 204 | 310 | 'access_key' => 'required', |
| 205 | 311 | 'secret_key' => 'required', |
| 206 | 312 | 'bucket' => 'required' |
| 207 | 313 | ]; |
| 314 | + } else if ($driver == 'bunny_cdn') { | |
| 315 | + $validation = [ | |
| 316 | + 'driver' => 'required', | |
| 317 | + 'access_key' => 'required', | |
| 318 | + 's3_endpoint' => 'required', | |
| 319 | + 'bucket' => 'required', | |
| 320 | + 'public_url' => 'required|url' | |
| 321 | + ]; | |
| 208 | 322 | } |
| 209 | 323 | |
| 210 | 324 | $this->validate($config, $validation); |
| 211 | 325 | |
| 212 | - if ($driver === 'cloudflare_r2' || $driver === 'amazon_s3') { | |
| 213 | - | |
| 326 | + if ($isRemote) { | |
| 214 | 327 | $previousConfig = \FluentCommunityPro\App\Modules\CloudStorage\StorageHelper::getConfig(); |
| 215 | 328 | if ($config['access_key'] == 'FCOM_ENCRYPTED_DATA_KEY') { |
| 216 | 329 | $config['access_key'] = Arr::get($previousConfig, 'access_key'); |
| 217 | 330 | } |
| @@ -223,16 +336,17 @@ | ||
| 223 | 336 | $driver = (new \FluentCommunityPro\App\Modules\CloudStorage\CloudStorageModule)->getConnectionDriver($config); |
| 224 | 337 | |
| 225 | 338 | if (!$driver) { |
| 226 | 339 | return $this->sendError([ |
| 227 | - 'message' => 'Could not connect to the remote storage service. Please check your credentials' | |
| 340 | + 'message' => __('Could not connect to the remote storage service. Please check your credentials', 'fluent-community') | |
| 228 | 341 | ]); |
| 229 | 342 | } |
| 230 | 343 | |
| 231 | 344 | $test = $driver->testConnection(); |
| 232 | 345 | if (!$test || is_wp_error($test)) { |
| 346 | + $errorMessage = is_wp_error($test) ? $test->get_error_message() : 'Unknown Error'; | |
| 233 | 347 | return $this->sendError([ |
| 234 | - 'message' => 'Could not connect to the remote storage service. Error: ' . is_wp_error($test) ? $test->get_error_message() : 'Unknow Error' | |
| 348 | + 'message' => __('Could not connect to the remote storage service. Error: ', 'fluent-community') . $errorMessage | |
| 235 | 349 | ]); |
| 236 | 350 | } |
| 237 | 351 | } |
| 238 | 352 | |
| @@ -241,8 +355,9 @@ | ||
| 241 | 355 | 'access_key', |
| 242 | 356 | 'secret_key', |
| 243 | 357 | 'bucket', |
| 244 | 358 | 'public_url', |
| 359 | + 'endpoint_url', | |
| 245 | 360 | 'account_id', |
| 246 | 361 | 'sub_folder', |
| 247 | 362 | 's3_endpoint' |
| 248 | 363 | ]); |
| @@ -264,16 +379,18 @@ | ||
| 264 | 379 | $config = array_filter($config); |
| 265 | 380 | \FluentCommunityPro\App\Modules\CloudStorage\StorageHelper::updateConfig($config); |
| 266 | 381 | |
| 267 | 382 | return [ |
| 268 | - 'message' => __('Storage settings has been updated successfully', 'fluent-community') | |
| 383 | + 'message' => __('Storage settings have been updated successfully', 'fluent-community') | |
| 269 | 384 | ]; |
| 270 | 385 | } |
| 271 | 386 | |
| 272 | 387 | public function getWelcomeBannerSettings(Request $request) |
| 273 | 388 | { |
| 389 | + $settings = apply_filters('fluent_community/get_welcome_banner_settings', Helper::getWelcomeBannerSettings(), $request->all()); | |
| 390 | + | |
| 274 | 391 | return [ |
| 275 | - 'settings' => Helper::getWelcomeBannerSettings() | |
| 392 | + 'settings' => $settings | |
| 276 | 393 | ]; |
| 277 | 394 | } |
| 278 | 395 | |
| 279 | 396 | public function updateWelcomeBannerSettings(Request $request) |
| @@ -282,27 +399,44 @@ | ||
| 282 | 399 | |
| 283 | 400 | $settings = CustomSanitizer::sanitizeWelcomeBannerSettings($settings); |
| 284 | 401 | |
| 285 | 402 | if (Arr::get($settings, 'login.enabled') == 'yes') { |
| 286 | - $settings['login']['description_rendered'] = FeedsHelper::mdToHtml(Arr::get($settings, 'login.description')); | |
| 403 | + $settings['login']['description_rendered'] = wp_kses_post(FeedsHelper::mdToHtml(Arr::get($settings, 'login.description'))); | |
| 287 | 404 | } |
| 288 | 405 | |
| 289 | 406 | if (Arr::get($settings, 'logout.enabled') == 'yes') { |
| 290 | - $settings['logout']['description_rendered'] = FeedsHelper::mdToHtml(Arr::get($settings, 'logout.description')); | |
| 407 | + $settings['logout']['description_rendered'] = wp_kses_post(FeedsHelper::mdToHtml(Arr::get($settings, 'logout.description'))); | |
| 291 | 408 | if (Arr::get($settings, 'logout.buttonLabel') && Arr::get($settings, 'logout.useCustomUrl') != 'yes') { |
| 292 | - $settings['logout']['buttonLink'] = Helper::baseUrl('?fcom_action=auth'); | |
| 409 | + $settings['logout']['buttonLink'] = Helper::getAuthUrl(); | |
| 293 | 410 | } |
| 294 | 411 | } |
| 295 | 412 | |
| 413 | + $settings = apply_filters('fluent_community/update_welcome_banner_settings', $settings); | |
| 414 | + | |
| 296 | 415 | Utility::updateOption('welcome_banner_settings', $settings); |
| 416 | + | |
| 297 | 417 | Utility::setCache('welcome_banner_settings', $settings, WEEK_IN_SECONDS); |
| 298 | 418 | |
| 299 | 419 | return [ |
| 300 | - 'message' => __('Welcome banner settings has been updated successfully', 'fluent-community'), | |
| 420 | + 'message' => __('Welcome banner settings have been updated successfully', 'fluent-community'), | |
| 301 | 421 | 'settings' => $settings |
| 302 | 422 | ]; |
| 303 | 423 | } |
| 304 | 424 | |
| 425 | + public function getAuthSettings() | |
| 426 | + { | |
| 427 | + $settings = AuthenticationService::getAuthSettings(); | |
| 428 | + | |
| 429 | + $settings['login']['form']['fields'] = AuthHelper::getLoginFormFields(); | |
| 430 | + $settings['signup']['form']['fields'] = AuthHelper::getFormFields(); | |
| 431 | + | |
| 432 | + $settings = apply_filters('fluent_community/get_auth_settings', $settings); | |
| 433 | + | |
| 434 | + return [ | |
| 435 | + 'settings' => $settings | |
| 436 | + ]; | |
| 437 | + } | |
| 438 | + | |
| 305 | 439 | public function getOnBoardingSettings() |
| 306 | 440 | { |
| 307 | 441 | $settings = Helper::generalSettings(); |
| 308 | 442 | |
| @@ -309,19 +443,27 @@ | ||
| 309 | 443 | $currentUser = get_user_by('ID', get_current_user_id()); |
| 310 | 444 | |
| 311 | 445 | $settings['has_fluentcrm'] = defined('FLUENTCRM') ? 'yes' : 'no'; |
| 312 | 446 | $settings['has_fluentsmtp'] = defined('FLUENTMAIL_PLUGIN_FILE') ? 'yes' : 'no'; |
| 447 | + $settings['has_fluentcart'] = defined('FLUENTCART_VERSION') ? 'yes' : 'no'; | |
| 313 | 448 | $settings['template'] = ''; |
| 314 | 449 | $settings['install_fluentcrm'] = 'yes'; |
| 315 | 450 | $settings['install_fluentsmtp'] = 'yes'; |
| 451 | + $settings['install_fluentcart'] = 'yes'; | |
| 316 | 452 | $settings['subscribe_to_newsletter'] = 'yes'; |
| 317 | 453 | $settings['share_data'] = 'no'; |
| 318 | - $settings['user_full_name'] = $currentUser->first_name ? $currentUser->first_name . ' ' . $currentUser->last_name : $currentUser->display_name; | |
| 319 | - $settings['user_email_address'] = $currentUser->user_email; | |
| 454 | + if ($currentUser) { | |
| 455 | + $settings['user_full_name'] = $currentUser->first_name ? $currentUser->first_name . ' ' . $currentUser->last_name : $currentUser->display_name; | |
| 456 | + $settings['user_email_address'] = $currentUser->user_email; | |
| 457 | + } else { | |
| 458 | + $settings['user_full_name'] = ''; | |
| 459 | + $settings['user_email_address'] = ''; | |
| 460 | + } | |
| 320 | 461 | |
| 321 | - return [ | |
| 462 | + $data = [ | |
| 322 | 463 | 'settings' => $settings |
| 323 | 464 | ]; |
| 465 | + return apply_filters('fluent_community/onboarding_settings_api_response', $data, $this->request->all()); | |
| 324 | 466 | } |
| 325 | 467 | |
| 326 | 468 | |
| 327 | 469 | public function saveOnBoardingSettings(Request $request) |
| @@ -349,9 +491,9 @@ | ||
| 349 | 491 | |
| 350 | 492 | if (Arr::get($inputs, 'slug') && empty($settings['is_slug_defined'])) { |
| 351 | 493 | $settings['slug'] = sanitize_title(Arr::get($inputs, 'slug')); |
| 352 | 494 | } |
| 353 | - update_option('fluent_community_settings', $settings, 'yes'); | |
| 495 | + update_option('fluent_community_settings', $settings, true); | |
| 354 | 496 | |
| 355 | 497 | // Email Subscription Settings |
| 356 | 498 | $subscriptionSettings = array_filter([ |
| 357 | 499 | 'user_id' => get_current_user_id(), |
| @@ -363,11 +505,12 @@ | ||
| 363 | 505 | |
| 364 | 506 | Utility::updateOption('onboarding_sub_settings', $subscriptionSettings); |
| 365 | 507 | OnboardingService::maybeCreateSpaceTemplates(Arr::get($inputs, 'template')); |
| 366 | 508 | |
| 367 | - $installableAddons = array_filter(array_keys([ | |
| 509 | + $installableAddons = array_keys(array_filter([ | |
| 368 | 510 | 'fluent-crm' => Arr::get($inputs, 'install_fluentcrm', 'no') == 'yes', |
| 369 | 511 | 'fluent-smtp' => Arr::get($inputs, 'install_fluentsmtp', 'no') == 'yes', |
| 512 | + 'fluent-cart' => Arr::get($inputs, 'install_fluentcart', 'no') == 'yes', | |
| 370 | 513 | ])); |
| 371 | 514 | |
| 372 | 515 | // Install Plugins which are checked |
| 373 | 516 | OnboardingService::installAddons($installableAddons); |
| @@ -378,9 +521,9 @@ | ||
| 378 | 521 | // flash the permalinks |
| 379 | 522 | flush_rewrite_rules(true); |
| 380 | 523 | |
| 381 | 524 | return [ |
| 382 | - 'message' => __('Onboarding settings has been updated', 'fluent-community') | |
| 525 | + 'message' => __('Onboarding settings have been updated.', 'fluent-community') | |
| 383 | 526 | ]; |
| 384 | 527 | } |
| 385 | 528 | |
| 386 | 529 | public function changePortalSlug(Request $request) |
| @@ -388,15 +531,15 @@ | ||
| 388 | 531 | $newSlug = sanitize_title($request->get('new_slug', '')); |
| 389 | 532 | |
| 390 | 533 | if (!$newSlug) { |
| 391 | 534 | return $this->sendError([ |
| 392 | - 'message' => __('Slug can not be empty', 'fluent-community') | |
| 535 | + 'message' => __('Slug cannot be empty', 'fluent-community') | |
| 393 | 536 | ]); |
| 394 | 537 | } |
| 395 | 538 | |
| 396 | 539 | if (defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { |
| 397 | 540 | return $this->sendError([ |
| 398 | - 'message' => __('You can not change the slug as it is defined in the config file', 'fluent-community') | |
| 541 | + 'message' => __('You cannot change the slug as it is defined in the config file', 'fluent-community') | |
| 399 | 542 | ]); |
| 400 | 543 | } |
| 401 | 544 | |
| 402 | 545 | $settings = Helper::generalSettings(); |
| @@ -418,7 +561,41 @@ | ||
| 418 | 561 | |
| 419 | 562 | return [ |
| 420 | 563 | 'message' => __('Slug has been changed successfully', 'fluent-community') |
| 421 | 564 | ]; |
| 565 | + } | |
| 566 | + | |
| 567 | + public function getProfileLinkProviders(Request $request) | |
| 568 | + { | |
| 569 | + $data = [ | |
| 570 | + 'providers' => ProfileHelper::socialLinkProviders() | |
| 571 | + ]; | |
| 572 | + return apply_filters('fluent_community/profile_link_providers_api_response', $data, $request->all()); | |
| 573 | + } | |
| 574 | + | |
| 575 | + public function updateProfileLinkProviders(Request $request) | |
| 576 | + { | |
| 577 | + $providerKeys = array_keys(ProfileHelper::socialLinkProviders()); | |
| 578 | + $config = $request->get('configs', []); | |
| 579 | + | |
| 580 | + $config = array_filter($config, function ($value) use ($providerKeys) { | |
| 581 | + return in_array($value, $providerKeys); | |
| 582 | + }); | |
| 583 | + | |
| 584 | + do_action('fluent_community/update_profile_link_providers', $config); | |
| 585 | + | |
| 586 | + return [ | |
| 587 | + 'message' => __('Profile link providers have been updated successfully', 'fluent-community'), | |
| 588 | + ]; | |
| 589 | + } | |
| 590 | + | |
| 591 | + public function getAllSpaceCourses(Request $request) | |
| 592 | + { | |
| 593 | + $data = [ | |
| 594 | + 'all_spaces' => BaseSpace::query()->withoutGlobalScopes() | |
| 595 | + ->whereIn('type', ['community', 'course']) | |
| 596 | + ->orderBy('serial', 'ASC')->get() | |
| 597 | + ]; | |
| 598 | + return apply_filters('fluent_community/all_space_courses_api_response', $data, $request->all()); | |
| 422 | 599 | } |
| 423 | 600 | |
| 424 | 601 | } |