aTestResults = array(); // should always be an array // we are working on an existing version if(!$iVersionId && !$oRow) return; /* * We fetch the data related to this version. */ if(!$oRow) { $sQuery = "SELECT * FROM appVersion WHERE versionId = '?'"; if($hResult = query_parameters($sQuery, $iVersionId)) $oRow = query_fetch_object($hResult); } if($oRow) { $this->iVersionId = $oRow->versionId; $this->iAppId = $oRow->appId; $this->iSubmitterId = $oRow->submitterId; $this->sSubmitTime = $oRow->submitTime; $this->sName = $oRow->versionName; $this->sDescription = $oRow->description; $this->sTestedRelease = $oRow->ratingRelease; $this->sTestedRating = $oRow->rating; $this->sState = $oRow->state; $this->sLicense = $oRow->license; $this->iObsoleteBy = $oRow->obsoleteBy; } } /** * Creates a new version. */ public function create() { if(!$_SESSION['current']->canCreateVersion()) return; $oApp = new application($this->iAppId); if($oApp->objectGetState() != 'accepted') $this->sState = 'pending'; else $this->sState = $this->mustBeQueued() ? 'queued' : 'accepted'; $hResult = query_parameters("INSERT INTO appVersion (versionName, description, ratingRelease, rating, appId, submitTime, submitterId, state, license) VALUES ('?', '?', '?', '?', '?', ?, '?', '?', '?')", $this->sName, $this->sDescription, $this->sTestedRelease, $this->sTestedRating, $this->iAppId, "NOW()", $_SESSION['current']->iUserId, $this->sState, $this->sLicense); if($hResult) { $this->iVersionId = query_appdb_insert_id(); $this->Version($this->iVersionId); $this->SendNotificationMail(); /* Submit maintainer request if asked to */ switch($this->iMaintainerRequest) { case MAINTAINER_REQUEST; $oMaintainer = new Maintainer(); $oMaintainer->iAppId = $this->iAppId; $oMaintainer->iVersionId = $this->iVersionId; $oMaintainer->iUserId = $_SESSION['current']->iUserId; $oMaintainer->sMaintainReason = "This user submitted the version;". "auto-queued."; $oMaintainer->bSuperMaintainer = 0; $oMaintainer->create(); break; case MONITOR_REQUEST: $oMonitor = new Monitor(); $oMonitor->iVersionId = $this->iVersionId; $oMonitor->iUserId = $_SESSION['current']->iUserId; $oMonitor->iAppId = $this->iAppId; $oMonitor->create(); break; } return true; } else { addmsg("Error while creating a new version", "red"); return false; } } /** * Update version. */ public function update($bSilent=false) { $sWhatChanged = ""; if(!$_SESSION['current']->hasAppVersionModifyPermission($this)) return; $oVersion = new Version($this->iVersionId); if ($this->sName && ($this->sName!=$oVersion->sName)) { if (!query_parameters("UPDATE appVersion SET versionName = '?' WHERE versionId = '?'", $this->sName, $this->iVersionId)) return false; $sWhatChanged .= "Name was changed from:\n\t'".$oVersion->sName."'\nto:\n\t'".$this->sName."'\n\n"; } if ($this->sDescription && ($this->sDescription!=$oVersion->sDescription)) { if (!query_parameters("UPDATE appVersion SET description = '?' WHERE versionId = '?'", $this->sDescription, $this->iVersionId)) return false; if($oVersion->sDescription != "") $sWhatChanged .= "Description was changed from\n ".$oVersion->sDescription."\n to \n".$this->sDescription.".\n\n"; else $sWhatChanged .= "Description was changed to \n".$this->sDescription.".\n\n"; } if ($this->sTestedRelease && ($this->sTestedRelease!=$oVersion->sTestedRelease)) { if (!query_parameters("UPDATE appVersion SET ratingRelease = '?' WHERE versionId = '?'", $this->sTestedRelease, $this->iVersionId)) return false; if($oVersion->sTestedRelease != "") $sWhatChanged .= "Last tested release was changed from ".$oVersion->sTestedRelease." to ".$this->sTestedRelease.".\n\n"; else $sWhatChanged .= "Last tested release was changed to ".$this->sTestedRelease.".\n\n"; } if ($this->sTestedRating && ($this->sTestedRating!=$oVersion->sTestedRating)) { if (!query_parameters("UPDATE appVersion SET rating = '?' WHERE versionId = '?'", $this->sTestedRating, $this->iVersionId)) return false; if($this->sTestedRating != "") $sWhatChanged .= "Rating was changed from ".$oVersion->sTestedRating." to ".$this->sTestedRating.".\n\n"; else $sWhatChanged .= "Rating was changed to ".$this->sTestedRating.".\n\n"; } if ($this->iAppId && ($this->iAppId!=$oVersion->iAppId)) { $oAppBefore = new Application($oVersion->iAppId); $oAppAfter = new Application($this->iAppId); if($oAppAfter->objectGetState() == 'accepted' && $this->sState == 'pending') $this->sState = 'queued'; if (!query_parameters("UPDATE appVersion SET appId = '?', state = '?' WHERE versionId = '?'", $this->iAppId, $this->sState, $this->iVersionId)) return false; $sWhatChanged .= "Version was moved from application ".$oAppBefore->sName." to application ".$oAppAfter->sName.".\n\n"; } if ($this->sLicense && ($this->sLicense!=$oVersion->sLicense)) { if(!query_parameters("UPDATE appVersion SET license = '?' WHERE versionId = '?'", $this->sLicense, $this->iVersionId)) return FALSE; $sWhatChanged .= "License was changed from $oVersion->sLicense to ". "$this->sLicense.\n\n"; } if($this->iObsoleteBy != $oVersion->iObsoleteBy) { if(!query_parameters("UPDATE appVersion SET obsoleteBy = '?' WHERE versionId = '?'", $this->iObsoleteBy, $this->iVersionId)) return FALSE; if($this->iObsoleteBy) $sWhatChanged .= "The version was marked as obsolete.\n\n"; else $sWhatChanged .= "The version is no longer marked as obsolete.\n\n"; if($this->iObsoleteBy) { query_parameters("UPDATE appVotes SET versionId = '?' WHERE versionId = '?'", $this->iObsoleteBy, $this->iVersionId); } } if($sWhatChanged and !$bSilent) $this->SendNotificationMail("edit",$sWhatChanged); return true; } /** * Removes the version from the database and * requests the same action for child entries */ public function purge() { /* We need the versionId to continue */ if(!$this->iVersionId) return; /* is the current user allowed to delete this version? */ if(!$_SESSION['current']->canDeleteVersion($this)) return false; $bSuccess = TRUE; foreach($this->objectGetChildren(TRUE) as $oChild) { if(!$oChild->purge()) $bSuccess = FALSE; } /* now remove the version from the DB */ $hResult = query_parameters("DELETE FROM appVersion WHERE versionId = '?' LIMIT 1", $this->iVersionId); if(!$hResult) $bSuccess = FALSE; return $bSuccess; } /** * Flags the version as deleted * and request the deletion of linked elements. */ public function delete() { /* We need the versionId to continue */ if(!$this->iVersionId) return; /* is the current user allowed to delete this version? */ if(!$_SESSION['current']->canDeleteVersion($this)) return false; $bSuccess = TRUE; foreach($this->objectGetChildren() as $oChild) { if(!$oChild->delete()) $bSuccess = FALSE; } /* now flag the version as deleted */ $hResult = query_parameters("UPDATE appVersion SET state = 'deleted' WHERE versionId = '?' LIMIT 1", $this->iVersionId); if(!$hResult) $bSuccess = FALSE; return $bSuccess; } /** * Move version out of the queue. */ public function unQueue() { if(!$_SESSION['current']->canUnQueueVersion($this)) return; // If we are not in the queue, we can't move the version out of the queue. if($this->sState == 'accepted') return false; if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'", 'accepted', $this->iVersionId)) { $this->sState = 'accepted'; // we send an e-mail to interested people $this->mailSubmitter("add"); $this->SendNotificationMail(); /* Unqueue matching maintainer request */ $hResultMaint = query_parameters("SELECT maintainerId FROM appMaintainers WHERE userId = '?' AND versionId = '?'", $this->iSubmitterId, $this->iVersionId); if($hResultMaint && query_num_rows($hResultMaint)) { $oMaintainerRow = query_fetch_object($hResultMaint); $oMaintainer = new Maintainer($oMaintainerRow->maintainerId); $oMaintainer->unQueue("OK"); } } } public function Reject($bSilent=false) { if(!$_SESSION['current']->canRejectVersion($this)) return; // If we are not in the queue, we can't move the version out of the queue. if($this->sState != 'queued') return false; if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'", 'rejected', $this->iVersionId)) { $this->sState = 'rejected'; // we send an e-mail to interested people if(!$bSilent) { $this->mailSubmitter("reject"); $this->SendNotificationMail("reject"); } // the version has been unqueued addmsg("The version has been rejected.", "green"); } } public function ReQueue() { if(!$_SESSION['current']->canRequeueVersion($this)) return; if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'", 'queued', $this->iVersionId)) { $this->sState = 'queued'; // we send an e-mail to interested people $this->SendNotificationMail(); // the version has been unqueued addmsg("The version has been re-submitted", "green"); } } public function objectGetSubmitterId() { return $this->iSubmitterId; } public static function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction) { return new mailOptions(); } public function objectGetMail($sAction, $bMailSubmitter, $bParentAction) { $oApp = new application($this->iAppId); if($bMailSubmitter) { switch($sAction) { case "delete": $sSubject = "Submitted version deleted"; $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName. ") has been deleted."; break; } $aMailTo = null; } else { switch($sAction) { case "delete": $sSubject = "Version '".$this->sName."' of '".$oApp->sName."' ". "deleted"; $sMsg = ""; break; } $aMailTo = User::get_notify_email_address_list(null, $this->iVersionId); } return array($sSubject, $sMsg, $aMailTo); } private function mailSubmitter($sAction="add") { global $aClean; //FIXME: we should pass the sReplyText value in // use 'sReplyText' if it is defined, otherwise define the value as an empty string if(!isset($aClean['sReplyText'])) $aClean['sReplyText'] = ""; if($this->iSubmitterId) { $oApp = new Application($this->iAppId); $oSubmitter = new User($this->iSubmitterId); switch($sAction) { case "add": $sSubject = "Submitted version accepted"; $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been accepted by ".$_SESSION['current']->sRealname.".\n"; $sMsg .= "Administrators response:\n"; break; case "reject": $sSubject = "Submitted version rejected"; $sMsg = "The version you submitted (".$oApp->sName." ".$this->sName.") has been rejected by ".$_SESSION['current']->sRealname."."; $sMsg .= "Clicking on the link in this email will allow you to modify and resubmit the version. "; $sMsg .= "A link to your queue of applications and versions will also show up on the left hand side of the Appdb site once you have logged in. "; $sMsg .= APPDB_ROOT."objectManager.php?sClass=version_queue". "&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId."&". "sTitle=Edit+Version\n"; break; } $sMsg .= $aClean['sReplyText']."\n"; $sMsg .= "We appreciate your help in making the Version Database better for all users."; mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg); } } private function SendNotificationMail($sAction="add",$sMsg=null) { global $aClean; // use 'sReplyText' if it is defined, otherwise define the value as an empty string if(!isset($aClean['sReplyText'])) $aClean['sReplyText'] = ""; $oApp = new Application($this->iAppId); switch($sAction) { case "add": if($this->sState == 'accepted') { $sSubject = "Version ".$this->sName." of ".$oApp->sName." added by ".$_SESSION['current']->sRealname; $sMsg = $this->objectMakeUrl()."\n"; if($this->iSubmitterId) { $oSubmitter = new User($this->iSubmitterId); $sMsg .= "This version has been submitted by ".$oSubmitter->sRealname."."; $sMsg .= "\n"; } if($aClean['sReplyText']) { $sMsg .= "Appdb admin reply text:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("The version was successfully added into the database.", "green"); } else // Version queued. { $sSubject = "Version '".$this->sName."' of '".$oApp->sName."' submitted by ".$_SESSION['current']->sRealname; $sMsg .= "This version has been queued."; $sMsg .= "\n"; addmsg("The version you submitted will be added to the database after being reviewed.", "green"); } break; case "edit": $sSubject = "'".$oApp->sName." ".$this->sName."' has been modified by ".$_SESSION['current']->sRealname; $sMsg .= $this->objectMakeUrl()."\n"; addmsg("Version modified.", "green"); break; case "delete": // if sReplyText is set we should report the reason the application was deleted if($aClean['sReplyText']) { $sMsg .= "Reason given:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("Version deleted.", "green"); break; case "reject": $sSubject = "Version '".$this->sName."' of '".$oApp->sName."' has been rejected by ".$_SESSION['current']->sRealname; $sMsg .= APPDB_ROOT."objectManager.php?sClass=version_queue". "&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId."&". "sTitle=Edit+Version\n"; // if sReplyText is set we should report the reason the version was rejected if($aClean['sReplyText']) { $sMsg .= "Reason given:\n"; $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any } addmsg("Version rejected.", "green"); break; } $sEmail = User::get_notify_email_address_list(null, $this->iVersionId); if($sEmail) mail_appdb($sEmail, $sSubject ,$sMsg); } public function get_buglink_ids() { /* * We fetch Bug linkIds. */ $aBuglinkIds = array(); $sQuery = "SELECT * FROM buglinks WHERE versionId = '?' ORDER BY bug_id"; if($hResult = query_parameters($sQuery, $this->iVersionId)) { while($oRow = query_fetch_object($hResult)) { $aBuglinkIds[] = $oRow->linkId; } } return $aBuglinkIds; } /* Makes a frame with title 'Mark as obsolete' and info about what it means, plus caller-defined content */ private static function makeObsoleteFrame($sContent = "") { $sMsg = html_frame_start("Mark as obsolete", "90%", "", 0); $sMsg .= "Some applications need to be updated from time to time in order to "; $sMsg .= "be of any use. An example is online multi-player games, where you need "; $sMsg .= "to be running a version compatible with the server. "; $sMsg .= "If this is such an application, and this version is no longer usable, "; $sMsg .= "you can mark it as obsolete and move its current votes to a usable "; $sMsg .= "version instead.

"; $sMsg .= $sContent; $sMsg .= html_frame_end(); return $sMsg; } /* output html and the current versions information for editing */ /* if $editParentApplication is true that means we need to display fields */ /* to let the user change the parent application of this version */ /* otherwise, if $editParentAppliation is false, we leave them out */ public function outputEditor() { HtmlAreaLoaderScript(array("version_editor")); echo html_frame_start("Version Form", "90%", "", 0); echo ''; $oTable = new Table(); $oTable->SetClass("color0"); $oTable->SetWidth("100%"); $oTable->SetBorder(0); $oTable->SetCellPadding(2); $oTable->SetCellSpacing(0); /* Fill in appId value */ global $aClean; if(!$this->iAppId) $this->iAppId = $aClean['iAppId']; if($this->sState == 'accepted' && $this->iVersionId) { // app parent $x = new TableVE("view"); $oTableRow = new TableRow(); $oTableRow->SetValign("top"); $oTableCell = new TableCell("Application"); $oTableCell->SetBold(true); $oTableRow->AddCell($oTableCell); $sOptionList = $x->make_option_list("iAppId", $this->iAppId, "appFamily", "appId", "appName"); $oTableCell = new TableCell($sOptionList); $oTableCell->SetClass("color0"); $oTableRow->AddCell($oTableCell); $oTable->AddRow($oTableRow); } else { echo ''; } // version name $oTableRow = new TableRow(); $oTableRow->SetValign("top"); $oTableCell = new TableCell("Version Name"); $oTableCell->SetBold(true); $oTableCell->SetClass("color0"); $oTableRow->AddCell($oTableCell); $oTableRow->AddTextCell(''); $oTable->AddRow($oTableRow); // version license $oTableRow = new TableRow(); $oTableCell = new TableCell("License"); $oTableCell->SetBold(true); $oTableCell->SetClass("color0"); $oTableRow->AddCell($oTableCell); $oTableRow->AddTextCell($this->makeLicenseList()); $oTable->AddRow($oTableRow); // version description $oTableRow = new TableRow(); $oTableRow->SetValign("top"); $oTableCell = new TableCell("Version description"); $oTableCell->SetBold(true); $oTableCell->SetClass("color0"); $oTableRow->AddCell($oTableCell); $oTableRow->AddTextCell('

'); $oTable->AddRow($oTableRow); // output the table echo $oTable->GetString(); echo html_frame_end(); if($this->sState == 'accepted' && $this->iVersionId) { /* Mark as obsolete */ $oApp = new application($this->iAppId); $oVersionInDB = new version($this->iVersionId); if($oVersionInDB->iObsoleteBy) { $sObsoleteTxt = ""; $sObsoleteTxt .= " This version is obsolete"; echo $this->makeObsoleteFrame($sObsoleteTxt); echo "iObsoleteBy."\" type=\"hidden\" />\n"; } else if(sizeof($oApp->getVersions(FALSE)) > 1) { if($this->iObsoleteBy) $sObsolete = "checked=\"checked\""; else $sObsolete = ""; $sObsoleteTxt = ""; $sObsoleteTxt .= "Mark as obsolete and move votes to \n"; $sObsoleteTxt .= $oApp->makeVersionDropDownList("iObsoleteBy", $this->iObsoleteBy, $this->iVersionId, FALSE); echo $this->makeObsoleteFrame($sObsoleteTxt); } } else { echo ''; echo ''; } } public function CheckOutputEditorInput($aValues) { $errors = ""; if (empty($aValues['sVersionName'])) $errors .= "
  • Please enter an application version.
  • \n"; if (empty($aValues['shVersionDescription'])) $errors .= "
  • Please enter a version description.
  • \n"; return $errors; } /* retrieves values from $aValues that were output by outputEditor() */ /* $aValues can be $_REQUEST or any array with the values from outputEditor() */ public function GetOutputEditorValues($aValues) { if($aValues['iAppId']) $this->iAppId = $aValues['iAppId']; if($aValues['iVersionId']) $this->iVersionId = $aValues['iVersionId']; $this->sName = $aValues['sVersionName']; $this->sDescription = $aValues['shVersionDescription']; $this->sLicense = $aValues['sLicense']; $this->iMaintainerRequest = $aValues['iMaintainerRequest']; if($aValues['bObsolete'] == "true") $this->iObsoleteBy = $aValues['iObsoleteBy']; else $this->iObsoleteBy = 0; } public function objectGetCustomTitle($sAction) { switch($sAction) { case "view": return "Viewing App: ".version::fullName($this->iVersionId); default: return null; } } public static function objectGetCustomVars($sAction) { switch($sAction) { case "view": /* Allow the user to select which test report is shown in the version view */ return array("iTestingId"); default: return null; } } public function objectShowPreview() { return TRUE; } /* Not standard OM function yet, but will be in the future */ public function objectGetParent() { /* No id so we can't query the DB, but perhaps an entry is cached? */ if(!$this->iAppId) return $this->oApp; return new application($this->iAppId); } public function getRatingInfo() { return testData::getRatingInfoForVersionId($this->iVersionId); } public function updateRatingInfo() { $aRatingInfo = $this->getRatingInfo(); $hResult = query_parameters("UPDATE appVersion SET rating = '?', ratingRelease = '?' WHERE versionId = '?'", $aRatingInfo[0], $aRatingInfo[1], $this->iVersionId); if(!$hResult) return false; return true; } public function display($aVars = array()) { /* is this user supposed to view this version? */ if(!$_SESSION['current']->canViewVersion($this)) util_show_error_page_and_exit("Something went wrong with the application or version id"); $iTestingId = $aVars['iTestingId'] ? $aVars['iTestingId'] : 0; $oApp = $this->objectGetParent(); // cat $oCategory = new Category($oApp->iCatId); $oCategory->display($oApp->iAppId, $this->iVersionId); // set URL $appLinkURL = ($oApp->sWebpage) ? "sWebpage."\">".substr(stripslashes($oApp->sWebpage),0,30)."": " "; // start version display echo html_frame_start("","98%","",0); echo '',"\n"; echo '',"\n"; echo "\n"; echo "\n"; echo html_tr(array( "License", $this->sLicense), "color0"); // main URL echo " \n"; // Votes if(!$this->iObsoleteBy) { $oM = new objectManager("voteManager", "Vote"); $oM->setReturnTo($this->objectMakeUrl()); if($_SESSION['current']->isLoggedIn()) $shVoteLink = '   iUserId).'&iVersionId='.$this->iVersionId.'">Vote'; else $shVoteLink = ''; $shVoteText = vote_count_version_total($this->iVersionId).$shVoteLink; } else { $shVoteText = 'Marked as obsolete'; } echo html_tr(array('Votes', $shVoteText), 'color0'); $sRating = $this->sTestedRating; $sRelease = $this->sTestedRelease; if($sRating != "/" && $sRating) $sRatingColor = $sRating; else $sRatingColor = 'color0'; // URLs if($sUrls = url::display($this->iVersionId)) { echo $sUrls; } // rating Area echo "\n"; echo "\n"; // Download URLs if($sDownloadurls = downloadurl::display($this->iVersionId)) echo $sDownloadurls; // image $img = Screenshot::get_random_screenshot_img($oApp->iAppId, $this->iVersionId, false); echo "\n"; // display all maintainers of this application echo "\n"; // display the app maintainer button echo '"; if ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($this->iVersionId) || $_SESSION['current']->isSuperMaintainer($this->iAppId)) { $shAdd = ''."\n"; echo ''."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo ''."\n"; $url = BASE."objectManager.php?sClass=version&sAction=delete&bQueued=false&sTitle=Delete%20".version::fullName($this->iVersionId)."&iId=".$this->iVersionId; echo "\n"; echo "\t".''."\n"; echo ''."\n"; echo $shAdd.'" />'; echo "\t".''."\n"; echo ''."\n"; echo $shAdd.'&sNoteTitle=HOWTO" />'; echo "\t".''."\n"; echo ''."\n"; echo $shAdd.'&sNoteTitle=WARNING" />'; echo "\t".''."\n"; echo ''; echo ""; } $oMonitor = new Monitor(); $oMonitor->find($_SESSION['current']->iUserId, $this->iVersionId); if($oMonitor->iMonitorId) { echo '\n"; } echo "
    Name".$oApp->sName."
    Version".$this->sName."
    URL".$appLinkURL."
    Rating".$sRating."
    Wine Version".$sRelease."
    $img
    Maintainers of this version:\n"; echo ""; $aMaintainers = $this->getMaintainersUserIds(); if(sizeof($aMaintainers)>0) { echo "\n"; } else { echo "\n"; } echo "
      "; while(list($index, $userIdValue) = each($aMaintainers)) { $oUser = new User($userIdValue); echo "
    • ".$oUser->objectMakeLink()."
    • "; } echo "
    "; echo "No maintainers. Volunteer today!
    '."\n"; if($_SESSION['current']->isLoggedIn()) { /* is this user a maintainer of this version by virtue of being a super maintainer */ /* of this app family? */ if($_SESSION['current']->isSuperMaintainer($oApp->iAppId)) { echo '
    '."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo "\tiAppId."\">\n"; echo "\tiVersionId."\">\n"; echo "
    \n"; } else { /* are we already a maintainer? */ if($_SESSION['current']->isMaintainer($this->iVersionId)) /* yep */ { echo '
    '."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo "\t"."iAppId."\">\n"; echo "\t"."iVersionId."\">\n"; echo "
    \n"; } else /* nope */ { echo '
    iVersionId)).'&sReturnTo='.urlencode($this->objectMakeUrl()).'">'."\n"; echo "\t".''."\n"; echo "\t"."iAppId."\">\n"; echo "\t"."iVersionId."\">\n"; echo "
    \n"; $oMonitor = new Monitor(); $oMonitor->find($_SESSION['current']->iUserId, $this->iVersionId); if(!$oMonitor->iMonitorId) { echo '
    \n"; echo "\tiAppId."\" />\n"; echo "\tiVersionId."\" />\n"; echo "\t\n"; echo "\t\n"; echo "\tobjectMakeUrl()."\" />\n"; echo "\t".''."\n"; echo "
    \n"; } } } } else { echo '
    '."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo '
    '."\n"; } echo "
    '."\n"; echo ''."\n"; echo '
    \n"; echo "\tiMonitorId."\" />\n"; echo "\t\n"; echo "\t\n"; echo "\tobjectMakeUrl()."\" />\n"; echo ''."\n"; echo "
    \n"; echo "
    \n"; // start of the right hand pane in the version display echo "\n"; echo "
    \n"; ///////////////////////// // output the description echo "
    \n"; // output the description title echo "\t
    \n"; echo "\t\tDescription\n"; echo "\t
    \n"; // output the description echo "\t
    \n"; echo "\t\t".$this->sDescription."\n"; echo "\t
    \n"; echo "
    \n"; // end the 'info_container' div // end description ///////////////////////// ////////////////////// // Show test data $iNewestId = 0; /* Set if the use chose to display a particular test report */ if($iTestingId) $oTest = new testData($iTestingId); else if($this->iVersionId) /* Let's query for the latest rest report */ { $iNewestId = testData::getNewestTestIdFromVersionId($this->iVersionId); $iTestingId = $iNewestId; if($iTestingId) /* We want all entries to have test data, but old versions might lack it, or data may have been deleted */ $oTest = new testData($iTestingId); } else /* Perhaps we have a cached entry? There should be */ { $aTests = $this->getTestResults(); if(sizeof($aTests)) /* ... but we cannot be certain */ $oTest = $aTests[0]; } if($oTest) { if($oTest->isOld()) { if($iNewestId != $oTest->objectGetId()) { $sWarnOldText = 'The test results you have selected are very old and may not represent the current state of Wine.'; } else { $sWarnOldText = 'The test results for this version are very old, and as such they may not represent '. 'the current state of Wine. Please consider submitting a new test report.'; } echo html_note('Old test results', $sWarnOldText); } echo "
    \n"; echo "\t
    \n"; echo "\t\tSelected test results (selected in 'Test Results' table below)\n"; echo "\t
    \n"; echo "
    \n"; $oTest->ShowTestResult(); echo "
    \n"; echo "
    \n"; } else /* Show a note saying that no test results are present, and encourage the user to take action */ { echo html_note('No Test Results', 'This version has no test results, please consider submitting some.
    '. 'They may be part of the '. 'version or application description. If they are, please '. 'consider becoming a maintainer and remove them, submitting '. 'a proper test report instead.'); } // end the 'info_container' div // end show test data ///////////////////// ////////////////////////////// // show the test results table if($oTest->iTestingId) { $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", 5); } else if($oTest) /* We are previewing the version */ { $oTable = $oTest->CreateTestTable(); $oTable->AddRow($oTest->CreateTestTableRow(0, "")); echo $oTable->GetString(); } if($_SESSION['current']->isLoggedIn()) { echo '
    iVersionId. '&sTitle=Add+Test+Data&sReturnTo='. urlencode($this->objectMakeUrl()).'>'."\n"; echo "\t".''."\n"; echo '
    '."\n"; } else { echo '
    '."\n"; echo "\t".''."\n"; echo "\t".''."\n"; echo '
    '."\n"; } // end show test results table ///////////////////////////// echo "
    \n"; // end the version info pane, the right hand pane in the // version display echo html_frame_end(); view_version_bugs($this->iVersionId, $this->get_buglink_ids()); /* display the notes for the application */ $hNotes = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?'", $this->iVersionId); while( $oRow = query_fetch_object($hNotes) ) { $oNote = new Note($oRow->noteId); $oNote->display(); } // Comments Section if($this->iVersionId) Comment::view_app_comments($this->iVersionId); } public static function lookup_name($versionId) { if(!$versionId) return null; $result = query_parameters("SELECT versionName FROM appVersion WHERE versionId = '?'", $versionId); if(!$result || query_num_rows($result) != 1) return null; $ob = query_fetch_object($result); return $ob->versionName; } function fullName($iVersionId) { if(!$iVersionId) return FALSE; $hResult = query_parameters( "SELECT appFamily.appName, appVersion.versionName FROM appVersion, appFamily WHERE appVersion.appId = appFamily.appId AND versionId = '?'", $iVersionId); if(!$hResult || !query_num_rows($hResult)) return FALSE; $oRow = query_fetch_object($hResult); return "$oRow->appName $oRow->versionName"; } /* Creates a link to the version labelled with the full application name */ public static function fullNameLink($iVersionId) { $oVersion = new version($iVersionId); $sLink = "objectMakeUrl()."\">". $oVersion->fullName($iVersionId).""; return $sLink; } // display the versions public static function displayList($aVersions) { if ($aVersions) { echo html_frame_start("","98%","",0); $oTable = new Table(); $oTable->SetWidth("100%"); $oTable->SetBorder(0); $oTable->SetCellPadding(3); $oTable->SetCellSpacing(1); $oTableRow = new TableRow(); $oTableRow->SetClass("color4"); $oTableCell = new TableCell("Version"); $oTableCell->SetWidth("80"); $oTableRow->AddCell($oTableCell); $oTableRow->AddTextCell("Description"); $oTableCell = new TableCell("Rating"); $oTableCell->SetWidth("80"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell("Wine version"); $oTableCell->SetWidth("80"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell("Test results"); $oTableCell->SetWidth("80"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell("Comments"); $oTableCell->SetWidth("40"); $oTableRow->AddCell($oTableCell); $oTable->SetHeader($oTableRow); $c = 0; foreach($aVersions as $oVersion) { $oApp = new application($oVersion->iAppId); if ($oVersion->sState == $oApp->objectGetState()) { // set row color $bgcolor = ($c % 2 == 0) ? "color0" : "color1"; $oTableRowHighlight = null; // if we have a valid tested rating if($oVersion->sTestedRating && ($oVersion->sTestedRating != "/") && ($oVersion->sTestedRating != " ")) { $sClass = $oVersion->sTestedRating; $oInactiveColor = new Color(); $oInactiveColor->SetColorByName($oVersion->sTestedRating); $oHighlightColor = GetHighlightColorFromInactiveColor($oInactiveColor); $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor); } else { $sClass = $bgcolor; $oTableRowHighlight = GetStandardRowHighlight($c); } //display row $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl()); $oTableRowClick->SetHighlight($oTableRowHighlight); $oTableRow = new TableRow(); $oTableRow->SetRowClick($oTableRowClick); // make the row clickable $oTableRow->AddTextCell($oVersion->objectMakeLink()); $oTableRow->SetClass($sClass); $oTableRow->AddTextCell(util_trim_description($oVersion->sDescription)); $oTableCell = new TableCell($oVersion->sTestedRating); $oTableCell->SetAlign("center"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell($oVersion->sTestedRelease); $oTableCell->SetAlign("center"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell(testData::get_testdata_count_for_versionid($oVersion->iVersionId)); $oTableCell->SetAlign("center"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell(Comment::get_comment_count_for_versionid($oVersion->iVersionId)); $oTableCell->SetAlign("center"); $oTableRow->AddCell($oTableCell); // add the row to the table $oTable->AddRow($oTableRow); $c++; } } // output the table echo $oTable->GetString(); echo html_frame_end("Click the Version Name to view the details of that Version"); } } /* returns the maintainers of this version in an array */ public function getMaintainersUserIds() { $aMaintainers = array(); /* early out if the versionId isn't valid */ if($this->iVersionId == 0) return $aMaintainers; $hResult = Maintainer::getMaintainersForAppIdVersionId(null, $this->iVersionId); $iCount = 0; while($oRow = query_fetch_object($hResult)) { $aMaintainers[$iCount] = $oRow->userId; $iCount++; } return $aMaintainers; } /* List the versions submitted by a user. Ignore versions for queued applications */ public static function listSubmittedBy($iUserId, $bQueued = true) { $hResult = query_parameters("SELECT appFamily.appName, appVersion.versionName, appVersion.description, appVersion.versionId, appVersion.submitTime FROM appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND appVersion.submitterId = '?' AND appVersion.state = '?' AND appFamily.state = '?'", $iUserId, $bQueued ? 'queued' : 'accepted', 'accepted'); if(!$hResult || !query_num_rows($hResult)) return false; $oTable = new Table(); $oTable->SetWidth("100%"); $oTable->SetAlign("center"); // setup the table header $oTableRow = new TableRow(); $oTableRow->AddTextCell("Name"); $oTableRow->AddTextCell("Description"); $oTableRow->AddTextCell("Submission Date"); $oTableRow->SetClass("color4"); $oTable->SetHeader($oTableRow); if($bQueued) $oTableRow->addTextCell('Action'); for($i = 1; $oRow = query_fetch_object($hResult); $i++) { $oTableRow = new TableRow(); $oTableRow->AddTextCell(version::fullNameLink($oRow->versionId)); $oTableRow->AddTextCell($oRow->description); $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))); $oTableRow->SetClass(($i % 2) ? "color0" : "color1"); if($bQueued) { $oM = new objectManager('version_queue'); $oM->setReturnTo(array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : ""); $shDeleteLink = 'delete'; $shEditLink = 'edit'; $oTableRow->addTextCell("[ $shEditLink ]   [ $shDeleteLink ]"); } $oTable->AddRow($oTableRow); } return $oTable->GetString(); } // returns a string containing the html for a selection list public function makeLicenseList($sLicense = NULL) { if(!$sLicense) $sLicense = $this->sLicense; $sReturn = "\n"; return $sReturn; } /* In order to prevent MySQL injections. Returns matched license */ public static function checkLicense($sLicense) { $aLicense = array(LICENSE_RETAIL, LICENSE_OPENSOURCE, LICENSE_FREETOUSE, LICENSE_FREETOSHARE, LICENSE_DEMO, LICENSE_SHAREWARE); foreach($aLicense as $sElement) { if($sLicense == $sElement) return $sElement; } return FALSE; } public function objectMakeUrl() { return APPDB_ROOT."objectManager.php?sClass=version&iId=$this->iVersionId"; } public function objectMakeLink() { $sLink = "objectMakeUrl()."\">". $this->sName.""; return $sLink; } public static function objectGetEntriesCount($sState) { $oVersion = new version(); if($sState != 'accepted' && !$oVersion->canEdit()) { /* Users should see their own rejected entries, but maintainers should not be able to see rejected entries for versions they maintain */ if($sState == 'rejected') $sQuery = "SELECT COUNT(DISTINCT appVersion.versionId) as count FROM appVersion WHERE appVersion.submitterId = '?' AND appVersion.state = '?'"; else $sQuery = "SELECT COUNT(DISTINCT appVersion.versionId) as count FROM appVersion, appMaintainers WHERE appMaintainers.appId = appVersion.appId AND superMaintainer = '1' AND appMaintainers.userId = '?' AND appMaintainers.state = 'accepted' AND appVersion.state = '?'"; $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $sState); } else { $sQuery = "SELECT COUNT(DISTINCT versionId) as count FROM appVersion WHERE appVersion.state = '?'"; $hResult = query_parameters($sQuery, $sState); } if(!$hResult) return FALSE; if(!$oRow = query_fetch_object($hResult)) return FALSE; return $oRow->count; } public function objectGetState() { return $this->sState; } public function objectSetState($sState) { $this->sState = $sState; } public function canEdit() { if($_SESSION['current']->hasPriv("admin")) return TRUE; if(isset($this) && is_object($this) && $this->iVersionId) { if(maintainer::isUserMaintainer($_SESSION['current'], $this->iVersionId)) return TRUE; if($this->iSubmitterId == $_SESSION['current']->iUserId) return TRUE; return FALSE; } else { return FALSE; } } public function mustBeQueued() { if($_SESSION['current']->hasPriv("admin")) return FALSE; // if we have a valid iAppId or iVersionId we should // check the status of these objects to determine whether // we need to queue this version object if($this->iVersionId or $this->iAppId) { // if the user is the super maintainer of the application then // they are authorized to unqueue versions of this application // so the version doesn't have to be queued if($this->iAppId && maintainer::isUserSuperMaintainer($_SESSION['current'], $this->iAppId)) return FALSE; // if the user is a maintainer of this version then // this version doesn't have to be queued if($this->iVersionId && maintainer::isUserMaintainer($_SESSION['current'], $this->iVersionId)) return FALSE; return TRUE; } else { return TRUE; } } public static function objectGetHeader() { $oTableRow = new TableRow(); $oTableRow->AddTextCell("Submission Date"); $oTableRow->AddTextCell("Submitter"); $oTableRow->AddTextCell("Vendor"); $oTableRow->AddTextCell("Application"); $oTableRow->AddTextCell("Version"); $oTableRow->AddTextCell("Has Maintainer"); return $oTableRow; } public static function objectGetItemsPerPage($sState = 'accepted') { $aItemsPerPage = array(25, 50, 100, 200); $iDefaultPerPage = 25; return array($aItemsPerPage, $iDefaultPerPage); } public static function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "versionId") { $sLimit = ""; /* Should we add a limit clause to the query? */ if($iRows || $iStart) { $sLimit = " LIMIT ?,?"; /* Selecting 0 rows makes no sense, so we assume the user wants to select all of them after an offset given by iStart */ if(!$iRows) $iRows = version::objectGetEntriesCount($sState); } if($sState != 'accepted' && !version::canEdit()) { /* Users should see their own rejected entries, but maintainers should not be able to see rejected entries for versions they maintain */ if($sState == 'rejected') $sQuery = "SELECT * FROM appVersion WHERE appVersion.submitterId = '?' AND appVersion.state = '?' ORDER BY ?$sLimit"; else $sQuery = "SELECT appVersion.* FROM appVersion, appMaintainers WHERE appMaintainers.appId = appVersion.appId and superMaintainer = '1' AND appMaintainers.userId = '?' AND appMaintainers.state = 'accepted' AND appVersion.state = '?' ORDER BY ?$sLimit"; if($sLimit) { $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $sState, $sOrderBy, $iStart, $iRows); } else { $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $sState, $sOrderBy); } } else { $sQuery = "SELECT * FROM appVersion WHERE appVersion.state = '?' ORDER BY ?$sLimit"; if($sLimit) { $hResult = query_parameters($sQuery, $sState, $sOrderBy, $iStart, $iRows); } else { $hResult = query_parameters($sQuery, $sState, $sOrderBy); } } if(!$hResult) return FALSE; return $hResult; } public function objectGetTableRow() { $oUser = new user($this->iSubmitterId); $oApp = new application($this->iAppId); $oVendor = new vendor($oApp->iVendorId); $aMaintainers = Maintainer::getSuperMaintainersUserIdsFromAppId($this->iAppId); $oTableRow = new TableRow(); $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime))); $oTableRow->AddTextCell($oUser->objectMakeLink()); $oTableRow->AddTextCell($oVendor->objectMakeLink()); $oTableRow->AddTextCell($oApp->objectMakeLink()); $oTableRow->AddTextCell($this->sName); $oTableRow->AddTextCell(sizeof($aMaintainers) ? "YES" : "No"); $oOMTableRow = new OMTableRow($oTableRow); return $oOMTableRow; } public function objectDisplayQueueProcessingHelp() { echo "

    This is the list of versions waiting for your approval, ". "or to be rejected.

    \n"; echo "

    To view a submission, click on its name. ". "From that page you can edit, delete or approve it into the AppDB.

    \n"; } public function getTestResults($bIncludeDeleted = false) { /* If we don't have an id we can't query the database, but perhaps we have some cached entries? */ if(!$this->iVersionId) return $this->aTestResults; $aTests = array(); if($bIncludeDeleted) $sExcludeDeleted = ""; else $sExcludeDeleted = " AND state != 'deleted'"; /* Find test results */ $sQuery = "SELECT * FROM testResults WHERE versionId = '?'$sExcludeDeleted"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) $aTests[] = new testData(0, $oRow); return $aTests; } public function objectGetChildren($bIncludeDeleted = false) { $aChildren = array(); foreach($this->getTestResults($bIncludeDeleted) as $oTest) { $aChildren += $oTest->objectGetChildren($bIncludeDeleted); $aChildren[] = $oTest; } /* Find maintainers */ $sQuery = "SELECT * FROM appMaintainers WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oMaintainer = new maintainer(0, $oRow); $aChildren += $oMaintainer->objectGetChildren($bIncludeDeleted); $aChildren[] = $oMaintainer; } /* Find monitors */ $sQuery = "SELECT * FROM appMonitors WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oMonitor = new monitor(0, $oRow); $aChildren += $oMonitor->objectGetChildren($bIncludeDeleted); $aChildren[] = $oMonitor; } /* Find notes */ $sQuery = "SELECT * FROM appNotes WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oNote = new note(0, $oRow); $aChildren += $oNote->objectGetChildren($bIncludeDeleted); $aChildren[] = $oNote; } /* Find screenshots */ $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'"; $hResult = query_parameters($sQuery, "screenshot", $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oScreenshot = new screenshot(0, $oRow); $aChildren += $oScreenshot->objectGetChildren($bIncludeDeleted); $aChildren[] = $oScreenshot; } /* Get bug links */ foreach($this->get_buglink_ids() as $iBugId) { $oBug = new bug($iBugId); $aChildren += $oBug->objectGetChildren($bIncludeDeleted); $aChildren[] = $oBug; } /* Get comments */ $sQuery = "SELECT * FROM appComments WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oComment = new comment(0, $oRow); $aChildren += $oComment->objectGetChildren($bIncludeDeleted); $aChildren[] = $oComment; } /* Get urls */ $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'"; $hResult = query_parameters($sQuery, "url", $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oUrl = new url(0, $oRow); $aChildren += $oUrl->objectGetChildren($bIncludeDeleted); $aChildren[] = $oUrl; } /* Get downloadurls */ $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'"; $hResult = query_parameters($sQuery, "downloadurl", $this->iVersionId); if(!$hResult) return FALSE; while($oRow = mysql_fetch_object($hResult)) { $oDownload = new downloadurl(0, $oRow); $aChildren += $oDownload->objectGetChildren($bIncludeDeleted); $aChildren[] = $oDownload; } return $aChildren; } public function objectMoveChildren($iNewId) { /* Keep track of how many items we have updated */ $iCount = 0; /* Move test results */ $sQuery = "SELECT * FROM testResults WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = query_fetch_object($hResult)) { $oTestData = new testData($oRow->testingId); $oTestData->iVersionId = $iNewId; if($oTestData->update()) $iCount++; else return FALSE; } /* Move all app data */ $sQuery = "SELECT * FROM appData WHERE versionId = '?'"; $hResult = query_parameters($sQuery, $this->iVersionId); if(!$hResult) return FALSE; while($oRow = query_fetch_object($hResult)) { $oAppData = new appData($oRow->testingId); $oAppData->iVersionId = $iNewId; if($oAppData->update(TRUE)) $iCount++; else return FALSE; } /* Return the number of updated objects if everything was successful */ return $iCount; } public static function allowAnonymousSubmissions() { return FALSE; } function objectAllowPurgingRejected() { return TRUE; } public function objectGetSubmitTime() { return mysqltimestamp_to_unixtimestamp($this->sSubmitTime); } public function objectGetId() { return $this->iVersionId; } } ?>