From 5e766bc2e5c8011aa02a951f667c2703a815c13f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=BCnther?= Date: Sat, 23 Mar 2024 20:46:44 +0100 Subject: [PATCH] =?UTF-8?q?Gruppen=20k=C3=B6nnen=20angelegt=20und=20bearbe?= =?UTF-8?q?itet=20werden=20Teili=20k=C3=B6nnen=20angelegt=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/partials/date-element.php | 24 ++++ components/partials/form-start.php | 18 +++ components/partials/message-box.php | 8 ++ components/partials/text-element.php | 14 +- includes/DatabaseHandler.php | 15 ++ includes/spl.php | 2 +- .../kompass_stammesgruppen_teilis.sql | 5 +- modules/Gruppen/Actions/CreateGroupAction.php | 18 +++ .../Actions/CreateGroupMemberAction.php | 21 +++ .../Actions/CreateGroupMemberDataAction.php | 37 +++++ modules/Gruppen/Actions/UpdateGroupAction.php | 19 +++ .../Controllers/CreateGroupController.php | 17 +++ .../Controllers/CreateMemberController.php | 17 +++ .../Gruppen/Controllers/MainController.php | 87 +++++++++--- .../Controllers/PrintGroupsController.php | 13 ++ .../Controllers/PrintMemberController.php | 15 ++ .../Controllers/PrintMemberListController.php | 16 +++ .../Gruppen/Requests/ListMemberRequest.php | 12 ++ .../Gruppen/Requests/SearchMemberRequest.php | 15 ++ modules/Gruppen/Views/CreateGroupForm.php | 64 +++++++++ modules/Gruppen/Views/CreateMemberForm.php | 131 ++++++++++++++++++ modules/Gruppen/Views/GruppenOverview.php | 54 +++++++- modules/Gruppen/Views/PrintMembers.php | 2 +- .../Controllers/SettingsPage.php | 2 +- .../includes/gui_elements.php | 15 +- modules/calendar/Views/settings-form.php | 4 +- modules/seo/Views/seo-form.php | 6 +- 27 files changed, 608 insertions(+), 43 deletions(-) create mode 100644 components/partials/date-element.php create mode 100644 components/partials/form-start.php create mode 100644 components/partials/message-box.php create mode 100644 modules/Gruppen/Actions/CreateGroupAction.php create mode 100644 modules/Gruppen/Actions/CreateGroupMemberAction.php create mode 100644 modules/Gruppen/Actions/CreateGroupMemberDataAction.php create mode 100644 modules/Gruppen/Actions/UpdateGroupAction.php create mode 100644 modules/Gruppen/Controllers/CreateGroupController.php create mode 100644 modules/Gruppen/Controllers/CreateMemberController.php create mode 100644 modules/Gruppen/Controllers/PrintGroupsController.php create mode 100644 modules/Gruppen/Controllers/PrintMemberController.php create mode 100644 modules/Gruppen/Controllers/PrintMemberListController.php create mode 100644 modules/Gruppen/Requests/ListMemberRequest.php create mode 100644 modules/Gruppen/Requests/SearchMemberRequest.php create mode 100644 modules/Gruppen/Views/CreateGroupForm.php create mode 100644 modules/Gruppen/Views/CreateMemberForm.php diff --git a/components/partials/date-element.php b/components/partials/date-element.php new file mode 100644 index 0000000..1ef6425 --- /dev/null +++ b/components/partials/date-element.php @@ -0,0 +1,24 @@ +'; + if (defined('WP_DEBUG') && WP_DEBUG == true) { + echo '
' . $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); +} diff --git a/components/partials/form-start.php b/components/partials/form-start.php new file mode 100644 index 0000000..93d92ab --- /dev/null +++ b/components/partials/form-start.php @@ -0,0 +1,18 @@ +'; + } + + echo ''; + foreach ($params as $key => $value) { + echo ''; + } +} + +function kompass_close_form(string $buttonText) +{ + submit_button($buttonText,'button'); + echo ''; +} \ No newline at end of file diff --git a/components/partials/message-box.php b/components/partials/message-box.php new file mode 100644 index 0000000..1971feb --- /dev/null +++ b/components/partials/message-box.php @@ -0,0 +1,8 @@ +'; + echo $message; + echo ''; + +} \ No newline at end of file diff --git a/components/partials/text-element.php b/components/partials/text-element.php index e26907b..30eea7c 100644 --- a/components/partials/text-element.php +++ b/components/partials/text-element.php @@ -1,13 +1,18 @@ '; if (defined('WP_DEBUG') && WP_DEBUG == true) { echo '
' . $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); } diff --git a/includes/DatabaseHandler.php b/includes/DatabaseHandler.php index 6bc2cc3..3b343aa 100644 --- a/includes/DatabaseHandler.php +++ b/includes/DatabaseHandler.php @@ -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; diff --git a/includes/spl.php b/includes/spl.php index b627892..b3d4fe1 100644 --- a/includes/spl.php +++ b/includes/spl.php @@ -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) { diff --git a/lib/database/kompass_stammesgruppen_teilis.sql b/lib/database/kompass_stammesgruppen_teilis.sql index 97e8045..c1353e1 100644 --- a/lib/database/kompass_stammesgruppen_teilis.sql +++ b/lib/database/kompass_stammesgruppen_teilis.sql @@ -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', diff --git a/modules/Gruppen/Actions/CreateGroupAction.php b/modules/Gruppen/Actions/CreateGroupAction.php new file mode 100644 index 0000000..ced14b1 --- /dev/null +++ b/modules/Gruppen/Actions/CreateGroupAction.php @@ -0,0 +1,18 @@ +insertRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData); + kompass_print_message_box(__('The group was created.', BDP_LV_PLUGIN_SLUG)); + } +} \ No newline at end of file diff --git a/modules/Gruppen/Actions/CreateGroupMemberAction.php b/modules/Gruppen/Actions/CreateGroupMemberAction.php new file mode 100644 index 0000000..d627734 --- /dev/null +++ b/modules/Gruppen/Actions/CreateGroupMemberAction.php @@ -0,0 +1,21 @@ +insertRows(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, $userData); + } +} \ No newline at end of file diff --git a/modules/Gruppen/Actions/CreateGroupMemberDataAction.php b/modules/Gruppen/Actions/CreateGroupMemberDataAction.php new file mode 100644 index 0000000..99bfb61 --- /dev/null +++ b/modules/Gruppen/Actions/CreateGroupMemberDataAction.php @@ -0,0 +1,37 @@ + '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; + } +} \ No newline at end of file diff --git a/modules/Gruppen/Actions/UpdateGroupAction.php b/modules/Gruppen/Actions/UpdateGroupAction.php new file mode 100644 index 0000000..455a984 --- /dev/null +++ b/modules/Gruppen/Actions/UpdateGroupAction.php @@ -0,0 +1,19 @@ +updateRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData, ['id' => $groupId]); + + kompass_print_message_box(__('The group was updated.', BDP_LV_PLUGIN_SLUG)); + } +} \ No newline at end of file diff --git a/modules/Gruppen/Controllers/CreateGroupController.php b/modules/Gruppen/Controllers/CreateGroupController.php new file mode 100644 index 0000000..2e1f070 --- /dev/null +++ b/modules/Gruppen/Controllers/CreateGroupController.php @@ -0,0 +1,17 @@ +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('
', $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); + } } \ No newline at end of file diff --git a/modules/Gruppen/Controllers/PrintGroupsController.php b/modules/Gruppen/Controllers/PrintGroupsController.php new file mode 100644 index 0000000..2e0a0c3 --- /dev/null +++ b/modules/Gruppen/Controllers/PrintGroupsController.php @@ -0,0 +1,13 @@ +readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['id' => $memberId]); + echo '
';print_r($member);die();
+    }
+}
\ No newline at end of file
diff --git a/modules/Gruppen/Controllers/PrintMemberListController.php b/modules/Gruppen/Controllers/PrintMemberListController.php
new file mode 100644
index 0000000..0089f08
--- /dev/null
+++ b/modules/Gruppen/Controllers/PrintMemberListController.php
@@ -0,0 +1,16 @@
+readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $groupId]);
+    }
+}
\ No newline at end of file
diff --git a/modules/Gruppen/Requests/SearchMemberRequest.php b/modules/Gruppen/Requests/SearchMemberRequest.php
new file mode 100644
index 0000000..62ede43
--- /dev/null
+++ b/modules/Gruppen/Requests/SearchMemberRequest.php
@@ -0,0 +1,15 @@
+readSqlFromDb( MainController::KOMPASS_STAMMESGRUPPEN_TEILIS,
+		    'SELECT * FROM %tablename% WHERE CONCAT(`vorname`, " " , `nachname`) LIKE "%' . $name . '%"');
+
+
+    }
+}
\ No newline at end of file
diff --git a/modules/Gruppen/Views/CreateGroupForm.php b/modules/Gruppen/Views/CreateGroupForm.php
new file mode 100644
index 0000000..8f6f400
--- /dev/null
+++ b/modules/Gruppen/Views/CreateGroupForm.php
@@ -0,0 +1,64 @@
+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']);
+}
diff --git a/modules/Gruppen/Views/CreateMemberForm.php b/modules/Gruppen/Views/CreateMemberForm.php
new file mode 100644
index 0000000..c29c28f
--- /dev/null
+++ b/modules/Gruppen/Views/CreateMemberForm.php
@@ -0,0 +1,131 @@
+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']);
+}
diff --git a/modules/Gruppen/Views/GruppenOverview.php b/modules/Gruppen/Views/GruppenOverview.php
index 617dbf8..0af502e 100644
--- a/modules/Gruppen/Views/GruppenOverview.php
+++ b/modules/Gruppen/Views/GruppenOverview.php
@@ -11,7 +11,8 @@ function kompass_print_gruppen_overview()
 		

+ placeholder="" /> +

@@ -28,15 +29,60 @@ function kompass_print_gruppen_overview() readFromDb( GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN) as $currentGruppe) { + $participantCount = $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]); echo ''; echo '' . $currentGruppe->gruppen_name .''; - echo '' . $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]) .''; - echo '' . - __('Show Members', BDP_LV_PLUGIN_SLUG) . ''; + echo '' . $participantCount . ''; + echo ' ' . kompass_get_group_actions($currentGruppe->id, $participantCount ) .''; echo ''; } ?> + '; + if ( current_user_can( 'send_mails' ) ) { + echo '' . + __( 'Mail to multiple groups', BDP_LV_PLUGIN_SLUG ) . '  '; + } + + if (current_user_can('create_teilis')) { + echo '' . + __( 'New Member', BDP_LV_PLUGIN_SLUG ) . '  '; + } + + if ( current_user_can( 'delete_teilis' ) ) { + ?> + + + '; +} + +function kompass_get_group_actions(int $groupId, int $participantCount) : string +{ + $elements = []; + if ($participantCount > 0) { + $elements[] = '' . + __('Show Members', BDP_LV_PLUGIN_SLUG) . ''; + if (current_user_can('send_mails')) { + $elements[] = '' . + __( 'Mail to group', BDP_LV_PLUGIN_SLUG ) . ''; + } + } else { + if (current_user_can('delete_groups')) { + $elements[] = '' . + __('Delete', BDP_LV_PLUGIN_SLUG) . ''; + } + } + + if (current_user_can('edit_groups')) { + $elements[] = '' . + __('Edit', BDP_LV_PLUGIN_SLUG) . ''; + } + + return implode('
' , $elements); + } diff --git a/modules/Gruppen/Views/PrintMembers.php b/modules/Gruppen/Views/PrintMembers.php index b87696c..251ee0a 100644 --- a/modules/Gruppen/Views/PrintMembers.php +++ b/modules/Gruppen/Views/PrintMembers.php @@ -29,7 +29,7 @@ function kompass_print_gruppen_members(array $memberList) - + id; ?>">
diff --git a/modules/KompassSettings/Controllers/SettingsPage.php b/modules/KompassSettings/Controllers/SettingsPage.php index 5923617..80d7180 100644 --- a/modules/KompassSettings/Controllers/SettingsPage.php +++ b/modules/KompassSettings/Controllers/SettingsPage.php @@ -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; diff --git a/modules/LimitLoginAttempts/includes/gui_elements.php b/modules/LimitLoginAttempts/includes/gui_elements.php index 3b3c834..3070c18 100644 --- a/modules/LimitLoginAttempts/includes/gui_elements.php +++ b/modules/LimitLoginAttempts/includes/gui_elements.php @@ -1,8 +1,5 @@ '; -} @@ -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']); diff --git a/modules/calendar/Views/settings-form.php b/modules/calendar/Views/settings-form.php index 34d117b..73afdc8 100644 --- a/modules/calendar/Views/settings-form.php +++ b/modules/calendar/Views/settings-form.php @@ -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']); diff --git a/modules/seo/Views/seo-form.php b/modules/seo/Views/seo-form.php index c9f5054..19841fb 100644 --- a/modules/seo/Views/seo-form.php +++ b/modules/seo/Views/seo-form.php @@ -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']); \ No newline at end of file