diff --git a/include/appData.php b/include/appData.php index 4cfeda7..b09a053 100644 --- a/include/appData.php +++ b/include/appData.php @@ -488,8 +488,7 @@ class appData } } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oVersion = new Version($this->iVersionId); @@ -504,11 +503,7 @@ class appData $oApp->objectMakeLink(), $this->iVersionId ? $oVersion->objectMakeLink() : "N/A"); - if(appData::canEdit($oObject->sClass)) - $aCells[] = "[ makeUrl("edit", - $this->iId)."\">$sEditLinkLabel ]"; - - echo html_tr($aCells, $sClass); + return array($aCells, null, false, null); } function objectDisplayQueueProcessingHelp() @@ -555,6 +550,11 @@ class appData " submitted application data here"; return $sReplyText; } + + function objectGetId() + { + return $this->iId; + } } ?> diff --git a/include/application.php b/include/application.php index 258df77..ca42ca7 100644 --- a/include/application.php +++ b/include/application.php @@ -849,7 +849,7 @@ class Application { return $aCells; } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oUser = new user($this->iSubmitterId); $oVendor = new vendor($this->iVendorId); @@ -864,14 +864,7 @@ class Application { $sVendor, $this->sName); - /* Display an edit link if the user has proper permissions */ - if($this->canEdit()) - { - $aCells[] = "[ makeUrl("edit", $this->iAppId, - "Edit Application")."\">$sEditLinkLabel ]"; - } - - echo html_tr($aCells, $sClass); + return array($aCells, null, false, null); } function canEdit() @@ -1002,6 +995,11 @@ class Application { { return FALSE; } + + function objectGetId() + { + return $this->iAppId; + } } function get_vendor_from_keywords($sKeywords) diff --git a/include/application_queue.php b/include/application_queue.php index 802fa70..0dbe0d8 100644 --- a/include/application_queue.php +++ b/include/application_queue.php @@ -302,9 +302,9 @@ class application_queue return $this->oApp->objectGetHeader(); } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { - return $this->oApp->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel); + return $this->oApp->objectGetTableRow(); } function objectMoveChildren($iNewId) @@ -321,6 +321,11 @@ class application_queue { return application::allowAnonymousSubmissions(); } + + function objectGetId() + { + return $this->oApp->objectGetId(); + } } ?> diff --git a/include/distribution.php b/include/distribution.php index 7ba4ff2..d774dd9 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -67,7 +67,7 @@ class distribution { ORDER BY testedRating;"; } - if($hResult = query_parameters($sQuery, $iDistributionId)) + if($hResult = query_parameters($sQuery, $this->iDistributionId)) { while($oRow = mysql_fetch_object($hResult)) { @@ -453,32 +453,17 @@ class distribution { $iStart, $iRows); } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function objectOutputTableRow($oManager, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $aCells = array( - "makeUrl("view", $this->iDistributionId, - "View distribution")."\">$this->sName.", + $this->objectMakeLink(), "sUrl\">$this->sUrl", array(sizeof($this->aTestingIds), "align=\"right\"")); - // add actions if the current user has permission to edit this object - if($this->canEdit()) - { // enable the 'delete' action if this distribution has no testing results - if(!sizeof($this->aTestingIds)) - { - $shDeleteLink = " [delete]"; - } + $bDeleteLink = sizeof($this->aTestingIds) ? FALSE : TRUE; - $aCells[] = array( - "[$sEditLinkLabel]$shDeleteLink", - "align=\"center\""); - } - - echo html_tr($aCells, $sClass); + return array($aCells, null, $bDeleteLink, null); } // Whether the user has permission to edit distributions diff --git a/include/downloadurl.php b/include/downloadurl.php index 6447ee4..4c0a3d5 100644 --- a/include/downloadurl.php +++ b/include/downloadurl.php @@ -405,11 +405,10 @@ class downloadurl return appData::objectGetHeader("downloadurl"); } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oAppData = new AppData(); - $oAppData->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel); + return $oAppData->objectGetTableRow(); } function getOutputEditorValues($aClean) @@ -446,6 +445,11 @@ class downloadurl /* FIXME: not implemented */ return TRUE; } + + function objectGetId() + { + return $this->iId; + } } ?> diff --git a/include/maintainer.php b/include/maintainer.php index 247aad3..776a7e2 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -461,8 +461,7 @@ class maintainer return $aCells; } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function ObjectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function ObjectGetTableRow() { $oUser = new User($this->iUserId); $oApp = new Application($this->iAppId); @@ -475,12 +474,7 @@ class maintainer ($this->bSuperMaintainer) ? "Yes" : "No", $oUser->objectMakeLink()); - if(maintainer::canEdit()) - $aCells[sizeof($aCells)] = "[ makeUrl("edit", - $this->iMaintainerId)."\">$sEditLinkLabel ]"; - - echo html_tr($aCells, - $sClass); + return array($aCells, null, false, null); } function ObjectDisplayQueueProcessingHelp() diff --git a/include/objectManager.php b/include/objectManager.php index 5246098..f89ba39 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -11,6 +11,7 @@ class ObjectManager var $iId; var $bIsRejected; var $oMultiPage; + var $oTableRow; function ObjectManager($sClass, $sTitle = "list", $iId = false) { @@ -18,6 +19,7 @@ class ObjectManager $this->sTitle = $sTitle; $this->iId = $iId; $this->oMultiPage = new MultiPage(FALSE); + $this->oTableRow = new TableRow(null); } /* Check whether the associated class has the given method */ @@ -59,7 +61,7 @@ class ObjectManager function display_table($aClean) { $this->checkMethods(array("ObjectGetEntries", "ObjectGetHeader", - "ObjectOutputTableRow", "canEdit")); + "objectGetTableRow", "objectGetId", "canEdit")); $oObject = new $this->sClass(); @@ -110,9 +112,28 @@ class ObjectManager { $oObject = new $this->sClass(null, $oRow); - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - $oObject->objectOutputTableRow($this, ($iCount % 2) ? "color0" : "color1", - $this->bIsQueue ? "process" : "edit"); + $this->oTableRow->TableRow($oObject->objectGetTableRow()); + + if(!$this->oTableRow->sStyle) + $this->oTableRow->sStyle = ($iCount % 2) ? "color0" : "color1"; + + $sEditLinkLabel = $this->bIsQueue ? "process" : "edit"; + + /* We add some action links */ + if($oObject->canEdit()) + { + $shDeleteLink = ""; + if($this->oTableRow->bDeleteLink) + { + $shDeleteLink = ' [ objectGetid()). + '">delete ]'; + } + + $this->oTableRow->aCells[] = '[ objectGetId()).'">'.$sEditLinkLabel.' ]'.$shDeleteLink; + } + + echo html_tr($this->oTableRow->aCells, $this->oTableRow->sStyle); } echo ""; @@ -640,4 +661,33 @@ class MultiPage } } +class TableRow +{ + var $aCells; + var $sStyle; + var $sEditLinkLabel; + var $bDeleteLink; + var $aRowClickable; + var $bCanEdit; + var $iId; + + function TableRow($aInput) + { + if(!$aInput) + return; + + /* aInput is returned from objectGetTableRow(); an array with the following members + 0: an array with the contents of the table row + 1: CSS style to be used. If it is null we use the default + 2: Is TRUE if we should display a delete link with the edit link + 3: Contains an array with info if we should make the entrie table row clickable, + null otherwise */ + + $this->aCells = $aInput[0]; + $this->sStyle = $aInput[1]; + $this->bDeleteLink = $aInput[2]; + $this->aRowClickable = $aInput[3]; + } +} + ?> diff --git a/include/screenshot.php b/include/screenshot.php index 31074fb..cb62ee8 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -559,11 +559,10 @@ class Screenshot { return appData::mustBeQueued(); } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oAppData = new AppData($this->iScreenshotId, null, $this); - $oAppData->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel); + return $oAppData->objectGetTableRow(); } function objectDisplayQueueProcessingHelp() @@ -646,6 +645,11 @@ class Screenshot { { return FALSE; } + + function objectGetId() + { + return $this->iScreenshotId; + } } ?> diff --git a/include/testData.php b/include/testData.php index 8cc4593..18b1462 100644 --- a/include/testData.php +++ b/include/testData.php @@ -939,13 +939,12 @@ class testData{ return $aCells; } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oVersion = new version($this->iVersionId); $oApp = new application($oVersion->iAppId); $oUser = new user($this->iSubmitterId); - // $hMaintainers = maintainer::getMaintainersForAppIdVersionId(null, $this->iVersionId); $bHasMaintainer = (mysql_num_rows($hMaintainers) == 0) ? false : true; @@ -958,18 +957,7 @@ class testData{ ($bHasMaintainer ? "YES" : "no"), $this->sTestedRating); - if($this->canEdit() or $this->sQueued == "rejected") - { - $shDeleteLink = "[ makeUrl("delete", - $this->iTestingId). - "\"> delete ]"; - - $aCells[] = "[ makeUrl("edit", - $this->iTestingId)."\">$sEditLinkLabel ]". - $shDeleteLink; - } - - echo html_tr($aCells, $this->sTestedRating); + return array($aCells, $this->sTestedRating, true, null); } function canEdit() @@ -1068,6 +1056,11 @@ class testData{ $iDefaultPerPage = 25; return array($aItemsPerPage, $iDefaultPerPage); } + + function objectGetId() + { + return $this->iTestingId; + } } ?> diff --git a/include/testData_queue.php b/include/testData_queue.php index 014513a..0c116f9 100644 --- a/include/testData_queue.php +++ b/include/testData_queue.php @@ -137,36 +137,30 @@ class testData_queue return $this->oTestData->objectGetHeader(); } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { - return $this->oTestData->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel); + return $this->oTestData->objectGetTableRow(); } function objectDisplayQueueProcessingHelp() { $oTest = new testData(); - echo "
"; - if($oTest->canEdit) - echo "This is the list of rejected test results, waiting to be resubmitted or deleted."; - else - echo "This is the list of your rejected test results. Here you can make changes to ". - "them and resubmit them into the database."; - echo "
\n"; + $oTest->objectDisplayQueueProcessingHelp(); } function display() { - return $this->oTest->display(); + return $this->oTestData->display(); } function objectMakeUrl() { - return $this->oTest->objectMakeUrl(); + return $this->oTestData->objectMakeUrl(); } function objectMakeLink() { - return $this->oTest->objectMakeLink(); + return $this->oTestData->objectMakeLink(); } function allowAnonymousSubmissions() @@ -178,6 +172,11 @@ class testData_queue { return testData::objectGetItemsPerPage($bQueued); } + + function objectGetId() + { + return $this->oTestData->objectGetId(); + } } ?> diff --git a/include/vendor.php b/include/vendor.php index c87fda6..95f7367 100644 --- a/include/vendor.php +++ b/include/vendor.php @@ -222,27 +222,16 @@ class Vendor { return $aCells; } - /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */ - function objectOutputTableRow($oObject, $sClass = "", $sEditLinkLabel) + function objectGetTableRow() { $aCells = array( - "makeUrl("view", $this->iVendorId, - "View Vendor")."\">$this->sName", + $this->objectMakeLink(), "sWebpage\">$this->sWebpage", array(sizeof($this->aApplicationsIds), "align=\"right\"")); - if($this->canEdit()) - { - if(!sizeof($this->aApplicationsIds)) - $shDeleteLink = " [makeUrl("delete", - $this->iVendorId, "View Vendors")."\">". - "delete]"; + $bDeleteLink = sizeof($this->aApplicationsIds) ? FALSE : TRUE; - $aCells[sizeof($aCells)] = "[makeUrl("edit", - $this->iVendorId, "Edit Vendor")."\">$sEditLinkLabel]$shDeleteLink"; - } - - echo html_tr($aCells, $sClass); + return array($aCells, null, $bDeleteLink, null); } function canEdit() diff --git a/include/version.php b/include/version.php index 9634c99..9595c6b 100644 --- a/include/version.php +++ b/include/version.php @@ -1340,7 +1340,7 @@ class Version { return $hResult; } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { $oUser = new user($this->iSubmitterId); $oApp = new application($this->iAppId); @@ -1352,13 +1352,7 @@ class Version { $oApp->objectMakeLink(), $this->sName); - if($this->canEdit()) - { - $aCells[] = "[ makeUrl("edit", - $this->iVersionId)."\">$sEditLinkLabel ]"; - } - - echo html_tr($aCells, $sClass); + return array($aCells, null, false, null); } function objectDisplayQueueProcessingHelp() @@ -1416,6 +1410,11 @@ class Version { { return FALSE; } + + function objectGetId() + { + return $this->iVersionId; + } } ?> diff --git a/include/version_queue.php b/include/version_queue.php index 33f94b6..4b3350a 100644 --- a/include/version_queue.php +++ b/include/version_queue.php @@ -166,9 +166,9 @@ class version_queue return $this->oVersion->objectGetHeader(); } - function objectOutputTableRow($oObject, $sClass, $sEditLinkLabel) + function objectGetTableRow() { - return $this->oVersion->objectOutputTableRow($oObject, $sClass, $sEditLinkLabel); + return $this->oVersion->objectGetTableRow(); } function display() @@ -247,6 +247,11 @@ class version_queue { return version::allowAnonymousSubmissions(); } + + function objectGetId() + { + return $this->oVersion->objectGetId(); + } } ?> diff --git a/unit_test/test_om_objects.php b/unit_test/test_om_objects.php index 6a031a0..227900b 100644 --- a/unit_test/test_om_objects.php +++ b/unit_test/test_om_objects.php @@ -227,7 +227,8 @@ function test_object_methods() "getOutputEditorValues", "objectGetEntries", "objectGetHeader", - "objectOutputTableRow", + "objectGetId", + "objectGetTableRow", "objectMakeLink", "objectMakeUrl", "outputEditor",