blob: fd9c723bd4093009cb3ac0097fd8e76fb56b19b4 [file] [log] [blame]
<?php
/* AUTHOR: Bjorn Freeman-Benson
* HISTORY: 2009-03-03 Karl Matthias
* Updated to use new DB system instead of projects.txt.
* Removed all the date math functions in favor of strtotime-based calculations that work on DB date strings.
*/
global $App;
class ReviewInfo {
var $_attributes;
/*
* J1 - IP log review requested
* J2 - review scheduled date & time
* J3 - review slides & bug posted
* J4 - review slides & bug & IP posted
* JP - review pending, waiting for legal or the Board
* J5 - review successful
* J6 - review not complete, further work to occur
* J7 - review withdrawn
*/
var $_status;
var $_lastdate;
var $_reviewdate;
function load($row) {
global $App;
$this->_attributes = $row;
$result = $App->foundation_sql("
SELECT * FROM ProjectReviewStatus
WHERE ID = '" . $this->_attributes['ID'] . "'
");
while($row = mysql_fetch_object($result)) {
$this->_attributes[$row->Status] = $row->Value;
}
if( $this->get("Legal Review Requested") != "" ) {
$this->_status = "J1";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Review Scheduled") != "" ) {
$this->_status = "J2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Slides Posted") != "" ) {
$this->_status = "J3";
$this->_lastdate = $this->_lastget;
}
if( $this->get("IP Log Posted") != "" ) {
$this->_status = "J4";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Review Pending") != "" ) {
$this->_status = "JP";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Review Successful") != "" ) {
$this->_status = "J5";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Review Unsuccessful") != "" ) {
$this->_status = "J6";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Review Withdrawn") != "" ) {
$this->_status = "J7";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
}
function lastdate() {
$date = strtotime($this->_lastdate);
return date('r', $date);
}
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("ProjectName");
}
function is_more_than_one_quarter_old() {
$today = time();
$then = strtotime($this->_lastdate);
return ($then + (110 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function review_is_more_than_one_month_old() {
$today = time();
$then = strtotime($this->_reviewdate);
return ($then + (31 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
}
class ProposalInfo {
var $_attributes;
/*
* P1 - proposal posted
* P2 - proposal updated
* P3 - review scheduled date & time
* P4 - review slides & bug posted
* PP - review completed, waiting for PMC or Board
* P5 - review successful, awaiting provisioning
* PW - review successful, awaiting webmaster to provision
* P6 - review not complete, further work required
* P7 - project completed
* P8 - proposal withdrawn
* P9 - proposal archived
*/
var $_status;
var $_lastdate;
var $_lastget;
var $_reviewdate;
function load($row) {
global $App;
$this->_attributes = $row;
$result = $App->foundation_sql("
SELECT * FROM ProjectReviewStatus
WHERE ID = '" . $this->_attributes['ID'] . "'
");
while($row = mysql_fetch_object($result)) {
$this->_attributes[$row->Status] = $row->Value;
}
if( $this->get("Proposal Posted") != "" ) {
$this->_status = "P1";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 1") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 2") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 3") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 4") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 5") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 6") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 7") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 8") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Updated 9") != "" ) {
$this->_status = "P2";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Review Scheduled") != "" ) {
$this->_status = "P3";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Slides Posted") != "" ) {
$this->_status = "P4";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Review Pending") != "" ) {
$this->_status = "PP";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Review Unsuccessful") != "" ) {
$this->_status = "P6";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Review Successful") != "" ) {
$this->_status = "P5";
$this->_lastdate = $this->_lastget;
if( $this->_reviewdate == "" ) $this->_reviewdate = $this->_lastget;
}
if( $this->get("Waiting Provisioning") != "" ) {
$this->_status = "PW";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Provisioning Complete") != "" ) {
$this->_status = "P7";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Proposal Withdrawn") != "" ) {
$this->_status = "P8";
$this->_lastdate = $this->_lastget;
}
if( $this->get("Project Archived") != "" ) {
$this->_status = "P9";
$this->_lastdate = $this->_lastget;
}
}
function lastdate() {
$date = strtotime($this->_lastdate);
return date('r-', $date);
}
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("ProposalName");
}
function is_more_than_one_quarter_old() {
$today = time();
$then = strtotime($this->_lastdate);
return ($then + (110 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function is_more_than_one_month_old() {
$today = time();
$then = strtotime($this->_lastdate);
return ($then + (31 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function is_more_than_two_months_old() {
$today = time();
$then = strtotime($this->_lastdate);
return ($then + (60 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function is_more_than_two_weeks_old() {
$today = time();
$then = strtotime($this->_lastdate);
return ($then + (15 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function review_is_more_than_one_month_old() {
if( $this->_reviewdate == "" ) return false;
$today = time();
$then = strtotime($this->_reviewdate);
return ($then + (31 /* days */ * 24 /* hours */ * 60 /* minutes */ * 60 /* seconds */ )) < $today;
}
function proposal_age() {
date_default_timezone_set('UTC');
$tm_then = strtotime($this->get("Proposal Posted"));
$tm_now = time();
$seconds = $tm_now - $tm_then;
$minutes = round($seconds/60); if ($minutes < 2) return "$seconds seconds";
$hours = round($minutes/60.5); if ($hours < 2) return "$minutes minutes";
$days = round($hours/24); if ($days < 2) return "$hours hours";
$weeks = round($days/7); if ($weeks < 2) return "$days days";
$months = round($days/30.5); if ($months < 2) return "$weeks weeks";
$years = round($days/365.5); if ($years < 2) return "$months months";
$decades = round($years/10); if ($decades < 2) return "$years years";
return "$decades decades";
}
}
class AllInfo {
var $_reviews;
var $_proposals;
function load($sort="") {
global $App;
switch ($sort) {
case "Date":
$sort = "ReviewDate DESC";
break;
default:
$sort = "ProposalName, ProjectName";
break;
}
$this->_reviews = Array();
$this->_proposals = Array();
$path = $_SERVER['DOCUMENT_ROOT'];
if( $path == "" ) {
$path = "../projects.txt";
} else {
$path = getcwd() . "/projects.txt";
}
$result = $App->foundation_sql("SELECT * FROM ProjectReviews ORDER BY $sort");
while($row = mysql_fetch_assoc($result)) {
if($row["ProposalName"] != '') {
$temp = new ProposalInfo();
$i = $temp->load($row);
if($temp->status() != "bogus") {
array_push( $this->_proposals, $temp);
}
}
if($row["ProjectName"] != '') {
$temp = new ReviewInfo();
$i = $temp->load($row);
if($temp->status() != "bogus") {
array_push( $this->_reviews, $temp);
}
}
}
}
}
function time_and_date_url($wdate) {
$wdate = strtotime($wdate);
$date = date("D, j M Y", $wdate);
$hour = date('H', $wdate);
$min = date('i', $wdate);
list($day, $smonth, $year) = sscanf(date('j M Y', $wdate), "%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";
}
?>