epic-anmeldungen #2
24
components/partials/date-element.php
Normal file
24
components/partials/date-element.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
function _kompass_print_datebox($settingName, $settingValue, $style = '') {
|
||||
echo '<input style="' . $style . '" type="date" name="' . $settingName . '" value="' . $settingValue. '" />';
|
||||
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||
echo '<br />' . $settingName;
|
||||
}
|
||||
}
|
||||
|
||||
function kompass_print_datebox(array $args) {
|
||||
if (!isset($args['setting'])) {
|
||||
wp_die('Missing argument setting at text-element ' . print_r($args, true));
|
||||
}
|
||||
$setting = get_option($args['setting'], null);
|
||||
$setting = $setting ?? ( $args['value'] ?? '' );
|
||||
|
||||
$style = isset($args['style']) ? $args['style'] : '';
|
||||
|
||||
$value = esc_attr($setting);
|
||||
|
||||
if ($value === null && isset($args['value'])) {
|
||||
$value = $args['value'];
|
||||
}
|
||||
_kompass_print_datebox($args['setting'], $value, $style);
|
||||
}
|
18
components/partials/form-start.php
Normal file
18
components/partials/form-start.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
function kompass_prepare_form($params = [])
|
||||
{
|
||||
if (isset($params['page'])) {
|
||||
echo ' <form method="post" action="admin.php?page=' .$params['page'] . '">';
|
||||
}
|
||||
|
||||
echo '<input type="hidden" name="update_options" value="true" />';
|
||||
foreach ($params as $key => $value) {
|
||||
echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
||||
}
|
||||
}
|
||||
|
||||
function kompass_close_form(string $buttonText)
|
||||
{
|
||||
submit_button($buttonText,'button');
|
||||
echo '</form>';
|
||||
}
|
8
components/partials/message-box.php
Normal file
8
components/partials/message-box.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
function kompass_print_message_box(string $message, string $type = 'success')
|
||||
{
|
||||
echo '<div class="notice notice-' . $type .'" style="padding: 5px 10px;">';
|
||||
echo $message;
|
||||
echo '</div>';
|
||||
|
||||
}
|
@ -1,13 +1,18 @@
|
||||
<?php
|
||||
function kompass_print_textbox($settingName, $settingValue, $style = '') {
|
||||
function _kompass_print_textbox($settingName, $settingValue, $style = '') {
|
||||
echo '<input style="' . $style . '" type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
|
||||
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||
echo '<br />' . $settingName;
|
||||
}
|
||||
}
|
||||
|
||||
function _kompass_limit_logins_settings_callback(array $args) {
|
||||
function kompass_print_textbox(array $args) {
|
||||
if (!isset($args['setting'])) {
|
||||
wp_die('Missing argument setting at text-element ' . print_r($args, true));
|
||||
}
|
||||
$setting = get_option($args['setting'], null);
|
||||
$setting = $setting ?? ( $args['value'] ?? '' );
|
||||
|
||||
$style = isset($args['style']) ? $args['style'] : '';
|
||||
|
||||
$value = esc_attr($setting);
|
||||
@ -15,5 +20,8 @@ function _kompass_limit_logins_settings_callback(array $args) {
|
||||
$value = (int)$value / (int)$args['unit_division'];
|
||||
}
|
||||
|
||||
kompass_print_textbox($args['setting'], $value, $style);
|
||||
if ($value === null && isset($args['value'])) {
|
||||
$value = $args['value'];
|
||||
}
|
||||
_kompass_print_textbox($args['setting'], $value, $style);
|
||||
}
|
||||
|
@ -17,6 +17,21 @@ class DatabaseHandler {
|
||||
return $this->getResults($sql);
|
||||
}
|
||||
|
||||
public function insertRows(string $tableName, array $newData) : int
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->insert( $tableName, $newData );
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
|
||||
public function updateRows(string $tableName, array $newData, $conditions = [])
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->update( $tableName, $newData, $conditions );
|
||||
}
|
||||
|
||||
public function countSqlRows(string $tableName, array $conditions = []) : int
|
||||
{
|
||||
global $wpdb;
|
||||
|
@ -28,7 +28,7 @@ foreach (glob($directoryPath . '*.php') as $file) {
|
||||
|
||||
|
||||
$modules = ['KompassSettings', 'LimitLoginAttempts', 'PasswordStrength', 'seo', 'Gruppen'];
|
||||
$subdirs = ['includes', 'Controllers', 'Views'];
|
||||
$subdirs = ['includes', 'Controllers', 'Views', 'Requests', 'Actions'];
|
||||
|
||||
foreach ($modules as $curModule) {
|
||||
foreach ($subdirs as $dir) {
|
||||
|
@ -8,6 +8,7 @@ CREATE TABLE `%tablename%` (
|
||||
`vorname` varchar(128) NOT NULL,
|
||||
`nachname` varchar(128) NOT NULL,
|
||||
`geburtsdatum` date DEFAULT NULL,
|
||||
`ansprechpartner` varchar(256) DEFAULT NULL,
|
||||
`strasse` varchar(128) DEFAULT NULL,
|
||||
`hausnummer` varchar(8) DEFAULT NULL,
|
||||
`plz` varchar(5) DEFAULT NULL,
|
||||
@ -16,9 +17,9 @@ CREATE TABLE `%tablename%` (
|
||||
`email_2` varchar(512) DEFAULT NULL,
|
||||
`telefon_1` varchar(16) NOT NULL,
|
||||
`telefon_2` varchar(16) DEFAULT NULL,
|
||||
`badeerlaubnis` enum('complete','partial','none','') NOT NULL,
|
||||
`badeerlaubnis` enum('complete','partial','none','') NOT NULL DEFAULT 'none',
|
||||
`allergien` varchar(2048) NOT NULL,
|
||||
`abholung` enum('alone','parents','other','') NOT NULL,
|
||||
`abholung` enum('alone','parents','other','') NOT NULL DEFAULT 'parents',
|
||||
`abholung_text` varchar(1024) NOT NULL DEFAULT '0',
|
||||
`foto_socialmedia` tinyint NOT NULL DEFAULT '0',
|
||||
`foto_print` tinyint NOT NULL DEFAULT '0',
|
||||
|
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));
|
||||
}
|
||||
}
|
17
modules/Gruppen/Controllers/CreateGroupController.php
Normal file
17
modules/Gruppen/Controllers/CreateGroupController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class CreateGroupController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (current_user_can('create_groups')) {
|
||||
kompass_create_group_form();
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
}
|
17
modules/Gruppen/Controllers/CreateMemberController.php
Normal file
17
modules/Gruppen/Controllers/CreateMemberController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class CreateMemberController
|
||||
{
|
||||
public function __construct(array $prefilledData = [])
|
||||
{
|
||||
if (current_user_can('create_teilis')) {
|
||||
kompass_create_group_member_form($prefilledData);
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
use SearchMemberRequest;
|
||||
|
||||
class MainController
|
||||
{
|
||||
@ -53,34 +54,86 @@ class MainController
|
||||
|
||||
public function router()
|
||||
{
|
||||
if (isset($_REQUEST['action'])) {
|
||||
if (isset($_REQUEST['action'])) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'searchmember':
|
||||
$this->searchMember();
|
||||
break;
|
||||
$memberList = SearchMemberRequest::listByName($_POST['member_name']);
|
||||
new PrintMemberListController($memberList);
|
||||
break;
|
||||
|
||||
default:
|
||||
kompass_print_gruppen_overview();
|
||||
case 'create_group_form':
|
||||
new CreateGroupController();
|
||||
break;
|
||||
|
||||
case 'update-group':
|
||||
\UpdateGroupAction::execute(['gruppen_name' => $_REQUEST['kompass_groups_group_name']],
|
||||
(int)$_REQUEST['group_id']);
|
||||
|
||||
new PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'create-group':
|
||||
$data = ['gruppen_name' => $_REQUEST['kompass_groups_group_name']];
|
||||
\CreateGroupAction::execute($data);
|
||||
new PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'new-member':
|
||||
new CreateMemberController();
|
||||
break;
|
||||
|
||||
case 'create-member':
|
||||
$userData = \CreateGroupMemberDataAction::execute($_REQUEST);
|
||||
if (count($userData['errors']) === 0) {
|
||||
$memberId = \CreateGroupMemberAction::execute( $userData['data'] );
|
||||
new PrintMemberController($memberId);
|
||||
} else {
|
||||
kompass_print_message_box(implode('<br />', $userData['errors']), 'error');
|
||||
new CreateMemberController($userData['rawData']);
|
||||
exit;
|
||||
}
|
||||
new PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'show-members':
|
||||
$memberList = \ListMemberRequest::listForGroup((int)$_REQUEST['group-id']);
|
||||
new PrintMemberListController($memberList);
|
||||
break;
|
||||
|
||||
case 'show-member':
|
||||
new PrintMemberController((int)$_REQUEST['member-id']);
|
||||
break;
|
||||
|
||||
case 'compose-mail':
|
||||
current_user_can('send_mails');
|
||||
break;
|
||||
|
||||
case 'delete-group':
|
||||
if (current_user_can('delete_groups')) {
|
||||
}
|
||||
break;
|
||||
case 'edit-group':
|
||||
if (current_user_can('edit_groups')) {
|
||||
kompass_edit_group_form($_REQUEST['group-id']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
new PrintGroupsController();
|
||||
}
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
new PrintGroupsController();
|
||||
}
|
||||
}
|
||||
|
||||
private function searchMember()
|
||||
{
|
||||
global $dbHandler;
|
||||
$members = $dbHandler->readSqlFromDb(self::KOMPASS_STAMMESGRUPPEN_TEILIS,
|
||||
'SELECT * FROM %tablename% WHERE CONCAT(`vorname`, " " , `nachname`) LIKE "%' . $_POST['member_name'] . '%"');
|
||||
$this->printMembers($members);
|
||||
}
|
||||
private function listMembers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function printMembers(array $memberList)
|
||||
{
|
||||
if (count($memberList) === 0) {
|
||||
exit;
|
||||
}
|
||||
kompass_print_gruppen_members($memberList);
|
||||
|
||||
}
|
||||
|
||||
}
|
13
modules/Gruppen/Controllers/PrintGroupsController.php
Normal file
13
modules/Gruppen/Controllers/PrintGroupsController.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintGroupsController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
15
modules/Gruppen/Controllers/PrintMemberController.php
Normal file
15
modules/Gruppen/Controllers/PrintMemberController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintMemberController
|
||||
{
|
||||
public function __construct(int $memberId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$member = $dbHandler->readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['id' => $memberId]);
|
||||
echo '<pre>';print_r($member);die();
|
||||
}
|
||||
}
|
16
modules/Gruppen/Controllers/PrintMemberListController.php
Normal file
16
modules/Gruppen/Controllers/PrintMemberListController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintMemberListController
|
||||
{
|
||||
public function __construct(array $memberList)
|
||||
{
|
||||
if (count($memberList) === 0) {
|
||||
exit;
|
||||
}
|
||||
kompass_print_gruppen_members($memberList);
|
||||
}
|
||||
}
|
12
modules/Gruppen/Requests/ListMemberRequest.php
Normal file
12
modules/Gruppen/Requests/ListMemberRequest.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class ListMemberRequest
|
||||
{
|
||||
public static function listForGroup(int $groupId) : array
|
||||
{
|
||||
global $dbHandler;
|
||||
return $dbHandler->readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $groupId]);
|
||||
}
|
||||
}
|
15
modules/Gruppen/Requests/SearchMemberRequest.php
Normal file
15
modules/Gruppen/Requests/SearchMemberRequest.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class SearchMemberRequest
|
||||
{
|
||||
public static function listByName(string $name) : array
|
||||
{
|
||||
global $dbHandler;
|
||||
return $dbHandler->readSqlFromDb( MainController::KOMPASS_STAMMESGRUPPEN_TEILIS,
|
||||
'SELECT * FROM %tablename% WHERE CONCAT(`vorname`, " " , `nachname`) LIKE "%' . $name . '%"');
|
||||
|
||||
|
||||
}
|
||||
}
|
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_form()
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Create Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-group',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_display_elements($page);
|
||||
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Create', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_display_elements(string $page, stdClass $currentGroup = null)
|
||||
{
|
||||
$value = '';
|
||||
if (null !== $currentGroup) {
|
||||
$value = $currentGroup->gruppen_name;
|
||||
}
|
||||
|
||||
add_settings_field(
|
||||
'kompass_group_field_1',
|
||||
__('Group Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_groups_group_name',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_member_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_member_form(array $prefilledData = [])
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-member';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Add Member', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-member',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_member_display_elements($page, $prefilledData);
|
||||
|
||||
do_settings_sections($page);
|
||||
kompass_close_form(__('Add member', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_member_display_elements(string $page, array $prefilledElements = [])
|
||||
{
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_firstname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_1',
|
||||
__('First Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_firstname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_lastname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_2',
|
||||
__('Last Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_lastname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_birthday'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_3',
|
||||
__('Birthday', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_datebox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_birthday',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_parents'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_4',
|
||||
__('Contact person', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_parents',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_5',
|
||||
__('E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_6',
|
||||
__('Alternative E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_7',
|
||||
__('Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_8',
|
||||
__('Alternative Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
@ -11,7 +11,8 @@ function kompass_print_gruppen_overview()
|
||||
<p style="width: 100%; text-align: right">
|
||||
<input type="hidden" name="action" value="searchmember">
|
||||
<input type="text" name="member_name" style="width: 500px;"
|
||||
placeholder="<?=__('Search for member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
placeholder="<?=__('Search member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
<input type="submit" class="button" value="<?= __('Search', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@ -28,15 +29,60 @@ function kompass_print_gruppen_overview()
|
||||
<?php
|
||||
|
||||
foreach ($dbHandler->readFromDb( GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN) as $currentGruppe) {
|
||||
$participantCount = $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $currentGruppe->gruppen_name .'</td>';
|
||||
echo '<td>' . $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]) .'</td>';
|
||||
echo '<td><a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">' .
|
||||
__('Show Members', BDP_LV_PLUGIN_SLUG) . '</a></td>';
|
||||
echo '<td>' . $participantCount . '</td>';
|
||||
echo '<td> ' . kompass_get_group_actions($currentGruppe->id, $participantCount ) .'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
echo '<p>';
|
||||
if ( current_user_can( 'send_mails' ) ) {
|
||||
echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=0">' .
|
||||
__( 'Mail to multiple groups', BDP_LV_PLUGIN_SLUG ) . '</a> ';
|
||||
}
|
||||
|
||||
if (current_user_can('create_teilis')) {
|
||||
echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=new-member">' .
|
||||
__( 'New Member', BDP_LV_PLUGIN_SLUG ) . '</a> ';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_teilis' ) ) {
|
||||
?>
|
||||
<a class="button" href="admin.php?page=kompass-groups&action=create_group_form">
|
||||
<?= __('Create Group', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<?php
|
||||
}
|
||||
echo '</p>';
|
||||
}
|
||||
|
||||
function kompass_get_group_actions(int $groupId, int $participantCount) : string
|
||||
{
|
||||
$elements = [];
|
||||
if ($participantCount > 0) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=show-members&group-id=' .$groupId .'">' .
|
||||
__('Show Members', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
if (current_user_can('send_mails')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=' .$groupId .'">' .
|
||||
__( 'Mail to group', BDP_LV_PLUGIN_SLUG ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
if (current_user_can('delete_groups')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=delete-group&group-id=' .$groupId .'">' .
|
||||
__('Delete', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (current_user_can('edit_groups')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=edit-group&group-id=' .$groupId .'">' .
|
||||
__('Edit', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
}
|
||||
|
||||
return implode('<br />' , $elements);
|
||||
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ function kompass_print_gruppen_members(array $memberList)
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<a href= <?= admin_url('admin.php?page=kompass-groups') . '&action=show-member&member-id=' .$curMember->id; ?>">
|
||||
<?= __('Show details', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
|
@ -24,7 +24,7 @@ class SettingsPage
|
||||
switch ($tab) {
|
||||
case 'tab1':
|
||||
update_option('bdp_calendar_categories', json_encode($_POST['category']));
|
||||
update_option('bdp_calendar_source_url', $_POST['ical_url']);
|
||||
update_option('bdp_calendar_source_url', $_POST['bdp_calendar_source_url']);
|
||||
$showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG);
|
||||
break;
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
function custom_settings_section_callback() {
|
||||
echo '<input type="hidden" name="update_options" value="true" />';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,7 +16,7 @@ bdp_kompass_load_plugin_textdomain();
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Options', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts'
|
||||
);
|
||||
|
||||
@ -34,7 +31,7 @@ $settings_page = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
|
||||
add_settings_field(
|
||||
'kompass_lla_1',
|
||||
__('Maximum reps until lockout', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_allowed_retries']);
|
||||
@ -42,7 +39,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_2',
|
||||
__('Duration of lockout (in minutes)', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_lockout_duration', 'unit_division' => 60 ]);
|
||||
@ -50,7 +47,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_3',
|
||||
__('Maximum number of lockouts', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_allowed_lockouts']);
|
||||
@ -58,7 +55,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_4',
|
||||
__('Long-term duration (in hours)', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_long_duration', 'unit_division' => 3600]);
|
||||
@ -98,7 +95,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_9',
|
||||
__('Failed attempts until notification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_notify_email_after']);
|
||||
|
@ -3,7 +3,7 @@
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Calendar settings', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-calendar-settings'
|
||||
);
|
||||
|
||||
@ -12,7 +12,7 @@ $seo_settings_page = BDP_LV_PLUGIN_SLUG . '-calendar-settings';
|
||||
add_settings_field(
|
||||
'kompass_cal_1',
|
||||
__('Calendar URL', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'bdp_calendar_source_url', 'style' => 'width: 1024px']);
|
||||
|
@ -4,7 +4,7 @@
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('SEO-Options', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-seo-settings'
|
||||
);
|
||||
|
||||
@ -13,7 +13,7 @@ $seo_settings_page = BDP_LV_PLUGIN_SLUG . '-seo-settings';
|
||||
add_settings_field(
|
||||
'kompass_seo_1',
|
||||
__('Google Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_google_verification', 'style' => 'width: 500px']);
|
||||
@ -22,7 +22,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_seo_2',
|
||||
__('Bing Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_bing_verification', 'style' => 'width: 500px']);
|
Loading…
Reference in New Issue
Block a user