PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.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 All 78 releases
← All changes | Modules/Auth/Classes/InvitationService.php +37 -11 1.0.972.11.0 View file →
@@ -16,9 +16,9 @@
16 16 $errors = new \WP_Error();
17 17
18 18 $sanitized_user_login = sanitize_user($user_login);
19 19
20 - $user_email = apply_filters('user_registration_email', $user_email);
20 + $user_email = apply_filters('user_registration_email', $user_email); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
21 21
22 22 // Check the username.
23 23 if ('' === $sanitized_user_login) {
24 24 $errors->add('empty_username', __('<strong>Error</strong>: Please enter a username.', 'fluent-community'));
@@ -28,9 +28,9 @@
28 28 } elseif (username_exists($sanitized_user_login)) {
29 29 $errors->add('username_exists', __('<strong>Error</strong>: This username is already registered. Please choose another one.', 'fluent-community'));
30 30 } else {
31 31 /** This filter is documented in wp-includes/user.php */
32 - $illegal_user_logins = (array)apply_filters('illegal_user_logins', array());
32 + $illegal_user_logins = (array)apply_filters('illegal_user_logins', array()); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
33 33 if (in_array(strtolower($sanitized_user_login), array_map('strtolower', $illegal_user_logins), true)) {
34 34 $errors->add('invalid_username', __('<strong>Error</strong>: Sorry, that username is not allowed.', 'fluent-community'));
35 35 }
36 36 }
@@ -47,11 +47,11 @@
47 47 __('<strong>Error:</strong> This email address is already registered. Please login or try resetting your password.', 'fluent-community')
48 48 );
49 49 }
50 50
51 - do_action('register_post', $sanitized_user_login, $user_email, $errors);
51 + do_action('register_post', $sanitized_user_login, $user_email, $errors); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
52 52
53 - $errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email);
53 + $errors = apply_filters('registration_errors', $errors, $sanitized_user_login, $user_email); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
54 54
55 55 if ($errors->has_errors()) {
56 56 return $errors;
57 57 }
@@ -106,15 +106,15 @@
106 106 return $errors;
107 107 }
108 108
109 109 if (!empty($_COOKIE['wp_lang'])) {
110 - $wp_lang = sanitize_text_field($_COOKIE['wp_lang']);
110 + $wp_lang = sanitize_text_field(wp_unslash($_COOKIE['wp_lang']));
111 111 if (in_array($wp_lang, get_available_languages(), true)) {
112 112 update_user_meta($user_id, 'locale', $wp_lang); // Set user locale if defined on registration.
113 113 }
114 114 }
115 115
116 - do_action('register_new_user', $user_id);
116 + do_action('register_new_user', $user_id); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
117 117
118 118 return $user_id;
119 119 }
120 120
@@ -126,9 +126,9 @@
126 126
127 127 $user = get_user_by('ID', $user->ID);
128 128
129 129 if ($user) {
130 - do_action('wp_login', $user->user_login, $user);
130 + do_action('wp_login', $user->user_login, $user); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
131 131 }
132 132
133 133 return $user;
134 134 }
@@ -194,8 +194,26 @@
194 194
195 195 return $inviation;
196 196 }
197 197
198 + public static function createLinkInvite($data)
199 + {
200 + $formattedData = array_filter([
201 + 'message' => '',
202 + 'user_id' => $data['user_id'],
203 + 'status' => 'active',
204 + 'post_id' => $data['space_id'],
205 + 'message_rendered' => md5($data['space_id'] . '_' . time() . '_' . wp_generate_uuid4(10) . '_' . $data['user_id']),
206 + 'meta' => Arr::only($data, ['title', 'limit', 'expire_date'])
207 + ]);
208 +
209 + $inviation = Invitation::create($formattedData);
210 +
211 + do_action('fluent_community/invitation_link_created', $inviation);
212 +
213 + return $inviation;
214 + }
215 +
198 216 public static function sendInvitationEmail(Invitation $invitation)
199 217 {
200 218 $xProfile = $invitation->xprofile;
201 219 if (!$xProfile) {
@@ -203,10 +221,10 @@
203 221 }
204 222
205 223 $portalSettings = Helper::generalSettings();
206 224
207 - $subject = \sprintf(
208 - __('%1$s has invited you to join the %2$s', 'fluent-community'),
225 + /* translators: %1$s is replaced by the name of the user, %2$s is replaced by the title of the site */
226 + $subject = \sprintf(__('%1$s has invited you to join the %2$s', 'fluent-community'),
209 227 $xProfile->display_name,
210 228 Arr::get($portalSettings, 'site_title')
211 229 );
212 230
@@ -213,8 +231,9 @@
213 231 if ($invitation->post_id) {
214 232 $space = $invitation->space;
215 233 if ($space) {
216 234 $subject = \sprintf(
235 + /* translators: %1$s is replaced by the name of the user, %2$s is replaced by the title of the space, %3$s is replaced by the title of the site */
217 236 __('%1$s has invited you to join the %2$s on %3$s', 'fluent-community'),
218 237 $xProfile->display_name,
219 238 $space->title,
220 239 Arr::get($portalSettings, 'site_title')
@@ -221,13 +240,19 @@
221 240 );
222 241 }
223 242 }
224 243
225 - $emailBody = self::getInviationEmailHtml($invitation);
226 -
227 244 $invitation->reactions_count += 1;
228 245 $invitation->save();
229 246
247 + $emailComposer = new \FluentCommunity\App\Services\Libs\EmailComposer();
248 +
249 + $emailComposer->addBlock('html_content', self::getInviationEmailHtml($invitation));
250 + $emailComposer->setDefaultLogo();
251 + $emailComposer->setDefaultFooter();
252 +
253 + $emailBody = $emailComposer->getHtml();
254 +
230 255 $mailer = new Mailer($invitation->message, $subject, $emailBody);
231 256
232 257 return $mailer->send();
233 258 }
@@ -237,8 +262,9 @@
237 262 $portalSettings = Helper::generalSettings();
238 263 $siteTitle = Arr::get($portalSettings, 'site_title');
239 264
240 265 if ($invitation->space) {
266 + /* translators: %1$s is replaced by the title of the space, %2$s is replaced by the title of the site */
241 267 $siteTitle = \sprintf(__('%1$s on %2$s', 'fluent-community'), $invitation->space->title, $siteTitle);
242 268 }
243 269
244 270 return (string)App::make('view')->make('email.Default._invitation', [