Well, this is a little hackish, but should get the job done. It could be done more gracefully with CRON, however I cannot access this on my current server, and hence cannot test to see if it would work...
Add 'pending' to the status field in mysql database using
ALTER TABLE ost_ticket MODIFY status enum('open', 'closed', 'pending')
Open scp/login.php
Find:
session_write_close();
session_regenerate_id();
Add immediately below it:
// define OSTSCPINC to make includes happy - this does happen later, but needs to happen before preLogin.php
define("OSTSCPINC",TRUE); //Make includes happy!
// do tasks prior to redirecting
include_once(INCLUDE_DIR.'staff/preLogin.php');
New file named include/staff/preLogin.php with:
<?php
if(!defined('OSTSCPINC') || !is_object($thisuser)) { die('Kwaheri'); }
// run script to mark pending tickets older than "X days" as closed
include_once(INCLUDE_DIR.'staff/autoClose.php');
?>
New file named include/staff/autoClose.php with:
<?php
if(!defined('OSTSCPINC') || !is_object($thisuser)) die('Kwaheri.');
include_once(INCLUDE_DIR.'class.ticket.php');
// select all tickets marked as 'pending' where updated is older than 5 days ago
$sql = "SELECT ticket_id FROM " . TICKET_TABLE;
$sql .= " WHERE status = 'pending'";
$sql .= " AND updated <= '" . date("Y-m-d", strtotime('-5 days')) . " 00'";
$old_pending_tickets = db_query($sql) or die("Query Error: " . mysql_error());
// for each record, mark as closed
while ($pendingTicket = mysql_fetch_array($old_pending_tickets)) {
$ticket = new Ticket(2);
$ticket->close();
}
?>
It would be possible to put the code from autoClose.php directly into login.php, but I think this will make it easier to troubleshoot errors - easier for me anyway!! ;)
strtotime('-5 days') is where you define how many days the ticket will sit at 'pending'.
Now find in scp/tickets.php
$nav->addSubMenu(array('desc'=>'Closed Tickets','title'=>'Closed Tickets', 'href'=>'tickets.php?status=closed', 'iconclass'=>'closedTickets'));
and below it add
$nav->addSubMenu(array('desc'=>'Pending Tickets','title'=>'Pending Tickets', 'href'=>'tickets.php?status=pending', 'iconclass'=>'closedTickets'));
This will give you a 'Pending Tickets" button on the admin screen. The bad news is I can't get any pending tickets to show up... Might need some more experienced help with this!!
I have changed tickets.php:
//$statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed'); $statusKeys=array('open'=>'Open','Reopen'=>'Open','Close'=>'Closed','pending'=>'pending');
Now open include/staff/tickets.inc.php, and find:
$status=null;
switch(strtolower($_REQUEST)){ //Status is overloaded
case 'open':
$status='open';
break;
Add case 'pending':
$status='pending';
break;
Now you are done, and you should be able to view a list of pending tickets!!