From d2c74a158ac2701ae83f5eeb7540c6370ccca09e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20G=C3=BCnther?=
Date: Sat, 16 Mar 2024 16:35:18 +0100
Subject: [PATCH] Added new user roles
---
bdp-kompass.php | 2 +-
changelog | 2 +-
includes/pre_requires.php | 3 +-
includes/roles.php | 102 ++++++++++++++++++++++++++++++++++++++
includes/setup.php | 8 +++
5 files changed, 114 insertions(+), 3 deletions(-)
create mode 100644 includes/roles.php
diff --git a/bdp-kompass.php b/bdp-kompass.php
index b126413..d5cc9cc 100644
--- a/bdp-kompass.php
+++ b/bdp-kompass.php
@@ -65,4 +65,4 @@ function enqueue_custom_password_js() {
]);
}
-#add_action( 'after_setup_theme', 'register_custom_theme_directory' );
+add_action( 'after_setup_theme', 'kompass_after_setup_theme' );
diff --git a/changelog b/changelog
index 9a9bbb2..dd71608 100644
--- a/changelog
+++ b/changelog
@@ -1,7 +1,7 @@
Version 4.3.8
- Google- und Bing-Verifizierung nun auch im Plugin möglich
-
+ - Neue Nutzerrollen
Version 4.3.7
diff --git a/includes/pre_requires.php b/includes/pre_requires.php
index 5c0a4af..6cedbae 100644
--- a/includes/pre_requires.php
+++ b/includes/pre_requires.php
@@ -3,5 +3,6 @@ require_once (ABSPATH . '/wp-admin/includes/plugin.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php');
require_once (ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php');
require_once (ABSPATH . '/wp-includes/pluggable.php');
+require_once (ABSPATH . '/wp-includes/capabilities.php');
require_once (ABSPATH . '/wp-admin/includes/template.php');
-require_once (ABSPATH . '/wp-admin/includes/file.php');
\ No newline at end of file
+require_once (ABSPATH . '/wp-admin/includes/file.php');
diff --git a/includes/roles.php b/includes/roles.php
new file mode 100644
index 0000000..dd4dd8b
--- /dev/null
+++ b/includes/roles.php
@@ -0,0 +1,102 @@
+ true, // Die Rolle kann Beiträge lesen
+ 'edit_posts' => true, // Die Rolle kann Beiträge bearbeiten
+ 'delete_posts' => true, // Die Rolle kann Beiträge löschen
+ 'publish_posts' => true, // Die Rolle kann Beiträge veröffentlichen
+ // Weitere Berechtigungen können nach Bedarf hinzugefügt werden
+ );
+
+ // Rolle hinzufügen
+ add_role( 'stafue', 'Stammesführung', kompass_get_capa_stafue() );
+ add_role( 'grufue', 'Gruppenführung', kompass_get_capa_grufue() );
+ add_role( 'aktionsleitung', 'Aktionsleitung', kompass_get_capa_aktionsleitung() );
+ add_role( 'author', 'Redakteur', kompass_get_capa_editor() );
+
+ $role = get_role( 'administrator' );
+ foreach (kompass_get_capa_stafue() as $capability => $value) {
+ $role->add_cap( $capability );
+ }
+ }
+
+function kompass_get_capa_stafue() : array
+{
+ return array_merge(
+ [
+ 'create_groups' => true,
+ 'delete_groups' => true,
+ 'edit_groups' => true,
+ 'delete_teilis' => true,
+ 'move_teilis' => true,
+ 'create_events' => true,
+ ], kompass_get_capa_aktionsleitung(), kompass_get_capa_grufue(), kompass_get_capa_editor());
+}
+
+
+
+function kompass_get_capa_aktionsleitung() : array
+{
+ return [
+ 'create_event_teilis' => true,
+ 'edit_event_teilis' => true,
+ 'delete_event_teilis' => true,
+ 'send_event_mails' => true,
+ ];
+}
+
+ function kompass_get_capa_grufue() : array
+ {
+ return [
+ 'create_teilis' => true,
+ 'edit_teilis' => true,
+ 'send_mails' => true
+ ];
+ }
+
+
+ function kompass_get_capa_editor() : array
+ {
+ return [
+ 'moderate_comments' => true,
+ 'manage_categories' => true,
+ 'manage_links' => true,
+ 'upload_files' => true,
+ 'unfiltered_html' => true,
+ 'edit_posts' => true,
+ 'edit_others_posts' => true,
+ 'edit_published_posts' => true,
+ 'publish_posts' => true,
+ 'edit_pages' => true,
+ 'read' => true,
+ 'level_7' => true,
+ 'level_6' => true,
+ 'level_5' => true,
+ 'level_4' => true,
+ 'level_3' => true,
+ 'level_2' => true,
+ 'level_1' => true,
+ 'level_0' => true,
+ 'edit_others_pages' => true,
+ 'edit_published_pages' => true,
+ 'publish_pages' => true,
+ 'delete_pages' => true,
+ 'delete_others_pages' => true,
+ 'delete_published_pages' => true,
+ 'delete_posts' => true,
+ 'delete_others_posts' => true,
+ 'delete_published_posts' => true,
+ 'delete_private_posts' => true,
+ 'edit_private_posts' => true,
+ 'read_private_posts' => true,
+ 'delete_private_pages' => true,
+ 'edit_private_pages' => true,
+ 'read_private_pages' => true,
+
+ ];
+ }
\ No newline at end of file
diff --git a/includes/setup.php b/includes/setup.php
index 8e420bb..2ded9b0 100644
--- a/includes/setup.php
+++ b/includes/setup.php
@@ -13,8 +13,10 @@ require_once dirname(__FILE__) . '/update.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/FileAccess.class.php';
require_once BDP_LV_PLUGIN_DIR . 'includes/WpConfigEditor.class.php';
+require_once (BDP_LV_PLUGIN_DIR . '/includes/roles.php');
require_once (BDP_LV_PLUGIN_DIR . '/includes/filters.php');
+
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/Event.php');
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/ICal.php');
@@ -37,6 +39,12 @@ function bdp_kompass_load_plugin_textdomain() {
}
+function kompass_after_setup_theme()
+{
+ setup_site_roles();
+ #register_custom_theme_directory();
+
+}
$loginHandler = new LoginHandler();