Difference between revisions of "Auto open stalled tickets after 14 days script"

From Request Tracker Wiki
Jump to navigation Jump to search
(Created page with "'''PHP Script for auto-opening Tickets that has been stalled X days (in this case 14):''' Requirements *Requesttracker (tested on 3.8) *PHP + mysql (tested on PHP5) *RT CLI <pre...")
 
m (2 revisions imported)
 
(One intermediate revision by the same user not shown)
Line 18: Line 18:
}
}
?></pre>
?></pre>
[[Category:automatic]]
[[Category:stalled tickets]]

Latest revision as of 15:03, 6 April 2016

PHP Script for auto-opening Tickets that has been stalled X days (in this case 14):

Requirements

  • Requesttracker (tested on 3.8)
  • PHP + mysql (tested on PHP5)
  • RT CLI
<?php

$link = mysql_connect("server", "username", "passwd") or die("cannot connect " . mysql_error());
mysql_select_db("rtdb") or die("seldb err: " . mysql_error());
$result = mysql_query("select id,Subject,LastUpdated,date(LastUpdated)-curdate() as diff From Tickets where Status='stalled' and date(LastUpdated)-curdate() < -14 order by LastUpdated;");

for ($i=0;$i < mysql_num_rows($result);$i++) {
$id=mysql_result($result,$i,"id");
system("RTUSER=user RTPASSWD=password rt comment -m 'Autoopening stalled ticket after 14 days.' " . $id);
system("RTUSER=user RTPASSWD=password rt edit " . $id . " set status='open'");
}
?>