| @@ -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,14 +29,15 @@ | ||
| 25 | 29 | } |
| 26 | 30 | |
| 27 | 31 | unset($formatedRoles['administrator']); |
| 28 | 32 | |
| 29 | - return [ | |
| 30 | - 'settings' => $settings, | |
| 31 | - 'user_roles' => $formatedRoles, | |
| 32 | - 'users_can_register' => !!get_option('users_can_register'), | |
| 33 | + $data = [ | |
| 34 | + 'settings' => $settings, | |
| 35 | + 'user_roles' => $formatedRoles, | |
| 36 | + 'users_can_register' => !!get_option('users_can_register'), | |
| 33 | 37 | 'user_registration_enable_url' => admin_url('options-general.php') |
| 34 | 38 | ]; |
| 39 | + return apply_filters('fluent_community/general_settings_api_response', $data, $request->all()); | |
| 35 | 40 | } |
| 36 | 41 | |
| 37 | 42 | public function saveGeneralSettings(Request $request) |
| 38 | 43 | { |
| @@ -37,8 +42,9 @@ | ||
| 37 | 42 | public function saveGeneralSettings(Request $request) |
| 38 | 43 | { |
| 39 | 44 | $inputs = $request->get('settings', []); |
| 40 | 45 | $settings = Helper::generalSettings(false); |
| 46 | + $storedSettings = $settings; | |
| 41 | 47 | $inputs = Arr::only($inputs, array_keys($settings)); |
| 42 | 48 | |
| 43 | 49 | $settings['logo'] = Arr::get($inputs, 'logo', ''); |
| 44 | 50 | $settings['white_logo'] = Arr::get($inputs, 'white_logo', ''); |
| @@ -64,8 +70,10 @@ | ||
| 64 | 70 | $settings['access'] = Arr::get($inputs, 'access', []); |
| 65 | 71 | $settings['auth_content'] = wp_kses_post(Arr::get($inputs, 'auth_content', '')); |
| 66 | 72 | $settings['auth_redirect'] = sanitize_url(Arr::get($inputs, 'auth_redirect', '')); |
| 67 | 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')); | |
| 68 | 76 | $settings['auth_url'] = sanitize_url(Arr::get($inputs, 'auth_url', '')); |
| 69 | 77 | $media = Helper::getMediaFromUrl($settings['logo']); |
| 70 | 78 | $whiteMedia = Helper::getMediaFromUrl($settings['white_logo']); |
| 71 | 79 | $featuredMedia = Helper::getMediaFromUrl($settings['featured_image']); |
| @@ -70,9 +78,27 @@ | ||
| 70 | 78 | $whiteMedia = Helper::getMediaFromUrl($settings['white_logo']); |
| 71 | 79 | $featuredMedia = Helper::getMediaFromUrl($settings['featured_image']); |
| 72 | 80 | $settings['cutsom_auth_url'] = sanitize_url(Arr::get($inputs, 'cutsom_auth_url', '')); |
| 73 | 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')); | |
| 74 | 83 | |
| 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'; | |
| 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 | + | |
| 75 | 101 | if ($media) { |
| 76 | 102 | $settings['logo'] = $media->public_url; |
| 77 | 103 | $media->update([ |
| 78 | 104 | 'is_active' => true, |
| @@ -99,13 +125,24 @@ | ||
| 99 | 125 | ]); |
| 100 | 126 | } |
| 101 | 127 | |
| 102 | 128 | $slugChanged = false; |
| 103 | - if ($settings['slug'] != $inputs['slug'] && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { | |
| 104 | - $settings['slug'] = $inputs['slug']; | |
| 129 | + $newSlug = sanitize_title($inputs['slug'] ?? ''); | |
| 130 | + if ($newSlug && $settings['slug'] != $newSlug && !defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { | |
| 131 | + $settings['slug'] = $newSlug; | |
| 105 | 132 | $slugChanged = true; |
| 106 | 133 | } |
| 107 | 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 | + | |
| 108 | 145 | update_option('fluent_community_settings', $settings); |
| 109 | 146 | |
| 110 | 147 | $redirectUrl = ''; |
| 111 | 148 | |
| @@ -123,11 +160,18 @@ | ||
| 123 | 160 | } |
| 124 | 161 | |
| 125 | 162 | public function getEmailSettings(Request $request) |
| 126 | 163 | { |
| 127 | - return [ | |
| 128 | - '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 | |
| 129 | 172 | ]; |
| 173 | + return apply_filters('fluent_community/email_settings_api_response', $data, $request->all()); | |
| 130 | 174 | } |
| 131 | 175 | |
| 132 | 176 | public function saveEmailSettings(Request $request) |
| 133 | 177 | { |
| @@ -133,8 +177,22 @@ | ||
| 133 | 177 | { |
| 134 | 178 | $prevSettings = Utility::getEmailNotificationSettings(); |
| 135 | 179 | $newSettings = $request->get('email_settings', []); |
| 136 | 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 | + | |
| 137 | 195 | $newSettings = wp_parse_args($newSettings, $prevSettings); |
| 138 | 196 | $newSettings = CustomSanitizer::santizeEmailSettings($newSettings); |
| 139 | 197 | |
| 140 | 198 | Utility::updateOption('global_email_settings', $newSettings); |
| @@ -154,8 +212,52 @@ | ||
| 154 | 212 | 'message' => __('Email notification settings have been updated', 'fluent-community') |
| 155 | 213 | ]; |
| 156 | 214 | } |
| 157 | 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 | + | |
| 158 | 260 | public function getStorageSettings(Request $request) |
| 159 | 261 | { |
| 160 | 262 | if (!defined('FLUENT_COMMUNITY_PRO')) { |
| 161 | 263 | $config = [ |
| @@ -166,9 +268,9 @@ | ||
| 166 | 268 | } |
| 167 | 269 | |
| 168 | 270 | return apply_filters('fluent_community/storage_settings_response', [ |
| 169 | 271 | 'config' => $config |
| 170 | - ]); | |
| 272 | + ], $request->all()); | |
| 171 | 273 | } |
| 172 | 274 | |
| 173 | 275 | public function updateStorageSettings(Request $request) |
| 174 | 276 | { |
| @@ -173,19 +275,19 @@ | ||
| 173 | 275 | public function updateStorageSettings(Request $request) |
| 174 | 276 | { |
| 175 | 277 | if (!defined('FLUENT_COMMUNITY_PRO')) { |
| 176 | 278 | return $this->sendError([ |
| 177 | - 'message' => 'Sorry, you can not update this config. Please activate pro' | |
| 279 | + 'message' => __('Sorry, you cannot update this config. Please activate pro', 'fluent-community') | |
| 178 | 280 | ]); |
| 179 | 281 | } |
| 180 | 282 | |
| 181 | 283 | if (defined('FLUENT_COMMUNITY_CLOUD_STORAGE') && FLUENT_COMMUNITY_CLOUD_STORAGE) { |
| 182 | 284 | return $this->sendError([ |
| 183 | - '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') | |
| 184 | 286 | ]); |
| 185 | 287 | } |
| 186 | 288 | |
| 187 | - $config = $request->get('config', []); | |
| 289 | + $config = (array)$request->get('config', []); | |
| 188 | 290 | |
| 189 | 291 | $driver = Arr::get($config, 'driver', 'local'); |
| 190 | 292 | |
| 191 | 293 | $validation = [ |
| @@ -191,16 +293,17 @@ | ||
| 191 | 293 | $validation = [ |
| 192 | 294 | 'driver' => 'required' |
| 193 | 295 | ]; |
| 194 | 296 | |
| 297 | + $isRemote = in_array($driver, ['amazon_s3', 'bunny_cdn', 'cloudflare_r2']); | |
| 298 | + | |
| 195 | 299 | if ($driver == 'cloudflare_r2') { |
| 196 | 300 | $validation = [ |
| 197 | - 'driver' => 'required', | |
| 198 | - 'access_key' => 'required', | |
| 199 | - 'secret_key' => 'required', | |
| 200 | - 'bucket' => 'required', | |
| 201 | - 'public_url' => 'required|url', | |
| 202 | - 'account_id' => 'required', | |
| 301 | + 'driver' => 'required', | |
| 302 | + 'access_key' => 'required', | |
| 303 | + 'secret_key' => 'required', | |
| 304 | + 'public_url' => 'required|url', | |
| 305 | + 'endpoint_url' => 'required|url', | |
| 203 | 306 | ]; |
| 204 | 307 | } else if ($driver == 'amazon_s3') { |
| 205 | 308 | $validation = [ |
| 206 | 309 | 'driver' => 'required', |
| @@ -207,14 +310,21 @@ | ||
| 207 | 310 | 'access_key' => 'required', |
| 208 | 311 | 'secret_key' => 'required', |
| 209 | 312 | 'bucket' => 'required' |
| 210 | 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 | + ]; | |
| 211 | 322 | } |
| 212 | 323 | |
| 213 | 324 | $this->validate($config, $validation); |
| 214 | 325 | |
| 215 | - if ($driver === 'cloudflare_r2' || $driver === 'amazon_s3') { | |
| 216 | - | |
| 326 | + if ($isRemote) { | |
| 217 | 327 | $previousConfig = \FluentCommunityPro\App\Modules\CloudStorage\StorageHelper::getConfig(); |
| 218 | 328 | if ($config['access_key'] == 'FCOM_ENCRYPTED_DATA_KEY') { |
| 219 | 329 | $config['access_key'] = Arr::get($previousConfig, 'access_key'); |
| 220 | 330 | } |
| @@ -226,16 +336,17 @@ | ||
| 226 | 336 | $driver = (new \FluentCommunityPro\App\Modules\CloudStorage\CloudStorageModule)->getConnectionDriver($config); |
| 227 | 337 | |
| 228 | 338 | if (!$driver) { |
| 229 | 339 | return $this->sendError([ |
| 230 | - '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') | |
| 231 | 341 | ]); |
| 232 | 342 | } |
| 233 | 343 | |
| 234 | 344 | $test = $driver->testConnection(); |
| 235 | 345 | if (!$test || is_wp_error($test)) { |
| 346 | + $errorMessage = is_wp_error($test) ? $test->get_error_message() : 'Unknown Error'; | |
| 236 | 347 | return $this->sendError([ |
| 237 | - '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 | |
| 238 | 349 | ]); |
| 239 | 350 | } |
| 240 | 351 | } |
| 241 | 352 | |
| @@ -244,8 +355,9 @@ | ||
| 244 | 355 | 'access_key', |
| 245 | 356 | 'secret_key', |
| 246 | 357 | 'bucket', |
| 247 | 358 | 'public_url', |
| 359 | + 'endpoint_url', | |
| 248 | 360 | 'account_id', |
| 249 | 361 | 'sub_folder', |
| 250 | 362 | 's3_endpoint' |
| 251 | 363 | ]); |
| @@ -273,10 +385,12 @@ | ||
| 273 | 385 | } |
| 274 | 386 | |
| 275 | 387 | public function getWelcomeBannerSettings(Request $request) |
| 276 | 388 | { |
| 389 | + $settings = apply_filters('fluent_community/get_welcome_banner_settings', Helper::getWelcomeBannerSettings(), $request->all()); | |
| 390 | + | |
| 277 | 391 | return [ |
| 278 | - 'settings' => Helper::getWelcomeBannerSettings() | |
| 392 | + 'settings' => $settings | |
| 279 | 393 | ]; |
| 280 | 394 | } |
| 281 | 395 | |
| 282 | 396 | public function updateWelcomeBannerSettings(Request $request) |
| @@ -285,19 +399,22 @@ | ||
| 285 | 399 | |
| 286 | 400 | $settings = CustomSanitizer::sanitizeWelcomeBannerSettings($settings); |
| 287 | 401 | |
| 288 | 402 | if (Arr::get($settings, 'login.enabled') == 'yes') { |
| 289 | - $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'))); | |
| 290 | 404 | } |
| 291 | 405 | |
| 292 | 406 | if (Arr::get($settings, 'logout.enabled') == 'yes') { |
| 293 | - $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'))); | |
| 294 | 408 | if (Arr::get($settings, 'logout.buttonLabel') && Arr::get($settings, 'logout.useCustomUrl') != 'yes') { |
| 295 | 409 | $settings['logout']['buttonLink'] = Helper::getAuthUrl(); |
| 296 | 410 | } |
| 297 | 411 | } |
| 298 | 412 | |
| 413 | + $settings = apply_filters('fluent_community/update_welcome_banner_settings', $settings); | |
| 414 | + | |
| 299 | 415 | Utility::updateOption('welcome_banner_settings', $settings); |
| 416 | + | |
| 300 | 417 | Utility::setCache('welcome_banner_settings', $settings, WEEK_IN_SECONDS); |
| 301 | 418 | |
| 302 | 419 | return [ |
| 303 | 420 | 'message' => __('Welcome banner settings have been updated successfully', 'fluent-community'), |
| @@ -304,8 +421,22 @@ | ||
| 304 | 421 | 'settings' => $settings |
| 305 | 422 | ]; |
| 306 | 423 | } |
| 307 | 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 | + | |
| 308 | 439 | public function getOnBoardingSettings() |
| 309 | 440 | { |
| 310 | 441 | $settings = Helper::generalSettings(); |
| 311 | 442 | |
| @@ -312,19 +443,27 @@ | ||
| 312 | 443 | $currentUser = get_user_by('ID', get_current_user_id()); |
| 313 | 444 | |
| 314 | 445 | $settings['has_fluentcrm'] = defined('FLUENTCRM') ? 'yes' : 'no'; |
| 315 | 446 | $settings['has_fluentsmtp'] = defined('FLUENTMAIL_PLUGIN_FILE') ? 'yes' : 'no'; |
| 447 | + $settings['has_fluentcart'] = defined('FLUENTCART_VERSION') ? 'yes' : 'no'; | |
| 316 | 448 | $settings['template'] = ''; |
| 317 | 449 | $settings['install_fluentcrm'] = 'yes'; |
| 318 | 450 | $settings['install_fluentsmtp'] = 'yes'; |
| 451 | + $settings['install_fluentcart'] = 'yes'; | |
| 319 | 452 | $settings['subscribe_to_newsletter'] = 'yes'; |
| 320 | 453 | $settings['share_data'] = 'no'; |
| 321 | - $settings['user_full_name'] = $currentUser->first_name ? $currentUser->first_name . ' ' . $currentUser->last_name : $currentUser->display_name; | |
| 322 | - $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 | + } | |
| 323 | 461 | |
| 324 | - return [ | |
| 462 | + $data = [ | |
| 325 | 463 | 'settings' => $settings |
| 326 | 464 | ]; |
| 465 | + return apply_filters('fluent_community/onboarding_settings_api_response', $data, $this->request->all()); | |
| 327 | 466 | } |
| 328 | 467 | |
| 329 | 468 | |
| 330 | 469 | public function saveOnBoardingSettings(Request $request) |
| @@ -352,9 +491,9 @@ | ||
| 352 | 491 | |
| 353 | 492 | if (Arr::get($inputs, 'slug') && empty($settings['is_slug_defined'])) { |
| 354 | 493 | $settings['slug'] = sanitize_title(Arr::get($inputs, 'slug')); |
| 355 | 494 | } |
| 356 | - update_option('fluent_community_settings', $settings, 'yes'); | |
| 495 | + update_option('fluent_community_settings', $settings, true); | |
| 357 | 496 | |
| 358 | 497 | // Email Subscription Settings |
| 359 | 498 | $subscriptionSettings = array_filter([ |
| 360 | 499 | 'user_id' => get_current_user_id(), |
| @@ -366,11 +505,12 @@ | ||
| 366 | 505 | |
| 367 | 506 | Utility::updateOption('onboarding_sub_settings', $subscriptionSettings); |
| 368 | 507 | OnboardingService::maybeCreateSpaceTemplates(Arr::get($inputs, 'template')); |
| 369 | 508 | |
| 370 | - $installableAddons = array_filter(array_keys([ | |
| 509 | + $installableAddons = array_keys(array_filter([ | |
| 371 | 510 | 'fluent-crm' => Arr::get($inputs, 'install_fluentcrm', 'no') == 'yes', |
| 372 | 511 | 'fluent-smtp' => Arr::get($inputs, 'install_fluentsmtp', 'no') == 'yes', |
| 512 | + 'fluent-cart' => Arr::get($inputs, 'install_fluentcart', 'no') == 'yes', | |
| 373 | 513 | ])); |
| 374 | 514 | |
| 375 | 515 | // Install Plugins which are checked |
| 376 | 516 | OnboardingService::installAddons($installableAddons); |
| @@ -391,15 +531,15 @@ | ||
| 391 | 531 | $newSlug = sanitize_title($request->get('new_slug', '')); |
| 392 | 532 | |
| 393 | 533 | if (!$newSlug) { |
| 394 | 534 | return $this->sendError([ |
| 395 | - 'message' => __('Slug can not be empty', 'fluent-community') | |
| 535 | + 'message' => __('Slug cannot be empty', 'fluent-community') | |
| 396 | 536 | ]); |
| 397 | 537 | } |
| 398 | 538 | |
| 399 | 539 | if (defined('FLUENT_COMMUNITY_PORTAL_SLUG')) { |
| 400 | 540 | return $this->sendError([ |
| 401 | - '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') | |
| 402 | 542 | ]); |
| 403 | 543 | } |
| 404 | 544 | |
| 405 | 545 | $settings = Helper::generalSettings(); |
| @@ -421,7 +561,41 @@ | ||
| 421 | 561 | |
| 422 | 562 | return [ |
| 423 | 563 | 'message' => __('Slug has been changed successfully', 'fluent-community') |
| 424 | 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()); | |
| 425 | 599 | } |
| 426 | 600 | |
| 427 | 601 | } |