Skip to content

Commit

Permalink
Added the ability to mark a ticket as read.
Browse files Browse the repository at this point in the history
Ensured that multiline fields display multiple lines in the ticket admin page.
Made the ticket number display tickets admin page.
  • Loading branch information
kezakez committed Dec 27, 2011
1 parent 91c5715 commit c7dd5c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions admin/admin.php
Expand Up @@ -132,6 +132,19 @@ function suptic_admin_init() {
wp_redirect( suptic_admin_url( 'edit-forms.php', array( 'message' => 'form_deleted' ) ) );
exit();

} elseif ( isset( $_POST['suptic-mark-ticket'] ) ) {
$ticket_id = (int) $_POST['ticket-id'];
check_admin_referer( 'suptic-edit-ticket-' . $ticket_id );

if ( ! suptic_you_can_access_all_tickets() )
wp_die( __( 'Cheatin’ uh?', 'suptic' ) );

if ( $ticket = suptic_get_ticket( $ticket_id ) )
$ticket->set_status( 'read' );

wp_redirect( suptic_admin_url( 'edit-tickets.php',
array( 'ticket_id' => $ticket_id, 'message' => 'ticket_read' ) ) );
exit();
} elseif ( isset( $_POST['suptic-close-ticket'] ) ) {
$ticket_id = (int) $_POST['ticket-id'];
check_admin_referer( 'suptic-edit-ticket-' . $ticket_id );
Expand Down
5 changes: 4 additions & 1 deletion admin/edit-ticket.php
Expand Up @@ -50,7 +50,7 @@
<tbody><?php foreach ( $metas as $meta ) : ?>
<tr>
<th><?php echo esc_html( $meta->meta_key ); ?></th>
<td><?php echo esc_html( $meta->meta_value ); ?></td>
<td><pre><?php echo esc_html( $meta->meta_value ); ?></pre></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand All @@ -66,6 +66,9 @@
<a href="<?php echo esc_attr( $ticket->url() ); ?>" class="button-primary" target="_blank"><?php echo esc_html( __( 'View Ticket Page', 'suptic' ) ); ?></a>

<?php if ( ! $ticket->has_status( 'closed' ) ) : ?>
<?php if ( ! $ticket->has_status( 'read' ) ) : ?>
&emsp;<input type="submit" name="suptic-mark-ticket" class="button" value="<?php echo esc_attr( __( 'Mark as Read', 'suptic' ) ); ?>" />
<?php endif ?>
&emsp;<input type="submit" name="suptic-close-ticket" class="button" value="<?php echo esc_attr( __( 'Close This Ticket', 'suptic' ) ); ?>" />
<?php else : ?>
&emsp;<input type="submit" name="suptic-reopen-ticket" class="button" value="<?php echo esc_attr( __( 'Reopen This Ticket', 'suptic' ) ); ?>" />
Expand Down
3 changes: 3 additions & 0 deletions admin/edit-tickets.php
Expand Up @@ -136,6 +136,7 @@
<tr>
<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Subject', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Ticket', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Author', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Messages', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Form', 'suptic' ) ); ?></th>
Expand All @@ -149,6 +150,7 @@
<tr>
<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Subject', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Ticket', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Author', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Messages', 'suptic' ) ); ?></th>
<th scope="col" class="manage-column column-name" style=""><?php echo esc_html( __( 'Form', 'suptic' ) ); ?></th>
Expand Down Expand Up @@ -179,6 +181,7 @@

<p class="row-actions"><a href="<?php echo suptic_admin_url( 'edit-tickets.php', array( 'ticket_id' => $ticket->id ) ); ?>"><?php echo esc_html( __( 'Edit', 'suptic' ) ); ?></a></p>
</td>
<td><?php echo esc_html( $ticket->id ); ?></td>
<td><?php echo esc_html( $ticket->author_name() ); ?></td>
<td><?php echo esc_html( $ticket->message_count() ); ?></td>
<td><?php $form = $ticket->form();
Expand Down

0 comments on commit c7dd5c0

Please sign in to comment.