Gruppen können angelegt und bearbeitet werden
Teili können angelegt werden
This commit is contained in:
18
modules/Gruppen/Actions/CreateGroupAction.php
Normal file
18
modules/Gruppen/Actions/CreateGroupAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupAction
|
||||
{
|
||||
public static function execute(array $newData)
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('create_groups')) {
|
||||
kompass_print_message_box(__('You are not allowed to create a group', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
$dbHandler->insertRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData);
|
||||
kompass_print_message_box(__('The group was created.', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
}
|
21
modules/Gruppen/Actions/CreateGroupMemberAction.php
Normal file
21
modules/Gruppen/Actions/CreateGroupMemberAction.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupMemberAction
|
||||
{
|
||||
public static function execute(array $userData) : int
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('create_teilis')) {
|
||||
kompass_print_message_box(__('You are not allowed to add a member', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
|
||||
$userData['gruppe_id'] = 1;
|
||||
|
||||
kompass_print_message_box(__('The member was added.', BDP_LV_PLUGIN_SLUG));
|
||||
return $dbHandler->insertRows(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, $userData);
|
||||
}
|
||||
}
|
37
modules/Gruppen/Actions/CreateGroupMemberDataAction.php
Normal file
37
modules/Gruppen/Actions/CreateGroupMemberDataAction.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupMemberDataAction
|
||||
{
|
||||
public static function execute(array $userData) : array
|
||||
{
|
||||
$dataKeys = [
|
||||
'vorname' => 'kompass_group_member_firstname',
|
||||
'nachname' => 'kompass_group_member_lastname',
|
||||
'geburtsdatum' => 'kompass_group_member_birthday',
|
||||
'ansprechpartner' => 'kompass_group_member_parents',
|
||||
'email_1' => 'kompass_group_member_email_1',
|
||||
'email_2' => 'kompass_group_member_email_2',
|
||||
'telefon_1' => 'kompass_group_member_phone_1',
|
||||
'telefon_2' => 'kompass_group_member_phone_2',
|
||||
];
|
||||
|
||||
$return = ['data' => [], 'rawData' => [], 'errors' => []];
|
||||
foreach ($dataKeys as $dbKey => $formKey) {
|
||||
$value = trim($userData[$formKey]);
|
||||
$return['rawData'][$formKey] = $value;
|
||||
if ($dbKey === 'email_2' || $dbKey === 'telefon_2') {
|
||||
$return['data'][$dbKey] = $value;
|
||||
} else {
|
||||
if ( $value === '' ) {
|
||||
$return['errors'][] = sprintf(__( 'The field "%s" is required.', BDP_LV_PLUGIN_SLUG ), $dbKey);
|
||||
} else {
|
||||
$return['data'][ $dbKey ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
19
modules/Gruppen/Actions/UpdateGroupAction.php
Normal file
19
modules/Gruppen/Actions/UpdateGroupAction.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class UpdateGroupAction
|
||||
{
|
||||
public static function execute(array $newData, int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('edit_groups')) {
|
||||
kompass_print_message_box(__('You are not allowed to update a group', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
$dbHandler->updateRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData, ['id' => $groupId]);
|
||||
|
||||
kompass_print_message_box(__('The group was updated.', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user