/**
 * Retrieve the meta for an event
 *
 * Because there are too many fields, it would be bad for performance
 * to store all as meta fields on the post, so instead
 * a meta field just stores the event id, then this function
 * is used to retrieve additional information, works for both
 * Eventbrite and etouches events, the caller should then
 * parse data based on the service.
 */
function ikit_event_get_meta($ikit_event_id)
{
    $meta = null;
    $service = get_post_meta($ikit_event_id, IKIT_CUSTOM_FIELD_IKIT_EVENT_SERVICE, true);
    if ($service == IKIT_EVENT_SERVICE_EVENTBRITE) {
        $meta = ikit_event_eventbrite_get_meta($ikit_event_id);
    } else {
        if ($service == IKIT_EVENT_SERVICE_ETOUCHES) {
            $meta = ikit_event_etouches_get_meta($ikit_event_id);
        } else {
            if ($service == IKIT_EVENT_SERVICE_EXTERNAL) {
                $meta = ikit_event_external_get_meta($ikit_event_id);
            } else {
                if ($service == IKIT_EVENT_SERVICE_INTERNAL) {
                    $meta = ikit_event_internal_get_meta($ikit_event_id);
                }
            }
        }
    }
    return $meta;
}
Example #2
0
function ikit_event_add_meta_box_integration($post)
{
    $event_service = get_post_meta($post->ID, IKIT_CUSTOM_FIELD_IKIT_EVENT_SERVICE, true);
    if ($event_service == IKIT_EVENT_SERVICE_EVENTBRITE) {
        $event_meta = ikit_event_eventbrite_get_meta($post->ID);
        $eventbrite_id = get_post_meta($post->ID, IKIT_CUSTOM_FIELD_IKIT_EVENT_EVENTBRITE_ID, true);
        $eventbrite_sync_data = unserialize(get_post_meta($post->ID, IKIT_CUSTOM_FIELD_IKIT_EVENT_EVENTBRITE_SYNC_DATA, true));
        $eventbrite_sync_enabled = get_post_meta($post->ID, IKIT_CUSTOM_FIELD_IKIT_EVENT_EVENTBRITE_SYNC_ENABLED, true);
        // Sync validation
        if ($eventbrite_sync_enabled) {
            if ($eventbrite_sync_data) {
                // Do nothing, correctly synced
            } else {
                ?>
                <div class="error"><p><strong>Automated member tickets are incorrectly configured with Eventbrite, if you would still like to automate tickets, please verify the following before saving:</strong><ul><li>- The event start date is not in the past</li><li>- There are no tickets currently existing on the event</li></ul></p></div>
                <?php 
            }
        }
        ?>
        <div class="wp-box">
        <div class="inner">

        <table class="widefat">
        <tr>
            <td>
            Service
            </td>
            <td>
            Eventbrite
            </td>
        </tr>
        <tr>
            <td>
                Automate member tickets
                <div class="note">Automatically creates tickets for each member type on Eventbrite. Login will be required for all member type tickets. If you would like to manually create your tickets do not check this box.</div>
            </td>
            <td>
                <input type="checkbox" name="<?php 
        echo IKIT_CUSTOM_FIELD_IKIT_EVENT_EVENTBRITE_SYNC_ENABLED;
        ?>
" <?php 
        if ($eventbrite_sync_enabled) {
            echo 'checked';
        }
        ?>
/>
            </td>
        </tr>
        <tr>
            <td>
            Status
            </td>
            <td>
            <?php 
        echo $event_meta->status;
        ?>
            </td>
        </tr>
        <tr>
            <td>
            Start Datetime
            </td>
            <td>
            <?php 
        echo ikit_date_without_time($event_meta->start_date) . ' ' . $event_meta->start_time;
        ?>
            </td>
        </tr>
        <tr>
            <td>
            End Datetime
            </td>
            <td>
            <?php 
        echo ikit_date_without_time($event_meta->end_date) . ' ' . $event_meta->end_time;
        ?>
            </td>
        </tr>
        </table>

        </div>
        </div>

        <?php 
    } else {
        if ($event_service == IKIT_EVENT_SERVICE_ETOUCHES) {
            $event_meta = ikit_event_get_meta($post->ID);
            ?>

        <div class="wp-box">
        <div class="inner">
        <table class="widefat">
        <tr>
            <td>
            Service
            </td>
            <td>
            etouches
            </td>
        </tr>
        <tr>
            <td>
            Status
            </td>
            <td>
            <?php 
            echo $event_meta->status;
            ?>
            </td>
        </tr>
        <tr>
            <td>
            Start Datetime
            </td>
            <td>
            <?php 
            echo ikit_date_without_time($event_meta->start_date) . ' ' . $event_meta->start_time;
            ?>
            </td>
        </tr>
        <tr>
            <td>
            End Datetime
            </td>
            <td>
            <?php 
            echo ikit_date_without_time($event_meta->end_date) . ' ' . $event_meta->end_time;
            ?>
            </td>
        </tr>
        </table>
        </div>
        </div>

        <?php 
        }
    }
}