blob: 374495ff1e9d64e52dcd7b1711a72525edddb41c [file] [log] [blame]
<?php
class ReviewInfo {
var $_attributes;
/*
* J2 - review scheduled date & time
* J3 - review slides posted
* J4 - review slides & IP posted
* J5 - review successful
* J6 - review not complete, further work to occur
*/
var $_status;
var $_lastdate;
function load( $firstbuffer, $file ) {
$this->_attributes = Array();
$pos = strpos($firstbuffer, ": ");
$key = substr($firstbuffer, 0, $pos);
$value = substr($firstbuffer, $pos+2);
$value = trim($value);
$this->_attributes[$key] = $value;
if( trim($value) == "" ) {
$this->_status = "bogus";
return;
}
while(!feof($file)){
$buffer = fgets($file);
$buffer = substr($buffer,0,-1); // Remove new line char
if (!strlen(trim($buffer)))
break;
$pos = strpos($buffer, ": ");
$key = substr($buffer, 0, $pos);
$value = substr($buffer, $pos+2);
$this->_attributes[$key] = $value;
}
if( $this->get("Status; Review Scheduled") != "" ) {
$this->_status = "J2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Slides Posted") != "" ) {
$this->_status = "J3";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; IP Log Posted") != "" ) {
$this->_status = "J4";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Successful") != "" ) {
$this->_status = "J5";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Unsuccessful") != "" ) {
$this->_status = "J6";
$this->_lastdate = $this->_lastget;
}
}
function lastdate() {
return $this->_lastdate;
}
function get($key) {
if( !array_key_exists($key, $this->_attributes) ) {
$this->_lastget = "";
return "";
}
$value = $this->_attributes[$key];
if( $value == null ) return "";
$value = trim($value);
$this->_lastget = $value;
return $value;
}
function status() {
return $this->_status;
}
function name() {
return $this->get("Project Name");
}
function is_more_than_one_quarter_old() {
$today = getdate();
$then = numerical_date($this->_lastdate);
$today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]);
return ($then + 110) < $today;
}
}
class ProposalInfo {
var $_attributes;
/*
* P1 - proposal posted
* P2 - proposal updated
* P3 - review scheduled date & time
* P4 - review slides posted
* PP - review completed, waiting for PMC
* P5 - review successful, awaiting provisioning
* P6 - review not complete, further work required
* P7 - project completed
* P8 - proposal withdrawn
* P9 - proposal archived
*/
var $_status;
var $_lastdate;
var $_lastget;
function load( $firstbuffer, $file ) {
$this->_attributes = Array();
$pos = strpos($firstbuffer, ": ");
$key = substr($firstbuffer, 0, $pos);
$value = substr($firstbuffer, $pos+2);
$value = trim($value);
$this->_attributes[$key] = $value;
if( $value == "" ) {
$this->_status = "bogus";
return;
}
while(!feof($file)){
$buffer = fgets($file);
$buffer = substr($buffer,0,-1); // Remove new line char
if (!strlen(trim($buffer)))
break;
$pos = strpos($buffer, ": ");
$key = substr($buffer, 0, $pos);
$value = substr($buffer, $pos+2);
$this->_attributes[$key] = $value;
}
if( $this->get("Status; Proposal Posted") != "" ) {
$this->_status = "P1";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 1") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 2") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 3") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 4") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 5") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 6") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 7") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 8") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Updated 9") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Scheduled") != "" ) {
$this->_status = "P3";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Slides Posted") != "" ) {
$this->_status = "P4";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Pending") != "" ) {
$this->_status = "PP";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Unsuccessful") != "" ) {
$this->_status = "P6";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Review Successful") != "" ) {
$this->_status = "P5";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Provisioning Complete") != "" ) {
$this->_status = "P7";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Proposal Withdrawn") != "" ) {
$this->_status = "P8";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Status; Project Archived") != "" ) {
$this->_status = "P9";
$this->_lastdate = $this->_lastget;
}
}
function lastdate() {
return $this->_lastdate;
}
function get($key) {
if( !array_key_exists($key, $this->_attributes) ) {
$this->_lastget = "";
return "";
}
$value = $this->_attributes[$key];
if( $value == null ) return "";
$value = trim($value);
$this->_lastget = $value;
return $value;
}
function status() {
return $this->_status;
}
function name() {
return $this->get("Proposal Name");
}
function is_more_than_one_quarter_old() {
$today = getdate();
$then = numerical_date($this->_lastdate);
$today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]);
return ($then + 110) < $today;
}
function is_more_than_two_months_old() {
$today = getdate();
$then = numerical_date($this->_lastdate);
$today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]);
return ($then + 60) < $today;
}
function is_more_than_one_month_old() {
$today = getdate();
$then = numerical_date($this->_lastdate);
$today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]);
return ($then + 30) < $today;
}
function is_more_than_two_weeks_old() {
$today = getdate();
$then = numerical_date($this->_lastdate);
$today = (($today["year"] - 2000) * 365) + ($today["mon"] * 31) + ($today["mday"]);
return ($then + 15) < $today;
}
}
class AllInfo {
var $_reviews;
var $_proposals;
function load() {
$this->_reviews = Array();
$this->_proposals = Array();
$path = $_SERVER['DOCUMENT_ROOT'];
if( $path == "" ) {
$path = "../projects.txt";
} else {
$path = $_SERVER['DOCUMENT_ROOT'] . "/projects/projects.txt";
}
$file = fopen($path,"r");
if (!$file){
print "Could not open file";
exit();
}
while(!feof($file)){
$buffer = fgets($file);
$buffer = substr($buffer,0,-1); // Remove new line char
if( substr($buffer, 0, 14) == "Proposal Name:" ) {
$temp = new ProposalInfo();
$temp->load($buffer,$file);
if( $temp->status() != "bogus" )
array_push( $this->_proposals, $temp);
}
if( substr($buffer, 0, 13) == "Project Name:" ) {
$temp = new ReviewInfo();
$temp->load($buffer,$file);
if( $temp->status() != "bogus" )
array_push( $this->_reviews, $temp);
}
}
fclose($file);
usort( $this->_proposals, "cmp_proposals");
}
}
function cmp_proposals($a, $b) {
if( $a == $b ) return 0;
if( $a->name() == $b->name() ) return 0;
if( $a->name() < $b->name() ) return -1;
return 1;
}
function numerical_date($s) {
$sday = substr($s, 0, 3);
$s = substr($s, 5);
list($day, $smonth, $year, $hour, $minute, $second) = sscanf($s, "%d %s %d %d:%d:%d");
$months = array( "Jan" => 1, "Feb" => 2, "Mar" => 3,
"Apr" => 4, "May" => 5, "Jun" => 6,
"Jul" => 7, "Aug" => 8, "Sep" => 9,
"Oct" => 10, "Nov" => 11, "Dec" => 12 );
$month = $months[$smonth];
return (($year - 2000) * 365) + ($month * 31) + ($day);
}
function time_and_date_url( $date, $time ) {
$hour = substr( $time, 0, 2 );
$min = substr( $time, 2, 2 );
$s = substr($date, 5);
list($day, $smonth, $year) = sscanf($s, "%d %s %d");
$months = array( "Jan" => 1, "Feb" => 2, "Mar" => 3,
"Apr" => 4, "May" => 5, "Jun" => 6,
"Jul" => 7, "Aug" => 8, "Sep" => 9,
"Oct" => 10, "Nov" => 11, "Dec" => 12 );
$month = $months[$smonth];
return "http://www.timeanddate.com/worldclock/fixedtime.html?month=" . $month . "&day=" . $day . "&year=" . $year . "&hour=" . $hour . "&min=" . $min . "&sec=0&p1=0";
}
?>