Esempio n. 1
0
function eventsList()
{
    $current_user = wp_get_current_user();
    if (isset($_GET['eventaction'])) {
        $event_action = (int) $_GET['eventaction'];
        if (is_numeric($_GET['eventid'])) {
            switch ($event_action) {
                case 0:
                    EventDatabaseManager::signIn($current_user->ID, $_GET['eventid']);
                    MailNotifications::sendSignInMail($current_user->user_email, EventDatabaseManager::getEvent($_GET['eventid']));
                    wp_redirect(wp_get_referer());
                    break;
                case 1:
                    break;
                case 2:
                    EventDatabaseManager::signOut($current_user->ID, $_GET['eventid']);
                    MailNotifications::sendSignOutMail($current_user->user_email, EventDatabaseManager::getEvent($_GET['eventid']));
                    wp_redirect(wp_get_referer());
                    break;
                default:
                    break;
            }
        }
        $events_custom = EventDatabaseManager::getAvailableEventsForUser($current_user->ID);
        return View::outputEventListForUser($_GET['page_id'], $_GET['page_id'], $current_user->ID, $events_custom);
    } elseif (isset($_GET['eventID'])) {
        $event = EventDatabaseManager::getEvent($_GET['eventID']);
        return eventsInfo($event);
    } else {
        $events_custom = EventDatabaseManager::getAvailableEventsForUser($current_user->ID);
        return View::outputEventListForUser($_GET['page_id'], $_GET['page_id'], $current_user->ID, $events_custom);
    }
}