v4.8.1 #3
@ -40,54 +40,51 @@ class MainController
|
|||||||
}
|
}
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
global $dbHandler, $wpdb;
|
global $dbHandler, $wpdb;
|
||||||
|
|
||||||
$show_menu = false;
|
$no_events = true;
|
||||||
|
|
||||||
foreach ([self::KOMPASS_EVENTS_EVENTS] as $table) {
|
foreach ( [ self::KOMPASS_EVENTS_EVENTS ] as $table ) {
|
||||||
$sqlTable = $wpdb->prefix . $table;
|
$sqlTable = $wpdb->prefix . $table;
|
||||||
$sql = "SHOW TABLES LIKE '$sqlTable'";
|
$sql = "SHOW TABLES LIKE '$sqlTable'";
|
||||||
|
|
||||||
$result = $wpdb->get_var( $sql );
|
$result = $wpdb->get_var( $sql );
|
||||||
if ( $result == $sqlTable ) {
|
if ( $result == $sqlTable ) {
|
||||||
$show_menu = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$show_menu) {
|
$no_events = 0 === $dbHandler->countSqlRows( self::KOMPASS_EVENTS_EVENTS, [ 'archived' => false ] );
|
||||||
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
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($dbHandler->readFromDb( self::KOMPASS_EVENTS_EVENTS, ['archived' => false]) as $currentEvent) {
|
if ( !$no_events ) {
|
||||||
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),
|
add_menu_page(
|
||||||
__('New Event', BDP_LV_PLUGIN_SLUG),
|
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
|
||||||
'show_groups',
|
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
|
||||||
'kompass-events&action=new-event',
|
'send_mails',
|
||||||
[ $this, 'router' ]);
|
'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' ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function router()
|
public function router()
|
||||||
{
|
{
|
||||||
if (isset($_REQUEST['action'])) {
|
if (isset($_REQUEST['action'])) {
|
||||||
|
Loading…
Reference in New Issue
Block a user