Moved gdpr goodie mail opt in to own configurable option

Co-authored-by: Michael Weimann <mail@michael-weimann.eu>
main
Igor Scheller 3 years ago
parent 15d9abd280
commit dc0cf101b2

@ -246,6 +246,9 @@ return [
// Enables the T-Shirt configuration on signup and profile
'enable_tshirt_size' => (bool)env('ENABLE_TSHIRT_SIZE', true),
// Enables the goody/voucher configuration on signup and profile
'enable_goody' => (bool)env('ENABLE_GOODY', false),
// Number of shifts to freeload until angel is locked for shift signup.
'max_freeloadable_shifts' => env('MAX_FREELOADABLE_SHIFTS', 2),

@ -19,6 +19,7 @@ class SettingsFactory extends Factory
'language' => $this->faker->locale(),
'theme' => $this->faker->numberBetween(1, 20),
'email_human' => $this->faker->boolean(),
'email_goody' => $this->faker->boolean(),
'email_shiftinfo' => $this->faker->boolean(),
'email_news' => $this->faker->boolean(),
];

@ -0,0 +1,42 @@
<?php
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
use Illuminate\Database\Schema\Blueprint;
class UsersSettingsAddEmailGoody extends Migration
{
use Reference;
/**
* Run the migration
*/
public function up()
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
$table->boolean('email_goody')->default(false)->after('email_human');
}
);
$connection = $this->schema->getConnection();
$connection
->table('users_settings')
->update(['email_goody' => $connection->raw('email_human')]);
}
/**
* Reverse the migration
*/
public function down()
{
$this->schema->table(
'users_settings',
function (Blueprint $table) {
$table->dropColumn('email_goody');
}
);
}
}

@ -47,6 +47,7 @@ function guest_register()
$email_shiftinfo = false;
$email_by_human_allowed = false;
$email_news = false;
$email_goody = false;
$tshirt_size = '';
$password_hash = '';
$selected_angel_types = [];
@ -118,6 +119,10 @@ function guest_register()
$email_news = true;
}
if ($request->has('email_goody')) {
$email_goody = true;
}
if ($enable_tshirt_size) {
if ($request->has('tshirt_size') && isset($tshirt_sizes[$request->input('tshirt_size')])) {
$tshirt_size = $request->input('tshirt_size');
@ -215,6 +220,7 @@ function guest_register()
'language' => $session->get('locale'),
'theme' => config('theme'),
'email_human' => $email_by_human_allowed,
'email_goody' => $email_goody,
'email_shiftinfo' => $email_shiftinfo,
'email_news' => $email_news,
]);
@ -365,9 +371,16 @@ function guest_register()
),
form_checkbox(
'email_by_human_allowed',
__('To receive vouchers, agree that nick, email address, worked hours and shirt size will be stored until the next similar event. To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]),
__('Allow heaven angels to contact you by e-mail.'),
$email_by_human_allowed
),
config('enable_goody') ?
form_checkbox(
'email_goody',
__('To receive vouchers, give consent that nick, email address, worked hours and shirt size will be stored until the next similar event.')
. (config('privacy_email') ? ' ' . __('To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]) : ''),
$email_goody
) : '',
])
]),
div('row', [

@ -39,6 +39,9 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
$user_source->settings->email_shiftinfo = $request->has('email_shiftinfo');
$user_source->settings->email_human = $request->has('email_by_human_allowed');
$user_source->settings->email_news = $request->has('email_news');
if (config('enable_goody')) {
$user_source->settings->email_goody = $request->has('email_goody');
}
if ($request->has('tshirt_size') && isset($tshirt_sizes[$request->input('tshirt_size')])) {
$user_source->personalData->shirt_size = $request->input('tshirt_size');
@ -180,7 +183,6 @@ function user_settings()
$enable_tshirt_size = config('enable_tshirt_size');
$tshirt_sizes = config('tshirt_sizes');
$locales = config('locales');
$oauth2_providers = config('oauth');
$buildup_start_date = null;
$teardown_end_date = null;
@ -211,7 +213,6 @@ function user_settings()
$buildup_start_date,
$teardown_end_date,
$enable_tshirt_size,
$tshirt_sizes,
$oauth2_providers
$tshirt_sizes
);
}

@ -19,7 +19,6 @@ use Engelsystem\Controllers\SettingsController;
* @param int $teardown_end_date Unix timestamp
* @param bool $enable_tshirt_size
* @param array $tshirt_sizes
* @param array $oauth2_providers
*
* @return string
*/
@ -30,14 +29,14 @@ function User_settings_view(
$buildup_start_date,
$teardown_end_date,
$enable_tshirt_size,
$tshirt_sizes,
$oauth2_providers
$tshirt_sizes
) {
$personalData = $user_source->personalData;
$enable_user_name = config('enable_user_name');
$enable_pronoun = config('enable_pronoun');
$enable_dect = config('enable_dect');
$enable_planned_arrival = config('enable_planned_arrival');
$enable_goody = config('enable_goody');
/** @var Renderer $renderer */
$renderer = app(Renderer::class);
@ -100,9 +99,15 @@ function User_settings_view(
),
form_checkbox(
'email_by_human_allowed',
__('To receive vouchers, agree that nick, email address, worked hours and shirt size will be stored until the next similar event. To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]),
__('Allow heaven angels to contact you by e-mail.'),
$user_source->settings->email_human
),
$enable_goody ? form_checkbox(
'email_goody',
__('To receive vouchers, give consent that nick, email address, worked hours and shirt size will be stored until the next similar event.')
. (config('privacy_email') ? ' ' . __('To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]) : ''),
$user_source->settings->email_goody
) : '',
$enable_tshirt_size ? form_select(
'tshirt_size',
__('Shirt size'),

@ -1627,8 +1627,14 @@ msgid "Notify me of new news"
msgstr "Benachrichtige mich bei neuen News"
#: includes/pages/guest_login.php:291 includes/view/User_view.php:73
msgid "To receive vouchers, agree that nick, email address, worked hours and shirt size will be stored until the next similar event. To withdraw your approval, send an email to <a href=\"mailto:%s\">%1$s</a>."
msgstr "Um Voucher zu erhalten, stimme zu, dass Nick, E-Mail-Adresse, geleistete Arbeit und Shirtgröße bis zum nächsten gleichartigen Event gespeichert werden. Dies kann jederzeit durch eine Email an <a href=\"mailto:%s\">%1$s</a> widerrufen werden."
msgid "Allow heaven angels to contact you by e-mail."
msgstr "Erlaube Himmel-Engeln dich per Mail zu kontaktieren."
msgid "To receive vouchers, give consent that nick, email address, worked hours and shirt size will be stored until the next similar event."
msgstr "Um Voucher zu erhalten, stimme zu, dass Nick, E-Mail-Adresse, geleistete Arbeit und Shirtgröße bis zum nächsten gleichartigen Event gespeichert werden."
msgid "To withdraw your approval, send an email to <a href=\"mailto:%s\">%1$s</a>."
msgstr "Dies kann jederzeit durch eine E-Mail an <a href=\"mailto:%s\">%1$s</a> widerrufen werden."
#: includes/pages/guest_login.php:300 includes/view/User_view.php:48
msgid "Planned date of arrival"

@ -1354,8 +1354,8 @@ msgstr ""
"mudam)"
#: includes/pages/guest_login.php:230 includes/view/User_view.php:51
msgid "To receive vouchers, agree that nick, email address, worked hours and shirt size will be stored until the next similar event. To withdraw your approval, send an email to <a href=\"mailto:%s\">%1$s</a>."
msgstr "Permito que humanos me enviem emails (por exemplo, para um voucher)"
msgid "Allow heaven angels to contact you by e-mail."
msgstr "Permito que humanos me enviem emails"
#: includes/pages/guest_login.php:235 includes/view/User_view.php:43
msgid "Planned date of arrival"

@ -120,6 +120,7 @@ class Controller extends BaseController
'type' => 'gauge',
['labels' => ['type' => 'system'], 'value' => $this->stats->email('system')],
['labels' => ['type' => 'humans'], 'value' => $this->stats->email('humans')],
['labels' => ['type' => 'goody'], 'value' => $this->stats->email('goody')],
['labels' => ['type' => 'news'], 'value' => $this->stats->email('news')],
],
'users_working' => [

@ -115,6 +115,9 @@ class Stats
case 'humans':
$query = Settings::whereEmailHuman(true);
break;
case 'goody':
$query = Settings::whereEmailGoody(true);
break;
case 'news':
$query = Settings::whereEmailNews(true);
break;

@ -9,12 +9,14 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
* @property string $language
* @property int $theme
* @property bool $email_human
* @property bool $email_goody
* @property bool $email_shiftinfo
* @property bool $email_news
*
* @method static QueryBuilder|Settings[] whereLanguage($value)
* @method static QueryBuilder|Settings[] whereTheme($value)
* @method static QueryBuilder|Settings[] whereEmailHuman($value)
* @method static QueryBuilder|Settings[] whereEmailGoody($value)
* @method static QueryBuilder|Settings[] whereEmailShiftinfo($value)
* @method static QueryBuilder|Settings[] whereEmailNews($value)
*/
@ -25,13 +27,32 @@ class Settings extends HasUserModel
/** @var string The table associated with the model */
protected $table = 'users_settings';
/** @var array Default attributes */
protected $attributes = [
'email_human' => false,
'email_goody' => false,
'email_shiftinfo' => false,
'email_news' => false,
];
/** The attributes that are mass assignable */
protected $fillable = [
'user_id',
'language',
'theme',
'email_human',
'email_goody',
'email_shiftinfo',
'email_news',
];
/** @var string[] */
protected $casts = [
'user_id' => 'integer',
'theme' => 'integer',
'email_human' => 'boolean',
'email_goody' => 'boolean',
'email_shiftinfo' => 'boolean',
'email_news' => 'boolean',
];
}

@ -260,6 +260,7 @@ class StatsTest extends TestCase
$this->assertEquals(0, $stats->email('not-available-option'));
$this->assertEquals(2, $stats->email('system'));
$this->assertEquals(3, $stats->email('humans'));
$this->assertEquals(1, $stats->email('goody'));
$this->assertEquals(1, $stats->email('news'));
}
@ -390,7 +391,7 @@ class StatsTest extends TestCase
{
$this->addUser();
$this->addUser([], ['shirt_size' => 'L'], ['email_human' => true, 'email_shiftinfo' => true]);
$this->addUser(['arrived' => 1], [], ['email_human' => true, 'email_news' => true]);
$this->addUser(['arrived' => 1], [], ['email_human' => true, 'email_goody' => true, 'email_news' => true]);
$this->addUser(['arrived' => 1], ['pronoun' => 'unicorn'], ['language' => 'lo_RM', 'email_shiftinfo' => true]);
$this->addUser(['arrived' => 1, 'got_voucher' => 2], ['shirt_size' => 'XXL'], ['language' => 'lo_RM']);
$this->addUser(['arrived' => 1, 'got_voucher' => 9, 'force_active' => true], [], ['theme' => 1]);

Loading…
Cancel
Save