Base setup for displaying groups and listing members
This commit is contained in:
86
modules/Gruppen/Controllers/MainController.php
Normal file
86
modules/Gruppen/Controllers/MainController.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class MainController
|
||||
{
|
||||
public const KOMPASS_STAMMESGRUPPEN_GRUPPEN = 'kompass_stammesgruppen_gruppen';
|
||||
public const KOMPASS_STAMMESGRUPPEN_TEILIS = 'kompass_stammesgruppen_teilis';
|
||||
|
||||
public static function setup()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$charset = $wpdb->get_charset_collate();
|
||||
$fileReader = new FileAccess();
|
||||
foreach ([self::KOMPASS_STAMMESGRUPPEN_GRUPPEN, self::KOMPASS_STAMMESGRUPPEN_TEILIS] as $table) {
|
||||
$sqlTable = $wpdb->prefix . $table;
|
||||
$sql = "SHOW TABLES LIKE '$sqlTable'";
|
||||
|
||||
$result = $wpdb->get_var( $sql );
|
||||
if ( $result == $sqlTable ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sqlSetup = str_replace(
|
||||
'%tablename%',
|
||||
$sqlTable,
|
||||
$fileReader->get_contents( WP_PLUGIN_DIR . '/' . BDP_LV_PLUGIN_SLUG . '/lib/database/' . $table . '.sql' ) );
|
||||
|
||||
$sqlSetup = str_replace('%charset%', $charset, $sqlSetup);
|
||||
$sqlSetup = str_replace('%prefix%', $wpdb->prefix, $sqlSetup);
|
||||
|
||||
|
||||
|
||||
dbDelta( $sqlSetup );
|
||||
}
|
||||
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
add_submenu_page(
|
||||
BDP_LV_PLUGIN_DIR . '/modules/index.php',
|
||||
__('Groups', BDP_LV_PLUGIN_SLUG),
|
||||
__('Groups', BDP_LV_PLUGIN_SLUG),
|
||||
'show_groups',
|
||||
'kompass-groups',
|
||||
[$this, 'router'],
|
||||
1);
|
||||
}
|
||||
|
||||
|
||||
public function router()
|
||||
{
|
||||
if (isset($_REQUEST['action'])) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'searchmember':
|
||||
$this->searchMember();
|
||||
break;
|
||||
|
||||
default:
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
|
||||
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 printMembers(array $memberList)
|
||||
{
|
||||
if (count($memberList) === 0) {
|
||||
exit;
|
||||
}
|
||||
kompass_print_gruppen_members($memberList);
|
||||
}
|
||||
|
||||
}
|
42
modules/Gruppen/Views/GruppenOverview.php
Normal file
42
modules/Gruppen/Views/GruppenOverview.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_print_gruppen_overview()
|
||||
{
|
||||
global $dbHandler;
|
||||
?>
|
||||
|
||||
<form method="post" action="admin.php?page=kompass-groups">
|
||||
<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); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Group Name', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Number Members', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th style="width: 100px;" class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
foreach ($dbHandler->readFromDb( GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN) as $currentGruppe) {
|
||||
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 '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
65
modules/Gruppen/Views/PrintMembers.php
Normal file
65
modules/Gruppen/Views/PrintMembers.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
function kompass_print_gruppen_members(array $memberList)
|
||||
{
|
||||
?>
|
||||
<p style="width: 100%; text-align: right">
|
||||
<input type="text" id="searchInput"
|
||||
onkeyup="searchTable('myTable', this)"
|
||||
placeholder="<?=__('Filter member', BDP_LV_PLUGIN_SLUG); ?>">
|
||||
</p>
|
||||
<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Name', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th style="width: 100px;" class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($memberList as $curMember) {
|
||||
?>
|
||||
<tr>
|
||||
<td> <?= $curMember->vorname . ' ' . $curMember->nachname ?>
|
||||
<br />
|
||||
<?php kompass_gruppen_printTelephonNumbers($curMember); ?>
|
||||
<br />
|
||||
<?= __('Allergies:', BDP_LV_PLUGIN_SLUG) . ' ' .
|
||||
($curMember->allergien != '' ? $curMember->allergien : '---'); ?>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Show details', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Send E-Mail', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
<?php
|
||||
if ( current_user_can( 'delete_teilis' ) ) {
|
||||
?>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Delete', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
function kompass_gruppen_printTelephonNumbers(stdClass $curMember)
|
||||
{
|
||||
kompass_print_telephone_link($curMember->telefon_1);
|
||||
if ($curMember->telefon_2 != '') {
|
||||
echo ' // ';
|
||||
kompass_print_telephone_link( $curMember->telefon_2 );
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function kompass_seo_add_verfications() {
|
||||
function kompass_seo_add_verifications() {
|
||||
$googleVerification = get_option('kompass_seo_google_verification', '');
|
||||
if ('' !== $googleVerification) {
|
||||
echo '<meta name="google-site-verification" content="' . $googleVerification . '" />' . "\n";
|
||||
|
Reference in New Issue
Block a user