number of days to take into account to raise warning # fromstat => Status that needs to be checked # tostat => Status to be set # muser => Userid from mantis (Integer) # sendmail => Should mantis noficiation take place # if not passed as parameter, default values 7,80,90,1,N are being used # # Call script like: http://www.YourMantisHome.com/automatic_status_update.php?days=7&fromstat=80&tostat=90&muser=1$sendmail='Y' # or like : http://www.YourMantisHome.com/automatic_status_update.php to use defaults # or like : http://www.YourMantisHome.com/automatic_status_update.php?sendmail='Y' to send mail and use other defaults # # Automatical scheduling # automatic_status_update.php can be used via cron like this: # */1440 * * * * lynx --dump http://mantis.homepage.com/automatic_status_update.php? # # or via command line interface # */1440 * * * * /usr/local/bin/php /path/to/mantis/automatic_status_update.php? # This line would update every day. # # You also can use a scheduled task under windows by calling a batch-file like: # REM *** this batch is running as a scheduled task under the ... Account *** # g: # cd \inetpub\wwwroot\mantis # php.exe automatic_status_update.php # # Created by Cas Nuy http://www.nuy.info # April 2009 # $reqVar = '_' . $_SERVER['REQUEST_METHOD']; $form_vars = $$reqVar; $parm1= $form_vars['days'] ; $parm2= $form_vars['fromstat'] ; $parm3= $form_vars['tostat'] ; $parm4= $form_vars['muser'] ; $parm5= $form_vars['sendmail'] ; if (!$parm1){ $t_days = 7; }else{ $t_days = $parm1; } if (!$parm2){ $t_fromstat = 80; }else{ $t_fromstat = $parm2; } if (!$parm3){ $t_tostat = 90; }else{ $t_tostat = $parm3; } if (!$parm4){ $muser = 1; }else{ $muser = $parm4; } if (!$parm5){ $sendmail = 'N'; }else{ $sendmail = $parm5; } require_once( 'core.php' ); $t_core_path = config_get( 'core_path' ); $t_bug_table = db_get_table( 'mantis_bug_table' ); $t_his_table = db_get_table( 'mantis_bug_history_table' ); $query1 ="select id from $t_bug_table where status=" ; $query1 .= $t_fromstat ; $result1 = db_query($query1); $num_records1 = db_num_rows( $result1 ); if ($num_records1 >0){ for( $i=0; $i < $num_records1; $i++ ) { $t_row = db_fetch_array( $result1 ); $val1=$t_row["id"] ; // now retrieve last date of from status $query2 = " select date_modified from $t_his_table where bug_id="; $query2 .= $val1; $query2 .= " and new_value = ".$t_fromstat; $query2 .=" AND field_name = 'status' order by date_modified"; $result2= db_query($query2); $t_row2 = db_fetch_array( $result2 ); $val2 = $t_row2["date_modified"] ; $val3 = round(strtotime($val2)/86400) ; $today = mktime(0, 0, 0, date("m") , date("d"), date("Y")); $val4 =round($today/86400); if (($val4-$val3)>$t_days){ // update status bug_set_field( $val1, 'status', $t_tostat ); // should we send an email if (strtoupper($sendmail)<>'N'){ email_close( $p_bug_id ); email_relationship_child_closed( $p_bug_id ); } } } } ?>