コード例 #1
0
function check_and_delete_ticket($ticket_id)
{
    $activation_time = get_activation_time($ticket_id);
    if (!empty($activation_time) && current_time('timestamp') - $activation_time >= 60 * fablab_get_option('ticket_delay')) {
        wp_delete_post($ticket_id);
    }
}
コード例 #2
0
function extend_timeticket()
{
    $ticket_id = sanitize_text_field($_POST['ticket_id']);
    $minutes = sanitize_text_field($_POST['minutes']);
    if (!is_timeticket_entry($ticket_id) || !has_timeticket_update_permission($ticket_id)) {
        die(false);
    }
    $start_time = get_post_meta($ticket_id, 'timeticket_start_time', true);
    $end_time = get_post_meta($ticket_id, 'timeticket_end_time', true);
    $new_time = $end_time + $minutes * 60;
    $ticket_max_time = fablab_get_option('ticket_max_time') * 60;
    if ($new_time - $start_time > $ticket_max_time && !is_manager()) {
        if ($end_time - $start_time < $ticket_max_time) {
            $new_time = $start_time + $ticket_max_time;
        } else {
            die(false);
        }
    }
    clear_device_activation_time(get_post_meta($ticket_id, 'timeticket_device', true));
    die(update_post_meta($ticket_id, 'timeticket_end_time', $new_time) == true);
}
コード例 #3
0
function fablab_deactivate_ticketing()
{
    if (current_user_can('delete_others_posts')) {
        $options = fablab_get_option();
        $options['ticket_online'] = 0;
        update_option('option_fields', $options);
        die(true);
    }
    die(false);
}
コード例 #4
0
        function print_active_timetickets($device_id = '')
        {
            global $post;
            echo '<h2>' . fablab_get_captions('time_tickets_caption') . '</h2>';
            echo '<p>Hier werden dir die aktiven ' . fablab_get_captions('time_tickets_caption') . ' angezeigt:</p>';
            if ($device_id) {
                $meta_array = array('relation' => 'and', array('key' => 'timeticket_start_time', 'value' => current_time('timestamp'), 'compare' => '<'), array('key' => 'timeticket_end_time', 'value' => current_time('timestamp') - $time_delay, 'compare' => '>'), array('key' => 'timeticket_device', 'value' => $device_id, 'compare' => '='));
            } else {
                $meta_array = array('relation' => 'and', array('key' => 'timeticket_start_time', 'value' => current_time('timestamp'), 'compare' => '<'), array('key' => 'timeticket_end_time', 'value' => current_time('timestamp') - $time_delay, 'compare' => '>'));
            }
            $time_delay = fablab_get_option('ticket_delay') * 60;
            $query_arg = array('post_type' => 'timeticket', 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'ASC', 'meta_query' => $meta_array);
            $ticket_query = new WP_Query($query_arg);
            if ($ticket_query->have_posts()) {
                while ($ticket_query->have_posts()) {
                    $ticket_query->the_post();
                    $device_id = get_post_meta($post->ID, 'timeticket_device', true);
                    $color = get_post_meta($device_id, 'device_color', true);
                    ?>
          <div class="fl-ticket-element" style="border: 4px solid <?php 
                    echo $color;
                    ?>
;"
            data-user="******"
            data-time-ticket-id="<?php 
                    echo $post->ID;
                    ?>
">
            <p><?php 
                    echo fablab_get_captions('device_caption');
                    ?>
 : <b><?php 
                    echo get_device_title_by_id($device_id);
                    ?>
</b> </p> 
            <h2><?php 
                    echo $post->post_title;
                    ?>
</h2>
            <p>Start Zeit: <b><?php 
                    echo get_timediff_string(get_post_meta($post->ID, 'timeticket_start_time', true));
                    ?>
</b></p>
            <p>End Zeit: <b><?php 
                    echo get_timediff_string(get_post_meta($post->ID, 'timeticket_end_time', true));
                    ?>
</b></p>
            <input type="submit" class="ticket-btn stop-time-ticket" value="Jetzt Beenden"/>
            <input type="submit" class="ticket-btn delete-time-ticket" value="Löschen"/>
            <input type="submit" data-minutes="30" class="ticket-btn extend-time-ticket" value="+30 Minuten"/>
          </div>
          <?php 
                }
            } else {
                echo '<p style="margin-bottom:40px; opacity: 0.6;"> -- Keine aktiven ' . fablab_get_captions('time_tickets_caption') . '! -- </p>';
            }
            wp_reset_query();
        }
コード例 #5
0
function get_ticket_shortcode($atts)
{
    global $post;
    global $fl_ticket_script;
    $fl_ticket_script = true;
    $user_id = get_current_user_id();
    //--------------------------------------------------------
    // User not Logged in
    //--------------------------------------------------------
    if ($user_id == 0) {
        ?>
    <div id="message" class="message-box">
      <p>Du bist nicht eingeloggt!</br>
      Du kannst dich <a href="<?php 
        echo bloginfo('url');
        ?>
/wp-login.php?redirect_to=<?php 
        echo get_permalink($post->ID);
        ?>
">hier</a>
      einloggen, oder <a href="<?php 
        echo bloginfo('url');
        ?>
/wp-login.php?action=register">hier</a> registrieren!</p>
    </div>
    <?php 
        return;
    }
    $permission_needed = fablab_get_option('tickets_permission') == '1';
    ?>
  <div id="message-container"></div>
  <div class="busy" hidden></div>
  <?php 
    new TicketShortcodeHelp();
    //--------------------------------------------------------
    // Check TAC
    //--------------------------------------------------------
    $tac_options = fablab_get_tac();
    $tac_acceptance_date = get_user_meta($user_id, 'tac_acceptance_date', true);
    $agb_page = get_post($tac_options['tac_pageid'], ARRAY_A);
    $content = apply_filters("the_content", $agb_page['post_content']);
    if (fablab_user_tac_acceptance()) {
        ?>
    <div id="tac-message" class="message-box">
      <p class="tac-toggle">Um ein Gerät zu nutzen, bitte den AGBs zustimmen! <a id="tac-show">Anzeigen</a></p>    
    </div>
    <?php 
        echo '<div id="tac-content" hidden class="tac-box">';
        if (!empty($content)) {
            echo $content;
            echo '<input type="submit" id="accept-tac" class="button-primary" value="Zustimmen"/>';
            echo '<input type="submit" id="cancel-tac" class="button-primary" value="Abbrechen"/>';
        } else {
            echo '<p>Keine AGBs vorhanden!</br>Bitte kontaktiere den Administrator!</p>';
        }
        echo '</div>';
    } else {
        //--------------------------------------------------------
        // Display Ticket options
        //--------------------------------------------------------
        $ticket_query = get_ticket_query_from_user($user_id);
        $timeticket_query = get_active_user_ticket($user_id);
        new TicketShortcodeTimeticket($timeticket_query);
        //print_active_user_timetickets($timeticket_query);
        $ticket_online = fablab_get_option('ticket_online') == 1;
        $ticket_count = $ticket_query->found_posts;
        $timeticket_count = $timeticket_query->found_posts;
        $tickets_per_user = fablab_get_option('tickets_per_user');
        $max_tickets = $ticket_count + $timeticket_count >= $tickets_per_user;
        $ticket_caption = fablab_get_captions('ticket_caption');
        $tickets_caption = fablab_get_captions('tickets_caption');
        $tickets = new TicketShortcodeTicket();
        if ($ticket_query->have_posts() && $timeticket_count < $tickets_per_user) {
            echo '<h2>' . $tickets_caption . '</h2>';
            $tickets->display_user_tickets($ticket_query);
        }
        echo '<h2>' . fablab_get_captions('devices_caption') . '</h2>';
        if (!$ticket_online) {
            echo '<p class="device-message">Zurzeit können keine ' . $tickets_caption . ' gezogen werden!</p>';
        } else {
            if (!$max_tickets) {
                $tickets->display_available_devices($permission_needed);
            } else {
                echo '<p class="device-message">Du hast die maximale Anzahl von ' . $tickets_caption . ' gezogen!</p>';
            }
        }
    }
    $instuctions = new TicketShortcodeInstructions();
    $instruction_query = get_instruction_query_from_user($user_id);
    echo '<h2>' . fablab_get_captions('instruction_requests_caption') . '</h2>';
    if ($instruction_query->have_posts()) {
        $instuctions->display_user_instructions($instruction_query);
    }
    if ($permission_needed) {
        $instuctions->display_available_instruction_devices();
    }
}
コード例 #6
0
ファイル: ticket.php プロジェクト: jellmaier/fablab-ticket
function update_ticket()
{
    $device_id = sanitize_text_field($_POST['device_id']);
    $duration = sanitize_text_field($_POST['duration']);
    $ticket_id = sanitize_text_field($_POST['ticket_id']);
    $user_id = get_current_user_id();
    $options = fablab_get_option();
    if (get_ticket_device($ticket_id) != $device_id && user_has_ticket($user_id, $device_id, 'device')) {
        die(false);
    }
    //valide input
    if ($duration > $options['ticket_max_time'] || is_no_device_entry($device_id) || !is_ticket_entry($ticket_id) || !has_ticket_update_permission($ticket_id)) {
        die(false);
    }
    if (intval($duration) && intval($ticket_id)) {
        update_post_meta($ticket_id, 'device_id', $device_id);
        update_post_meta($ticket_id, 'duration', $duration);
    } else {
        die('naN');
        return;
    }
    die(true);
}