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 " );
2007-08-27 03:48:44 +00:00
require_once ( BASE . " include/monitor.php " );
2007-09-18 12:28:37 +02:00
require_once ( BASE . " include/vote.php " );
2005-02-09 23:51:38 +00:00
2007-01-21 00:37:06 +00:00
define ( " LICENSE_OPENSOURCE " , " Open Source " );
define ( " LICENSE_SHAREWARE " , " Shareware " );
define ( " LICENSE_DEMO " , " Demo " );
define ( " LICENSE_RETAIL " , " Retail " );
2008-01-06 13:20:40 +01:00
define ( 'LICENSE_FREETOUSE' , 'Free to use' );
define ( 'LICENSE_FREETOSHARE' , 'Free to use and share' );
2007-01-21 00:37:06 +00:00
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 ;
2007-10-25 11:57:18 +02:00
var $oApp ; /* Parento object */
2005-02-06 17:49:48 +00:00
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 ;
2007-12-12 20:56:04 +01:00
private $sState ;
2007-01-21 00:37:06 +00:00
var $sLicense ;
2007-10-25 11:10:32 +02:00
var $aTestResults ; /* Array of test result objects . Especially useful when
we want to preview a version before submitting it ;
in that case there is no data in the database */
2007-09-08 22:52:00 +00:00
var $iObsoleteBy ; /* Whether this version is marked as obsolete , and if so which
version its votes should be moved to . */
2007-01-20 17:41:43 +00:00
var $iMaintainerRequest ; /* Temporary variable for version submisson .
Indicates whether the user wants to become a
2007-11-13 21:09:38 +01:00
maintainer or monitor of the version being submitted .
2007-01-20 17:41:43 +00:00
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-09-24 21:11:29 -04:00
public function Version ( $iVersionId = null , $oRow = null )
2005-02-06 17:49:48 +00:00
{
2007-10-25 11:10:32 +02:00
$this -> aTestResults = array (); // should always be an array
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 ))
2007-08-03 23:27:25 +00:00
$oRow = query_fetch_object ( $hResult );
2007-06-10 22:15:35 +00:00
}
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 ;
2007-12-28 22:57:02 +01:00
$this -> sTestedRelease = $oRow -> ratingRelease ;
$this -> sTestedRating = $oRow -> rating ;
2007-12-12 20:56:04 +01:00
$this -> sState = $oRow -> state ;
2007-06-10 22:15:35 +00:00
$this -> sLicense = $oRow -> license ;
2007-09-08 22:52:00 +00:00
$this -> iObsoleteBy = $oRow -> obsoleteBy ;
2005-02-06 17:49:48 +00:00
}
}
/**
* Creates a new version .
*/
2007-09-24 21:11:29 -04:00
public function create ()
2005-02-06 17:49:48 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canCreateVersion ())
return ;
2007-11-06 23:27:33 +01:00
$oApp = new application ( $this -> iAppId );
2007-12-12 22:25:01 +01:00
if ( $oApp -> objectGetState () != 'accepted' )
2007-12-12 20:56:04 +01:00
$this -> sState = 'pending' ;
2007-11-06 23:27:33 +01:00
else
2007-12-12 20:56:04 +01:00
$this -> sState = $this -> mustBeQueued () ? 'queued' : 'accepted' ;
2005-02-06 17:49:48 +00:00
2007-01-21 00:37:06 +00:00
$hResult = query_parameters ( " INSERT INTO appVersion
2007-12-28 22:57:02 +01:00
( versionName , description , ratingRelease ,
rating , appId , submitTime , submitterId ,
2007-12-12 20:56:04 +01:00
state , license )
2007-07-31 23:48:22 +00:00
VALUES ( '?' , '?' , '?' , '?' , '?' , ? , '?' , '?' , '?' ) " ,
2007-01-21 00:37:06 +00:00
$this -> sName , $this -> sDescription , $this -> sTestedRelease ,
2007-07-31 23:48:22 +00:00
$this -> sTestedRating , $this -> iAppId , " NOW() " ,
2007-12-12 20:56:04 +01:00
$_SESSION [ 'current' ] -> iUserId , $this -> sState ,
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
{
2007-08-03 23:27:25 +00:00
$this -> iVersionId = query_appdb_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 */
2007-11-13 21:09:38 +01:00
switch ( $this -> iMaintainerRequest )
2007-01-20 17:41:43 +00:00
{
2007-11-13 21:09:38 +01:00
case MAINTAINER_REQUEST ;
$oMaintainer = new Maintainer ();
$oMaintainer -> iAppId = $this -> iAppId ;
$oMaintainer -> iVersionId = $this -> iVersionId ;
$oMaintainer -> iUserId = $_SESSION [ 'current' ] -> iUserId ;
$oMaintainer -> sMaintainReason = " This user submitted the version; " .
" auto-queued. " ;
$oMaintainer -> bSuperMaintainer = 0 ;
$oMaintainer -> create ();
break ;
case MONITOR_REQUEST :
$oMonitor = new Monitor ();
$oMonitor -> iVersionId = $this -> iVersionId ;
$oMonitor -> iUserId = $_SESSION [ 'current' ] -> iUserId ;
$oMonitor -> iAppId = $this -> iAppId ;
$oMonitor -> create ();
break ;
2007-01-20 17:41:43 +00:00
}
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 .
*/
2007-09-24 21:11:29 -04:00
public 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
{
2007-12-28 22:57:02 +01:00
if ( ! query_parameters ( " UPDATE appVersion SET ratingRelease = '?' WHERE versionId = '?' " ,
2006-06-27 19:16:27 +00:00
$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
{
2007-12-28 22:57:02 +01:00
if ( ! query_parameters ( " UPDATE appVersion SET rating = '?' WHERE versionId = '?' " ,
2006-06-27 19:16:27 +00:00
$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
{
2005-10-10 02:37:55 +00:00
$oAppBefore = new Application ( $oVersion -> iAppId );
$oAppAfter = new Application ( $this -> iAppId );
2007-12-17 19:34:04 +01:00
if ( $oAppAfter -> objectGetState () == 'accepted' && $this -> sState == 'pending' )
$this -> sState = 'queued' ;
if ( ! query_parameters ( " UPDATE appVersion SET appId = '?', state = '?' WHERE versionId = '?' " ,
$this -> iAppId , $this -> sState , $this -> iVersionId ))
return false ;
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 " ;
}
2007-09-08 22:52:00 +00:00
if ( $this -> iObsoleteBy != $oVersion -> iObsoleteBy )
{
if ( ! query_parameters ( " UPDATE appVersion SET obsoleteBy = '?' WHERE versionId = '?' " ,
$this -> iObsoleteBy , $this -> iVersionId ))
2007-09-09 00:32:29 +00:00
return FALSE ;
2007-09-08 22:52:00 +00:00
if ( $this -> iObsoleteBy )
$sWhatChanged .= " The version was marked as obsolete. \n \n " ;
else
$sWhatChanged .= " The version is no longer marked as obsolete. \n \n " ;
if ( $this -> iObsoleteBy )
{
query_parameters ( " UPDATE appVotes SET versionId = '?' WHERE versionId = '?' " ,
$this -> iObsoleteBy , $this -> iVersionId );
}
}
2009-06-28 14:37:38 +02:00
if ( $this -> objectGetState () != $oVersion -> objectGetState ())
query_parameters ( " UPDATE appVersion SET state = '?' WHERE versionId = '?' " , $this -> objectGetState (), $this -> objectGetId ());
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 ;
}
2007-12-12 22:43:22 +01:00
/**
* Removes the version from the database and
* requests the same action for child entries
*/
public function purge ()
{
/* We need the versionId to continue */
if ( ! $this -> iVersionId )
return ;
/* is the current user allowed to delete this version? */
if ( ! $_SESSION [ 'current' ] -> canDeleteVersion ( $this ))
return false ;
$bSuccess = TRUE ;
2005-02-06 17:49:48 +00:00
2007-12-12 22:43:22 +01:00
foreach ( $this -> objectGetChildren ( TRUE ) as $oChild )
{
if ( ! $oChild -> purge ())
$bSuccess = FALSE ;
}
/* now remove the version from the DB */
$hResult = query_parameters ( " DELETE FROM appVersion
WHERE versionId = '?'
LIMIT 1 " , $this->iVersionId );
if ( ! $hResult )
$bSuccess = FALSE ;
return $bSuccess ;
}
/**
* Flags the version as deleted
2005-02-06 17:49:48 +00:00
* and request the deletion of linked elements .
*/
2007-09-24 21:11:29 -04:00
public function delete ()
2005-02-06 17:49:48 +00:00
{
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
2007-09-08 22:38:20 +00:00
$bSuccess = TRUE ;
2006-07-09 00:48:33 +00:00
2007-09-08 22:38:20 +00:00
foreach ( $this -> objectGetChildren () as $oChild )
2005-06-30 01:59:32 +00:00
{
2007-09-08 22:38:20 +00:00
if ( ! $oChild -> delete ())
$bSuccess = FALSE ;
2005-06-30 01:59:32 +00:00
}
2007-12-12 22:43:22 +01:00
/* now flag the version as deleted */
$hResult = query_parameters ( " UPDATE appVersion SET state = 'deleted'
2006-06-27 19:16:27 +00:00
WHERE versionId = '?'
LIMIT 1 " , $this->iVersionId );
if ( ! $hResult )
2007-09-08 22:38:20 +00:00
$bSuccess = FALSE ;
2005-05-07 18:45:33 +00:00
2007-09-08 22:38:20 +00:00
return $bSuccess ;
2005-02-06 17:49:48 +00:00
}
/**
* Move version out of the queue .
*/
2007-09-24 21:11:29 -04:00
public function unQueue ()
2005-02-06 17:49:48 +00:00
{
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.
2007-12-12 20:56:04 +01:00
if ( $this -> sState == 'accepted' )
2005-02-06 17:49:48 +00:00
return false ;
2007-12-12 20:56:04 +01:00
if ( query_parameters ( " UPDATE appVersion SET state = '?' WHERE versionId = '?' " ,
'accepted' , $this -> iVersionId ))
2005-02-06 17:49:48 +00:00
{
2007-12-12 20:56:04 +01:00
$this -> sState = 'accepted' ;
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 );
2007-08-03 23:27:25 +00:00
if ( $hResultMaint && query_num_rows ( $hResultMaint ))
2007-01-20 17:41:43 +00:00
{
2007-08-03 23:27:25 +00:00
$oMaintainerRow = query_fetch_object ( $hResultMaint );
2007-01-20 17:41:43 +00:00
$oMaintainer = new Maintainer ( $oMaintainerRow -> maintainerId );
$oMaintainer -> unQueue ( " OK " );
}
2005-02-06 17:49:48 +00:00
}
}
2007-09-24 21:11:29 -04:00
public function Reject ( $bSilent = false )
2005-08-15 03:44:03 +00:00
{
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.
2007-12-12 20:56:04 +01:00
if ( $this -> sState != 'queued' )
2005-08-15 03:44:03 +00:00
return false ;
2007-12-12 20:56:04 +01:00
if ( query_parameters ( " UPDATE appVersion SET state = '?' WHERE versionId = '?' " ,
'rejected' , $this -> iVersionId ))
2005-08-15 03:44:03 +00:00
{
2007-12-12 20:56:04 +01:00
$this -> sState = '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
2007-09-24 21:11:29 -04:00
public function ReQueue ()
2005-08-15 03:44:03 +00:00
{
2005-10-26 02:09:49 +00:00
if ( ! $_SESSION [ 'current' ] -> canRequeueVersion ( $this ))
2005-08-15 03:44:03 +00:00
return ;
2007-12-12 20:56:04 +01:00
if ( query_parameters ( " UPDATE appVersion SET state = '?' WHERE versionId = '?' " ,
'queued' , $this -> iVersionId ))
2005-08-15 03:44:03 +00:00
{
2007-12-12 20:56:04 +01:00
$this -> sState = 'queued' ;
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 " );
}
}
2007-09-24 21:11:29 -04:00
public function objectGetSubmitterId ()
2007-09-14 23:02:12 -04:00
{
return $this -> iSubmitterId ;
}
2007-09-24 21:11:29 -04:00
public static function objectGetMailOptions ( $sAction , $bMailSubmitter ,
$bParentAction )
2007-09-14 23:02:12 -04:00
{
return new mailOptions ();
}
2007-09-24 21:11:29 -04:00
public function objectGetMail ( $sAction , $bMailSubmitter , $bParentAction )
2007-09-14 23:02:12 -04:00
{
$oApp = new application ( $this -> iAppId );
if ( $bMailSubmitter )
{
switch ( $sAction )
{
case " delete " :
$sSubject = " Submitted version deleted " ;
$sMsg = " The version you submitted ( " . $oApp -> sName . " " . $this -> sName .
" ) has been deleted. " ;
break ;
}
$aMailTo = null ;
} else
{
switch ( $sAction )
{
case " delete " :
$sSubject = " Version ' " . $this -> sName . " ' of ' " . $oApp -> sName . " ' " .
" deleted " ;
$sMsg = " " ;
break ;
}
$aMailTo = User :: get_notify_email_address_list ( null , $this -> iVersionId );
}
return array ( $sSubject , $sMsg , $aMailTo );
}
2007-09-24 21:11:29 -04:00
private 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 " ;
2008-01-08 19:36:13 +01:00
$sMsg = " The version you submitted ( " . $oApp -> sName . " " . $this -> sName . " ) has been accepted by " . $_SESSION [ 'current' ] -> sRealname . " . \n " ;
$sMsg .= " Administrators response: \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 " .
2008-02-23 12:06:24 +11:00
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iVersionId . " & " .
2007-04-24 23:48:14 +00:00
" sTitle=Edit+Version \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 );
}
}
2007-09-24 21:11:29 -04:00
private 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 " :
2007-12-12 20:56:04 +01:00
if ( $this -> sState == 'accepted' )
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-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 " .
2008-02-23 12:06:24 +11:00
" &bIsQueue=true&bIsRejected=true&iId= " . $this -> iVersionId . " & " .
2007-04-24 23:48:14 +00:00
" 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
2007-09-24 21:11:29 -04:00
public function get_buglink_ids ()
2006-07-09 00:48:33 +00:00
{
/*
* We fetch Bug linkIds .
*/
$aBuglinkIds = array ();
$sQuery = " SELECT *
FROM buglinks
WHERE versionId = '?'
ORDER BY bug_id " ;
if ( $hResult = query_parameters ( $sQuery , $this -> iVersionId ))
{
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2006-07-09 00:48:33 +00:00
{
$aBuglinkIds [] = $oRow -> linkId ;
}
}
return $aBuglinkIds ;
}
2007-09-08 22:52:00 +00:00
/* Makes a frame with title 'Mark as obsolete' and info about what it means , plus
caller - defined content */
2007-09-24 21:11:29 -04:00
private static function makeObsoleteFrame ( $sContent = " " )
2007-09-08 22:52:00 +00:00
{
$sMsg = html_frame_start ( " Mark as obsolete " , " 90% " , " " , 0 );
$sMsg .= " Some applications need to be updated from time to time in order to " ;
$sMsg .= " be of any use. An example is online multi-player games, where you need " ;
$sMsg .= " to be running a version compatible with the server. " ;
$sMsg .= " If this is such an application, and this version is no longer usable, " ;
$sMsg .= " you can mark it as obsolete and move its current votes to a usable " ;
2008-02-23 12:06:24 +11:00
$sMsg .= " version instead.<br><br> " ;
2007-09-08 22:52:00 +00:00
$sMsg .= $sContent ;
$sMsg .= html_frame_end ();
return $sMsg ;
}
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-09-24 21:11:29 -04:00
public function outputEditor ()
2005-10-10 02:37:55 +00:00
{
HtmlAreaLoaderScript ( array ( " version_editor " ));
echo html_frame_start ( " Version Form " , " 90% " , " " , 0 );
2008-02-23 12:06:24 +11:00
echo '<input type="hidden" name="iVersionId" value="' . $this -> iVersionId . '">' ;
2005-10-16 04:24:37 +00:00
2007-07-23 19:56:43 +00:00
$oTable = new Table ();
$oTable -> SetClass ( " color0 " );
$oTable -> SetWidth ( " 100% " );
$oTable -> SetBorder ( 0 );
$oTable -> SetCellPadding ( 2 );
$oTable -> SetCellSpacing ( 0 );
2007-04-19 23:45:15 +00:00
/* Fill in appId value */
global $aClean ;
if ( ! $this -> iAppId )
$this -> iAppId = $aClean [ 'iAppId' ];
2007-12-12 20:56:04 +01:00
if ( $this -> sState == 'accepted' && $this -> iVersionId )
2005-10-10 02:37:55 +00:00
{
// app parent
$x = new TableVE ( " view " );
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
$oTableRow -> SetValign ( " top " );
2007-08-04 16:56:27 +00:00
$oTableCell = new TableCell ( " Application " );
$oTableCell -> SetBold ( true );
$oTableRow -> AddCell ( $oTableCell );
2007-07-23 19:56:43 +00:00
$sOptionList = $x -> make_option_list ( " iAppId " , $this -> iAppId ,
" appFamily " , " appId " , " appName " );
2007-08-04 16:56:27 +00:00
$oTableCell = new TableCell ( $sOptionList );
2007-07-23 19:56:43 +00:00
$oTableCell -> SetClass ( " color0 " );
$oTableRow -> AddCell ( $oTableCell );
$oTable -> AddRow ( $oTableRow );
2005-10-16 04:24:37 +00:00
} else
{
2008-02-23 12:06:24 +11:00
echo '<input type="hidden" name="iAppId" value="' . $this -> iAppId . '">' ;
2005-10-10 02:37:55 +00:00
}
// version name
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
$oTableRow -> SetValign ( " top " );
$oTableCell = new TableCell ( " Version Name " );
$oTableCell -> SetBold ( true );
$oTableCell -> SetClass ( " color0 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableRow -> AddTextCell ( '<input size="20" type="text" name="sVersionName" value="' . $this -> sName . '">' );
$oTable -> AddRow ( $oTableRow );
2005-10-10 02:37:55 +00:00
2007-01-21 00:37:06 +00:00
// version license
2007-07-23 22:03:02 +00:00
$oTableRow = new TableRow ();
2007-07-23 19:56:43 +00:00
$oTableCell = new TableCell ( " License " );
$oTableCell -> SetBold ( true );
$oTableCell -> SetClass ( " color0 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableRow -> AddTextCell ( $this -> makeLicenseList ());
$oTable -> AddRow ( $oTableRow );
2007-01-21 00:37:06 +00:00
2005-10-10 02:37:55 +00:00
// version description
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
$oTableRow -> SetValign ( " top " );
$oTableCell = new TableCell ( " Version description " );
$oTableCell -> SetBold ( true );
$oTableCell -> SetClass ( " color0 " );
$oTableRow -> AddCell ( $oTableCell );
2005-10-10 02:37:55 +00:00
2007-07-23 19:56:43 +00:00
$oTableRow -> AddTextCell ( '<p><textarea cols="80" rows="20" id="version_editor" name="shVersionDescription">' .
$this -> sDescription . '</textarea></p>' );
2005-10-10 02:37:55 +00:00
2007-07-23 19:56:43 +00:00
$oTable -> AddRow ( $oTableRow );
// output the table
echo $oTable -> GetString ();
2005-10-10 02:37:55 +00:00
echo html_frame_end ();
2005-10-16 04:24:37 +00:00
2007-12-12 20:56:04 +01:00
if ( $this -> sState == 'accepted' && $this -> iVersionId )
2005-10-16 04:24:37 +00:00
{
2007-09-08 22:52:00 +00:00
/* Mark as obsolete */
$oApp = new application ( $this -> iAppId );
$oVersionInDB = new version ( $this -> iVersionId );
if ( $oVersionInDB -> iObsoleteBy )
{
2008-02-23 12:06:24 +11:00
$sObsoleteTxt = " <input type= \" checkbox \" name= \" bObsolete \" value= \" true \" checked= \" checked \" > " ;
2007-09-08 22:52:00 +00:00
$sObsoleteTxt .= " This version is obsolete " ;
echo $this -> makeObsoleteFrame ( $sObsoleteTxt );
echo " <input type= \" hidden \" name= \" iObsoleteBy \" value= \" " .
2008-02-23 12:06:24 +11:00
$oVersionInDB -> iObsoleteBy . " \" type= \" hidden \" > \n " ;
2008-07-14 14:33:18 +02:00
} else if ( sizeof ( $oApp -> getVersions ( TRUE , FALSE )) > 1 )
2007-09-08 22:52:00 +00:00
{
if ( $this -> iObsoleteBy )
$sObsolete = " checked= \" checked \" " ;
else
$sObsolete = " " ;
2008-02-23 12:06:24 +11:00
$sObsoleteTxt = " <input type= \" checkbox \" name= \" bObsolete \" value= \" true \" $sObsolete > " ;
2007-09-08 22:52:00 +00:00
$sObsoleteTxt .= " Mark as obsolete and move votes to \n " ;
$sObsoleteTxt .= $oApp -> makeVersionDropDownList ( " iObsoleteBy " , $this -> iObsoleteBy , $this -> iVersionId , FALSE );
echo $this -> makeObsoleteFrame ( $sObsoleteTxt );
}
2005-10-16 04:24:37 +00:00
} else
{
2008-02-23 12:06:24 +11: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
}
2007-09-24 21:11:29 -04:00
public 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() */
2007-09-24 21:11:29 -04:00
public function GetOutputEditorValues ( $aValues )
2005-10-10 02:37:55 +00:00
{
2007-10-22 18:58:15 +02:00
if ( $aValues [ 'iAppId' ])
$this -> iAppId = $aValues [ 'iAppId' ];
if ( $aValues [ 'iVersionId' ])
$this -> iVersionId = $aValues [ 'iVersionId' ];
2006-07-08 22:06:28 +00:00
$this -> sName = $aValues [ 'sVersionName' ];
$this -> sDescription = $aValues [ 'shVersionDescription' ];
2007-01-21 00:37:06 +00:00
$this -> sLicense = $aValues [ 'sLicense' ];
2007-01-20 17:41:43 +00:00
$this -> iMaintainerRequest = $aValues [ 'iMaintainerRequest' ];
2007-09-08 22:52:00 +00:00
if ( $aValues [ 'bObsolete' ] == " true " )
$this -> iObsoleteBy = $aValues [ 'iObsoleteBy' ];
else
$this -> iObsoleteBy = 0 ;
2005-10-10 02:37:55 +00:00
}
2006-01-29 04:04:46 +00:00
2007-09-24 21:11:29 -04:00
public function objectGetCustomTitle ( $sAction )
2007-09-18 13:18:50 +02:00
{
switch ( $sAction )
{
2008-06-03 12:19:17 +02:00
case 'delete' :
return 'Delete ' . version :: fullName ( $this -> iVersionId );
2007-09-24 21:35:35 -04:00
case " view " :
2008-02-26 13:17:35 +11:00
return version :: fullName ( $this -> iVersionId );
2007-09-18 13:18:50 +02:00
default :
return null ;
}
}
2007-09-24 21:11:29 -04:00
public static function objectGetCustomVars ( $sAction )
2007-09-18 12:28:37 +02:00
{
switch ( $sAction )
{
2007-09-24 21:35:35 -04:00
case " view " :
2007-09-18 12:28:37 +02:00
/* Allow the user to select which test report is
shown in the version view */
return array ( " iTestingId " );
default :
return null ;
}
}
2007-10-22 17:59:40 +02:00
public function objectShowPreview ()
{
return TRUE ;
}
2009-04-22 21:36:26 +02:00
public function objectSetParent ( $iNewId , $sClass = '' )
{
$this -> iAppId = $iNewId ;
}
2007-10-25 11:57:18 +02:00
/* Not standard OM function yet, but will be in the future */
2009-04-16 00:26:20 +02:00
public function objectGetParent ( $sClass = '' )
2007-10-25 11:57:18 +02:00
{
/* No id so we can't query the DB, but perhaps an entry is cached? */
2009-07-21 17:11:57 +02:00
if ( ! $this -> iAppId && $this -> oApp )
2007-10-25 11:57:18 +02:00
return $this -> oApp ;
return new application ( $this -> iAppId );
}
2009-04-29 21:23:01 +02:00
/* Only show children of (grand)parents in the Move Child Objects and Change Parent lists */
public static function objectRestrictMoveObjectListsToParents ()
{
return true ;
}
2007-12-25 19:26:35 +01:00
public function getRatingInfo ()
{
return testData :: getRatingInfoForVersionId ( $this -> iVersionId );
}
public function updateRatingInfo ()
{
$aRatingInfo = $this -> getRatingInfo ();
$hResult = query_parameters ( " UPDATE appVersion SET
2007-12-28 22:57:02 +01:00
rating = '?' ,
ratingRelease = '?'
2007-12-25 19:26:35 +01:00
WHERE versionId = '?' " ,
$aRatingInfo [ 0 ],
$aRatingInfo [ 1 ],
$this -> iVersionId );
if ( ! $hResult )
return false ;
return true ;
}
2007-10-25 11:10:32 +02:00
public function display ( $aVars = array ())
2006-01-29 04:04:46 +00:00
{
/* is this user supposed to view this version? */
if ( ! $_SESSION [ 'current' ] -> canViewVersion ( $this ))
2009-03-29 21:01:12 +02:00
{
$sError = 'You do not have permission to view this entry' ;
if ( $this -> objectGetState () == 'deleted' )
$sError = 'This entry has been deleted; it\'s contents may have been moved to another entry' ;
objectManager :: error_exit ( $sError );
}
2006-01-29 04:04:46 +00:00
2007-10-25 11:10:32 +02:00
$iTestingId = $aVars [ 'iTestingId' ] ? $aVars [ 'iTestingId' ] : 0 ;
2007-09-18 12:28:37 +02:00
2007-10-25 11:57:18 +02:00
$oApp = $this -> objectGetParent ();
2006-01-29 04:04:46 +00:00
// 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
2008-08-09 00:41:50 +02:00
$appLinkURL = ( $oApp -> sWebpage ) ? trimmed_link ( $oApp -> sWebpage , 30 ) : " " ;
2006-01-29 04:04:46 +00:00
// 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
2008-01-18 17:24:17 +01:00
if ( ! $this -> iObsoleteBy )
{
$oM = new objectManager ( " voteManager " , " Vote " );
$oM -> setReturnTo ( $this -> objectMakeUrl ());
if ( $_SESSION [ 'current' ] -> isLoggedIn ())
2008-02-23 12:06:24 +11:00
$shVoteLink = ' <a href="' . $oM -> makeUrl ( " edit " , $_SESSION [ 'current' ] -> iUserId ) . '&iVersionId=' . $this -> iVersionId . '">Vote</a>' ;
2008-01-18 17:24:17 +01:00
else
$shVoteLink = '' ;
2009-07-22 20:11:07 +02:00
// Allow admins to see which users have voted, in order to identify
// bogus votes
if ( $_SESSION [ 'current' ] -> hasPriv ( 'admin' ))
{
$oMVoteInspector = new objectManager ( 'voteInspector' , 'Vote inspector' );
2009-07-22 20:30:18 +02:00
$shVoteLink .= ' <a href="' . $oMVoteInspector -> makeUrl ( 'edit' , $this -> iVersionId ) . '">Inspect</a>' ;
2009-07-22 20:11:07 +02:00
}
2008-01-18 17:24:17 +01:00
$shVoteText = vote_count_version_total ( $this -> iVersionId ) . $shVoteLink ;
} else
{
$shVoteText = 'Marked as obsolete' ;
}
echo html_tr ( array ( '<b>Votes</b>' , $shVoteText ), 'color0' );
2007-01-21 18:53:13 +00:00
2007-12-25 19:26:35 +01:00
$sRating = $this -> sTestedRating ;
$sRelease = $this -> sTestedRelease ;
if ( $sRating != " / " && $sRating )
$sRatingColor = $sRating ;
2006-12-09 04:28:20 +00:00
else
2007-12-25 19:26:35 +01:00
$sRatingColor = 'color0' ;
2006-12-09 04:28:20 +00:00
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
2007-12-25 19:26:35 +01:00
echo " <tr class= \" $sRatingColor\ " valign = \ " top \" ><td><b>Rating</b></td><td> " . $sRating . " </td></tr> \n " ;
echo " <tr class= \" $sRatingColor\ " valign = \ " top \" ><td><b>Wine Version</b></td><td> " . $sRelease . " </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 */
{
2009-01-30 20:28:38 +01:00
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 " ;
echo " \t " . '<input type="submit" value="Be a Maintainer of This Version" class="button" title="Click here to know more about maintainers.">' . " \n " ;
2007-04-23 02:33:19 +00:00
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-09-14 23:31:20 -04:00
echo '<form method="post" name="sMessage" action="' .
APPDB_ROOT . " objectManager.php \" > \n " ;
echo " \t <input type= \" hidden \" name= \" iAppId \" value= \" " .
2008-02-23 12:06:24 +11:00
$this -> iAppId . " \" > \n " ;
2007-09-14 23:31:20 -04:00
echo " \t <input type= \" hidden \" name= \" iVersionId \" value= \" " .
2008-02-23 12:06:24 +11:00
$this -> iVersionId . " \" > \n " ;
echo " \t <input type= \" hidden \" name= \" sSubmit \" value= \" Submit \" > \n " ;
echo " \t <input type= \" hidden \" name= \" sClass \" value= \" monitor \" > \n " ;
2007-09-14 23:31:20 -04:00
echo " \t <input type= \" hidden \" name= \" sReturnTo \" value= \" " .
2008-02-23 12:06:24 +11:00
$this -> objectMakeUrl () . " \" > \n " ;
echo " \t " . '<input type=submit value="Monitor Changes" class="button">' . " \n " ;
2007-04-23 02:33:19 +00:00
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 ))
{
2008-02-23 12:06:24 +11:00
$shAdd = '<form method="post" name="sMessage" action="objectManager.php?sClass=note&sAction=add&iVersionId=' . $this -> iVersionId . '&sReturnTo=' . urlencode ( $this -> objectMakeUrl ());
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 " ;
2008-02-23 12:06:24 +11:00
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 " ;
2007-04-23 02:33:19 +00:00
echo '</form>' . " \n " ;
2008-06-03 12:19:17 +02:00
$url = BASE . " objectManager.php?sClass=version&sAction=delete&bQueued=false&iId= " . $this -> iVersionId ;
2007-09-14 23:02:12 -04:00
echo " <form method= \" post \" name= \" sDelete \" action= \" javascript:self.location = ' " . $url . " ' \" > \n " ;
2008-02-23 12:06:24 +11:00
echo " \t " . '<input type=submit value="Delete Version" class="button">' . " \n " ;
2007-04-23 02:33:19 +00:00
echo '</form>' . " \n " ;
2007-09-19 20:12:37 +02:00
echo $shAdd . '" />' ;
2008-02-23 12:06:24 +11:00
echo " \t " . '<input type="submit" value="Add Note" class="button">' . " \n " ;
2007-04-23 02:33:19 +00:00
echo '</form>' . " \n " ;
2008-02-23 12:06:24 +11:00
echo $shAdd . '&sNoteTitle=HOWTO" />' ;
echo " \t " . '<input type=submit value="Add How To" class="button">' . " \n " ;
2007-04-23 02:33:19 +00:00
echo '</form>' . " \n " ;
2008-02-23 12:06:24 +11:00
echo $shAdd . '&sNoteTitle=WARNING" />' ;
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-09-14 23:27:36 -04:00
echo '<form method="post" name="sMessage" action="' .
APPDB_ROOT . " objectManager.php \" > \n " ;
echo " \t <input type= \" hidden \" name= \" iId \" value= \" " .
2008-02-23 12:06:24 +11:00
$oMonitor -> iMonitorId . " \" > \n " ;
echo " \t <input type= \" hidden \" name= \" sSubmit \" value= \" Delete \" > \n " ;
echo " \t <input type= \" hidden \" name= \" sClass \" value= \" monitor \" > \n " ;
2007-09-14 23:27:36 -04:00
echo " \t <input type= \" hidden \" name= \" sReturnTo \" value= \" " .
2008-02-23 12:06:24 +11:00
$this -> objectMakeUrl () . " \" > \n " ;
echo '<input type=submit value="Stop Monitoring Version" class="button" >' . " \n " ;
2007-04-23 02:33:19 +00:00
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
2006-07-10 15:42:00 +00:00
2007-12-19 23:01:05 +01:00
$iNewestId = 0 ;
2009-01-30 20:55:32 +01:00
$oTest = null ;
2007-10-22 17:59:40 +02:00
2007-10-25 11:10:32 +02:00
/* Set if the use chose to display a particular test report */
if ( $iTestingId )
2009-01-30 20:55:32 +01:00
{
2007-10-22 17:59:40 +02:00
$oTest = new testData ( $iTestingId );
2009-01-30 20:55:32 +01:00
$oTestParent = $oTest -> objectGetParent ();
/* Check that the test report doesn't belong to another version */
if ( $oTestParent -> objectGetId () && $oTestParent -> objectGetId () != $this -> objectGetId ())
$oTest = null ;
}
if ( ! $oTest && $this -> iVersionId ) /* Let's query for the latest rest report */
2006-07-10 15:42:00 +00:00
{
2007-12-19 23:01:05 +01:00
$iNewestId = testData :: getNewestTestIdFromVersionId ( $this -> iVersionId );
$iTestingId = $iNewestId ;
2007-11-04 23:09:12 +01:00
if ( $iTestingId ) /* We want all entries to have test data , but old versions might lack
it , or data may have been deleted */
$oTest = new testData ( $iTestingId );
2009-01-30 20:55:32 +01:00
} else if ( ! $oTest ) /* Perhaps we have a cached entry? There should be */
2007-10-25 11:10:32 +02:00
{
$aTests = $this -> getTestResults ();
2007-11-04 23:09:12 +01:00
if ( sizeof ( $aTests )) /* ... but we cannot be certain */
$oTest = $aTests [ 0 ];
2006-07-10 15:42:00 +00:00
}
2007-11-04 23:09:12 +01:00
if ( $oTest )
{
2007-12-19 23:01:05 +01:00
if ( $oTest -> isOld ())
{
if ( $iNewestId != $oTest -> objectGetId ())
{
$sWarnOldText = 'The test results you have selected are very old and may not represent the current state of Wine.' ;
} else
{
$sWarnOldText = 'The test results for this version are very old, and as such they may not represent ' .
'the current state of Wine. Please consider submitting a new test report.' ;
}
echo html_note ( 'Old test results' , $sWarnOldText );
}
2007-11-04 23:09:12 +01:00
echo " <div class='info_container'> \n " ;
2007-04-23 02:33:19 +00:00
2007-11-04 23:09:12 +01: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 " ;
echo " <div class='info_contents'> \n " ;
$oTest -> ShowTestResult ();
echo " </div> \n " ;
echo " </div> \n " ;
} else /* Show a note saying that no test results are present ,
and encourage the user to take action */
{
echo html_note ( 'No Test Results' ,
2008-02-23 12:06:24 +11:00
'This version has no test results, please consider submitting some.<br>' .
2007-11-04 23:09:12 +01:00
'They may be part of the ' .
'version or application description. If they are, please ' .
'consider becoming a maintainer and remove them, submitting ' .
'a proper test report instead.' );
}
// end the 'info_container' div
2007-04-23 02:33:19 +00:00
// end show test data
/////////////////////
//////////////////////////////
// show the test results table
2009-01-30 22:03:12 +01:00
if ( $oTest )
{
if ( $oTest -> iTestingId )
{
$oTest -> ShowVersionsTestingTable ( $this -> objectMakeUrl () . " &iTestingId= " , 5 );
} else /* We are previewing the version */
{
$oTable = $oTest -> CreateTestTable ();
$oTable -> AddRow ( $oTest -> CreateTestTableRow ( 0 , " " ));
echo $oTable -> GetString ();
}
2006-01-29 04:04:46 +00:00
}
2007-10-22 17:59:40 +02:00
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?' .
2008-02-23 12:06:24 +11:00
'sClass=testData_queue&sAction=add&iVersionId=' . $this -> iVersionId .
'&sTitle=Add+Test+Data&sReturnTo=' .
2007-09-19 20:26:05 +02:00
urlencode ( $this -> objectMakeUrl ()) . '>' . " \n " ;
2008-02-23 12:06:24 +11:00
echo " \t " . '<input type=submit value="Add Test Data" class="button" >' . " \n " ;
2007-04-23 02:33:19 +00:00
echo '</form>' . " \n " ;
2006-07-16 05:39:56 +00:00
} else
{
2007-09-20 20:03:35 +02:00
echo '<form method="post" name="sMessage" action="' . login_url () . '">' . " \n " ;
2007-04-23 02:33:19 +00:00
echo " \t " . '<input type="hidden" name="sCmd" value="login">' . " \n " ;
2007-09-20 20:03:35 +02:00
echo " \t " . '<input type=submit value="Log in to add test data" class="button">' . " \n " ;
2007-04-23 02:33:19 +00:00
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
2009-07-21 16:02:05 +02:00
/* display the notes for the application */
$hNotes = query_parameters ( " SELECT noteId FROM appNotes WHERE versionId = '?' " ,
$this -> iVersionId );
while ( $oRow = query_fetch_object ( $hNotes ) )
{
$oNote = new Note ( $oRow -> noteId );
$oNote -> display ();
}
2007-09-14 23:02:12 -04:00
2006-01-29 04:04:46 +00:00
// Comments Section
2007-10-22 17:59:40 +02:00
if ( $this -> iVersionId )
Comment :: view_app_comments ( $this -> iVersionId );
2006-01-29 04:04:46 +00:00
}
2005-10-10 02:37:55 +00:00
2007-09-24 21:11:29 -04:00
public static function lookup_name ( $versionId )
2006-06-29 16:07:19 +00:00
{
if ( ! $versionId ) return null ;
$result = query_parameters ( " SELECT versionName FROM appVersion WHERE versionId = '?' " ,
$versionId );
2007-08-03 23:27:25 +00:00
if ( ! $result || query_num_rows ( $result ) != 1 )
2006-06-29 16:07:19 +00:00
return null ;
2007-08-03 23:27:25 +00:00
$ob = query_fetch_object ( $result );
2006-06-29 16:07:19 +00:00
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 );
2007-08-03 23:27:25 +00:00
if ( ! $hResult || ! query_num_rows ( $hResult ))
2007-01-21 18:06:53 +00:00
return FALSE ;
2007-08-03 23:27:25 +00:00
$oRow = query_fetch_object ( $hResult );
2007-01-21 18:06:53 +00:00
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 */
2007-09-24 21:11:29 -04:00
public static function fullNameLink ( $iVersionId )
2007-03-17 19:39:29 +00:00
{
$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
2007-10-23 14:16:00 +02:00
public static function displayList ( $aVersions )
2005-10-30 22:27:14 +00:00
{
2007-10-23 14:16:00 +02:00
if ( $aVersions )
2005-10-30 22:27:14 +00:00
{
2006-06-29 16:07:19 +00:00
echo html_frame_start ( " " , " 98% " , " " , 0 );
2007-07-23 19:56:43 +00:00
$oTable = new Table ();
$oTable -> SetWidth ( " 100% " );
$oTable -> SetBorder ( 0 );
$oTable -> SetCellPadding ( 3 );
$oTable -> SetCellSpacing ( 1 );
$oTableRow = new TableRow ();
$oTableRow -> SetClass ( " color4 " );
$oTableCell = new TableCell ( " Version " );
$oTableCell -> SetWidth ( " 80 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableRow -> AddTextCell ( " Description " );
$oTableCell = new TableCell ( " Rating " );
$oTableCell -> SetWidth ( " 80 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableCell = new TableCell ( " Wine version " );
$oTableCell -> SetWidth ( " 80 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableCell = new TableCell ( " Test results " );
$oTableCell -> SetWidth ( " 80 " );
$oTableRow -> AddCell ( $oTableCell );
$oTableCell = new TableCell ( " Comments " );
$oTableCell -> SetWidth ( " 40 " );
$oTableRow -> AddCell ( $oTableCell );
$oTable -> SetHeader ( $oTableRow );
2006-06-29 16:07:19 +00:00
$c = 0 ;
2007-10-23 14:16:00 +02:00
foreach ( $aVersions as $oVersion )
2005-10-30 22:27:14 +00:00
{
2007-09-14 23:45:51 -04:00
$oApp = new application ( $oVersion -> iAppId );
2007-12-12 20:56:04 +01:00
2007-12-12 22:25:01 +01:00
if ( $oVersion -> sState == $oApp -> objectGetState ())
2006-06-29 16:07:19 +00:00
{
// set row color
$bgcolor = ( $c % 2 == 0 ) ? " color0 " : " color1 " ;
2007-07-23 19:56:43 +00:00
$oTableRowHighlight = null ;
2007-07-12 23:58:00 +00:00
// if we have a valid tested rating
2007-07-23 20:39:49 +00:00
if ( $oVersion -> sTestedRating && ( $oVersion -> sTestedRating != " / " ) &&
( $oVersion -> sTestedRating != " " ))
2007-07-12 23:58:00 +00:00
{
$sClass = $oVersion -> sTestedRating ;
2007-07-23 19:56:43 +00:00
$oInactiveColor = new Color ();
2007-07-23 20:39:49 +00:00
$oInactiveColor -> SetColorByName ( $oVersion -> sTestedRating );
2007-07-23 19:56:43 +00:00
$oHighlightColor = GetHighlightColorFromInactiveColor ( $oInactiveColor );
2007-07-12 23:58:00 +00:00
2007-07-23 19:56:43 +00:00
$oTableRowHighlight = new TableRowHighlight ( $oHighlightColor , $oInactiveColor );
2007-07-12 23:58:00 +00:00
} else
{
$sClass = $bgcolor ;
2007-07-23 19:56:43 +00:00
$oTableRowHighlight = GetStandardRowHighlight ( $c );
2007-07-12 23:58:00 +00:00
}
2006-12-09 04:28:20 +00:00
2006-06-29 16:07:19 +00:00
//display row
2007-07-23 19:56:43 +00:00
$oTableRowClick = new TableRowClick ( $oVersion -> objectMakeUrl ());
$oTableRowClick -> SetHighlight ( $oTableRowHighlight );
$oTableRow = new TableRow ();
$oTableRow -> SetRowClick ( $oTableRowClick ); // make the row clickable
$oTableRow -> AddTextCell ( $oVersion -> objectMakeLink ());
$oTableRow -> SetClass ( $sClass );
$oTableRow -> AddTextCell ( util_trim_description ( $oVersion -> sDescription ));
$oTableCell = new TableCell ( $oVersion -> sTestedRating );
$oTableCell -> SetAlign ( " center " );
$oTableRow -> AddCell ( $oTableCell );
2007-07-24 01:50:19 +00:00
$oTableCell = new TableCell ( $oVersion -> sTestedRelease );
$oTableCell -> SetAlign ( " center " );
$oTableRow -> AddCell ( $oTableCell );
2007-07-23 19:56:43 +00:00
$oTableCell = new TableCell ( testData :: get_testdata_count_for_versionid ( $oVersion -> iVersionId ));
$oTableCell -> SetAlign ( " center " );
$oTableRow -> AddCell ( $oTableCell );
$oTableCell = new TableCell ( Comment :: get_comment_count_for_versionid ( $oVersion -> iVersionId ));
$oTableCell -> SetAlign ( " center " );
$oTableRow -> AddCell ( $oTableCell );
// add the row to the table
$oTable -> AddRow ( $oTableRow );
2006-06-29 16:07:19 +00:00
$c ++ ;
}
2005-10-30 22:27:14 +00:00
}
2007-07-23 19:56:43 +00:00
// output the table
echo $oTable -> GetString ();
2006-06-29 16:07:19 +00:00
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 */
2007-09-24 21:11:29 -04:00
public function getMaintainersUserIds ()
2006-07-07 16:44:41 +00:00
{
$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 ;
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2006-07-07 16:44:41 +00:00
{
$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 */
2007-09-24 21:11:29 -04:00
public static function listSubmittedBy ( $iUserId , $bQueued = true )
2006-12-27 03:26:16 +00:00
{
2007-12-12 22:25:01 +01:00
$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' );
2006-12-27 03:26:16 +00:00
2007-08-03 23:27:25 +00:00
if ( ! $hResult || ! query_num_rows ( $hResult ))
2006-12-27 03:26:16 +00:00
return false ;
2007-07-23 19:56:43 +00:00
$oTable = new Table ();
$oTable -> SetWidth ( " 100% " );
$oTable -> SetAlign ( " center " );
// setup the table header
$oTableRow = new TableRow ();
$oTableRow -> AddTextCell ( " Name " );
$oTableRow -> AddTextCell ( " Description " );
$oTableRow -> AddTextCell ( " Submission Date " );
$oTableRow -> SetClass ( " color4 " );
$oTable -> SetHeader ( $oTableRow );
2006-12-27 03:26:16 +00:00
2007-12-21 23:55:27 +01:00
if ( $bQueued )
$oTableRow -> addTextCell ( 'Action' );
2007-08-03 23:27:25 +00:00
for ( $i = 1 ; $oRow = query_fetch_object ( $hResult ); $i ++ )
2007-07-23 19:56:43 +00:00
{
2007-12-21 23:55:27 +01:00
$oTableRow = new TableRow ();
$oTableRow -> AddTextCell ( version :: fullNameLink ( $oRow -> versionId ));
$oTableRow -> AddTextCell ( $oRow -> description );
$oTableRow -> AddTextCell ( print_date ( mysqldatetime_to_unixtimestamp ( $oRow -> submitTime )));
$oTableRow -> SetClass (( $i % 2 ) ? " color0 " : " color1 " );
if ( $bQueued )
{
$oM = new objectManager ( 'version_queue' );
$oM -> setReturnTo ( array_key_exists ( 'REQUEST_URI' , $_SERVER ) ? $_SERVER [ 'REQUEST_URI' ] : " " );
$shDeleteLink = '<a href="' . $oM -> makeUrl ( 'delete' , $oRow -> versionId , 'Delete entry' ) . '">delete</a>' ;
$shEditLink = '<a href="' . $oM -> makeUrl ( 'edit' , $oRow -> versionId , 'Edit entry' ) . '">edit</a>' ;
$oTableRow -> addTextCell ( " [ $shEditLink ] [ $shDeleteLink ] " );
}
2006-12-27 03:26:16 +00:00
2007-12-21 23:55:27 +01:00
$oTable -> AddRow ( $oTableRow );
2007-07-23 19:56:43 +00:00
}
2006-12-27 03:26:16 +00:00
2007-07-23 19:56:43 +00:00
return $oTable -> GetString ();
2006-12-27 03:26:16 +00:00
}
2007-01-21 00:37:06 +00:00
2008-06-13 21:28:08 +02:00
/* Returns an array containg the different software licences */
public function getLicenses ()
{
return array ( LICENSE_RETAIL , LICENSE_OPENSOURCE , LICENSE_FREETOUSE ,
LICENSE_FREETOSHARE , LICENSE_DEMO , LICENSE_SHAREWARE );
}
2007-07-23 19:56:43 +00:00
// returns a string containing the html for a selection list
2007-09-26 21:56:16 -04:00
public 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 " ;
2008-06-15 13:37:47 +10:00
$aLicense = version :: getLicenses ();
2007-01-21 00:37:06 +00:00
$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
2007-07-23 19:56:43 +00:00
$sReturn .= " <option value= \" $aLicense[$i] \" $sSelected > " .
" $aLicense[$i] </option> \n " ;
2007-01-21 00:37:06 +00:00
}
$sReturn .= " </select> \n " ;
return $sReturn ;
}
2007-01-27 22:58:12 +00:00
/* In order to prevent MySQL injections. Returns matched license */
2007-09-24 21:11:29 -04:00
public static function checkLicense ( $sLicense )
2007-01-27 22:58:12 +00:00
{
2008-01-06 13:20:40 +01:00
$aLicense = array ( LICENSE_RETAIL , LICENSE_OPENSOURCE , LICENSE_FREETOUSE ,
LICENSE_FREETOSHARE , LICENSE_DEMO , LICENSE_SHAREWARE );
2007-01-27 22:58:12 +00:00
foreach ( $aLicense as $sElement )
{
if ( $sLicense == $sElement )
return $sElement ;
}
return FALSE ;
}
2007-03-13 00:26:31 +00:00
2009-04-30 23:14:55 +02:00
public function objectGetClassDisplayName ()
{
return 'version' ;
}
2007-09-24 21:11:29 -04:00
public function objectMakeUrl ()
2007-03-15 23:43:46 +00:00
{
2008-02-23 12:06:24 +11:00
return APPDB_ROOT . " objectManager.php?sClass=version&iId= $this->iVersionId " ;
2007-03-15 23:43:46 +00:00
}
2007-09-24 21:11:29 -04:00
public function objectMakeLink ()
2007-03-13 00:26:31 +00:00
{
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
2008-01-20 21:31:15 +01:00
public static function objectGetEntriesCount ( $sState )
2007-04-04 00:30:42 +00:00
{
2007-04-07 20:42:08 +00:00
$oVersion = new version ();
2008-01-20 21:31:15 +01:00
if ( $sState != 'accepted' && ! $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 */
2008-01-20 21:31:15 +01:00
if ( $sState == 'rejected' )
2007-04-05 02:29:22 +00:00
$sQuery = " SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
2007-11-06 23:34:50 +01:00
appVersion WHERE
2007-04-05 02:29:22 +00:00
appVersion . submitterId = '?'
AND
2007-12-12 20:56:04 +01:00
appVersion . state = '?' " ;
2007-04-05 02:29:22 +00:00
else
$sQuery = " SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
2007-11-06 23:34:50 +01:00
appVersion , appMaintainers WHERE
appMaintainers . appId = appVersion . appId
2007-04-05 02:29:22 +00:00
AND
2007-11-06 23:34:50 +01:00
superMaintainer = '1'
2007-04-05 02:29:22 +00:00
AND
appMaintainers . userId = '?'
AND
2008-01-20 21:31:15 +01:00
appMaintainers . state = 'accepted'
2007-04-05 02:29:22 +00:00
AND
2007-12-12 20:56:04 +01:00
appVersion . state = '?' " ;
2007-04-05 02:29:22 +00:00
2007-12-12 20:56:04 +01:00
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId , $sState );
2007-04-04 00:30:42 +00:00
} else
{
$sQuery = " SELECT COUNT(DISTINCT versionId) as count
2007-11-06 23:34:50 +01:00
FROM appVersion WHERE
2007-12-12 20:56:04 +01:00
appVersion . state = '?' " ;
$hResult = query_parameters ( $sQuery , $sState );
2007-04-04 00:30:42 +00:00
}
if ( ! $hResult )
return FALSE ;
2007-08-03 23:27:25 +00:00
if ( ! $oRow = query_fetch_object ( $hResult ))
2007-04-04 00:30:42 +00:00
return FALSE ;
return $oRow -> count ;
}
2007-12-12 20:56:04 +01:00
public function objectGetState ()
{
return $this -> sState ;
}
public function objectSetState ( $sState )
{
$this -> sState = $sState ;
}
2007-09-24 21:11:29 -04:00
public function canEdit ()
2007-04-04 00:30:42 +00:00
{
2007-04-07 20:42:08 +00:00
if ( $_SESSION [ 'current' ] -> hasPriv ( " admin " ))
return TRUE ;
2007-04-21 18:00:46 +00:00
2007-09-24 22:09:01 -04:00
if ( isset ( $this ) && is_object ( $this ) && $this -> iVersionId )
2007-04-21 18:00:46 +00:00
{
if ( maintainer :: isUserMaintainer ( $_SESSION [ 'current' ], $this -> iVersionId ))
return TRUE ;
2008-07-22 14:07:32 +02:00
if ( $this -> sState != 'accepted' && $this -> iSubmitterId == $_SESSION [ 'current' ] -> iUserId )
2007-04-21 18:00:46 +00:00
return TRUE ;
return FALSE ;
2007-09-24 22:09:01 -04:00
} else
{
2007-04-07 20:42:08 +00:00
return FALSE ;
2007-09-24 22:09:01 -04:00
}
2007-04-07 20:42:08 +00:00
}
2007-09-24 21:11:29 -04:00
public function mustBeQueued ()
2007-04-21 18:00:46 +00:00
{
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-09-24 21:11:29 -04:00
public static function objectGetHeader ()
2007-04-07 20:42:08 +00:00
{
2007-07-31 01:51:40 +00:00
$oTableRow = new TableRow ();
$oTableRow -> AddTextCell ( " Submission Date " );
$oTableRow -> AddTextCell ( " Submitter " );
$oTableRow -> AddTextCell ( " Vendor " );
$oTableRow -> AddTextCell ( " Application " );
$oTableRow -> AddTextCell ( " Version " );
2007-11-04 22:32:19 +01:00
$oTableRow -> AddTextCell ( " Has Maintainer " );
2007-07-31 01:51:40 +00:00
return $oTableRow ;
2007-04-07 20:42:08 +00:00
}
2007-12-19 15:06:35 +01:00
public static function objectGetItemsPerPage ( $sState = 'accepted' )
2007-07-28 20:10:54 +00:00
{
$aItemsPerPage = array ( 25 , 50 , 100 , 200 );
$iDefaultPerPage = 25 ;
return array ( $aItemsPerPage , $iDefaultPerPage );
}
2008-04-12 21:50:02 +02:00
public static function objectGetDefaultSort ()
{
return 'versionId' ;
}
public static function objectGetEntries ( $sState , $iRows = 0 , $iStart = 0 , $sOrderBy = " versionId " , $bAscending = true )
2007-04-07 20:42:08 +00:00
{
2007-07-28 20:10:54 +00:00
$sLimit = " " ;
/* Should we add a limit clause to the query? */
if ( $iRows || $iStart )
{
$sLimit = " LIMIT ?,? " ;
/* Selecting 0 rows makes no sense , so we assume the user wants to select all of them
after an offset given by iStart */
if ( ! $iRows )
2008-01-20 21:31:15 +01:00
$iRows = version :: objectGetEntriesCount ( $sState );
2007-07-28 20:10:54 +00:00
}
2008-01-20 21:31:15 +01:00
if ( $sState != 'accepted' && ! version :: canEdit ())
2007-04-07 20:42:08 +00:00
{
/* Users should see their own rejected entries , but maintainers should
not be able to see rejected entries for versions they maintain */
2008-01-20 21:31:15 +01:00
if ( $sState == 'rejected' )
2007-11-06 23:34:50 +01:00
$sQuery = " SELECT * FROM appVersion WHERE
2007-04-07 20:42:08 +00:00
appVersion . submitterId = '?'
AND
2007-12-12 20:56:04 +01:00
appVersion . state = '?' ORDER BY ? $sLimit " ;
2007-04-07 20:42:08 +00:00
else
$sQuery = " SELECT appVersion.* FROM
2007-11-06 23:34:50 +01:00
appVersion , appMaintainers WHERE
appMaintainers . appId = appVersion . appId
and
superMaintainer = '1'
2007-04-07 20:42:08 +00:00
AND
appMaintainers . userId = '?'
AND
2008-01-20 21:31:15 +01:00
appMaintainers . state = 'accepted'
2007-04-07 20:42:08 +00:00
AND
2007-12-12 20:56:04 +01:00
appVersion . state = '?' ORDER BY ? $sLimit " ;
2007-04-07 20:42:08 +00:00
2007-07-28 20:10:54 +00:00
if ( $sLimit )
{
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId ,
2007-12-12 20:56:04 +01:00
$sState , $sOrderBy , $iStart , $iRows );
2007-07-28 20:10:54 +00:00
} else
{
$hResult = query_parameters ( $sQuery , $_SESSION [ 'current' ] -> iUserId ,
2007-12-12 20:56:04 +01:00
$sState , $sOrderBy );
2007-07-28 20:10:54 +00:00
}
2007-04-07 20:42:08 +00:00
} else
{
2007-11-06 23:34:50 +01:00
$sQuery = " SELECT * FROM appVersion WHERE
2007-12-12 20:56:04 +01:00
appVersion . state = '?' ORDER BY ? $sLimit " ;
2007-07-28 20:10:54 +00:00
if ( $sLimit )
{
2007-12-12 20:56:04 +01:00
$hResult = query_parameters ( $sQuery , $sState , $sOrderBy ,
2007-07-28 20:10:54 +00:00
$iStart , $iRows );
} else
{
2007-12-12 20:56:04 +01:00
$hResult = query_parameters ( $sQuery , $sState , $sOrderBy );
2007-07-28 20:10:54 +00:00
}
2007-04-07 20:42:08 +00:00
}
if ( ! $hResult )
return FALSE ;
return $hResult ;
}
2007-09-24 21:11:29 -04:00
public 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 );
2007-07-23 19:56:43 +00:00
2007-11-04 22:32:19 +01:00
$aMaintainers = Maintainer :: getSuperMaintainersUserIdsFromAppId ( $this -> iAppId );
2007-10-20 06:39:01 -06:00
2007-07-23 19:56:43 +00:00
$oTableRow = new TableRow ();
2007-07-31 23:48:22 +00:00
$oTableRow -> AddTextCell ( print_date ( mysqldatetime_to_unixtimestamp ( $this -> sSubmitTime )));
2007-07-23 19:56:43 +00:00
$oTableRow -> AddTextCell ( $oUser -> objectMakeLink ());
$oTableRow -> AddTextCell ( $oVendor -> objectMakeLink ());
$oTableRow -> AddTextCell ( $oApp -> objectMakeLink ());
$oTableRow -> AddTextCell ( $this -> sName );
2007-11-04 22:32:19 +01:00
$oTableRow -> AddTextCell ( sizeof ( $aMaintainers ) ? " YES " : " No " );
2007-07-23 19:56:43 +00:00
$oOMTableRow = new OMTableRow ( $oTableRow );
return $oOMTableRow ;
2007-04-07 20:42:08 +00:00
}
2007-09-24 21:11:29 -04:00
public function objectDisplayQueueProcessingHelp ()
2007-04-07 20:42:08 +00:00
{
2008-11-25 21:30:41 +01:00
echo " <p>This is the list of version entries waiting to be processed.</p> \n " ;
echo " <p>To view and process an entry, use the links under ‘Action’</p> " ;
2007-04-04 00:30:42 +00:00
}
2007-04-23 23:31:24 +00:00
2007-12-12 22:43:22 +01:00
public function getTestResults ( $bIncludeDeleted = false )
2007-09-08 22:38:20 +00:00
{
2007-12-12 22:43:22 +01:00
/* If we don 't have an id we can' t query the database , but perhaps we
2007-10-25 11:10:32 +02:00
have some cached entries ? */
if ( ! $this -> iVersionId )
return $this -> aTestResults ;
$aTests = array ();
2007-09-08 22:38:20 +00:00
2007-12-12 22:43:22 +01:00
if ( $bIncludeDeleted )
$sExcludeDeleted = " " ;
else
$sExcludeDeleted = " AND state != 'deleted' " ;
2007-09-08 22:38:20 +00:00
/* Find test results */
2007-12-12 22:43:22 +01:00
$sQuery = " SELECT * FROM testResults WHERE versionId = '?' $sExcludeDeleted " ;
2007-09-08 22:38:20 +00:00
$hResult = query_parameters ( $sQuery , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
2007-10-25 11:10:32 +02:00
$aTests [] = new testData ( 0 , $oRow );
return $aTests ;
}
2007-12-12 22:43:22 +01:00
public function objectGetChildren ( $bIncludeDeleted = false )
2009-04-16 00:26:20 +02:00
{
return $this -> objectGetChildrenClassSpecific ( '' , $bIncludeDeleted );
}
public function objectGetChildrenClassSpecific ( $sClass = '' , $bIncludeDeleted = false )
2007-10-25 11:10:32 +02:00
{
$aChildren = array ();
2007-12-12 22:43:22 +01:00
foreach ( $this -> getTestResults ( $bIncludeDeleted ) as $oTest )
2007-09-08 22:38:20 +00:00
{
2007-12-12 22:43:22 +01:00
$aChildren += $oTest -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oTest ;
}
/* Find maintainers */
$sQuery = " SELECT * FROM appMaintainers WHERE versionId = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oMaintainer = new maintainer ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oMaintainer -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oMaintainer ;
}
/* Find monitors */
$sQuery = " SELECT * FROM appMonitors WHERE versionId = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oMonitor = new monitor ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oMonitor -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oMonitor ;
}
/* Find notes */
$sQuery = " SELECT * FROM appNotes WHERE versionId = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oNote = new note ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oNote -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oNote ;
}
/* Find screenshots */
$sQuery = " SELECT * FROM appData WHERE type = '?' AND versionId = '?' " ;
$hResult = query_parameters ( $sQuery , " screenshot " , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oScreenshot = new screenshot ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oScreenshot -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oScreenshot ;
}
/* Get bug links */
foreach ( $this -> get_buglink_ids () as $iBugId )
{
$oBug = new bug ( $iBugId );
2007-12-12 22:43:22 +01:00
$aChildren += $oBug -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oBug ;
}
/* Get comments */
$sQuery = " SELECT * FROM appComments WHERE versionId = '?' " ;
$hResult = query_parameters ( $sQuery , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oComment = new comment ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oComment -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oComment ;
}
/* Get urls */
$sQuery = " SELECT * FROM appData WHERE type = '?' AND versionId = '?' " ;
$hResult = query_parameters ( $sQuery , " url " , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oUrl = new url ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oUrl -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oUrl ;
}
/* Get downloadurls */
$sQuery = " SELECT * FROM appData WHERE type = '?' AND versionId = '?' " ;
$hResult = query_parameters ( $sQuery , " downloadurl " , $this -> iVersionId );
if ( ! $hResult )
return FALSE ;
while ( $oRow = mysql_fetch_object ( $hResult ))
{
$oDownload = new downloadurl ( 0 , $oRow );
2007-12-12 22:43:22 +01:00
$aChildren += $oDownload -> objectGetChildren ( $bIncludeDeleted );
2007-09-08 22:38:20 +00:00
$aChildren [] = $oDownload ;
}
return $aChildren ;
}
2007-09-24 21:11:29 -04:00
public function objectMoveChildren ( $iNewId )
2007-04-23 23:31:24 +00:00
{
/* 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 ;
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2007-04-23 23:31:24 +00:00
{
$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 ;
2007-08-03 23:27:25 +00:00
while ( $oRow = query_fetch_object ( $hResult ))
2007-04-23 23:31:24 +00:00
{
$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
2007-09-24 21:11:29 -04:00
public static function allowAnonymousSubmissions ()
2007-04-29 23:00:01 +00:00
{
return FALSE ;
}
2007-06-14 00:50:35 +00:00
2007-11-05 18:38:06 +01:00
function objectAllowPurgingRejected ()
{
return TRUE ;
}
public function objectGetSubmitTime ()
{
return mysqltimestamp_to_unixtimestamp ( $this -> sSubmitTime );
}
2007-09-24 21:11:29 -04:00
public function objectGetId ()
2007-06-14 00:50:35 +00:00
{
return $this -> iVersionId ;
}
2005-10-30 22:27:14 +00:00
}
2005-02-06 17:49:48 +00:00
?>