diff --git a/include/appData.php b/include/appData.php index a310ad9..70a038e 100644 --- a/include/appData.php +++ b/include/appData.php @@ -199,7 +199,7 @@ class appData } - function objectOutputHeader($sClass, $sType) + function objectGetHeader($sType) { $aCells = array( "Submission Date", @@ -207,10 +207,7 @@ class appData "Application", "Version"); - if(appData::canEdit($sType)) - $aCells[] = "Action"; - - echo html_tr($aCells, $sClass); + return $aCells; } function objectGetEntries($bQueued, $iRows = 0, $iStart = 0, $sType) diff --git a/include/distribution.php b/include/distribution.php index 6231865..73fbbaa 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -400,17 +400,14 @@ class distribution { echo "\n"; } - function objectOutputHeader($sClass = "") + function objectGetHeader() { $aCells = array( "Distribution name", "Distribution url", array("Linked Tests", "align=\"right\"")); - if(distribution::canEdit()) - $aCells[3] = array("Action", "align=\"center\""); - - echo html_tr($aCells, $sClass); + return $aCells; } function objectGetEntries($bQueued, $iRows = 0, $iStart = 0) diff --git a/include/maintainer.php b/include/maintainer.php index 0dab56c..37a722b 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -409,7 +409,7 @@ class maintainer return $aUserIds; } - function ObjectOutputHeader($sClass) + function ObjectGetHeader() { $aCells = array( "Submission Date", @@ -418,10 +418,7 @@ class maintainer "Super maintainer?", "Submitter"); - if(maintainer::canEdit()) - $aCells[sizeof($aCells)] = "Action"; - - echo html_tr($aCells, $sClass); + return $aCells; } /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ diff --git a/include/objectManager.php b/include/objectManager.php index eaffeca..2f00a59 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -55,7 +55,7 @@ class ObjectManager /* displays the list of entries */ function display_table() { - $this->checkMethods(array("ObjectGetEntries", "ObjectOutputHeader", + $this->checkMethods(array("ObjectGetEntries", "ObjectGetHeader", "ObjectGetInstanceFromRow", "ObjectOutputTableRow", "canEdit")); @@ -85,9 +85,8 @@ class ObjectManager /* output the header */ echo ''; - call_user_func(array($this->sClass, - "objectOutputHeader"), "color4"); - + /* Output header cells */ + $this->outputHeader("color4"); /* output each entry */ for($iCount = 0; $oRow = mysql_fetch_object($hResult); $iCount++) @@ -324,6 +323,20 @@ class ObjectManager $sId = "i".ucfirst($this->sClass)."Id"; return $aClean[$sId]; } + + /* Output headers for a table */ + function outputHeader($sClass) + { + $oObject = new $this->sClass(); + $aCells = $oObject->objectGetHeader(); + + /* Add an action column if the user can edit this class, or if it is a queue. + Even though a user annot process items, he can edit his queued submissions */ + if($oObject->canEdit() || $this->bIsQueue) + $aCells[] = "Action"; + + echo html_tr($aCells, $sClass); + } } ?> diff --git a/include/screenshot.php b/include/screenshot.php index 781f7cd..6a5137e 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -518,9 +518,9 @@ class Screenshot { return appData::objectGetEntries($bQueued, $iRows, $iStart, "screenshot"); } - function objectOutputHeader($sClass) + function objectGetHeader() { - return appData::objectOutputHeader($sClass, "screenshot"); + return appData::objectGetHeader("screenshot"); } function canEdit() diff --git a/include/vendor.php b/include/vendor.php index eac9d36..e848cf2 100644 --- a/include/vendor.php +++ b/include/vendor.php @@ -167,17 +167,14 @@ class Vendor { return $hResult; } - function objectOutputHeader($sClass = "") + function objectGetHeader() { - $sCells = array( + $aCells = array( "Name", "Website", array("Linked apps", "align=\"right\"")); - if(vendor::canEdit()) - $sCells[sizeof($sCells)] = "Action"; - - echo html_tr($sCells, $sClass); + return $aCells; } function objectGetInstanceFromRow($oRow) diff --git a/unit_test/test_om_objects.php b/unit_test/test_om_objects.php index 744a0e9..d95938a 100644 --- a/unit_test/test_om_objects.php +++ b/unit_test/test_om_objects.php @@ -143,7 +143,7 @@ function test_object_methods() echo "PASSED:\t\t".$sClassName."\n"; }*/ - $aTestMethods = array("objectOutputHeader", "objectOutputTableRow", + $aTestMethods = array("objectGetHeader", "objectOutputTableRow", "objectGetEntries", "display", "objectGetInstanceFromRow", "outputEditor", "canEdit", "getOutputEditorValues", "objectMakeUrl", "objectMakeLink");