Compare commits

..

No commits in common. "da63fe3b3cc1e3b992bbe738ec90a5566dbbf8c6" and "e7fe409ae5d017654c093630f2d9628f66ba82d2" have entirely different histories.

12 changed files with 66 additions and 261 deletions

View File

@ -393,14 +393,4 @@ li.wp-has-submenu.wp-not-current-submenu.opensub:hover:after,
background-color: #FFFFFF !important;
}
.bdp-newplugin-button:hover {
color: #ffffff !important;
background-color: #1d4899 !important;
}
.bdp-newplugin-button {
background-color: #ffffff !important;
padding: 5px 20px !important;
cursor: pointer !important;
color: #1d4899 !important;
}

View File

@ -2,7 +2,7 @@
/**
* Plugin Name: BdP Kompass
* Description: Wordpress-Plugin zur Unterstützung von Stämmen im Bund der Pfadfinderinnen und Pfadfinder e.V. zur optimalen Verwaltung eurer Webseite
* Version: 4.8.1
* Version: 4.6.2
* Tags: bdp, utility, helper
* Requires at least: 6.0
* Requires PHP: 8.2
@ -34,6 +34,7 @@ function bdp_plugin_init() {
if (null == get_option('kompass_already_installed', null)) {
Seo::setup();
Calendar::setup();
Security::setup();
update_option('kompass_already_installed', true);
wp_redirect( 'site-health.php?tab=bdp_enhanced_security');

View File

@ -20,51 +20,3 @@ function bdp_update_dashboard_style() {
wp_enqueue_style('custom-calendar-styles', BDP_LV_PLUGIN_URL . '/assets/calendar.css');
wp_enqueue_style('custom-security-styles', BDP_LV_PLUGIN_URL . '/assets/security.css');
}
function kompass_install_plugin($url, $slug) {
// Überprüfen, ob die URL gültig ist
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
echo 'Ungültige URL';
return;
}
// Dateinamen und Pfad festlegen
$tmp_file = download_url($url);
// Überprüfen, ob der Download erfolgreich war
if (is_wp_error($tmp_file)) {
echo 'Download-Fehler: ' . $tmp_file->get_error_message();
return;
}
// Pfad des Plugins
$plugin_folder = WP_PLUGIN_DIR;
// Plugin Upgrader Klassen einbinden
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php';
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
// Plugin upgrader initialisieren
$upgrader = new Plugin_Upgrader(new WP_Ajax_Upgrader_Skin());
// Plugin installieren
$result = $upgrader->install($tmp_file);
// Temp Datei löschen
unlink($tmp_file);
activate_plugin($slug . '/' . $slug . '.php' );
// Überprüfen, ob die Installation erfolgreich war
if (is_wp_error($result)) {
echo 'Installations-Fehler: ' . $result->get_error_message();
} else {
echo 'Plugin erfolgreich installiert';
}
}

View File

@ -1,6 +1,5 @@
<?php
class BdpVersionChecker
{
public $plugin_slug;

View File

@ -6,49 +6,6 @@ namespace Bdp\Modules\KompassSettings\Controllers;
class SettingsPage
{
public static function add_menu() {
if (
null !== get_option('bdp_calendar_source_url', null ) ||
!file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php')
)
{
add_menu_page(
'Kalender Installation',
'Kalender Installation',
'manage_options',
'kompass-calendar',
['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_calendar'],
'dashicons-calendar-alt',
2
);
if ( file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php') ) {
add_action( 'admin_notices', array( 'Bdp\Modules\PluginInstaller\Controllers\OutdatedModule', 'calender' ) );
}
}
if (
!file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../solea/solea.php')
)
{
add_menu_page(
'Installiere solea (Veranstaltungen)',
'Installiere solea (Veranstaltungen)',
'manage_options',
'kompass-events',
['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_events'],
'dashicons-tickets-alt',
2
);
}
add_submenu_page('options-general.php',
'kompass Einstellungen',
'kompass Einstellungen',
@ -106,8 +63,10 @@ class SettingsPage
if (isset($_REQUEST['update_options']) && $_REQUEST['update_options'] == true) {
switch ($tab) {
case 'tab2':
kompass_print_message_box('Diese Funktion wird nicht mdehr unterstützt.', 'error');
break;
update_option('bdp_calendar_categories', json_encode($_POST['category']));
update_option('bdp_calendar_source_url', $_POST['bdp_calendar_source_url']);
$showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG);
break;
case 'tab3':
update_option('kompass_seo_google_verification', $_POST['kompass_seo_google_verification']);

View File

@ -5,6 +5,25 @@ class Calendar
public $ical;
private $categories = [];
public static function setup()
{
$pageName = 'Kalender';
$page_exists = get_page_by_path($pageName, OBJECT, 'page');
// Wenn die Seite nicht existiert, erstelle sie
if (!$page_exists) {
$page_id = wp_insert_post(array(
'post_title' => $pageName,
'post_content' => '{{calendar}}',
'post_status' => 'publish',
'post_type' => 'page',
));
update_option('bdp_calendar_source_url', 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics');
}
}
public static function printCalendar($content) : string {
// Der zu ersetzende String
$original_string = '{{calendar}}';
@ -48,10 +67,8 @@ class Calendar
}
$calendarUrl = get_option('bdp_calendar_source_url', null);
if (null === '') {
return;
}
$calendarUrl = get_option('bdp_calendar_source_url', 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics');
$this->ical = new \ICal('', array(
'defaultSpan' => 2, // Default value
'defaultTimeZone' => '',

View File

@ -40,51 +40,54 @@ class MainController
}
public function __construct()
{
global $dbHandler, $wpdb;
global $dbHandler, $wpdb;
$no_events = true;
$show_menu = false;
foreach ( [ self::KOMPASS_EVENTS_EVENTS ] as $table ) {
$sqlTable = $wpdb->prefix . $table;
$sql = "SHOW TABLES LIKE '$sqlTable'";
foreach ([self::KOMPASS_EVENTS_EVENTS] as $table) {
$sqlTable = $wpdb->prefix . $table;
$sql = "SHOW TABLES LIKE '$sqlTable'";
$result = $wpdb->get_var( $sql );
if ( $result == $sqlTable ) {
$result = $wpdb->get_var( $sql );
if ( $result == $sqlTable ) {
$show_menu = true;
}
}
$no_events = 0 === $dbHandler->countSqlRows( self::KOMPASS_EVENTS_EVENTS, [ 'archived' => false ] );
}
}
if (!$show_menu) {
return;
}
add_menu_page(
__('Events (legacy)', BDP_LV_PLUGIN_SLUG),
__('Events (legacy)', BDP_LV_PLUGIN_SLUG),
'send_mails',
'kompass-events',
[$this, 'router'],
'dashicons-tickets-alt',
3
);
if ( !$no_events ) {
foreach ($dbHandler->readFromDb( self::KOMPASS_EVENTS_EVENTS, ['archived' => false]) as $currentEvent) {
add_submenu_page(
'kompass-events',
$currentEvent->event_name,
$currentEvent->event_name,
'show_groups',
'kompass-events&action=show-event&event-id=' . $currentEvent->id,
[ $this, 'router' ]);
}
add_menu_page(
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
'send_mails',
'kompass-events',
[ $this, 'router' ],
'dashicons-tickets-alt',
3
);
foreach ( $dbHandler->readFromDb( self::KOMPASS_EVENTS_EVENTS, [ 'archived' => false ] ) as $currentEvent ) {
add_submenu_page(
'kompass-events',
$currentEvent->event_name,
$currentEvent->event_name,
'show_groups',
'kompass-events&action=show-event&event-id=' . $currentEvent->id,
[ $this, 'router' ] );
}
}
add_submenu_page(
'kompass-events',
__('New Event', BDP_LV_PLUGIN_SLUG),
__('New Event', BDP_LV_PLUGIN_SLUG),
'show_groups',
'kompass-events&action=new-event',
[ $this, 'router' ]);
}
public function router()
{
if (isset($_REQUEST['action'])) {

View File

@ -1,57 +0,0 @@
<?php
/**
* File: class-installsingleplugin.php
*
*
* @since 2024-08-12
* @license GPL-3.0-or-later
*
* @package
*/
namespace Bdp\Modules\PluginInstaller\Controllers;
use Plugin_Upgrader;
use WP_Ajax_Upgrader_Skin;
class InstallSingleplugin
{
public static function install_calendar ()
{
if ( isset( $_REQUEST[ 'install' ] ) ) {
if ( !file_exists( dirname( BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php' ) ) {
$pageName = 'Kalender';
$page_exists = get_page_by_path( $pageName, OBJECT, 'page' );
if ( is_object( $page_exists ) ) {
wp_delete_post( $page_exists->ID, false );
}
$calendar_connection = get_option( 'bdp_calendar_source_url',
'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics' );
if ( 'https://wiki.sachsen.pfadfinden.de/rest/calendar-services/1.0/calendar/export/subcalendar/private/ff69f5a689391ac0d7f78a70189cfde7c48cb923.ics' !== $calendar_connection ) {
update_option( 'kronos_calendar_url', $calendar_connection );
}
delete_option( 'bdp_calendar_source_url' );
kompass_install_plugin( 'https://repos.contelli.de/plugins/kronos/download', 'kronos' );
}
} else {
$install_link = admin_url( 'admin.php?page=kompass-calendar&install=true' );
require dirname( __FILE__ ) . '/../views/install-item.php';
}
}
public static function install_events ()
{
if ( isset( $_REQUEST[ 'install' ] ) ) {
if ( !file_exists( dirname( BDP_LV_STARTUP_FILE ) . '/../solea/solea.php' ) ) {
kompass_install_plugin( 'https://repos.contelli.de/plugins/solea/download', 'solea' );
}
} else {
$install_link = admin_url( 'admin.php?page=kompass-events&install=true' );
require dirname( __FILE__ ) . '/../views/install-item.php';
}
}
}

View File

@ -1,21 +0,0 @@
<?php
/**
* File: class-outdatedmodule.php
*
*
* @since 2024-08-12
* @license GPL-3.0-or-later
*
* @package
*/
namespace Bdp\Modules\PluginInstaller\Controllers;
class OutdatedModule
{
public static function calender() {
$module = 'Kalender';
$install_url = admin_url('admin.php?page=kompass-calendar');
require dirname(__FILE__) . '/../views/outdated-component.php';
}
}

View File

@ -1,20 +0,0 @@
<?php
/**
* File: install-item.php
*
*
* @since 2024-08-12
* @license GPL-3.0-or-later
*
* @package
*/
?>
<div style="width: 80%; margin: 50px auto; border-style: solid; border-width: 2px; border-color: #1d4899; padding: 10px;">
Um die gewünschte Komponente zu aktivieren, klicke bitte hier auf aktivieren.<br />
kompass führt dabei die Installation im Hintergrund durch.
<div style="text-align: center">
<a href="<?php echo $install_link; ?>" class="button bdp-newplugin-button">Jetzt installieren</a>
</div>
</div>

View File

@ -1,18 +0,0 @@
<?php
/**
* File: outdated-component.php
*
*
* @since 2024-08-12
* @license GPL-3.0-or-later
*
* @package
*/
?>
<div style="padding: 10px 10px; font-size: 15pt; margin-top: 20px; line-height: 30px; background-color: #fafafa; border-left: #f10905 10px solid;">
kompass hat festgestellt, dass du die Komponente <?php echo esc_html($module); ?> nutzt, die nicht weiterentwickelt wird.<br />
Es steht eine neue Version bereit, bitte klicke <a href="<?php echo esc_url($install_url); ?>">hier</a>, um die Aktualisierung durchzuführen.
</div>

View File

@ -50,4 +50,4 @@ wp-submenu ul,
#wp-admin-bar-wp-logo
{
display: none;
}
}