2005-02-06 17:49:48 +00:00
< ? php
/************************************/
/* this class represents an version */
/************************************/
2005-02-09 23:51:38 +00:00
require_once ( BASE . " include/note.php " );
require_once ( BASE . " include/comment.php " );
2005-02-11 01:34:16 +00:00
require_once ( BASE . " include/url.php " );
2005-02-19 01:19:07 +00:00
require_once ( BASE . " include/screenshot.php " );
2005-07-13 01:14:53 +00:00
require_once ( BASE . " include/bugs.php " );
2006-06-17 06:10:10 +00:00
require_once ( BASE . " include/util.php " );
2006-07-12 00:29:35 +00:00
require_once ( BASE . " include/testData.php " );
2007-01-05 05:20:05 +00:00
require_once ( BASE . " include/downloadurl.php " );
2005-02-09 23:51:38 +00:00
2007-01-21 00:37:06 +00:00
define ( " LICENSE_OPENSOURCE " , " Open Source " );
define ( " LICENSE_FREEWARE " , " Freeware " );
define ( " LICENSE_SHAREWARE " , " Shareware " );
define ( " LICENSE_DEMO " , " Demo " );
define ( " LICENSE_RETAIL " , " Retail " );
2005-02-06 17:49:48 +00:00
/**
* Version class for handling versions .
*/
2007-06-19 00:26:21 +00:00
class version {
2005-02-06 17:49:48 +00:00
var $iVersionId ;
var $iAppId ;
var $sName ;
var $sDescription ;
var $sTestedRelease ;
var $sTestedRating ;
2005-02-07 23:21:33 +00:00
var $sSubmitTime ;
2005-02-06 17:49:48 +00:00
var $iSubmitterId ;
2005-08-15 03:44:03 +00:00
var $sQueued ;
2007-01-21 00:37:06 +00:00
var $sLicense ;
2007-01-20 17:41:43 +00:00
var $iMaintainerRequest ; /* Temporary variable for version submisson .
Indicates whether the user wants to become a
maintainer of the version being submitted .
Value denotes type of request . */
2005-02-06 17:49:48 +00:00
2006-07-07 16:44:41 +00:00
/**
2005-02-06 17:49:48 +00:00
* constructor , fetches the data .
*/
2007-04-07 20:42:08 +00:00
function Version ( $iVersionId = null , $oRow = null )
2005-02-06 17:49:48 +00:00
{
// we are working on an existing version
2007-06-10 18:51:33 +00:00
if ( ! $iVersionId && ! $oRow )
return ;
/*
* We fetch the data related to this version .
*/
2007-06-10 22:15:35 +00:00
if ( ! $oRow )
2005-02-06 17:49:48 +00:00
{
2007-06-10 22:15:35 +00:00
$sQuery = " SELECT *
2007-06-10 18:51:33 +00:00
FROM appVersion
WHERE versionId = '?' " ;
2007-06-10 22:15:35 +00:00
if ( $hResult = query_parameters ( $sQuery , $iVersionId ))
$oRow = mysql_fetch_object ( $hResult );
}
2007-04-07 20:42:08 +00:00
2007-06-10 22:15:35 +00:00
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 -> maintainer_release ;
$this -> sTestedRating = $oRow -> maintainer_rating ;
$this -> sQueued = $oRow -> queued ;
$this -> sLicense = $oRow -> license ;
2005-02-06 17:49:48 +00:00
}
}
/**
* Creates a new version .
*/
2005-10-10 02:37:55 +00:00
function create ()
2005-02-06 17:49:48 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canCreateVersion ())
return ;
2007-04-21 19:50:52 +00:00
$this -> sQueued = $this -> mustBeQueued () ? " true " : " false " ;
2005-02-06 17:49:48 +00:00
2007-01-21 00:37:06 +00:00
$hResult = query_parameters ( " INSERT INTO appVersion
( versionName , description , maintainer_release ,
maintainer_rating , appId , submitterId , queued , license )
VALUES ( '?' , '?' , '?' , '?' , '?' , '?' , '?' , '?' ) " ,
$this -> sName , $this -> sDescription , $this -> sTestedRelease ,
$this -> sTestedRating , $this -> iAppId ,
2007-04-21 19:50:52 +00:00
$_SESSION [ 'current' ] -> iUserId , $this -> sQueued ,
2007-01-21 00:37:06 +00:00
$this -> sLicense );
2006-06-24 04:20:32 +00:00
if ( $hResult )
2005-02-06 17:49:48 +00:00
{
$this -> iVersionId = mysql_insert_id ();
2005-10-28 00:11:35 +00:00
$this -> Version ( $this -> iVersionId );
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ();
2007-01-20 17:41:43 +00:00
/* Submit maintainer request if asked to */
if ( $this -> iMaintainerRequest == 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 ();
}
2005-02-06 17:49:48 +00:00
return true ;
}
else
2005-10-10 02:37:55 +00:00
{
2006-06-24 04:20:32 +00:00
addmsg ( " Error while creating a new version " , " red " );
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
}
2005-02-06 17:49:48 +00:00
}
/**
* Update version .
*/
2006-01-28 23:06:07 +00:00
function update ( $bSilent = false )
2005-02-06 17:49:48 +00:00
{
2005-02-09 23:51:38 +00:00
$sWhatChanged = " " ;
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> hasAppVersionModifyPermission ( $this ))
return ;
2005-10-10 02:37:55 +00:00
$oVersion = new Version ( $this -> iVersionId );
if ( $this -> sName && ( $this -> sName != $oVersion -> sName ))
2005-02-06 17:49:48 +00:00
{
2006-06-27 19:16:27 +00:00
if ( ! query_parameters ( " UPDATE appVersion SET versionName = '?' WHERE versionId = '?' " ,
$this -> sName , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Name was changed from: \n \t ' " . $oVersion -> sName . " ' \n to: \n \t ' " . $this -> sName . " ' \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> sDescription && ( $this -> sDescription != $oVersion -> sDescription ))
2005-02-06 17:49:48 +00:00
{
2006-06-27 19:16:27 +00:00
if ( ! query_parameters ( " UPDATE appVersion SET description = '?' WHERE versionId = '?' " ,
$this -> sDescription , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-05-11 00:58:58 +00:00
2005-10-10 02:37:55 +00:00
if ( $oVersion -> sDescription != " " )
$sWhatChanged .= " Description was changed from \n " . $oVersion -> sDescription . " \n to \n " . $this -> sDescription . " . \n \n " ;
2005-05-11 00:58:58 +00:00
else
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Description was changed to \n " . $this -> sDescription . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> sTestedRelease && ( $this -> sTestedRelease != $oVersion -> sTestedRelease ))
2005-02-06 17:49:48 +00:00
{
2006-06-27 19:16:27 +00:00
if ( ! query_parameters ( " UPDATE appVersion SET maintainer_release = '?' WHERE versionId = '?' " ,
$this -> sTestedRelease , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-05-11 00:58:58 +00:00
2005-10-10 02:37:55 +00:00
if ( $oVersion -> sTestedRelease != " " )
$sWhatChanged .= " Last tested release was changed from " . $oVersion -> sTestedRelease . " to " . $this -> sTestedRelease . " . \n \n " ;
2005-05-11 00:58:58 +00:00
else
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Last tested release was changed to " . $this -> sTestedRelease . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> sTestedRating && ( $this -> sTestedRating != $oVersion -> sTestedRating ))
2005-02-06 17:49:48 +00:00
{
2006-06-27 19:16:27 +00:00
if ( ! query_parameters ( " UPDATE appVersion SET maintainer_rating = '?' WHERE versionId = '?' " ,
$this -> sTestedRating , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-05-09 22:10:51 +00:00
2005-05-10 02:48:02 +00:00
if ( $this -> sTestedRating != " " )
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Rating was changed from " . $oVersion -> sTestedRating . " to " . $this -> sTestedRating . " . \n \n " ;
2005-05-09 22:10:51 +00:00
else
2005-10-10 02:37:55 +00:00
$sWhatChanged .= " Rating was changed to " . $this -> sTestedRating . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
if ( $this -> iAppId && ( $this -> iAppId != $oVersion -> iAppId ))
2005-02-06 17:49:48 +00:00
{
2006-06-27 19:16:27 +00:00
if ( ! query_parameters ( " UPDATE appVersion SET appId = '?' WHERE versionId = '?' " ,
$this -> iAppId , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
return false ;
2005-10-10 02:37:55 +00:00
$oAppBefore = new Application ( $oVersion -> iAppId );
$oAppAfter = new Application ( $this -> iAppId );
2005-06-05 21:26:07 +00:00
$sWhatChanged .= " Version was moved from application " . $oAppBefore -> sName . " to application " . $oAppAfter -> sName . " . \n \n " ;
2005-02-06 17:49:48 +00:00
}
2005-10-10 02:37:55 +00:00
2007-01-21 00:37:06 +00:00
if ( $this -> sLicense && ( $this -> sLicense != $oVersion -> sLicense ))
{
if ( ! query_parameters ( " UPDATE appVersion SET license = '?'
WHERE versionId = '?' " ,
$this -> sLicense , $this -> iVersionId ))
return FALSE ;
2007-01-21 04:31:55 +00:00
$sWhatChanged .= " License was changed from $oVersion->sLicense to " .
2007-01-21 00:37:06 +00:00
" $this->sLicense . \n \n " ;
}
2006-01-28 23:06:07 +00:00
if ( $sWhatChanged and ! $bSilent )
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ( " edit " , $sWhatChanged );
2005-02-06 17:49:48 +00:00
return true ;
}
/**
* Deletes the version from the database .
* and request the deletion of linked elements .
*/
function delete ( $bSilent = false )
{
2007-04-27 00:06:07 +00:00
/* We need the versionId to continue */
if ( ! $this -> iVersionId )
return ;
2005-08-05 22:07:41 +00:00
/* is the current user allowed to delete this version? */
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canDeleteVersion ( $this ))
return false ;
2005-08-05 22:07:41 +00:00
2006-07-09 00:48:33 +00:00
/* fetch notesIds */
$aNotesIds = array ();
$sQuery = " SELECT noteId
FROM appNotes
WHERE versionId = '?' " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$aNotesIds [] = $oRow -> noteId ;
}
}
2005-06-30 01:59:32 +00:00
/* remove all of the items this version contains */
2006-07-09 00:48:33 +00:00
foreach ( $aNotesIds as $iNoteId )
2005-06-30 01:59:32 +00:00
{
$oNote = new Note ( $iNoteId );
$oNote -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
/* We fetch commentsIds. */
$aCommentsIds = array ();
$sQuery = " SELECT commentId
FROM appComments
WHERE versionId = '?' " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$aCommentsIds [] = $oRow -> commentId ;
}
}
foreach ( $aCommentsIds as $iCommentId )
2005-06-30 01:59:32 +00:00
{
$oComment = new Comment ( $iCommentId );
$oComment -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
/* fetch screenshotsIds and urlsIds */
$aScreenshotsIds = array ();
$aUrlsIds = array ();
$sQuery = " SELECT id, type
FROM appData
WHERE versionId = '?' " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
while ( $oRow = mysql_fetch_object ( $hResult ))
{
if ( $oRow -> type = " image " )
$aScreenshotsIds [] = $oRow -> id ;
else
$aUrlsIds [] = $oRow -> id ;
}
}
foreach ( $aScreenshotsIds as $iScreenshotId )
2005-06-30 01:59:32 +00:00
{
$oScreenshot = new Screenshot ( $iScreenshotId );
$oScreenshot -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
foreach ( $aUrlsIds as $iUrlId )
2005-06-30 01:59:32 +00:00
{
$oUrl = new Url ( $iUrlId );
$oUrl -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
2006-09-26 02:09:26 +00:00
$aBuglinkIds = $this -> get_buglink_ids ();
foreach ( $aBuglinkIds as $iBug_id )
2005-07-13 01:14:53 +00:00
{
2006-09-06 01:43:30 +00:00
$oBug = new Bug ( $iBug_id );
2005-07-13 01:14:53 +00:00
$oBug -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
/* fetch Test Results Ids */
$aTestingIds = array ();
$sQuery = " SELECT *
FROM testResults
WHERE versionId = '?'
ORDER BY testingId " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$aTestingIds [] = $oRow -> testingId ;
}
}
foreach ( $aTestingIds as $iTestId )
2005-10-29 04:41:10 +00:00
{
$oTest = new testData ( $iTestId );
$oTest -> delete ( $bSilent );
}
2006-07-09 00:48:33 +00:00
/* fetch monitor Ids */
$aMonitorIds = array ();
$sQuery = " SELECT *
FROM appMonitors
WHERE versionId = '?'
ORDER BY monitorId " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$aMonitorIds [] = $oRow -> monitorId ;
}
}
foreach ( $aMonitorIds as $iMonitorId )
2005-10-29 04:41:10 +00:00
{
$oMonitor = new Monitor ( $iMonitorId );
$oMonitor -> delete ( $bSilent );
}
2005-06-30 01:59:32 +00:00
2006-07-09 00:48:33 +00:00
2005-06-30 01:59:32 +00:00
// remove any maintainers for this version so we don't orphan them
2006-07-24 16:20:40 +00:00
$result = Maintainer :: deleteMaintainersForVersion ( $this );
if ( ! $result )
2005-06-30 01:59:32 +00:00
{
addmsg ( " Error removing version maintainers for the deleted version! " , " red " );
}
/* now delete the version */
2006-06-27 19:16:27 +00:00
$hResult = query_parameters ( " DELETE FROM appVersion
WHERE versionId = '?'
LIMIT 1 " , $this->iVersionId );
if ( ! $hResult )
2005-02-06 17:49:48 +00:00
{
2005-06-30 01:59:32 +00:00
addmsg ( " Error removing the deleted version! " , " red " );
2005-02-06 17:49:48 +00:00
}
2005-06-30 01:59:32 +00:00
2005-02-06 17:49:48 +00:00
if ( ! $bSilent )
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ( " delete " );
2005-05-07 18:45:33 +00:00
2005-08-15 03:44:03 +00:00
$this -> mailSubmitter ( " delete " );
2005-10-26 02:09:49 +00:00
return true ;
2005-02-06 17:49:48 +00:00
}
/**
* Move version out of the queue .
*/
function unQueue ()
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canUnQueueVersion ( $this ))
2005-08-05 22:07:41 +00:00
return ;
2005-02-06 17:49:48 +00:00
// If we are not in the queue, we can't move the version out of the queue.
2005-08-15 03:44:03 +00:00
if ( ! $this -> sQueued == 'true' )
2005-02-06 17:49:48 +00:00
return false ;
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE appVersion SET queued = '?' WHERE versionId = '?' " ,
" false " , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
{
2005-08-15 03:44:03 +00:00
$this -> sQueued = 'false' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2007-04-24 23:41:22 +00:00
$this -> mailSubmitter ( " add " );
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ();
2007-01-20 17:41:43 +00:00
/* Unqueue matching maintainer request */
$hResultMaint = query_parameters ( " SELECT maintainerId FROM
appMaintainers WHERE userId = '?' AND versionId = '?' " ,
$this -> iSubmitterId , $this -> iVersionId );
if ( $hResultMaint && mysql_num_rows ( $hResultMaint ))
{
$oMaintainerRow = mysql_fetch_object ( $hResultMaint );
$oMaintainer = new Maintainer ( $oMaintainerRow -> maintainerId );
$oMaintainer -> unQueue ( " OK " );
}
2005-02-06 17:49:48 +00:00
}
}
2005-08-15 03:44:03 +00:00
function Reject ( $bSilent = false )
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canRejectVersion ( $this ))
2005-08-15 03:44:03 +00:00
return ;
// If we are not in the queue, we can't move the version out of the queue.
if ( ! $this -> sQueued == 'true' )
return false ;
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE appVersion SET queued = '?' WHERE versionId = '?' " ,
" rejected " , $this -> iVersionId ))
2005-08-15 03:44:03 +00:00
{
$this -> sQueued = 'rejected' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-08-15 03:44:03 +00:00
if ( ! $bSilent )
{
$this -> mailSubmitter ( " reject " );
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ( " reject " );
2005-08-15 03:44:03 +00:00
}
// the version has been unqueued
addmsg ( " The version has been rejected. " , " green " );
}
}
2005-02-06 17:49:48 +00:00
2005-08-15 03:44:03 +00:00
function ReQueue ()
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canRequeueVersion ( $this ))
2005-08-15 03:44:03 +00:00
return ;
2006-06-27 19:16:27 +00:00
if ( query_parameters ( " UPDATE appVersion SET queued = '?' WHERE versionId = '?' " ,
" true " , $this -> iVersionId ))
2005-08-15 03:44:03 +00:00
{
$this -> sQueued = 'true' ;
2006-12-31 19:39:41 +00:00
// we send an e-mail to interested people
2005-09-30 01:55:51 +00:00
$this -> SendNotificationMail ();
2005-08-15 03:44:03 +00:00
// the version has been unqueued
addmsg ( " The version has been re-submitted " , " green " );
}
}
function mailSubmitter ( $sAction = " add " )
2005-02-06 17:49:48 +00:00
{
2007-01-04 02:35:01 +00:00
global $aClean ; //FIXME: we should pass the sReplyText value in
2006-11-25 17:24:44 +00:00
// use 'sReplyText' if it is defined, otherwise define the value as an empty string
2007-01-04 02:35:01 +00:00
if ( ! isset ( $aClean [ 'sReplyText' ]))
2006-11-25 17:24:44 +00:00
$aClean [ 'sReplyText' ] = " " ;
2006-06-17 06:10:10 +00:00
2005-02-06 17:49:48 +00:00
if ( $this -> iSubmitterId )
{
2006-03-19 18:06:18 +00:00
$oApp = new Application ( $this -> iAppId );
2005-02-06 17:49:48 +00:00
$oSubmitter = new User ( $this -> iSubmitterId );
2005-08-15 03:44:03 +00:00
switch ( $sAction )
2005-02-06 17:49:48 +00:00
{
2005-08-15 03:44:03 +00:00
case " add " :
2006-11-25 17:24:44 +00:00
$sSubject = " Submitted version accepted " ;
2006-11-22 01:41:36 +00:00
$sMsg = " The version you submitted ( " . $oApp -> sName . " " . $this -> sName . " ) has been accepted by " . $_SESSION [ 'current' ] -> sRealname . " . " ;
2006-02-22 02:20:02 +00:00
$sMsg .= " Administrators Responce: \n " ;
2005-08-15 03:44:03 +00:00
break ;
case " reject " :
2006-11-25 17:24:44 +00:00
$sSubject = " Submitted version rejected " ;
2006-11-22 01:41:36 +00:00
$sMsg = " The version you submitted ( " . $oApp -> sName . " " . $this -> sName . " ) has been rejected by " . $_SESSION [ 'current' ] -> sRealname . " . " ;
2006-02-22 02:20:02 +00:00
$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. " ;
2007-04-24 23:48:14 +00:00
$sMsg .= APPDB_ROOT . " objectManager.php?sClass=version_queue " .
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iVersionId . " & " .
" sTitle=Edit+Version \n " ;
2005-08-15 03:44:03 +00:00
break ;
case " delete " :
2006-11-25 17:24:44 +00:00
$sSubject = " Submitted version deleted " ;
2006-11-22 01:41:36 +00:00
$sMsg = " The version you submitted ( " . $oApp -> sName . " " . $this -> sName . " ) has been deleted by " . $_SESSION [ 'current' ] -> sRealname . " . " ;
2006-02-22 02:20:02 +00:00
$sMsg .= " Reason given: \n " ;
2005-08-15 03:44:03 +00:00
break ;
2005-02-06 17:49:48 +00:00
}
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ;
2005-02-06 17:49:48 +00:00
$sMsg .= " We appreciate your help in making the Version Database better for all users. " ;
2005-08-15 03:44:03 +00:00
2005-02-06 17:49:48 +00:00
mail_appdb ( $oSubmitter -> sEmail , $sSubject , $sMsg );
}
}
2005-09-30 01:55:51 +00:00
function SendNotificationMail ( $sAction = " add " , $sMsg = null )
2005-02-06 17:49:48 +00:00
{
2007-01-04 02:35:01 +00:00
global $aClean ;
2006-11-25 17:24:44 +00:00
// use 'sReplyText' if it is defined, otherwise define the value as an empty string
2007-01-04 02:35:01 +00:00
if ( ! isset ( $aClean [ 'sReplyText' ]))
2006-11-25 17:24:44 +00:00
$aClean [ 'sReplyText' ] = " " ;
2006-06-17 06:10:10 +00:00
2005-02-19 01:18:31 +00:00
$oApp = new Application ( $this -> iAppId );
2005-02-09 23:51:38 +00:00
switch ( $sAction )
2005-02-06 17:49:48 +00:00
{
2005-02-09 23:51:38 +00:00
case " add " :
2005-08-15 03:44:03 +00:00
if ( $this -> sQueued == " false " )
2005-02-09 23:51:38 +00:00
{
2005-02-19 01:18:31 +00:00
$sSubject = " Version " . $this -> sName . " of " . $oApp -> sName . " added by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-08 23:04:31 +00:00
$sMsg = $this -> objectMakeUrl () . " \n " ;
2005-02-09 23:51:38 +00:00
if ( $this -> iSubmitterId )
{
$oSubmitter = new User ( $this -> iSubmitterId );
$sMsg .= " This version has been submitted by " . $oSubmitter -> sRealname . " . " ;
$sMsg .= " \n " ;
2006-02-22 02:20:02 +00:00
}
2006-07-13 18:54:10 +00:00
if ( $aClean [ 'sReplyText' ])
2006-02-22 02:20:02 +00:00
{
2005-06-23 00:34:31 +00:00
$sMsg .= " Appdb admin reply text: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-02-09 23:51:38 +00:00
}
2006-02-22 02:20:02 +00:00
2005-02-09 23:51:38 +00:00
addmsg ( " The version was successfully added into the database. " , " green " );
} else // Version queued.
2005-02-06 17:49:48 +00:00
{
2005-06-19 15:46:57 +00:00
$sSubject = " Version ' " . $this -> sName . " ' of ' " . $oApp -> sName . " ' submitted by " . $_SESSION [ 'current' ] -> sRealname ;
2005-02-09 23:51:38 +00:00
$sMsg .= " This version has been queued. " ;
2005-02-06 17:49:48 +00:00
$sMsg .= " \n " ;
2005-08-15 03:44:03 +00:00
addmsg ( " The version you submitted will be added to the database after being reviewed. " , " green " );
2005-02-06 17:49:48 +00:00
}
2005-02-09 23:51:38 +00:00
break ;
case " edit " :
2005-06-19 15:46:57 +00:00
$sSubject = " ' " . $oApp -> sName . " " . $this -> sName . " ' has been modified by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-08 23:04:31 +00:00
$sMsg .= $this -> objectMakeUrl () . " \n " ;
2005-02-09 23:51:38 +00:00
addmsg ( " Version modified. " , " green " );
break ;
case " delete " :
2005-06-30 01:59:32 +00:00
$sSubject = " Version ' " . $this -> sName . " ' of ' " . $oApp -> sName . " ' has been deleted by " . $_SESSION [ 'current' ] -> sRealname ;
2005-05-09 22:14:09 +00:00
2006-07-13 18:54:10 +00:00
// if sReplyText is set we should report the reason the application was deleted
if ( $aClean [ 'sReplyText' ])
2005-05-09 22:14:09 +00:00
{
$sMsg .= " Reason given: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-05-09 22:14:09 +00:00
}
2005-02-09 23:51:38 +00:00
addmsg ( " Version deleted. " , " green " );
break ;
2005-08-15 03:44:03 +00:00
case " reject " :
$sSubject = " Version ' " . $this -> sName . " ' of ' " . $oApp -> sName . " ' has been rejected by " . $_SESSION [ 'current' ] -> sRealname ;
2007-04-24 23:48:14 +00:00
$sMsg .= APPDB_ROOT . " objectManager.php?sClass=version_queue " .
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iVersionId . " & " .
" sTitle=Edit+Version \n " ;
2005-08-15 03:44:03 +00:00
2006-07-13 18:54:10 +00:00
// if sReplyText is set we should report the reason the version was rejected
if ( $aClean [ 'sReplyText' ])
2005-08-15 03:44:03 +00:00
{
$sMsg .= " Reason given: \n " ;
2006-07-13 18:54:10 +00:00
$sMsg .= $aClean [ 'sReplyText' ] . " \n " ; // append the reply text, if there is any
2005-08-15 03:44:03 +00:00
}
addmsg ( " Version rejected. " , " green " );
break ;
2005-02-06 17:49:48 +00:00
}
2006-06-29 15:54:29 +00:00
$sEmail = User :: get_notify_email_address_list ( null , $this -> iVersionId );
2005-02-06 17:49:48 +00:00
if ( $sEmail )
mail_appdb ( $sEmail , $sSubject , $sMsg );
}
2005-10-10 02:37:55 +00:00
2006-07-09 00:48:33 +00:00
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 = mysql_fetch_object ( $hResult ))
{
$aBuglinkIds [] = $oRow -> linkId ;
}
}
return $aBuglinkIds ;
}
2005-10-10 02:37:55 +00:00
/* 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 */
2007-04-19 23:45:15 +00:00
function outputEditor ()
2005-10-10 02:37:55 +00:00
{
HtmlAreaLoaderScript ( array ( " version_editor " ));
echo html_frame_start ( " Version Form " , " 90% " , " " , 0 );
2007-05-02 01:08:22 +00:00
echo " <table class='color0' width='100%' border=0 cellpadding=2 cellspacing=0> \n " ;
2005-10-10 02:37:55 +00:00
2006-12-01 02:55:09 +00:00
echo '<input type="hidden" name="iVersionId" value="' . $this -> iVersionId . '" />' ;
2005-10-16 04:24:37 +00:00
2007-04-19 23:45:15 +00:00
/* Fill in appId value */
global $aClean ;
if ( ! $this -> iAppId )
$this -> iAppId = $aClean [ 'iAppId' ];
if ( $this -> sQueued == " false " && $this -> iVersionId )
2005-10-10 02:37:55 +00:00
{
// app parent
$x = new TableVE ( " view " );
echo '<tr valign=top><td class=color0><b>Application</b></td>' , " \n " ;
echo '<td>' , " \n " ;
2006-07-06 17:27:54 +00:00
$x -> make_option_list ( " iAppId " , $this -> iAppId , " appFamily " , " appId " , " appName " );
2005-10-10 02:37:55 +00:00
echo '</td></tr>' , " \n " ;
2005-10-16 04:24:37 +00:00
} else
{
2006-12-01 02:55:09 +00:00
echo '<input type="hidden" name="iAppId" value="' . $this -> iAppId . '" />' ;
2005-10-10 02:37:55 +00:00
}
// version name
echo '<tr valign=top><td class="color0"><b>Version name</b></td>' , " \n " ;
2006-07-06 17:27:54 +00:00
echo '<td><input size="20" type="text" name="sVersionName" value="' . $this -> sName . '"></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
2007-01-21 00:37:06 +00:00
// version license
echo html_tr ( array (
array ( " <b>License</b> " , " class= \" color0 \" " ),
2007-01-21 18:22:41 +00:00
$this -> makeLicenseList ()));
2007-01-21 00:37:06 +00:00
2005-10-10 02:37:55 +00:00
// version description
echo '<tr valign=top><td class=color0><b>Version description</b></td>' , " \n " ;
2006-07-06 17:27:54 +00:00
echo '<td><p><textarea cols="80" rows="20" id="version_editor" name="shVersionDescription">' , " \n " ;
2005-10-10 02:37:55 +00:00
2006-06-26 00:44:44 +00:00
echo $this -> sDescription . '</textarea></p></td></tr>' , " \n " ;
2005-10-10 02:37:55 +00:00
echo '</table>' , " \n " ;
echo html_frame_end ();
2005-10-16 04:24:37 +00:00
2007-04-19 23:45:15 +00:00
if ( $this -> sQueued == " false " && $this -> iVersionId )
2005-10-16 04:24:37 +00:00
{
echo html_frame_start ( " Info " , " 90% " , " " , 0 );
echo " <table border=0 cellpadding=2 cellspacing=0> \n " ;
echo '<tr><td class="color4">Rating</td><td class="color0">' , " \n " ;
2006-07-06 17:27:54 +00:00
make_maintainer_rating_list ( " sMaintainerRating " , $this -> sTestedRating );
2005-10-16 04:24:37 +00:00
echo '</td></tr>' , " \n " ;
echo '<tr><td class=color1>Release</td><td class=color0>' , " \n " ;
2006-07-06 17:27:54 +00:00
make_bugzilla_version_list ( " sMaintainerRelease " , $this -> sTestedRelease );
2005-10-16 04:24:37 +00:00
echo '</td></tr>' , " \n " ;
echo html_table_end ();
echo html_frame_end ();
} else
{
2006-12-01 02:55:09 +00:00
echo '<input type="hidden" name="sMaintainerRating" value="' . $this -> sTestedRating . '" />' ;
echo '<input type="hidden" name="sMaintainerRelease" value="' . $this -> sTestedRelease . '" />' ;
2005-10-16 04:24:37 +00:00
}
2005-10-10 02:37:55 +00:00
}
2006-07-08 22:06:28 +00:00
function CheckOutputEditorInput ( $aValues )
2005-10-10 02:37:55 +00:00
{
$errors = " " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'sVersionName' ]))
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter an application version.</li> \n " ;
2006-07-08 22:06:28 +00:00
if ( empty ( $aValues [ 'shVersionDescription' ]))
2005-10-10 02:37:55 +00:00
$errors .= " <li>Please enter a version description.</li> \n " ;
return $errors ;
}
2007-01-21 18:06:53 +00:00
/* retrieves values from $aValues that were output by outputEditor() */
/* $aValues can be $_REQUEST or any array with the values from outputEditor() */
2006-07-08 22:06:28 +00:00
function GetOutputEditorValues ( $aValues )
2005-10-10 02:37:55 +00:00
{
2006-07-08 22:06:28 +00:00
$this -> iAppId = $aValues [ 'iAppId' ];
$this -> iVersionId = $aValues [ 'iVersionId' ];
$this -> sName = $aValues [ 'sVersionName' ];
$this -> sDescription = $aValues [ 'shVersionDescription' ];
$this -> sTestedRating = $aValues [ 'sMaintainerRating' ];
$this -> sTestedRelease = $aValues [ 'sMaintainerRelease' ];
2007-01-21 00:37:06 +00:00
$this -> sLicense = $aValues [ 'sLicense' ];
2007-01-20 17:41:43 +00:00
$this -> iMaintainerRequest = $aValues [ 'iMaintainerRequest' ];
2005-10-10 02:37:55 +00:00
}
2006-01-29 04:04:46 +00:00
2006-07-08 22:10:56 +00:00
function display ( $iTestingId )
2006-01-29 04:04:46 +00:00
{
/* is this user supposed to view this version? */
if ( ! $_SESSION [ 'current' ] -> canViewVersion ( $this ))
2006-07-06 18:44:56 +00:00
util_show_error_page_and_exit ( " Something went wrong with the application or version id " );
2006-01-29 04:04:46 +00:00
$oApp = new Application ( $this -> iAppId );
2006-07-06 17:59:52 +00:00
// Oops! application not found or other error. do something
2006-01-29 04:04:46 +00:00
if ( ! $oApp -> iAppId )
2006-07-06 18:44:56 +00:00
util_show_error_page_and_exit ( 'Internal Database Access Error. No App found.' );
2006-01-29 04:04:46 +00:00
2006-07-06 17:59:52 +00:00
// Oops! Version not found or other error. do something
2006-01-29 04:04:46 +00:00
if ( ! $this -> iVersionId )
2006-07-06 18:44:56 +00:00
util_show_error_page_and_exit ( 'Internal Database Access Error. No Version Found.' );
2006-01-29 04:04:46 +00:00
2007-01-21 18:53:13 +00:00
// show Vote Menu
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
apidb_sidebar_add ( " vote_menu " );
2006-01-29 04:04:46 +00:00
// header
apidb_header ( " Viewing App- " . $oApp -> sName . " Version - " . $this -> sName );
// cat
2006-07-11 18:53:06 +00:00
$oCategory = new Category ( $oApp -> iCatId );
$oCategory -> display ( $oApp -> iAppId , $this -> iVersionId );
2006-01-29 04:04:46 +00:00
// set URL
$appLinkURL = ( $oApp -> sWebpage ) ? " <a href= \" " . $oApp -> sWebpage . " \" > " . substr ( stripslashes ( $oApp -> sWebpage ), 0 , 30 ) . " </a> " : " " ;
// start version display
echo html_frame_start ( " " , " 98% " , " " , 0 );
echo '<tr><td class="color4" valign="top">' , " \n " ;
echo '<table width="250" border="0" cellpadding="3" cellspacing="1">' , " \n " ;
echo " <tr class= \" color0 \" valign= \" top \" ><td width= \" 100 \" > <b>Name</b></td><td width= \" 100% \" > " . $oApp -> sName . " </td> \n " ;
echo " <tr class= \" color1 \" valign= \" top \" ><td><b>Version</b></td><td> " . $this -> sName . " </td></tr> \n " ;
2007-01-21 00:37:06 +00:00
echo html_tr ( array (
" <b>License</b> " ,
$this -> sLicense ),
" color0 " );
2006-01-29 04:04:46 +00:00
// main URL
echo " <tr class= \" color1 \" ><td><b>URL</b></td><td> " . $appLinkURL . " </td></tr> \n " ;
2007-01-21 18:53:13 +00:00
// Votes
echo html_tr ( array (
" <b>Votes</b> " ,
vote_count_version_total ( $this -> iVersionId )),
" color0 " );
2006-12-09 04:28:20 +00:00
if ( $this -> sTestedRating != " / " && $this -> sTestedRating )
$sMaintainerColor = $this -> sTestedRating ;
else
$sMaintainerColor = " color0 " ;
2007-01-18 02:28:21 +00:00
// URLs
if ( $sUrls = url :: display ( $this -> iVersionId ))
2007-06-10 22:15:35 +00:00
{
2007-01-18 02:28:21 +00:00
echo $sUrls ;
2007-06-10 22:15:35 +00:00
}
2007-01-18 02:28:21 +00:00
2006-01-29 04:04:46 +00:00
// rating Area
2006-12-09 04:28:20 +00:00
echo " <tr class= \" $sMaintainerColor\ " valign = \ " top \" ><td><b>Maintainer’s Rating</b></td><td> " . $this -> sTestedRating . " </td></tr> \n " ;
echo " <tr class= \" $sMaintainerColor\ " valign = \ " top \" ><td><b>Maintainer’s Version</b></td><td> " . $this -> sTestedRelease . " </td></tr> \n " ;
2006-01-29 04:04:46 +00:00
2007-01-18 02:28:21 +00:00
// Download URLs
2007-01-05 05:20:05 +00:00
if ( $sDownloadurls = downloadurl :: display ( $this -> iVersionId ))
echo $sDownloadurls ;
2006-01-29 04:04:46 +00:00
// image
2006-07-21 04:18:28 +00:00
$img = Screenshot :: get_random_screenshot_img ( $oApp -> iAppId , $this -> iVersionId , false );
2006-01-29 04:04:46 +00:00
echo " <tr><td align= \" center \" colspan= \" 2 \" > $img </td></tr> \n " ;
// display all maintainers of this application
echo " <tr class= \" color0 \" ><td align= \" left \" colspan= \" 2 \" ><b>Maintainers of this version:</b> \n " ;
echo " <table width= \" 250 \" border= \" 0 \" > " ;
2006-07-07 16:44:41 +00:00
$aMaintainers = $this -> getMaintainersUserIds ();
2007-03-10 03:35:06 +00:00
if ( sizeof ( $aMaintainers ) > 0 )
2006-01-29 04:04:46 +00:00
{
echo " <tr class= \" color0 \" ><td align= \" left \" colspan= \" 2 \" ><ul> " ;
2007-03-10 03:35:06 +00:00
while ( list ( $index , $userIdValue ) = each ( $aMaintainers ))
2006-01-29 04:04:46 +00:00
{
$oUser = new User ( $userIdValue );
2007-03-31 17:25:12 +00:00
echo " <li> " . $oUser -> objectMakeLink () . " </li> " ;
2006-01-29 04:04:46 +00:00
}
echo " </ul></td></tr> \n " ;
} else
{
echo " <tr class=color0><td align=right colspan=2> " ;
echo " No maintainers. Volunteer today!</td></tr> \n " ;
}
2007-04-23 02:33:19 +00:00
echo " </table></td></tr> \n " ;
2006-01-29 04:04:46 +00:00
// display the app maintainer button
2007-04-23 02:33:19 +00:00
echo '<tr><td colspan="2" align="center">' . " \n " ;
2006-01-29 04:04:46 +00:00
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 ))
{
2007-04-23 02:33:19 +00:00
echo '<form method="post" name="sMessage" action="maintainerdelete.php">' . " \n " ;
echo " \t " . '<input type="submit" value="Remove yourself as a super maintainer" class="button">' . " \n " ;
echo " \t " . '<input type="hidden" name="iSuperMaintainer" value="1">' . " \n " ;
echo " \t <input type=hidden name= \" iAppId \" value= \" " . $oApp -> iAppId . " \" > \n " ;
echo " \t <input type=hidden name= \" iVersionId \" value= \" " . $this -> iVersionId . " \" > \n " ;
echo " </form> \n " ;
2006-01-29 04:04:46 +00:00
} else
{
/* are we already a maintainer? */
if ( $_SESSION [ 'current' ] -> isMaintainer ( $this -> iVersionId )) /* yep */
{
2007-04-23 02:33:19 +00:00
echo '<form method="post" name="sMessage" action="maintainerdelete.php">' . " \n " ;
echo " \t " . '<input type="submit" value="Remove yourself as a maintainer" class=button>' . " \n " ;
echo " \t " . '<input type="hidden" name="iSuperMaintainer" value="0">' . " \n " ;
echo " \t " . " <input type=hidden name= \" iAppId \" value= \" " . $oApp -> iAppId . " \" > \n " ;
echo " \t " . " <input type=hidden name= \" iVersionId \" value= \" " . $this -> iVersionId . " \" > \n " ;
echo " </form> \n " ;
2006-01-29 04:04:46 +00:00
} else /* nope */
{
2007-04-23 02:33:19 +00:00
echo '<form method="post" name="sMessage" action="maintainersubmit.php">' . " \n " ;
echo " \t " . '<input type="submit" value="Be a Maintainer for This Version" class="button" title="Click here to know more about maintainers.">' . " \n " ;
echo " \t " . " <input type=hidden name= \" iAppId \" value= \" " . $oApp -> iAppId . " \" > \n " ;
echo " \t " . " <input type=hidden name= \" iVersionId \" value= \" " . $this -> iVersionId . " \" > \n " ;
echo " </form> \n " ;
2006-01-29 04:04:46 +00:00
$oMonitor = new Monitor ();
2007-01-10 01:25:18 +00:00
$oMonitor -> find ( $_SESSION [ 'current' ] -> iUserId , $this -> iVersionId );
2006-01-29 04:04:46 +00:00
if ( ! $oMonitor -> iMonitorId )
{
2007-04-08 23:04:31 +00:00
echo '<form method="post" name="sMessage" action=' .
2007-04-23 02:33:19 +00:00
$this -> objectMakeUrl () . '&iAppId=' . $oApp -> iAppId . '>' . " \n " ;
echo " \t " . '<input type=hidden name="sSub" value="StartMonitoring" />' . " \n " ;
echo " \t " . '<input type=submit value="Monitor Changes" class="button" />' . " \n " ;
echo " </form> \n " ;
2006-01-29 04:04:46 +00:00
}
}
}
} else
{
2007-04-23 02:33:19 +00:00
echo '<form method="post" name="sMessage" action="account.php">' . " \n " ;
echo " \t " . '<input type="hidden" name="sCmd" value="login">' . " \n " ;
echo " \t " . '<input type=submit value="Log in to become an app maintainer" class="button">' . " \n " ;
echo '</form>' . " \n " ;
2006-01-29 04:04:46 +00:00
}
echo " </td></tr> " ;
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ) || $_SESSION [ 'current' ] -> isMaintainer ( $this -> iVersionId ) || $_SESSION [ 'current' ] -> isSuperMaintainer ( $this -> iAppId ))
{
2007-04-23 02:33:19 +00:00
echo '<tr><td colspan="2" align="center">' . " \n " ;
echo '<form method="post" name="sMessage" action="admin/editAppVersion.php">' . " \n " ;
echo " \t " . '<input type="hidden" name="iAppId" value="' . $oApp -> iAppId . '" />' . " \n " ;
echo " \t " . '<input type="hidden" name="iVersionId" value="' . $this -> iVersionId . '" />' . " \n " ;
echo " \t " . '<input type=submit value="Edit Version" class="button" />' . " \n " ;
echo '</form>' . " \n " ;
2006-07-06 17:27:54 +00:00
$url = BASE . " admin/deleteAny.php?sWhat=appVersion&iAppId= " . $oApp -> iAppId . " &iVersionId= " . $this -> iVersionId . " &sConfirmed=yes " ;
2007-04-23 02:33:19 +00:00
echo " <form method= \" post \" name= \" sDelete \" action= \" javascript:deleteURL('Are you sure?', ' " . $url . " ') \" > \n " ;
echo " \t " . '<input type=submit value="Delete Version" class="button" />' . " \n " ;
echo '</form>' . " \n " ;
echo '<form method="post" name="message" action="admin/addAppNote.php">' . " \n " ;
echo " \t " . '<input type="hidden" name="iVersionId" value="' . $this -> iVersionId . '" />' . " \n " ;
echo " \t " . '<input type="submit" value="Add Note" class="button" />' . " \n " ;
echo '</form>' . " \n " ;
echo '<form method=post name=message action=admin/addAppNote.php?iVersionId=' . $this -> iVersionId . '>' . " \n " ;
echo " \t " . '<input type=hidden name="sNoteTitle" value="HOWTO" />' . " \n " ;
echo " \t " . '<input type=submit value="Add How To" class="button" />' . " \n " ;
echo '</form>' . " \n " ;
echo '<form method=post name=message action=admin/addAppNote.php?iVersionId=' . $this -> iVersionId . '>' . " \n " ;
echo " \t " . '<input type=hidden name="sNoteTitle" value="WARNING" />' . " \n " ;
echo " \t " . '<input type=submit value="Add Warning" class="button" />' . " \n " ;
2006-01-29 04:04:46 +00:00
echo '</form>' ;
echo " </td></tr> " ;
}
$oMonitor = new Monitor ();
2007-01-10 01:25:18 +00:00
$oMonitor -> find ( $_SESSION [ 'current' ] -> iUserId , $this -> iVersionId );
2006-01-29 04:04:46 +00:00
if ( $oMonitor -> iMonitorId )
{
2007-04-23 02:33:19 +00:00
echo '<tr><td colspan="2" align="center">' . " \n " ;
echo '</form>' . " \n " ;
2007-04-08 23:04:31 +00:00
echo '<form method="post" name="sMessage" action=' .
2007-04-23 02:33:19 +00:00
$this -> objectMakeUrl () . '>' . " \n " ;
2007-04-23 23:40:41 +00:00
echo '<input type=hidden name="sSub" value="StopMonitoring" />' . " \n " ;
2007-04-23 02:33:19 +00:00
echo '<input type=submit value="Stop Monitoring Version" class="button" />' . " \n " ;
echo " </form> \n " ;
echo " </td></tr> \n " ;
2006-01-29 04:04:46 +00:00
}
2007-04-23 02:33:19 +00:00
echo " </table> \n " ;
// start of the right hand pane in the version display
echo " <td class=color2 valign=top width='100%'> \n " ;
echo " <div class='version_info_pane'> \n " ;
/////////////////////////
// output the description
echo " <div class='info_container'> \n " ;
// output the description title
echo " \t <div class='title_class'> \n " ;
echo " \t \t Description \n " ;
echo " \t </div> \n " ;
2006-01-29 04:04:46 +00:00
2007-04-23 02:33:19 +00:00
// output the description
echo " \t <div class='info_contents'> \n " ;
echo " \t \t " . $this -> sDescription . " \n " ;
echo " \t </div> \n " ;
2006-01-29 04:04:46 +00:00
2007-04-23 02:33:19 +00:00
echo " </div> \n " ; // end the 'info_container' div
// end description
/////////////////////////
2006-07-10 15:42:00 +00:00
2007-04-23 02:33:19 +00:00
//////////////////////
2006-12-31 19:39:41 +00:00
// Show test data
2007-04-23 02:33:19 +00:00
echo " <div class='info_container'> \n " ;
2006-07-10 15:42:00 +00:00
2007-04-23 02:33:19 +00:00
echo " \t <div class='title_class'> \n " ;
echo " \t \t Selected test results <small><small>(selected in 'Test Results' table below)</small></small> \n " ;
echo " \t </div> \n " ;
2006-07-10 15:42:00 +00:00
$oTest = new testData ( $iTestingId );
/* if $iTestingId wasn't valid then it won't be valid in $oTest */
if ( ! $oTest -> iTestingId )
{
2006-12-31 19:39:41 +00:00
/* fetch a new test id for this version */
2007-04-01 22:34:33 +00:00
$iTestingId = testData :: getNewestTestIdFromVersionId ( $this -> iVersionId );
2006-07-10 15:42:00 +00:00
$oTest = new testData ( $iTestingId );
}
2007-04-23 02:33:19 +00:00
echo " <div class='info_contents'> \n " ;
2006-07-10 15:42:00 +00:00
$oTest -> ShowTestResult ();
2007-04-23 02:33:19 +00:00
echo " </div> \n " ;
echo " </div> \n " ; // end the 'info_container' div
// end show test data
/////////////////////
//////////////////////////////
// show the test results table
2006-07-10 15:42:00 +00:00
if ( $oTest -> iTestingId )
2006-01-29 04:04:46 +00:00
{
2006-07-10 15:42:00 +00:00
$oTest -> ShowVersionsTestingTable ( $_SERVER [ 'PHP_SELF' ] . " ?iVersionId= " . $this -> iVersionId . " &iTestingId= " ,
2006-01-29 04:04:46 +00:00
5 );
}
2006-07-16 05:39:56 +00:00
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
{
2007-04-16 23:10:08 +00:00
echo '<form method=post name=sMessage action=objectManager.php?' .
'sClass=testData_queue&sAction=add&iVersionId=' . $this -> iVersionId .
2007-04-23 02:33:19 +00:00
'&sTitle=Add+Test+Data>' . " \n " ;
echo " \t " . '<input type=submit value="Add Test Data" class="button" />' . " \n " ;
echo '</form>' . " \n " ;
2006-07-16 05:39:56 +00:00
} else
{
2007-04-23 02:33:19 +00:00
echo '<form method="post" name="sMessage" action="account.php">' . " \n " ;
echo " \t " . '<input type="hidden" name="sCmd" value="login">' . " \n " ;
echo " \t " . '<input type=submit value="Log in add Test Data" class="button">' . " \n " ;
echo '</form>' . " \n " ;
2006-07-16 05:39:56 +00:00
}
2007-04-23 02:33:19 +00:00
// end show test results table
/////////////////////////////
echo " </div> \n " ; // end the version info pane, the right hand pane in the
// version display
2006-01-29 04:04:46 +00:00
echo html_frame_end ();
2006-07-09 00:48:33 +00:00
view_version_bugs ( $this -> iVersionId , $this -> get_buglink_ids ());
2006-01-29 04:04:46 +00:00
2006-06-29 19:22:26 +00:00
/* display the notes for the application */
$hNotes = query_parameters ( " SELECT noteId FROM appNotes WHERE versionId = '?' " ,
2006-06-27 19:16:27 +00:00
$this -> iVersionId );
2006-01-29 04:04:46 +00:00
2006-06-29 19:22:26 +00:00
while ( $oRow = mysql_fetch_object ( $hNotes ) )
2006-01-29 04:04:46 +00:00
{
2006-06-29 19:22:26 +00:00
$oNote = new Note ( $oRow -> noteId );
$oNote -> show ();
2006-01-29 04:04:46 +00:00
}
// Comments Section
2006-07-08 22:09:14 +00:00
Comment :: view_app_comments ( $this -> iVersionId );
2006-01-29 04:04:46 +00:00
}
2005-10-10 02:37:55 +00:00
2006-06-29 16:07:19 +00:00
function lookup_name ( $versionId )
{
if ( ! $versionId ) return null ;
$result = query_parameters ( " SELECT versionName FROM appVersion WHERE versionId = '?' " ,
$versionId );
if ( ! $result || mysql_num_rows ( $result ) != 1 )
return null ;
$ob = mysql_fetch_object ( $result );
return $ob -> versionName ;
}
2007-01-21 18:06:53 +00:00
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 || ! mysql_num_rows ( $hResult ))
return FALSE ;
$oRow = mysql_fetch_object ( $hResult );
return " $oRow->appName $oRow->versionName " ;
2007-03-13 00:26:31 +00:00
}
2007-01-21 18:06:53 +00:00
2007-03-17 19:39:29 +00:00
/* Creates a link to the version labelled with the full application name */
function fullNameLink ( $iVersionId )
{
$oVersion = new version ( $iVersionId );
$sLink = " <a href= \" " . $oVersion -> objectMakeUrl () . " \" > " .
$oVersion -> fullName ( $iVersionId ) . " </a> " ;
return $sLink ;
}
2006-06-29 16:07:19 +00:00
// display the versions
function display_approved ( $aVersionsIds )
2005-10-30 22:27:14 +00:00
{
2006-06-29 16:07:19 +00:00
if ( $aVersionsIds )
2005-10-30 22:27:14 +00:00
{
2006-06-29 16:07:19 +00:00
echo html_frame_start ( " " , " 98% " , " " , 0 );
echo " <table width= \" 100% \" border= \" 0 \" cellpadding= \" 3 \" cellspacing= \" 1 \" > \n \n " ;
echo " <tr class=color4> \n " ;
echo " <td width= \" 80 \" >Version</td> \n " ;
echo " <td>Description</td> \n " ;
echo " <td width= \" 80 \" >Rating</td> \n " ;
echo " <td width= \" 80 \" >Wine version</td> \n " ;
echo " <td width= \" 40 \" >Comments</td> \n " ;
echo " </tr> \n \n " ;
$c = 0 ;
foreach ( $aVersionsIds as $iVersionId )
2005-10-30 22:27:14 +00:00
{
2006-06-29 16:07:19 +00:00
$oVersion = new Version ( $iVersionId );
if ( $oVersion -> sQueued == 'false' )
{
// set row color
$bgcolor = ( $c % 2 == 0 ) ? " color0 " : " color1 " ;
2006-12-09 04:28:20 +00:00
if ( $oVersion -> sTestedRating && $oVersion -> sTestedRating != " / " )
$sRatingColor = " class= \" $oVersion->sTestedRating\ " " ;
2006-12-09 15:56:56 +00:00
else
$sRatingColor = " class= \" $bgcolor\ " " ;
2006-12-09 04:28:20 +00:00
2006-06-29 16:07:19 +00:00
//display row
echo " <tr class= $bgcolor > \n " ;
2007-04-01 01:21:58 +00:00
echo " <td> " . $oVersion -> objectMakeLink () . " </td> \n " ;
2006-06-29 16:07:19 +00:00
echo " <td> " . util_trim_description ( $oVersion -> sDescription ) . " </td> \n " ;
2006-12-09 04:28:20 +00:00
echo " <td $sRatingColor align=center> " . $oVersion -> sTestedRating . " </td> \n " ;
echo " <td $sRatingColor align=center> " . $oVersion -> sTestedRelease . " </td> \n " ;
2006-07-09 00:48:33 +00:00
echo " <td align=center> " . Comment :: get_comment_count_for_versionid ( $oVersion -> iVersionId ) . " </td> \n " ;
2006-06-29 16:07:19 +00:00
echo " </tr> \n \n " ;
$c ++ ;
}
2005-10-30 22:27:14 +00:00
}
2006-06-29 16:07:19 +00:00
echo " </table> \n " ;
echo html_frame_end ( " Click the Version Name to view the details of that Version " );
2005-10-30 22:27:14 +00:00
}
}
2006-07-07 16:44:41 +00:00
/* returns the maintainers of this version in an array */
function getMaintainersUserIds ()
{
$aMaintainers = array ();
/* early out if the versionId isn't valid */
if ( $this -> iVersionId == 0 )
return $aMaintainers ;
2006-07-24 16:20:40 +00:00
$hResult = Maintainer :: getMaintainersForAppIdVersionId ( null , $this -> iVersionId );
2006-07-07 16:44:41 +00:00
$iCount = 0 ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$aMaintainers [ $iCount ] = $oRow -> userId ;
$iCount ++ ;
}
return $aMaintainers ;
}
2006-12-27 03:26:16 +00:00
/* List the versions submitted by a user. Ignore versions for queued applications */
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.queued = '?' AND appFamily.queued = '?' " , $iUserId , $bQueued ? " true " : " false " , " false " );
if ( ! $hResult || ! mysql_num_rows ( $hResult ))
return false ;
$sResult = html_table_begin ( " width= \" 100% \" align= \" center \" " );
$sResult .= html_tr ( array (
" Name " ,
" Description " ,
" Submission Date " ),
" color4 " );
for ( $i = 1 ; $oRow = mysql_fetch_object ( $hResult ); $i ++ )
$sResult .= html_tr ( array (
2007-04-08 23:04:31 +00:00
version :: fullNameLink ( $oRow -> versionId ),
2006-12-27 03:26:16 +00:00
$oRow -> description ,
print_date ( mysqltimestamp_to_unixtimestamp ( $oRow -> submitTime ))),
( $i % 2 ) ? " color0 " : " color1 " );
$sResult .= html_table_end ();
return $sResult ;
}
2007-01-21 00:37:06 +00:00
2007-01-21 18:22:41 +00:00
function makeLicenseList ( $sLicense = NULL )
2007-01-21 00:37:06 +00:00
{
2007-01-21 18:22:41 +00:00
if ( ! $sLicense )
$sLicense = $this -> sLicense ;
2007-01-21 00:37:06 +00:00
$sReturn = " <select name= \" sLicense \" > \n " ;
$sReturn .= " <option value= \" \" >Choose . . .</option> \n " ;
$aLicense = array ( LICENSE_RETAIL , LICENSE_OPENSOURCE , LICENSE_FREEWARE ,
LICENSE_DEMO , LICENSE_SHAREWARE );
$iMax = count ( $aLicense );
for ( $i = 0 ; $i < $iMax ; $i ++ )
{
2007-01-21 18:22:41 +00:00
if ( $aLicense [ $i ] == $sLicense )
2007-01-21 00:37:06 +00:00
$sSelected = " selected= \" selected \" " ;
2007-01-21 18:22:41 +00:00
else
$sSelected = " " ;
2007-01-21 00:37:06 +00:00
$sReturn .= " <option value= \" $aLicense[$i] \" $sSelected > " .
" $aLicense[$i] </option> \n " ;
}
$sReturn .= " </select> \n " ;
return $sReturn ;
}
2007-01-27 22:58:12 +00:00
/* In order to prevent MySQL injections. Returns matched license */
function checkLicense ( $sLicense )
{
$aLicense = array ( LICENSE_RETAIL , LICENSE_OPENSOURCE , LICENSE_FREEWARE ,
LICENSE_DEMO , LICENSE_SHAREWARE );
foreach ( $aLicense as $sElement )
{
if ( $sLicense == $sElement )
return $sElement ;
}
return FALSE ;
}
2007-03-13 00:26:31 +00:00
2007-03-15 23:43:46 +00:00
function objectMakeUrl ()
{
2007-04-08 23:04:31 +00:00
return APPDB_ROOT . " appview.php?iVersionId= $this->iVersionId " ;
2007-03-15 23:43:46 +00:00
}
2007-03-13 00:26:31 +00:00
function objectMakeLink ()
{
2007-03-15 23:43:46 +00:00
$sLink = " <a href= \" " . $this -> objectMakeUrl () . " \" > " .
2007-03-13 00:26:31 +00:00
$this -> sName . " </a> " ;
return $sLink ;
}
2007-04-04 00:30:42 +00:00
function objectGetEntriesCount ( $bQueued , $bRejected )
{
$sQueued = objectManager :: getQueueString ( $bQueued , $bRejected );
2007-04-07 20:42:08 +00:00
$oVersion = new version ();
if ( $bQueued && ! $oVersion -> canEdit ())
2007-04-04 00:30:42 +00:00
{
2007-04-05 02:29:22 +00:00
/* Users should see their own rejected entries , but maintainers should
not be able to see rejected entries for versions they maintain */
2007-04-04 00:30:42 +00:00
if ( $bRejected )
2007-04-05 02:29:22 +00:00
$sQuery = " SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
appVersion , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
appVersion . submitterId = '?'
AND
appVersion . queued = '?' " ;
else
$sQuery = " SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
appVersion , appMaintainers , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
2007-04-04 00:30:42 +00:00
(
(
2007-04-05 02:29:22 +00:00
appMaintainers . appId = appVersion . appId
AND
superMaintainer = '1'
)
OR
(
appMaintainers . versionId = appVersion . versionId
AND
superMaintainer = '0'
2007-04-04 00:30:42 +00:00
)
)
2007-04-05 02:29:22 +00:00
AND
appMaintainers . userId = '?'
AND
appMaintainers . queued = 'false'
AND
appVersion . queued = '?' " ;
2007-04-04 00:30:42 +00:00
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId , $sQueued );
} else
{
$sQuery = " SELECT COUNT(DISTINCT versionId) as count
FROM appVersion , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
appVersion . queued = '?' " ;
$hResult = query_parameters ( $sQuery , $sQueued );
}
if ( ! $hResult )
return FALSE ;
if ( ! $oRow = mysql_fetch_object ( $hResult ))
return FALSE ;
return $oRow -> count ;
}
function canEdit ()
{
2007-04-07 20:42:08 +00:00
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
return TRUE ;
2007-04-21 18:00:46 +00:00
else if ( $this -> iVersionId )
{
if ( maintainer :: isUserMaintainer ( $_SESSION [ 'current' ], $this -> iVersionId ))
return TRUE ;
if ( $this -> iSubmitterId == $_SESSION [ 'current' ] -> iUserId )
return TRUE ;
return FALSE ;
}
2007-04-07 20:42:08 +00:00
else
return FALSE ;
}
2007-04-21 18:00:46 +00:00
function mustBeQueued ()
{
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
return FALSE ;
2007-04-22 16:15:12 +00:00
// 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 )
2007-04-21 18:00:46 +00:00
{
2007-04-22 16:15:12 +00:00
// 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 ))
2007-04-21 18:00:46 +00:00
return FALSE ;
return TRUE ;
2007-04-22 16:15:12 +00:00
} else
{
2007-04-21 18:00:46 +00:00
return TRUE ;
2007-04-22 16:15:12 +00:00
}
2007-04-21 18:00:46 +00:00
}
2007-04-07 20:42:08 +00:00
function objectGetHeader ()
{
$aCells = array (
" Submission Date " ,
" Submitter " ,
" Vendor " ,
" Application " ,
" Version " );
return $aCells ;
}
2007-06-10 00:28:52 +00:00
function objectGetEntries ( $bQueued , $bRejected , $sOrderBy = " versionId " )
2007-04-07 20:42:08 +00:00
{
$sQueued = objectManager :: getQueueString ( $bQueued , $bRejected );
if ( $bQueued && ! $this -> canEdit ())
{
/* Users should see their own rejected entries , but maintainers should
not be able to see rejected entries for versions they maintain */
if ( $bRejected )
$sQuery = " SELECT appVersion.* FROM
appVersion , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
appVersion . submitterId = '?'
AND
2007-06-10 00:28:52 +00:00
appVersion . queued = '?' ORDER BY '?' " ;
2007-04-07 20:42:08 +00:00
else
$sQuery = " SELECT appVersion.* FROM
appVersion , appMaintainers , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
(
(
appMaintainers . appId = appVersion . appId
AND
superMaintainer = '1'
)
OR
(
appMaintainers . versionId = appVersion . versionId
AND
superMaintainer = '0'
)
)
AND
appMaintainers . userId = '?'
AND
appMaintainers . queued = 'false'
AND
2007-06-10 00:28:52 +00:00
appVersion . queued = '?' ORDER BY '?' " ;
2007-04-07 20:42:08 +00:00
2007-06-10 00:28:52 +00:00
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId , $sQueued ,
$sOrderBy );
2007-04-07 20:42:08 +00:00
} else
{
$sQuery = " SELECT appVersion.*
FROM appVersion , appFamily WHERE
appFamily . appId = appVersion . appId
AND
appFamily . queued = 'false'
AND
2007-06-10 00:28:52 +00:00
appVersion . queued = '?' ORDER BY '?' " ;
$hResult = query_parameters ( $sQuery , $sQueued , $sOrderBy );
2007-04-07 20:42:08 +00:00
}
if ( ! $hResult )
return FALSE ;
return $hResult ;
}
2007-06-14 00:50:35 +00:00
function objectGetTableRow ()
2007-04-07 20:42:08 +00:00
{
$oUser = new user ( $this -> iSubmitterId );
$oApp = new application ( $this -> iAppId );
$oVendor = new vendor ( $oApp -> iVendorId );
$aCells = array (
print_date ( mysqltimestamp_to_unixtimestamp ( $this -> sSubmitTime )),
$oUser -> objectMakeLink (),
$oVendor -> objectMakeLink (),
$oApp -> objectMakeLink (),
$this -> sName );
2007-07-02 00:35:17 +00:00
$oTableRow = new TableRow ( $aCells );
return $oTableRow ;
2007-04-07 20:42:08 +00:00
}
function objectDisplayQueueProcessingHelp ()
{
echo " <p>This is the list of versions waiting for your approval, " .
" or to be rejected.</p> \n " ;
echo " <p>To view a submission, click on its name. " .
" From that page you can edit, delete or approve it into the AppDB.</p> \n " ;
2007-04-04 00:30:42 +00:00
}
2007-04-23 23:31:24 +00:00
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 = mysql_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 = mysql_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 ;
}
2007-04-29 23:00:01 +00:00
function allowAnonymousSubmissions ()
{
return FALSE ;
}
2007-06-14 00:50:35 +00:00
function objectGetId ()
{
return $this -> iVersionId ;
}
2005-10-30 22:27:14 +00:00
}
2005-02-06 17:49:48 +00:00
?>