diff --git a/config/config.default.php b/config/config.default.php index c045f8b6..decbe847 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -259,6 +259,9 @@ return [ // Whether the DECT field should be enabled 'enable_dect' => (bool)env('ENABLE_DECT', true), + // Whether the mobile number can be shown to other users + 'enable_mobile_show' => (bool)env('ENABLE_MOBILE_SHOW', false), + // Enables prename and lastname 'enable_user_name' => (bool)env('ENABLE_USER_NAME', false), diff --git a/db/factories/User/SettingsFactory.php b/db/factories/User/SettingsFactory.php index 4ef37a57..d030ef1e 100644 --- a/db/factories/User/SettingsFactory.php +++ b/db/factories/User/SettingsFactory.php @@ -22,6 +22,7 @@ class SettingsFactory extends Factory 'email_goody' => $this->faker->boolean(), 'email_shiftinfo' => $this->faker->boolean(), 'email_news' => $this->faker->boolean(), + 'mobile_show' => $this->faker->boolean(), ]; } } diff --git a/db/migrations/2022_10_16_000000_add_mobile_show_to_users_settings.php b/db/migrations/2022_10_16_000000_add_mobile_show_to_users_settings.php new file mode 100644 index 00000000..9e04f7df --- /dev/null +++ b/db/migrations/2022_10_16_000000_add_mobile_show_to_users_settings.php @@ -0,0 +1,35 @@ +schema->table( + 'users_settings', + function (Blueprint $table) { + $table->boolean('mobile_show')->default(false)->after('email_news'); + } + ); + } + + /** + * Reverse the migration + */ + public function down() + { + $this->schema->table( + 'users_settings', + function (Blueprint $table) { + $table->dropColumn('mobile_show'); + } + ); + } +} diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 4757bead..f03351f1 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -36,6 +36,7 @@ function guest_register() $min_password_length = config('min_password_length'); $enable_password = config('enable_password'); $enable_pronoun = config('enable_pronoun'); + $enable_mobile_show = config('enable_mobile_show'); $config = config(); $request = request(); $session = session(); @@ -49,6 +50,7 @@ function guest_register() $preName = ''; $dect = ''; $mobile = ''; + $mobile_show = false; $email = ''; $pronoun = ''; $email_shiftinfo = false; @@ -121,6 +123,10 @@ function guest_register() $msg .= error(__('Please enter a nickname.'), true); } + if ($request->has('mobile_show') && $enable_mobile_show) { + $mobile_show = true; + } + if ($request->has('email') && strlen(strip_request_item('email')) > 0) { $email = strip_request_item('email'); if (!check_email($email)) { @@ -255,6 +261,7 @@ function guest_register() 'email_goody' => $email_goody, 'email_shiftinfo' => $email_shiftinfo, 'email_news' => $email_news, + 'mobile_show' => $mobile_show, ]); $settings->user() ->associate($user) @@ -442,7 +449,12 @@ function guest_register() ]) : '', div('col', [ - form_text('mobile', __('Mobile'), $mobile, false, 40, 'tel-national') + form_text('mobile', __('Mobile'), $mobile, false, 40, 'tel-national'), + $enable_mobile_show ? form_checkbox( + 'mobile_show', + __('Show mobile number to other users to contact me'), + $mobile_show + ) : '' ]) ]), diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 3998715a..5df5c82e 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -91,6 +91,9 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) } } $user_source->contact->mobile = strip_request_item('mobile', $user_source->contact->mobile); + if (config('enable_mobile_show')) { + $user_source->settings->mobile_show = $request->has('mobile_show'); + } if ($valid) { $user_source->save(); diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 918121ed..9db71997 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -34,6 +34,7 @@ function User_settings_view( $enable_dect = config('enable_dect'); $enable_planned_arrival = config('enable_planned_arrival'); $enable_goody = config('enable_goody'); + $enable_mobile_show = config('enable_mobile_show'); /** @var $urlGenerator UrlGeneratorInterface */ $urlGenerator = app(UrlGeneratorInterface::class); @@ -82,6 +83,11 @@ function User_settings_view( ) : '', $enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect, false, 40) : '', form_text('mobile', __('Mobile'), $user_source->contact->mobile, false, 40), + $enable_mobile_show ? form_checkbox( + 'mobile_show', + __('Show mobile number to other users to contact me'), + $user_source->settings->mobile_show + ): '', form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email, false, 254), form_checkbox( 'email_shiftinfo', @@ -676,7 +682,7 @@ function User_view( ]), div('row user-info', [ div('col-md-2', [ - config('enable_dect') ? + config('enable_dect') && $user_source->contact->dect ? heading( icon('phone') . ' ' @@ -684,6 +690,16 @@ function User_view( . '' ) : '' , + config('enable_mobile_show') && $user_source->contact->mobile ? + $user_source->settings->mobile_show ? + heading( + icon('phone') + . ' ' + . $user_source->contact->mobile + . '' + ) + : '' + : '' , $auth->can('user_messages') ? heading( '' diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 09105278..7647f8f1 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -2716,6 +2716,10 @@ msgstr "Keine Gutscheine bekommen" msgid "out of %s" msgstr "von %s" +#: includes/view/User_view.php:89 +msgid "Show mobile number to other users to contact me" +msgstr "Mache meine Handynummer für andere Benutzer sichtbar" + #: includes/view/User_view.php:797 msgid "Rights" msgstr "Rechte" diff --git a/src/Models/Room.php b/src/Models/Room.php index 5bdc7267..f245b40f 100644 --- a/src/Models/Room.php +++ b/src/Models/Room.php @@ -20,6 +20,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; * @method static QueryBuilder|Room[] whereId($value) * @method static QueryBuilder|Room[] whereName($value) * @method static QueryBuilder|Room[] whereMapUrl($value) + * @method static QueryBuilder|Room[] whereDect($value) * @method static QueryBuilder|Room[] whereDescription($value) * @method static QueryBuilder|Room[] whereCreatedAt($value) * @method static QueryBuilder|Room[] whereUpdatedAt($value) diff --git a/src/Models/User/Settings.php b/src/Models/User/Settings.php index 263564f9..69a84f73 100644 --- a/src/Models/User/Settings.php +++ b/src/Models/User/Settings.php @@ -12,6 +12,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; * @property bool $email_goody * @property bool $email_shiftinfo * @property bool $email_news + * @property bool $mobile_show * * @method static QueryBuilder|Settings[] whereLanguage($value) * @method static QueryBuilder|Settings[] whereTheme($value) @@ -19,6 +20,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder; * @method static QueryBuilder|Settings[] whereEmailGoody($value) * @method static QueryBuilder|Settings[] whereEmailShiftinfo($value) * @method static QueryBuilder|Settings[] whereEmailNews($value) + * @method static QueryBuilder|Settings[] whereMobileShow($value) */ class Settings extends HasUserModel { @@ -33,6 +35,7 @@ class Settings extends HasUserModel 'email_goody' => false, 'email_shiftinfo' => false, 'email_news' => false, + 'mobile_show' => false, ]; /** The attributes that are mass assignable */ @@ -44,6 +47,7 @@ class Settings extends HasUserModel 'email_goody', 'email_shiftinfo', 'email_news', + 'mobile_show', ]; /** @var string[] */ @@ -54,5 +58,6 @@ class Settings extends HasUserModel 'email_goody' => 'boolean', 'email_shiftinfo' => 'boolean', 'email_news' => 'boolean', + 'mobile_show' => 'boolean', ]; }