2 /************************************/
3 /* this class represents an version */
4 /************************************/
6 require_once(BASE
."include/note.php");
7 require_once(BASE
."include/comment.php");
8 require_once(BASE
."include/url.php");
9 require_once(BASE
."include/screenshot.php");
10 require_once(BASE
."include/bugs.php");
11 require_once(BASE
."include/util.php");
12 require_once(BASE
."include/testData.php");
13 require_once(BASE
."include/downloadurl.php");
14 require_once(BASE
."include/monitor.php");
15 require_once(BASE
."include/vote.php");
17 define("LICENSE_OPENSOURCE", "Open Source");
18 define("LICENSE_SHAREWARE", "Shareware");
19 define("LICENSE_DEMO", "Demo");
20 define("LICENSE_RETAIL", "Retail");
21 define('LICENSE_FREETOUSE', 'Free to use');
22 define('LICENSE_FREETOSHARE', 'Free to use and share');
25 * Version class for handling versions.
30 var $oApp; /* Parento object */
39 var $aTestResults; /* Array of test result objects. Especially useful when
40 we want to preview a version before submitting it;
41 in that case there is no data in the database */
42 var $iObsoleteBy; /* Whether this version is marked as obsolete, and if so which
43 version its votes should be moved to. */
44 var $iMaintainerRequest; /* Temporary variable for version submisson.
45 Indicates whether the user wants to become a
46 maintainer or monitor of the version being submitted.
47 Value denotes type of request. */
50 * constructor, fetches the data.
52 public function Version($iVersionId = null, $oRow = null)
54 $this->aTestResults
= array(); // should always be an array
55 // we are working on an existing version
56 if(!$iVersionId && !$oRow)
60 * We fetch the data related to this version.
66 WHERE versionId = '?'";
67 if($hResult = query_parameters($sQuery, $iVersionId))
68 $oRow = query_fetch_object($hResult);
73 $this->iVersionId
= $oRow->versionId
;
74 $this->iAppId
= $oRow->appId
;
75 $this->iSubmitterId
= $oRow->submitterId
;
76 $this->sSubmitTime
= $oRow->submitTime
;
77 $this->sName
= $oRow->versionName
;
78 $this->sDescription
= $oRow->description
;
79 $this->sTestedRelease
= $oRow->ratingRelease
;
80 $this->sTestedRating
= $oRow->rating
;
81 $this->sState
= $oRow->state
;
82 $this->sLicense
= $oRow->license
;
83 $this->iObsoleteBy
= $oRow->obsoleteBy
;
89 * Creates a new version.
91 public function create()
93 if(!$_SESSION['current']->canCreateVersion())
96 $oApp = new application($this->iAppId
);
97 if($oApp->objectGetState() != 'accepted')
98 $this->sState
= 'pending';
100 $this->sState
= $this->mustBeQueued() ?
'queued' : 'accepted';
102 $hResult = query_parameters("INSERT INTO appVersion
103 (versionName, description, ratingRelease,
104 rating, appId, submitTime, submitterId,
106 VALUES ('?', '?', '?', '?', '?', ?, '?', '?', '?')",
107 $this->sName
, $this->sDescription
, $this->sTestedRelease
,
108 $this->sTestedRating
, $this->iAppId
, "NOW()",
109 $_SESSION['current']->iUserId
, $this->sState
,
114 $this->iVersionId
= query_appdb_insert_id();
115 $this->Version($this->iVersionId
);
116 $this->SendNotificationMail();
118 /* Submit maintainer request if asked to */
119 switch($this->iMaintainerRequest
)
121 case MAINTAINER_REQUEST
;
122 $oMaintainer = new Maintainer();
123 $oMaintainer->iAppId
= $this->iAppId
;
124 $oMaintainer->iVersionId
= $this->iVersionId
;
125 $oMaintainer->iUserId
= $_SESSION['current']->iUserId
;
126 $oMaintainer->sMaintainReason
= "This user submitted the version;".
128 $oMaintainer->bSuperMaintainer
= 0;
129 $oMaintainer->create();
132 case MONITOR_REQUEST
:
133 $oMonitor = new Monitor();
134 $oMonitor->iVersionId
= $this->iVersionId
;
135 $oMonitor->iUserId
= $_SESSION['current']->iUserId
;
136 $oMonitor->iAppId
= $this->iAppId
;
144 addmsg("Error while creating a new version", "red");
153 public function update($bSilent=false)
157 if(!$_SESSION['current']->hasAppVersionModifyPermission($this))
160 $oVersion = new Version($this->iVersionId
);
162 if ($this->sName
&& ($this->sName
!=$oVersion->sName
))
164 if (!query_parameters("UPDATE appVersion SET versionName = '?' WHERE versionId = '?'",
165 $this->sName
, $this->iVersionId
))
167 $sWhatChanged .= "Name was changed from:\n\t'".$oVersion->sName
."'\nto:\n\t'".$this->sName
."'\n\n";
170 if ($this->sDescription
&& ($this->sDescription
!=$oVersion->sDescription
))
172 if (!query_parameters("UPDATE appVersion SET description = '?' WHERE versionId = '?'",
173 $this->sDescription
, $this->iVersionId
))
176 if($oVersion->sDescription
!= "")
177 $sWhatChanged .= "Description was changed from\n ".$oVersion->sDescription
."\n to \n".$this->sDescription
.".\n\n";
179 $sWhatChanged .= "Description was changed to \n".$this->sDescription
.".\n\n";
182 if ($this->sTestedRelease
&& ($this->sTestedRelease
!=$oVersion->sTestedRelease
))
184 if (!query_parameters("UPDATE appVersion SET ratingRelease = '?' WHERE versionId = '?'",
185 $this->sTestedRelease
, $this->iVersionId
))
188 if($oVersion->sTestedRelease
!= "")
189 $sWhatChanged .= "Last tested release was changed from ".$oVersion->sTestedRelease
." to ".$this->sTestedRelease
.".\n\n";
191 $sWhatChanged .= "Last tested release was changed to ".$this->sTestedRelease
.".\n\n";
194 if ($this->sTestedRating
&& ($this->sTestedRating
!=$oVersion->sTestedRating
))
196 if (!query_parameters("UPDATE appVersion SET rating = '?' WHERE versionId = '?'",
197 $this->sTestedRating
, $this->iVersionId
))
200 if($this->sTestedRating
!= "")
201 $sWhatChanged .= "Rating was changed from ".$oVersion->sTestedRating
." to ".$this->sTestedRating
.".\n\n";
203 $sWhatChanged .= "Rating was changed to ".$this->sTestedRating
.".\n\n";
206 if ($this->iAppId
&& ($this->iAppId
!=$oVersion->iAppId
))
208 $oAppBefore = new Application($oVersion->iAppId
);
209 $oAppAfter = new Application($this->iAppId
);
211 if($oAppAfter->objectGetState() == 'accepted' && $this->sState
== 'pending')
212 $this->sState
= 'queued';
214 if (!query_parameters("UPDATE appVersion SET appId = '?', state = '?' WHERE versionId = '?'",
215 $this->iAppId
, $this->sState
, $this->iVersionId
))
218 $sWhatChanged .= "Version was moved from application ".$oAppBefore->sName
." to application ".$oAppAfter->sName
.".\n\n";
221 if ($this->sLicense
&& ($this->sLicense
!=$oVersion->sLicense
))
223 if(!query_parameters("UPDATE appVersion SET license = '?'
224 WHERE versionId = '?'",
225 $this->sLicense
, $this->iVersionId
))
228 $sWhatChanged .= "License was changed from $oVersion->sLicense to ".
229 "$this->sLicense.\n\n";
232 if($this->iObsoleteBy
!= $oVersion->iObsoleteBy
)
234 if(!query_parameters("UPDATE appVersion SET obsoleteBy = '?' WHERE versionId = '?'",
235 $this->iObsoleteBy
, $this->iVersionId
))
238 if($this->iObsoleteBy
)
239 $sWhatChanged .= "The version was marked as obsolete.\n\n";
241 $sWhatChanged .= "The version is no longer marked as obsolete.\n\n";
243 if($this->iObsoleteBy
)
245 query_parameters("UPDATE appVotes SET versionId = '?' WHERE versionId = '?'",
246 $this->iObsoleteBy
, $this->iVersionId
);
250 if($sWhatChanged and !$bSilent)
251 $this->SendNotificationMail("edit",$sWhatChanged);
256 * Removes the version from the database and
257 * requests the same action for child entries
259 public function purge()
261 /* We need the versionId to continue */
262 if(!$this->iVersionId
)
265 /* is the current user allowed to delete this version? */
266 if(!$_SESSION['current']->canDeleteVersion($this))
271 foreach($this->objectGetChildren(TRUE) as $oChild)
273 if(!$oChild->purge())
277 /* now remove the version from the DB */
278 $hResult = query_parameters("DELETE FROM appVersion
279 WHERE versionId = '?'
280 LIMIT 1", $this->iVersionId
);
288 * Flags the version as deleted
289 * and request the deletion of linked elements.
291 public function delete()
293 /* We need the versionId to continue */
294 if(!$this->iVersionId
)
297 /* is the current user allowed to delete this version? */
298 if(!$_SESSION['current']->canDeleteVersion($this))
303 foreach($this->objectGetChildren() as $oChild)
305 if(!$oChild->delete())
309 /* now flag the version as deleted */
310 $hResult = query_parameters("UPDATE appVersion SET state = 'deleted'
311 WHERE versionId = '?'
312 LIMIT 1", $this->iVersionId
);
320 * Move version out of the queue.
322 public function unQueue()
324 if(!$_SESSION['current']->canUnQueueVersion($this))
327 // If we are not in the queue, we can't move the version out of the queue.
328 if($this->sState
== 'accepted')
331 if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'",
332 'accepted', $this->iVersionId
))
334 $this->sState
= 'accepted';
335 // we send an e-mail to interested people
336 $this->mailSubmitter("add");
337 $this->SendNotificationMail();
339 /* Unqueue matching maintainer request */
340 $hResultMaint = query_parameters("SELECT maintainerId FROM
341 appMaintainers WHERE userId = '?' AND versionId = '?'",
342 $this->iSubmitterId
, $this->iVersionId
);
344 if($hResultMaint && query_num_rows($hResultMaint))
346 $oMaintainerRow = query_fetch_object($hResultMaint);
347 $oMaintainer = new Maintainer($oMaintainerRow->maintainerId
);
348 $oMaintainer->unQueue("OK");
353 public function Reject($bSilent=false)
355 if(!$_SESSION['current']->canRejectVersion($this))
358 // If we are not in the queue, we can't move the version out of the queue.
359 if($this->sState
!= 'queued')
362 if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'",
363 'rejected', $this->iVersionId
))
365 $this->sState
= 'rejected';
366 // we send an e-mail to interested people
369 $this->mailSubmitter("reject");
370 $this->SendNotificationMail("reject");
372 // the version has been unqueued
373 addmsg("The version has been rejected.", "green");
377 public function ReQueue()
379 if(!$_SESSION['current']->canRequeueVersion($this))
382 if(query_parameters("UPDATE appVersion SET state = '?' WHERE versionId = '?'",
383 'queued', $this->iVersionId
))
385 $this->sState
= 'queued';
386 // we send an e-mail to interested people
387 $this->SendNotificationMail();
389 // the version has been unqueued
390 addmsg("The version has been re-submitted", "green");
394 public function objectGetSubmitterId()
396 return $this->iSubmitterId
;
399 public static function objectGetMailOptions($sAction, $bMailSubmitter,
402 return new mailOptions();
405 public function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
407 $oApp = new application($this->iAppId
);
414 $sSubject = "Submitted version deleted";
415 $sMsg = "The version you submitted (".$oApp->sName
." ".$this->sName
.
416 ") has been deleted.";
425 $sSubject = "Version '".$this->sName
."' of '".$oApp->sName
."' ".
430 $aMailTo = User
::get_notify_email_address_list(null, $this->iVersionId
);
432 return array($sSubject, $sMsg, $aMailTo);
435 private function mailSubmitter($sAction="add")
437 global $aClean; //FIXME: we should pass the sReplyText value in
439 // use 'sReplyText' if it is defined, otherwise define the value as an empty string
440 if(!isset($aClean['sReplyText']))
441 $aClean['sReplyText'] = "";
443 if($this->iSubmitterId
)
445 $oApp = new Application($this->iAppId
);
446 $oSubmitter = new User($this->iSubmitterId
);
450 $sSubject = "Submitted version accepted";
451 $sMsg = "The version you submitted (".$oApp->sName
." ".$this->sName
.") has been accepted by ".$_SESSION['current']->sRealname
.".\n";
452 $sMsg .= "Administrators response:\n";
455 $sSubject = "Submitted version rejected";
456 $sMsg = "The version you submitted (".$oApp->sName
." ".$this->sName
.") has been rejected by ".$_SESSION['current']->sRealname
.".";
457 $sMsg .= "Clicking on the link in this email will allow you to modify and resubmit the version. ";
458 $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. ";
459 $sMsg .= APPDB_ROOT
."objectManager.php?sClass=version_queue".
460 "&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId
."&".
461 "sTitle=Edit+Version\n";
464 $sMsg .= $aClean['sReplyText']."\n";
465 $sMsg .= "We appreciate your help in making the Version Database better for all users.";
467 mail_appdb($oSubmitter->sEmail
, $sSubject ,$sMsg);
471 private function SendNotificationMail($sAction="add",$sMsg=null)
475 // use 'sReplyText' if it is defined, otherwise define the value as an empty string
476 if(!isset($aClean['sReplyText']))
477 $aClean['sReplyText'] = "";
479 $oApp = new Application($this->iAppId
);
483 if($this->sState
== 'accepted')
485 $sSubject = "Version ".$this->sName
." of ".$oApp->sName
." added by ".$_SESSION['current']->sRealname
;
486 $sMsg = $this->objectMakeUrl()."\n";
487 if($this->iSubmitterId
)
489 $oSubmitter = new User($this->iSubmitterId
);
490 $sMsg .= "This version has been submitted by ".$oSubmitter->sRealname
.".";
493 if($aClean['sReplyText'])
495 $sMsg .= "Appdb admin reply text:\n";
496 $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any
499 addmsg("The version was successfully added into the database.", "green");
500 } else // Version queued.
502 $sSubject = "Version '".$this->sName
."' of '".$oApp->sName
."' submitted by ".$_SESSION['current']->sRealname
;
503 $sMsg .= "This version has been queued.";
505 addmsg("The version you submitted will be added to the database after being reviewed.", "green");
509 $sSubject = "'".$oApp->sName
." ".$this->sName
."' has been modified by ".$_SESSION['current']->sRealname
;
510 $sMsg .= $this->objectMakeUrl()."\n";
511 addmsg("Version modified.", "green");
515 // if sReplyText is set we should report the reason the application was deleted
516 if($aClean['sReplyText'])
518 $sMsg .= "Reason given:\n";
519 $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any
522 addmsg("Version deleted.", "green");
525 $sSubject = "Version '".$this->sName
."' of '".$oApp->sName
."' has been rejected by ".$_SESSION['current']->sRealname
;
526 $sMsg .= APPDB_ROOT
."objectManager.php?sClass=version_queue".
527 "&bIsQueue=true&bIsRejected=true&iId=".$this->iVersionId
."&".
528 "sTitle=Edit+Version\n";
530 // if sReplyText is set we should report the reason the version was rejected
531 if($aClean['sReplyText'])
533 $sMsg .= "Reason given:\n";
534 $sMsg .= $aClean['sReplyText']."\n"; // append the reply text, if there is any
537 addmsg("Version rejected.", "green");
540 $sEmail = User
::get_notify_email_address_list(null, $this->iVersionId
);
542 mail_appdb($sEmail, $sSubject ,$sMsg);
545 public function get_buglink_ids()
548 * We fetch Bug linkIds.
550 $aBuglinkIds = array();
553 WHERE versionId = '?'
555 if($hResult = query_parameters($sQuery, $this->iVersionId
))
557 while($oRow = query_fetch_object($hResult))
559 $aBuglinkIds[] = $oRow->linkId
;
566 /* Makes a frame with title 'Mark as obsolete' and info about what it means, plus
567 caller-defined content */
568 private static function makeObsoleteFrame($sContent = "")
570 $sMsg = html_frame_start("Mark as obsolete", "90%", "", 0);
572 $sMsg .= "Some applications need to be updated from time to time in order to ";
573 $sMsg .= "be of any use. An example is online multi-player games, where you need ";
574 $sMsg .= "to be running a version compatible with the server. ";
575 $sMsg .= "If this is such an application, and this version is no longer usable, ";
576 $sMsg .= "you can mark it as obsolete and move its current votes to a usable ";
577 $sMsg .= "version instead.<br><br>";
581 $sMsg .= html_frame_end();
586 /* output html and the current versions information for editing */
587 /* if $editParentApplication is true that means we need to display fields */
588 /* to let the user change the parent application of this version */
589 /* otherwise, if $editParentAppliation is false, we leave them out */
590 public function outputEditor()
592 HtmlAreaLoaderScript(array("version_editor"));
593 echo html_frame_start("Version Form", "90%", "", 0);
595 echo '<input type="hidden" name="iVersionId" value="'.$this->iVersionId
.'">';
597 $oTable = new Table();
598 $oTable->SetClass("color0");
599 $oTable->SetWidth("100%");
600 $oTable->SetBorder(0);
601 $oTable->SetCellPadding(2);
602 $oTable->SetCellSpacing(0);
604 /* Fill in appId value */
607 $this->iAppId
= $aClean['iAppId'];
609 if($this->sState
== 'accepted' && $this->iVersionId
)
612 $x = new TableVE("view");
613 $oTableRow = new TableRow();
614 $oTableRow->SetValign("top");
616 $oTableCell = new TableCell("Application");
617 $oTableCell->SetBold(true);
618 $oTableRow->AddCell($oTableCell);
620 $sOptionList = $x->make_option_list("iAppId", $this->iAppId
,
621 "appFamily", "appId", "appName");
622 $oTableCell = new TableCell($sOptionList);
623 $oTableCell->SetClass("color0");
625 $oTableRow->AddCell($oTableCell);
627 $oTable->AddRow($oTableRow);
630 echo '<input type="hidden" name="iAppId" value="'.$this->iAppId
.'">';
634 $oTableRow = new TableRow();
635 $oTableRow->SetValign("top");
637 $oTableCell = new TableCell("Version Name");
638 $oTableCell->SetBold(true);
639 $oTableCell->SetClass("color0");
640 $oTableRow->AddCell($oTableCell);
642 $oTableRow->AddTextCell('<input size="20" type="text" name="sVersionName" value="'.$this->sName
.'">');
644 $oTable->AddRow($oTableRow);
647 $oTableRow = new TableRow();
648 $oTableCell = new TableCell("License");
649 $oTableCell->SetBold(true);
650 $oTableCell->SetClass("color0");
651 $oTableRow->AddCell($oTableCell);
653 $oTableRow->AddTextCell($this->makeLicenseList());
655 $oTable->AddRow($oTableRow);
657 // version description
658 $oTableRow = new TableRow();
659 $oTableRow->SetValign("top");
661 $oTableCell = new TableCell("Version description");
662 $oTableCell->SetBold(true);
663 $oTableCell->SetClass("color0");
664 $oTableRow->AddCell($oTableCell);
666 $oTableRow->AddTextCell('<p><textarea cols="80" rows="20" id="version_editor" name="shVersionDescription">'.
667 $this->sDescription
.'</textarea></p>');
669 $oTable->AddRow($oTableRow);
672 echo $oTable->GetString();
674 echo html_frame_end();
676 if($this->sState
== 'accepted' && $this->iVersionId
)
678 /* Mark as obsolete */
679 $oApp = new application($this->iAppId
);
680 $oVersionInDB = new version($this->iVersionId
);
682 if($oVersionInDB->iObsoleteBy
)
684 $sObsoleteTxt = "<input type=\"checkbox\" name=\"bObsolete\" value=\"true\" checked=\"checked\">";
685 $sObsoleteTxt .= " This version is obsolete";
686 echo $this->makeObsoleteFrame($sObsoleteTxt);
688 echo "<input type=\"hidden\" name=\"iObsoleteBy\" value=\"".
689 $oVersionInDB->iObsoleteBy
."\" type=\"hidden\" >\n";
690 } else if(sizeof($oApp->getVersions(TRUE, FALSE)) > 1)
692 if($this->iObsoleteBy
)
693 $sObsolete = "checked=\"checked\"";
697 $sObsoleteTxt = "<input type=\"checkbox\" name=\"bObsolete\" value=\"true\"$sObsolete >";
698 $sObsoleteTxt .= "Mark as obsolete and move votes to \n";
699 $sObsoleteTxt .= $oApp->makeVersionDropDownList("iObsoleteBy", $this->iObsoleteBy
, $this->iVersionId
, FALSE);
701 echo $this->makeObsoleteFrame($sObsoleteTxt);
705 echo '<input type="hidden" name="sMaintainerRating" value="'.$this->sTestedRating
.'">';
706 echo '<input type="hidden" name="sMaintainerRelease" value="'.$this->sTestedRelease
.'">';
710 public function CheckOutputEditorInput($aValues)
714 if (empty($aValues['sVersionName']))
715 $errors .= "<li>Please enter an application version.</li>\n";
717 if (empty($aValues['shVersionDescription']))
718 $errors .= "<li>Please enter a version description.</li>\n";
723 /* retrieves values from $aValues that were output by outputEditor() */
724 /* $aValues can be $_REQUEST or any array with the values from outputEditor() */
725 public function GetOutputEditorValues($aValues)
727 if($aValues['iAppId'])
728 $this->iAppId
= $aValues['iAppId'];
730 if($aValues['iVersionId'])
731 $this->iVersionId
= $aValues['iVersionId'];
733 $this->sName
= $aValues['sVersionName'];
734 $this->sDescription
= $aValues['shVersionDescription'];
735 $this->sLicense
= $aValues['sLicense'];
736 $this->iMaintainerRequest
= $aValues['iMaintainerRequest'];
738 if($aValues['bObsolete'] == "true")
739 $this->iObsoleteBy
= $aValues['iObsoleteBy'];
741 $this->iObsoleteBy
= 0;
744 public function objectGetCustomTitle($sAction)
749 return 'Delete '.version
::fullName($this->iVersionId
);
751 return version
::fullName($this->iVersionId
);
758 public static function objectGetCustomVars($sAction)
763 /* Allow the user to select which test report is
764 shown in the version view */
765 return array("iTestingId");
772 public function objectShowPreview()
777 /* Not standard OM function yet, but will be in the future */
778 public function objectGetParent()
780 /* No id so we can't query the DB, but perhaps an entry is cached? */
784 return new application($this->iAppId
);
787 public function getRatingInfo()
789 return testData
::getRatingInfoForVersionId($this->iVersionId
);
792 public function updateRatingInfo()
794 $aRatingInfo = $this->getRatingInfo();
796 $hResult = query_parameters("UPDATE appVersion SET
799 WHERE versionId = '?'",
810 public function display($aVars = array())
812 /* is this user supposed to view this version? */
813 if(!$_SESSION['current']->canViewVersion($this))
814 util_show_error_page_and_exit("Something went wrong with the application or version id");
816 $iTestingId = $aVars['iTestingId'] ?
$aVars['iTestingId'] : 0;
818 $oApp = $this->objectGetParent();
821 $oCategory = new Category($oApp->iCatId
);
822 $oCategory->display($oApp->iAppId
, $this->iVersionId
);
825 $appLinkURL = ($oApp->sWebpage
) ?
trimmed_link($oApp->sWebpage
,30) : " ";
827 // start version display
828 echo html_frame_start("","98%","",0);
829 echo '<tr><td class="color4" valign="top">',"\n";
830 echo '<table width="250" border="0" cellpadding="3" cellspacing="1">',"\n";
831 echo "<tr class=\"color0\" valign=\"top\"><td width=\"100\"> <b>Name</b></td><td width=\"100%\">".$oApp->sName
."</td>\n";
832 echo "<tr class=\"color1\" valign=\"top\"><td><b>Version</b></td><td>".$this->sName
."</td></tr>\n";
839 echo " <tr class=\"color1\"><td><b>URL</b></td><td>".$appLinkURL."</td></tr>\n";
842 if(!$this->iObsoleteBy
)
844 $oM = new objectManager("voteManager", "Vote");
845 $oM->setReturnTo($this->objectMakeUrl());
847 if($_SESSION['current']->isLoggedIn())
848 $shVoteLink = ' <a href="'.$oM->makeUrl("edit", $_SESSION['current']->iUserId
).'&iVersionId='.$this->iVersionId
.'">Vote</a>';
852 $shVoteText = vote_count_version_total($this->iVersionId
).$shVoteLink;
855 $shVoteText = 'Marked as obsolete';
858 echo html_tr(array('<b>Votes</b>', $shVoteText), 'color0');
860 $sRating = $this->sTestedRating
;
861 $sRelease = $this->sTestedRelease
;
862 if($sRating != "/" && $sRating)
863 $sRatingColor = $sRating;
865 $sRatingColor = 'color0';
868 if($sUrls = url
::display($this->iVersionId
))
874 echo "<tr class=\"$sRatingColor\" valign=\"top\"><td><b>Rating</b></td><td>".$sRating."</td></tr>\n";
875 echo "<tr class=\"$sRatingColor\" valign=\"top\"><td><b>Wine Version</b></td><td>".$sRelease."</td></tr>\n";
878 if($sDownloadurls = downloadurl
::display($this->iVersionId
))
882 $img = Screenshot
::get_random_screenshot_img($oApp->iAppId
, $this->iVersionId
, false);
883 echo "<tr><td align=\"center\" colspan=\"2\">$img</td></tr>\n";
885 // display all maintainers of this application
886 echo "<tr class=\"color0\"><td align=\"left\" colspan=\"2\"><b>Maintainers of this version:</b>\n";
887 echo "<table width=\"250\" border=\"0\">";
888 $aMaintainers = $this->getMaintainersUserIds();
889 if(sizeof($aMaintainers)>0)
891 echo "<tr class=\"color0\"><td align=\"left\" colspan=\"2\"><ul>";
892 while(list($index, $userIdValue) = each($aMaintainers))
894 $oUser = new User($userIdValue);
895 echo "<li>".$oUser->objectMakeLink()."</li>";
897 echo "</ul></td></tr>\n";
900 echo "<tr class=color0><td align=right colspan=2>";
901 echo "No maintainers. Volunteer today!</td></tr>\n";
903 echo "</table></td></tr>\n";
905 // display the app maintainer button
906 echo '<tr><td colspan="2" align="center">'."\n";
907 if($_SESSION['current']->isLoggedIn())
909 /* is this user a maintainer of this version by virtue of being a super maintainer */
910 /* of this app family? */
911 if($_SESSION['current']->isSuperMaintainer($oApp->iAppId
))
913 echo '<form method="post" name="sMessage" action="maintainerdelete.php">'."\n";
914 echo "\t".'<input type="submit" value="Remove yourself as a super maintainer" class="button">'."\n";
915 echo "\t".'<input type="hidden" name="iSuperMaintainer" value="1">'."\n";
916 echo "\t<input type=hidden name=\"iAppId\" value=\"".$oApp->iAppId
."\">\n";
917 echo "\t<input type=hidden name=\"iVersionId\" value=\"".$this->iVersionId
."\">\n";
921 /* are we already a maintainer? */
922 if($_SESSION['current']->isMaintainer($this->iVersionId
)) /* yep */
924 echo '<form method="post" name="sMessage" action="maintainerdelete.php">'."\n";
925 echo "\t".'<input type="submit" value="Remove yourself as a maintainer" class=button>'."\n";
926 echo "\t".'<input type="hidden" name="iSuperMaintainer" value="0">'."\n";
927 echo "\t"."<input type=hidden name=\"iAppId\" value=\"".$oApp->iAppId
."\">\n";
928 echo "\t"."<input type=hidden name=\"iVersionId\" value=\"".$this->iVersionId
."\">\n";
932 echo '<form method="post" name="sMessage" action="objectManager.php?sClass=maintainer&sAction=add&iVersionId='.$this->iVersionId
.'&sTitle='.urlencode("Be a Maintainer of ".version
::fullName($this->iVersionId
)).'&sReturnTo='.urlencode($this->objectMakeUrl()).'">'."\n";
933 echo "\t".'<input type="submit" value="Be a Maintainer of This Version" class="button" title="Click here to know more about maintainers.">'."\n";
934 echo "\t"."<input type=hidden name=\"iAppId\" value=\"".$oApp->iAppId
."\">\n";
935 echo "\t"."<input type=hidden name=\"iVersionId\" value=\"".$this->iVersionId
."\">\n";
937 $oMonitor = new Monitor();
938 $oMonitor->find($_SESSION['current']->iUserId
, $this->iVersionId
);
939 if(!$oMonitor->iMonitorId
)
941 echo '<form method="post" name="sMessage" action="'.
942 APPDB_ROOT
."objectManager.php\">\n";
943 echo "\t<input type=\"hidden\" name=\"iAppId\" value=\"".
944 $this->iAppId
."\" >\n";
945 echo "\t<input type=\"hidden\" name=\"iVersionId\" value=\"".
946 $this->iVersionId
."\" >\n";
947 echo "\t<input type=\"hidden\" name=\"sSubmit\" value=\"Submit\" >\n";
948 echo "\t<input type=\"hidden\" name=\"sClass\" value=\"monitor\" >\n";
949 echo "\t<input type=\"hidden\" name=\"sReturnTo\" value=\"".
950 $this->objectMakeUrl()."\" >\n";
951 echo "\t".'<input type=submit value="Monitor Changes" class="button">'."\n";
959 echo '<form method="post" name="sMessage" action="account.php">'."\n";
960 echo "\t".'<input type="hidden" name="sCmd" value="login">'."\n";
961 echo "\t".'<input type=submit value="Log in to become an app maintainer" class="button">'."\n";
967 if ($_SESSION['current']->hasPriv("admin") ||
$_SESSION['current']->isMaintainer($this->iVersionId
) ||
$_SESSION['current']->isSuperMaintainer($this->iAppId
))
969 $shAdd = '<form method="post" name="sMessage" action="objectManager.php?sClass=note&sAction=add&iVersionId='.$this->iVersionId
.'&sReturnTo='.urlencode($this->objectMakeUrl());
970 echo '<tr><td colspan="2" align="center">'."\n";
971 echo '<form method="post" name="sMessage" action="admin/editAppVersion.php">'."\n";
972 echo "\t".'<input type="hidden" name="iAppId" value="'.$oApp->iAppId
.'">'."\n";
973 echo "\t".'<input type="hidden" name="iVersionId" value="'.$this->iVersionId
.'">'."\n";
974 echo "\t".'<input type=submit value="Edit Version" class="button">'."\n";
976 $url = BASE
."objectManager.php?sClass=version&sAction=delete&bQueued=false&iId=".$this->iVersionId
;
977 echo "<form method=\"post\" name=\"sDelete\" action=\"javascript:self.location = '".$url."'\">\n";
978 echo "\t".'<input type=submit value="Delete Version" class="button">'."\n";
981 echo "\t".'<input type="submit" value="Add Note" class="button">'."\n";
983 echo $shAdd.'&sNoteTitle=HOWTO" />';
984 echo "\t".'<input type=submit value="Add How To" class="button">'."\n";
986 echo $shAdd.'&sNoteTitle=WARNING" />';
987 echo "\t".'<input type=submit value="Add Warning" class="button">'."\n";
991 $oMonitor = new Monitor();
992 $oMonitor->find($_SESSION['current']->iUserId
, $this->iVersionId
);
993 if($oMonitor->iMonitorId
)
995 echo '<tr><td colspan="2" align="center">'."\n";
997 echo '<form method="post" name="sMessage" action="'.
998 APPDB_ROOT
."objectManager.php\">\n";
999 echo "\t<input type=\"hidden\" name=\"iId\" value=\"".
1000 $oMonitor->iMonitorId
."\">\n";
1001 echo "\t<input type=\"hidden\" name=\"sSubmit\" value=\"Delete\">\n";
1002 echo "\t<input type=\"hidden\" name=\"sClass\" value=\"monitor\">\n";
1003 echo "\t<input type=\"hidden\" name=\"sReturnTo\" value=\"".
1004 $this->objectMakeUrl()."\">\n";
1005 echo '<input type=submit value="Stop Monitoring Version" class="button" >'."\n";
1007 echo "</td></tr>\n";
1011 // start of the right hand pane in the version display
1012 echo "<td class=color2 valign=top width='100%'>\n";
1013 echo "<div class='version_info_pane'>\n";
1015 /////////////////////////
1016 // output the description
1017 echo "<div class='info_container'>\n";
1019 // output the description title
1020 echo "\t<div class='title_class'>\n";
1021 echo "\t\tDescription\n";
1024 // output the description
1025 echo "\t<div class='info_contents'>\n";
1026 echo "\t\t".$this->sDescription
."\n";
1029 echo "</div>\n"; // end the 'info_container' div
1031 /////////////////////////
1034 //////////////////////
1040 /* Set if the use chose to display a particular test report */
1043 $oTest = new testData($iTestingId);
1044 $oTestParent = $oTest->objectGetParent();
1046 /* Check that the test report doesn't belong to another version */
1047 if($oTestParent->objectGetId() && $oTestParent->objectGetId() != $this->objectGetId())
1051 if(!$oTest && $this->iVersionId
) /* Let's query for the latest rest report */
1053 $iNewestId = testData
::getNewestTestIdFromVersionId($this->iVersionId
);
1054 $iTestingId = $iNewestId;
1056 if($iTestingId) /* We want all entries to have test data, but old versions might lack
1057 it, or data may have been deleted */
1058 $oTest = new testData($iTestingId);
1059 } else if(!$oTest) /* Perhaps we have a cached entry? There should be */
1061 $aTests = $this->getTestResults();
1063 if(sizeof($aTests)) /* ... but we cannot be certain */
1064 $oTest = $aTests[0];
1071 if($iNewestId != $oTest->objectGetId())
1073 $sWarnOldText = 'The test results you have selected are very old and may not represent the current state of Wine.';
1076 $sWarnOldText = 'The test results for this version are very old, and as such they may not represent '.
1077 'the current state of Wine. Please consider submitting a new test report.';
1079 echo html_note('Old test results', $sWarnOldText);
1082 echo "<div class='info_container'>\n";
1084 echo "\t<div class='title_class'>\n";
1085 echo "\t\tSelected test results <small><small>(selected in 'Test Results' table below)</small></small>\n";
1088 echo "<div class='info_contents'>\n";
1090 $oTest->ShowTestResult();
1095 } else /* Show a note saying that no test results are present,
1096 and encourage the user to take action */
1098 echo html_note('No Test Results',
1099 'This version has no test results, please consider submitting some.<br>'.
1100 'They may be part of the '.
1101 'version or application description. If they are, please '.
1102 'consider becoming a maintainer and remove them, submitting '.
1103 'a proper test report instead.');
1106 // end the 'info_container' div
1107 // end show test data
1108 /////////////////////
1111 //////////////////////////////
1112 // show the test results table
1115 if($oTest->iTestingId
)
1117 $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", 5);
1118 } else /* We are previewing the version */
1120 $oTable = $oTest->CreateTestTable();
1121 $oTable->AddRow($oTest->CreateTestTableRow(0, ""));
1122 echo $oTable->GetString();
1126 if($_SESSION['current']->isLoggedIn())
1128 echo '<form method=post name=sMessage action=objectManager.php?'.
1129 'sClass=testData_queue&sAction=add&iVersionId='.$this->iVersionId
.
1130 '&sTitle=Add+Test+Data&sReturnTo='.
1131 urlencode($this->objectMakeUrl()).'>'."\n";
1132 echo "\t".'<input type=submit value="Add Test Data" class="button" >'."\n";
1133 echo '</form>'."\n";
1136 echo '<form method="post" name="sMessage" action="'.login_url().'">'."\n";
1137 echo "\t".'<input type="hidden" name="sCmd" value="login">'."\n";
1138 echo "\t".'<input type=submit value="Log in to add test data" class="button">'."\n";
1139 echo '</form>'."\n";
1142 // end show test results table
1143 /////////////////////////////
1146 echo "</div>\n"; // end the version info pane, the right hand pane in the
1149 echo html_frame_end();
1151 view_version_bugs($this->iVersionId
, $this->get_buglink_ids());
1153 /* display the notes for the application */
1154 $hNotes = query_parameters("SELECT noteId FROM appNotes WHERE versionId = '?'",
1157 while( $oRow = query_fetch_object($hNotes) )
1159 $oNote = new Note($oRow->noteId
);
1164 if($this->iVersionId
)
1165 Comment
::view_app_comments($this->iVersionId
);
1168 public static function lookup_name($versionId)
1170 if(!$versionId) return null;
1171 $result = query_parameters("SELECT versionName FROM appVersion WHERE versionId = '?'",
1173 if(!$result ||
query_num_rows($result) != 1)
1175 $ob = query_fetch_object($result);
1176 return $ob->versionName
;
1179 function fullName($iVersionId)
1184 $hResult = query_parameters(
1185 "SELECT appFamily.appName, appVersion.versionName
1186 FROM appVersion, appFamily WHERE appVersion.appId = appFamily.appId
1187 AND versionId = '?'",
1190 if(!$hResult ||
!query_num_rows($hResult))
1193 $oRow = query_fetch_object($hResult);
1194 return "$oRow->appName $oRow->versionName";
1197 /* Creates a link to the version labelled with the full application name */
1198 public static function fullNameLink($iVersionId)
1200 $oVersion = new version($iVersionId);
1201 $sLink = "<a href=\"".$oVersion->objectMakeUrl()."\">".
1202 $oVersion->fullName($iVersionId)."</a>";
1206 // display the versions
1207 public static function displayList($aVersions)
1211 echo html_frame_start("","98%","",0);
1213 $oTable = new Table();
1214 $oTable->SetWidth("100%");
1215 $oTable->SetBorder(0);
1216 $oTable->SetCellPadding(3);
1217 $oTable->SetCellSpacing(1);
1219 $oTableRow = new TableRow();
1220 $oTableRow->SetClass("color4");
1222 $oTableCell = new TableCell("Version");
1223 $oTableCell->SetWidth("80");
1224 $oTableRow->AddCell($oTableCell);
1226 $oTableRow->AddTextCell("Description");
1228 $oTableCell = new TableCell("Rating");
1229 $oTableCell->SetWidth("80");
1230 $oTableRow->AddCell($oTableCell);
1232 $oTableCell = new TableCell("Wine version");
1233 $oTableCell->SetWidth("80");
1234 $oTableRow->AddCell($oTableCell);
1236 $oTableCell = new TableCell("Test results");
1237 $oTableCell->SetWidth("80");
1238 $oTableRow->AddCell($oTableCell);
1240 $oTableCell = new TableCell("Comments");
1241 $oTableCell->SetWidth("40");
1242 $oTableRow->AddCell($oTableCell);
1244 $oTable->SetHeader($oTableRow);
1247 foreach($aVersions as $oVersion)
1249 $oApp = new application($oVersion->iAppId
);
1251 if ($oVersion->sState
== $oApp->objectGetState())
1254 $bgcolor = ($c %
2 == 0) ?
"color0" : "color1";
1256 $oTableRowHighlight = null;
1258 // if we have a valid tested rating
1259 if($oVersion->sTestedRating
&& ($oVersion->sTestedRating
!= "/") &&
1260 ($oVersion->sTestedRating
!= " "))
1262 $sClass = $oVersion->sTestedRating
;
1264 $oInactiveColor = new Color();
1265 $oInactiveColor->SetColorByName($oVersion->sTestedRating
);
1267 $oHighlightColor = GetHighlightColorFromInactiveColor($oInactiveColor);
1269 $oTableRowHighlight = new TableRowHighlight($oHighlightColor, $oInactiveColor);
1274 $oTableRowHighlight = GetStandardRowHighlight($c);
1278 $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl());
1279 $oTableRowClick->SetHighlight($oTableRowHighlight);
1281 $oTableRow = new TableRow();
1282 $oTableRow->SetRowClick($oTableRowClick); // make the row clickable
1283 $oTableRow->AddTextCell($oVersion->objectMakeLink());
1284 $oTableRow->SetClass($sClass);
1285 $oTableRow->AddTextCell(util_trim_description($oVersion->sDescription
));
1287 $oTableCell = new TableCell($oVersion->sTestedRating
);
1288 $oTableCell->SetAlign("center");
1289 $oTableRow->AddCell($oTableCell);
1291 $oTableCell = new TableCell($oVersion->sTestedRelease
);
1292 $oTableCell->SetAlign("center");
1293 $oTableRow->AddCell($oTableCell);
1295 $oTableCell = new TableCell(testData
::get_testdata_count_for_versionid($oVersion->iVersionId
));
1296 $oTableCell->SetAlign("center");
1297 $oTableRow->AddCell($oTableCell);
1299 $oTableCell = new TableCell(Comment
::get_comment_count_for_versionid($oVersion->iVersionId
));
1300 $oTableCell->SetAlign("center");
1301 $oTableRow->AddCell($oTableCell);
1303 // add the row to the table
1304 $oTable->AddRow($oTableRow);
1311 echo $oTable->GetString();
1313 echo html_frame_end("Click the Version Name to view the details of that Version");
1317 /* returns the maintainers of this version in an array */
1318 public function getMaintainersUserIds()
1320 $aMaintainers = array();
1322 /* early out if the versionId isn't valid */
1323 if($this->iVersionId
== 0)
1324 return $aMaintainers;
1326 $hResult = Maintainer
::getMaintainersForAppIdVersionId(null, $this->iVersionId
);
1328 while($oRow = query_fetch_object($hResult))
1330 $aMaintainers[$iCount] = $oRow->userId
;
1334 return $aMaintainers;
1337 /* List the versions submitted by a user. Ignore versions for queued applications */
1338 public static function listSubmittedBy($iUserId, $bQueued = true)
1340 $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');
1342 if(!$hResult ||
!query_num_rows($hResult))
1345 $oTable = new Table();
1346 $oTable->SetWidth("100%");
1347 $oTable->SetAlign("center");
1349 // setup the table header
1350 $oTableRow = new TableRow();
1351 $oTableRow->AddTextCell("Name");
1352 $oTableRow->AddTextCell("Description");
1353 $oTableRow->AddTextCell("Submission Date");
1354 $oTableRow->SetClass("color4");
1355 $oTable->SetHeader($oTableRow);
1358 $oTableRow->addTextCell('Action');
1360 for($i = 1; $oRow = query_fetch_object($hResult); $i++
)
1362 $oTableRow = new TableRow();
1363 $oTableRow->AddTextCell(version
::fullNameLink($oRow->versionId
));
1364 $oTableRow->AddTextCell($oRow->description
);
1365 $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime
)));
1366 $oTableRow->SetClass(($i %
2) ?
"color0" : "color1");
1370 $oM = new objectManager('version_queue');
1371 $oM->setReturnTo(array_key_exists('REQUEST_URI', $_SERVER) ?
$_SERVER['REQUEST_URI'] : "");
1372 $shDeleteLink = '<a href="'.$oM->makeUrl('delete', $oRow->versionId
, 'Delete entry').'">delete</a>';
1373 $shEditLink = '<a href="'.$oM->makeUrl('edit', $oRow->versionId
, 'Edit entry').'">edit</a>';
1374 $oTableRow->addTextCell("[ $shEditLink ] [ $shDeleteLink ]");
1377 $oTable->AddRow($oTableRow);
1380 return $oTable->GetString();
1383 /* Returns an array containg the different software licences */
1384 public function getLicenses()
1386 return array(LICENSE_RETAIL
, LICENSE_OPENSOURCE
, LICENSE_FREETOUSE
,
1387 LICENSE_FREETOSHARE
, LICENSE_DEMO
, LICENSE_SHAREWARE
);
1390 // returns a string containing the html for a selection list
1391 public function makeLicenseList($sLicense = NULL)
1394 $sLicense = $this->sLicense
;
1396 $sReturn = "<select name=\"sLicense\">\n";
1397 $sReturn .= "<option value=\"\">Choose . . .</option>\n";
1398 $aLicense = version
::getLicenses();
1399 $iMax = count($aLicense);
1401 for($i = 0; $i < $iMax; $i++
)
1403 if($aLicense[$i] == $sLicense)
1404 $sSelected = " selected=\"selected\"";
1408 $sReturn .= "<option value=\"$aLicense[$i]\"$sSelected>".
1409 "$aLicense[$i]</option>\n";
1412 $sReturn .= "</select>\n";
1417 /* In order to prevent MySQL injections. Returns matched license */
1418 public static function checkLicense($sLicense)
1420 $aLicense = array(LICENSE_RETAIL
, LICENSE_OPENSOURCE
, LICENSE_FREETOUSE
,
1421 LICENSE_FREETOSHARE
, LICENSE_DEMO
, LICENSE_SHAREWARE
);
1423 foreach($aLicense as $sElement)
1425 if($sLicense == $sElement)
1432 public function objectMakeUrl()
1434 return APPDB_ROOT
."objectManager.php?sClass=version&iId=$this->iVersionId";
1437 public function objectMakeLink()
1439 $sLink = "<a href=\"".$this->objectMakeUrl()."\">".
1440 $this->sName
."</a>";
1444 public static function objectGetEntriesCount($sState)
1446 $oVersion = new version();
1447 if($sState != 'accepted' && !$oVersion->canEdit())
1449 /* Users should see their own rejected entries, but maintainers should
1450 not be able to see rejected entries for versions they maintain */
1451 if($sState == 'rejected')
1452 $sQuery = "SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
1454 appVersion.submitterId = '?'
1456 appVersion.state = '?'";
1458 $sQuery = "SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
1459 appVersion, appMaintainers WHERE
1460 appMaintainers.appId = appVersion.appId
1462 superMaintainer = '1'
1464 appMaintainers.userId = '?'
1466 appMaintainers.state = 'accepted'
1468 appVersion.state = '?'";
1470 $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId
, $sState);
1473 $sQuery = "SELECT COUNT(DISTINCT versionId) as count
1474 FROM appVersion WHERE
1475 appVersion.state = '?'";
1476 $hResult = query_parameters($sQuery, $sState);
1482 if(!$oRow = query_fetch_object($hResult))
1485 return $oRow->count
;
1488 public function objectGetState()
1490 return $this->sState
;
1493 public function objectSetState($sState)
1495 $this->sState
= $sState;
1498 public function canEdit()
1500 if($_SESSION['current']->hasPriv("admin"))
1503 if(isset($this) && is_object($this) && $this->iVersionId
)
1505 if(maintainer
::isUserMaintainer($_SESSION['current'], $this->iVersionId
))
1508 if($this->sState
!= 'accepted' && $this->iSubmitterId
== $_SESSION['current']->iUserId
)
1518 public function mustBeQueued()
1520 if($_SESSION['current']->hasPriv("admin"))
1523 // if we have a valid iAppId or iVersionId we should
1524 // check the status of these objects to determine whether
1525 // we need to queue this version object
1526 if($this->iVersionId
or $this->iAppId
)
1528 // if the user is the super maintainer of the application then
1529 // they are authorized to unqueue versions of this application
1530 // so the version doesn't have to be queued
1532 maintainer
::isUserSuperMaintainer($_SESSION['current'], $this->iAppId
))
1535 // if the user is a maintainer of this version then
1536 // this version doesn't have to be queued
1537 if($this->iVersionId
&&
1538 maintainer
::isUserMaintainer($_SESSION['current'], $this->iVersionId
))
1548 public static function objectGetHeader()
1550 $oTableRow = new TableRow();
1551 $oTableRow->AddTextCell("Submission Date");
1552 $oTableRow->AddTextCell("Submitter");
1553 $oTableRow->AddTextCell("Vendor");
1554 $oTableRow->AddTextCell("Application");
1555 $oTableRow->AddTextCell("Version");
1556 $oTableRow->AddTextCell("Has Maintainer");
1560 public static function objectGetItemsPerPage($sState = 'accepted')
1562 $aItemsPerPage = array(25, 50, 100, 200);
1563 $iDefaultPerPage = 25;
1564 return array($aItemsPerPage, $iDefaultPerPage);
1567 public static function objectGetDefaultSort()
1572 public static function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "versionId", $bAscending = true)
1576 /* Should we add a limit clause to the query? */
1577 if($iRows ||
$iStart)
1579 $sLimit = " LIMIT ?,?";
1581 /* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
1582 after an offset given by iStart */
1584 $iRows = version
::objectGetEntriesCount($sState);
1587 if($sState != 'accepted' && !version
::canEdit())
1589 /* Users should see their own rejected entries, but maintainers should
1590 not be able to see rejected entries for versions they maintain */
1591 if($sState == 'rejected')
1592 $sQuery = "SELECT * FROM appVersion WHERE
1593 appVersion.submitterId = '?'
1595 appVersion.state = '?' ORDER BY ?$sLimit";
1597 $sQuery = "SELECT appVersion.* FROM
1598 appVersion, appMaintainers WHERE
1599 appMaintainers.appId = appVersion.appId
1601 superMaintainer = '1'
1603 appMaintainers.userId = '?'
1605 appMaintainers.state = 'accepted'
1607 appVersion.state = '?' ORDER BY ?$sLimit";
1611 $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId
,
1612 $sState, $sOrderBy, $iStart, $iRows);
1615 $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId
,
1616 $sState, $sOrderBy);
1620 $sQuery = "SELECT * FROM appVersion WHERE
1621 appVersion.state = '?' ORDER BY ?$sLimit";
1625 $hResult = query_parameters($sQuery, $sState, $sOrderBy,
1629 $hResult = query_parameters($sQuery, $sState, $sOrderBy);
1639 public function objectGetTableRow()
1641 $oUser = new user($this->iSubmitterId
);
1642 $oApp = new application($this->iAppId
);
1643 $oVendor = new vendor($oApp->iVendorId
);
1645 $aMaintainers = Maintainer
::getSuperMaintainersUserIdsFromAppId($this->iAppId
);
1647 $oTableRow = new TableRow();
1648 $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime
)));
1649 $oTableRow->AddTextCell($oUser->objectMakeLink());
1650 $oTableRow->AddTextCell($oVendor->objectMakeLink());
1651 $oTableRow->AddTextCell($oApp->objectMakeLink());
1652 $oTableRow->AddTextCell($this->sName
);
1653 $oTableRow->AddTextCell(sizeof($aMaintainers) ?
"YES" : "No");
1655 $oOMTableRow = new OMTableRow($oTableRow);
1656 return $oOMTableRow;
1659 public function objectDisplayQueueProcessingHelp()
1661 echo "<p>This is the list of version entries waiting to be processed.</p>\n";
1662 echo "<p>To view and process an entry, use the links under ‘Action’</p>";
1665 public function getTestResults($bIncludeDeleted = false)
1667 /* If we don't have an id we can't query the database, but perhaps we
1668 have some cached entries? */
1669 if(!$this->iVersionId
)
1670 return $this->aTestResults
;
1674 if($bIncludeDeleted)
1675 $sExcludeDeleted = "";
1677 $sExcludeDeleted = " AND state != 'deleted'";
1679 /* Find test results */
1680 $sQuery = "SELECT * FROM testResults WHERE versionId = '?'$sExcludeDeleted";
1681 $hResult = query_parameters($sQuery, $this->iVersionId
);
1686 while($oRow = mysql_fetch_object($hResult))
1687 $aTests[] = new testData(0, $oRow);
1692 public function objectGetChildren($bIncludeDeleted = false)
1694 $aChildren = array();
1696 foreach($this->getTestResults($bIncludeDeleted) as $oTest)
1698 $aChildren +
= $oTest->objectGetChildren($bIncludeDeleted);
1699 $aChildren[] = $oTest;
1702 /* Find maintainers */
1703 $sQuery = "SELECT * FROM appMaintainers WHERE versionId = '?'";
1704 $hResult = query_parameters($sQuery, $this->iVersionId
);
1709 while($oRow = mysql_fetch_object($hResult))
1711 $oMaintainer = new maintainer(0, $oRow);
1712 $aChildren +
= $oMaintainer->objectGetChildren($bIncludeDeleted);
1713 $aChildren[] = $oMaintainer;
1717 $sQuery = "SELECT * FROM appMonitors WHERE versionId = '?'";
1718 $hResult = query_parameters($sQuery, $this->iVersionId
);
1723 while($oRow = mysql_fetch_object($hResult))
1725 $oMonitor = new monitor(0, $oRow);
1726 $aChildren +
= $oMonitor->objectGetChildren($bIncludeDeleted);
1727 $aChildren[] = $oMonitor;
1731 $sQuery = "SELECT * FROM appNotes WHERE versionId = '?'";
1732 $hResult = query_parameters($sQuery, $this->iVersionId
);
1737 while($oRow = mysql_fetch_object($hResult))
1739 $oNote = new note(0, $oRow);
1740 $aChildren +
= $oNote->objectGetChildren($bIncludeDeleted);
1741 $aChildren[] = $oNote;
1744 /* Find screenshots */
1745 $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'";
1746 $hResult = query_parameters($sQuery, "screenshot", $this->iVersionId
);
1751 while($oRow = mysql_fetch_object($hResult))
1753 $oScreenshot = new screenshot(0, $oRow);
1754 $aChildren +
= $oScreenshot->objectGetChildren($bIncludeDeleted);
1755 $aChildren[] = $oScreenshot;
1759 foreach($this->get_buglink_ids() as $iBugId)
1761 $oBug = new bug($iBugId);
1762 $aChildren +
= $oBug->objectGetChildren($bIncludeDeleted);
1763 $aChildren[] = $oBug;
1767 $sQuery = "SELECT * FROM appComments WHERE versionId = '?'";
1768 $hResult = query_parameters($sQuery, $this->iVersionId
);
1773 while($oRow = mysql_fetch_object($hResult))
1775 $oComment = new comment(0, $oRow);
1776 $aChildren +
= $oComment->objectGetChildren($bIncludeDeleted);
1777 $aChildren[] = $oComment;
1781 $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'";
1782 $hResult = query_parameters($sQuery, "url", $this->iVersionId
);
1787 while($oRow = mysql_fetch_object($hResult))
1789 $oUrl = new url(0, $oRow);
1790 $aChildren +
= $oUrl->objectGetChildren($bIncludeDeleted);
1791 $aChildren[] = $oUrl;
1794 /* Get downloadurls */
1795 $sQuery = "SELECT * FROM appData WHERE type = '?' AND versionId = '?'";
1796 $hResult = query_parameters($sQuery, "downloadurl", $this->iVersionId
);
1801 while($oRow = mysql_fetch_object($hResult))
1803 $oDownload = new downloadurl(0, $oRow);
1804 $aChildren +
= $oDownload->objectGetChildren($bIncludeDeleted);
1805 $aChildren[] = $oDownload;
1811 public function objectMoveChildren($iNewId)
1813 /* Keep track of how many items we have updated */
1816 /* Move test results */
1817 $sQuery = "SELECT * FROM testResults WHERE versionId = '?'";
1818 $hResult = query_parameters($sQuery, $this->iVersionId
);
1823 while($oRow = query_fetch_object($hResult))
1825 $oTestData = new testData($oRow->testingId
);
1826 $oTestData->iVersionId
= $iNewId;
1827 if($oTestData->update())
1833 /* Move all app data */
1834 $sQuery = "SELECT * FROM appData WHERE versionId = '?'";
1835 $hResult = query_parameters($sQuery, $this->iVersionId
);
1840 while($oRow = query_fetch_object($hResult))
1842 $oAppData = new appData($oRow->testingId
);
1843 $oAppData->iVersionId
= $iNewId;
1844 if($oAppData->update(TRUE))
1850 /* Return the number of updated objects if everything was successful */
1854 public static function allowAnonymousSubmissions()
1859 function objectAllowPurgingRejected()
1864 public function objectGetSubmitTime()
1866 return mysqltimestamp_to_unixtimestamp($this->sSubmitTime
);
1869 public function objectGetId()
1871 return $this->iVersionId
;