function check_and_deactivate_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')) { deactivate_ticket($ticket_id); } }
function insert_timeticket() { $device_id = $_POST['device_id']; $duration = $_POST['duration']; $user_id = $_POST['user_id']; $ticket_id = $_POST['ticket_id']; $start_time = current_time('timestamp'); $end_time = current_time('timestamp') + 60 * $duration; $post_information = array('post_title' => fablab_get_captions('time_ticket_caption') . ' von: ' . get_user_by('id', $user_id)->display_name, 'post_type' => 'timeticket', 'author' => $user_id, 'post_status' => 'publish'); $ID = wp_insert_post($post_information); if ($ID != 0) { add_post_meta($ID, 'timeticket_device', $device_id); add_post_meta($ID, 'timeticket_start_time', $start_time); add_post_meta($ID, 'timeticket_end_time', $end_time); add_post_meta($ID, 'timeticket_user', $user_id); } deactivate_ticket($ticket_id); set_activation_time($ticket_id); die($ID != 0); }
function deactivate_ticket_ajax() { $ticket_id = sanitize_text_field($_POST['ticket_id']); //valide input if (!is_ticket_entry($ticket_id) || !is_manager()) { die(false); } die(deactivate_ticket($ticket_id)); }