kompass/modules/Mail/Controllers/MailController.php

116 lines
3.1 KiB
PHP

<?php
namespace Bdp\Modules\Mail\Controllers;
use Bdp\Libs\FileAccess;
use SearchMemberRequest;
class MailController
{
public function __construct()
{
add_menu_page(
__('E-Mail', BDP_LV_PLUGIN_SLUG),
__('E-Mail', BDP_LV_PLUGIN_SLUG),
'send_mails',
'kompass-mail',
[$this, 'router'],
'dashicons-email',
4
);
/*$mailCompose = new MailCompose();
add_submenu_page(
'kompass-mail',
__('Templates', BDP_LV_PLUGIN_SLUG),
__('Templates', BDP_LV_PLUGIN_SLUG),
'send_mails',
'kompass-mail-compose',
[$mailCompose, '__construct'],
1);*/
}
public function router()
{
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
case 'send-email':
new Sendmail();
new MailCompose();
break;
case 'create_group_form':
new \Bdp\Modules\Gruppen\Controllers\CreateGroupController();
break;
case 'update-group':
\UpdateGroupAction::execute(['gruppen_name' => $_REQUEST['kompass_groups_group_name']],
(int)$_REQUEST['group_id']);
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
break;
case 'create-group':
$data = ['gruppen_name' => $_REQUEST['kompass_groups_group_name']];
\CreateGroupAction::execute($data);
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
break;
case 'new-member':
new \Bdp\Modules\Gruppen\Controllers\CreateMemberController();
break;
case 'create-member':
$userData = \CreateGroupMemberDataAction::execute($_REQUEST);
if (count($userData['errors']) === 0) {
$memberId = \CreateGroupMemberAction::execute( $userData['data'] );
new \Bdp\Modules\Gruppen\Controllers\PrintMemberController($memberId);
} else {
kompass_print_message_box(implode('<br />', $userData['errors']), 'error');
new \Bdp\Modules\Gruppen\Controllers\CreateMemberController($userData['rawData']);
exit;
}
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
break;
case 'show-members':
$memberList = \ListMemberRequest::listForGroup((int)$_REQUEST['group-id']);
new \Bdp\Modules\Gruppen\Controllers\PrintMemberListController($memberList);
break;
case 'show-member':
new \Bdp\Modules\Gruppen\Controllers\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:
}
} else {
new MailCompose();
}
}
private function listMembers()
{
}
private function printMembers(array $memberList)
{
}
}