objectManager: Fix lower-case letter in 'email Text'
[NewAppDB.git] / include / maintainerView.php
blobdf8591b81ad931528305c94e712e20ca2979f92e
1 <?php
3 /**
4 * Class to show an overview of a user's maintainership, including apps maintained
5 * and their ratings
6 */
7 class maintainerView
9 var $iUserId;
10 var $bViewingSelf;
12 function maintainerView($iUserId = null)
14 if(!$iUserId)
15 $this->iUserId = $_SESSION['current']->iUserId;
16 else
17 $this->iUserId = $iUserId;
19 if(!$iUserId || $this->iUserId == $_SESSION['current']->iUserId)
20 $this->bViewingSelf = true;
21 else
22 $this->bViewingSelf = false;
25 function objectGetId()
27 return $this->iUserId;
30 function addVersionRatingInfo($oTableRow, $oVersion)
32 $oTableRow->AddTextCell($oVersion->objectMakeLink());
34 /* Rating info */
35 $oTableCell = new TableCell($oVersion->sTestedRating);
36 $oTableCell->SetClass($oVersion->sTestedRating);
37 $oTableRow->AddCell($oTableCell);
38 $oTableCell = new TableCell($oVersion->sTestedRelease);
39 $oTableCell->SetClass($oVersion->sTestedRating);
40 $oTableRow->AddCell($oTableCell);
42 /* Get test reports submitted by the user */
43 $aTestData = testData::getTestResultsForUser($this->iUserId,
44 $oVersion->iVersionId);
46 if(sizeof($aTestData))
48 $oTest = $aTestData[0];
49 $sUserRating = $oTest->sTestedRating;
50 $sUserRelease = $oTest->sTestedRelease;
51 } else
53 $sUserRating = '';
54 $sUserRelease = '';
57 $oTableCell = new TableCell($sUserRating);
58 $oTableCell->SetClass($sUserRating);
59 $oTableRow->AddCell($oTableCell);
60 $oTableCell = new TableCell($sUserRelease);
61 $oTableCell->SetClass($sUserRating);
62 $oTableRow->AddCell($oTableCell);
64 return $oTableRow;
67 /* Shows a detailed vis of the user's maintained applications,
68 including last tested release & rating */
69 function display()
71 $oUser = new user($this->iUserId);
73 $aMaintainedApps = maintainer::getAppsMaintained($oUser);
74 if(!$aMaintainedApps || !sizeof($aMaintainedApps))
76 if($this->bViewingSelf)
77 echo '<p>You do not maintain any apps</p>';
78 else
79 echo "<p>{$oUser->sRealname} does not maintain any apps</p>";
80 return;
83 if($this->bViewingSelf)
84 echo '<p>Viewing your maintained apps</p>';
85 else
86 echo "<p>Viewing {$oUser->sRealname}'s maintained apps</p>";
88 $oTable = new Table();
89 $oTableRow = new TableRow();
90 $oTableRow->setClass('color4');
91 $oTable->setCellSpacing(0);
92 $oTable->setCellPadding(3);
93 $oTableRow->AddTextCell('Application');
94 $oTableRow->AddTextCell('Version');
95 $oTableRow->AddTextCell('Current Rating');
96 $oTableRow->AddTextCell('Current Version');
97 $oTableRow->AddTextCell($this->bViewingSelf ? 'Your Rating' : "User's Rating");
98 $oTableRow->AddTextCell($this->bViewingSelf ? 'Your Version' : "User's Version");
99 $oTable->AddRow($oTableRow);
101 $i = 1;
102 while(list($iIndex, list($iAppId, $iVersionId, $bSuperMaintainer)) = each($aMaintainedApps))
104 $oApp = new application($iAppId);
105 $aVersions = array();
107 $oTableRow = new TableRow();
108 $oTableRow->AddTextCell($oApp->objectMakeLink());
110 $oTableRow->SetClass(($i % 2) ? 'color0' : 'color1');
111 $i++;
113 if($iVersionId)
115 $oVersion = new version($iVersionId);
116 $oTableRow = maintainerView::addVersionRatingInfo($oTableRow, $oVersion);
117 $oTable->AddRow($oTableRow);
118 } else
120 $aVersions = $oApp->getVersions(true);
121 $oTableRow->AddTextCell('*');
122 $oTableRow->AddTextCell('');
123 $oTableRow->AddTextCell('');
124 $oTableRow->AddTextCell('');
125 $oTableRow->AddTextCell('');
126 $oTable->AddRow($oTableRow);
129 foreach($aVersions as $oVersion)
131 $oTableRow = new TableRow($oTableRow);
132 $oTableRow->AddTextCell('');
133 $oTableRow = maintainerView::addVersionRatingInfo($oTableRow, $oVersion);
135 $oTableRow->SetClass(($i % 2) ? 'color0' : 'color1');
136 $i++;
138 $oTable->AddRow($oTableRow);
141 echo $oTable->GetString();