2005-10-17 03:59:24 +00:00
|
|
|
<?php
|
|
|
|
|
/***************************************/
|
|
|
|
|
/* this class represents Distributions */
|
|
|
|
|
/***************************************/
|
|
|
|
|
require_once(BASE."include/mail.php");
|
2006-06-17 06:10:10 +00:00
|
|
|
require_once(BASE."include/util.php");
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2006-12-31 19:39:41 +00:00
|
|
|
// Test class for handling Distributions.
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2007-01-27 00:30:00 +00:00
|
|
|
class distribution {
|
2005-10-17 03:59:24 +00:00
|
|
|
var $iDistributionId;
|
|
|
|
|
var $sName;
|
|
|
|
|
var $sUrl;
|
|
|
|
|
var $sSubmitTime;
|
|
|
|
|
var $iSubmitterId;
|
2007-12-12 19:13:16 +01:00
|
|
|
private $sState;
|
2005-10-17 03:59:24 +00:00
|
|
|
var $aTestingIds;
|
|
|
|
|
|
|
|
|
|
// constructor, fetches the data.
|
2007-02-01 02:06:38 +00:00
|
|
|
function distribution($iDistributionId = null, $oRow = null)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-09-08 22:38:20 +00:00
|
|
|
$this->aTestingIds = array();
|
2005-10-17 03:59:24 +00:00
|
|
|
// we are working on an existing distribution.
|
2007-06-10 18:51:33 +00:00
|
|
|
if(!$iDistributionId && !$oRow)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// We fetch the data related to this distribution.
|
|
|
|
|
if(!$oRow)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-06-10 18:51:33 +00:00
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM distributions
|
|
|
|
|
WHERE distributionId = '?'";
|
|
|
|
|
if($hResult = query_parameters($sQuery, $iDistributionId))
|
2007-08-03 23:27:25 +00:00
|
|
|
$oRow = query_fetch_object($hResult);
|
2007-06-10 18:51:33 +00:00
|
|
|
}
|
2007-02-01 02:06:38 +00:00
|
|
|
|
2007-06-10 18:51:33 +00:00
|
|
|
if($oRow)
|
|
|
|
|
{
|
|
|
|
|
$this->iDistributionId = $oRow->distributionId;
|
|
|
|
|
$this->sName = $oRow->name;
|
|
|
|
|
$this->sUrl = $oRow->url;
|
|
|
|
|
$this->sSubmitTime = $oRow->submitTime;
|
|
|
|
|
$this->iSubmitterId = $oRow->submitterId;
|
2007-12-10 22:35:45 +01:00
|
|
|
$this->sState = $oRow->state;
|
2007-06-10 18:51:33 +00:00
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2007-06-10 18:51:33 +00:00
|
|
|
/*
|
|
|
|
|
* We fetch Test Result Ids.
|
|
|
|
|
*/
|
2006-01-14 03:30:35 +00:00
|
|
|
|
2007-06-10 18:51:33 +00:00
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT testingId
|
|
|
|
|
FROM testResults
|
|
|
|
|
WHERE distributionId = '?'
|
|
|
|
|
ORDER BY testedRating;" ;
|
|
|
|
|
} else /* only let users view test results that aren't queued and for apps that */
|
|
|
|
|
/* aren't queued or versions that aren't queued */
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT testingId
|
|
|
|
|
FROM testResults, appFamily, appVersion
|
2007-12-12 20:17:27 +01:00
|
|
|
WHERE testResults.state = 'accepted' AND
|
2007-06-10 18:51:33 +00:00
|
|
|
testResults.versionId = appVersion.versionId AND
|
|
|
|
|
appFamily.appId = appVersion.appId AND
|
2007-12-12 22:25:01 +01:00
|
|
|
appFamily.state = 'accepted' AND
|
2007-12-12 20:56:04 +01:00
|
|
|
appVersion.state = 'accepted' AND
|
2007-06-10 18:51:33 +00:00
|
|
|
distributionId = '?'
|
|
|
|
|
ORDER BY testedRating;";
|
|
|
|
|
}
|
2006-01-14 03:30:35 +00:00
|
|
|
|
2007-06-14 00:50:35 +00:00
|
|
|
if($hResult = query_parameters($sQuery, $this->iDistributionId))
|
2007-06-10 18:51:33 +00:00
|
|
|
{
|
2007-08-03 23:27:25 +00:00
|
|
|
while($oRow = query_fetch_object($hResult))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-06-10 18:51:33 +00:00
|
|
|
$this->aTestingIds[] = $oRow->testingId;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Creates a new distribution.
|
|
|
|
|
function create()
|
|
|
|
|
{
|
|
|
|
|
//Let's not create a duplicate
|
|
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM distributions
|
2007-05-26 01:37:25 +00:00
|
|
|
WHERE name = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $this->sName);
|
|
|
|
|
|
2007-08-03 23:27:25 +00:00
|
|
|
if($hResult && $oRow = query_fetch_object($hResult))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-08-03 23:27:25 +00:00
|
|
|
if(query_num_rows($hResult))
|
2007-05-26 01:37:25 +00:00
|
|
|
{
|
|
|
|
|
addmsg("There was an existing distribution called ".$this->sName.".", "red");
|
|
|
|
|
$this->distribution($oRow->distributionId);
|
|
|
|
|
|
|
|
|
|
/* Even though we did not create a new distribution, the caller is provided
|
|
|
|
|
with a valid distribution object. Thus no special handling is necessary,
|
|
|
|
|
so we return TRUE */
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-31 23:48:22 +00:00
|
|
|
$hResult = query_parameters("INSERT INTO distributions (name, url, submitTime, ".
|
2007-12-10 22:35:45 +01:00
|
|
|
"submitterId, state) ".
|
2007-07-31 23:48:22 +00:00
|
|
|
"VALUES ('?', '?', ?, '?', '?')",
|
2007-04-21 17:50:44 +00:00
|
|
|
$this->sName, $this->sUrl,
|
2007-07-31 23:48:22 +00:00
|
|
|
"NOW()",
|
2007-04-21 17:50:44 +00:00
|
|
|
$_SESSION['current']->iUserId,
|
2007-12-10 22:35:45 +01:00
|
|
|
$this->mustBeQueued() ? 'queued' : 'accepted');
|
2006-06-24 04:20:32 +00:00
|
|
|
if($hResult)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-08-03 23:27:25 +00:00
|
|
|
$this->iDistributionId = query_appdb_insert_id();
|
2005-10-17 03:59:24 +00:00
|
|
|
$this->distribution($this->iDistributionId);
|
|
|
|
|
$this->SendNotificationMail();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
2006-06-24 04:20:32 +00:00
|
|
|
{
|
|
|
|
|
addmsg("Error while creating Distribution.", "red");
|
2005-10-17 03:59:24 +00:00
|
|
|
return false;
|
2006-06-24 04:20:32 +00:00
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update Distribution.
|
|
|
|
|
function update()
|
|
|
|
|
{
|
|
|
|
|
// is the current user allowed to update this Distribution?
|
|
|
|
|
if(!$_SESSION['current']->hasPriv("admin") &&
|
|
|
|
|
!($_SESSION['current']->iUserId == $this->iSubmitterId))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-07-04 03:43:06 +00:00
|
|
|
if(query_parameters("UPDATE distributions SET name = '?', url = '?' WHERE distributionId = '?'",
|
|
|
|
|
$this->sName, $this->sUrl, $this->iDistributionId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
$this->SendNotificationMail("edit");
|
|
|
|
|
return true;
|
2006-06-27 19:16:27 +00:00
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
addmsg("Error while updating Distribution", "red");
|
2005-10-17 03:59:24 +00:00
|
|
|
return false;
|
2006-06-27 19:16:27 +00:00
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
2007-09-14 23:02:12 -04:00
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
// Delete Distributution.
|
2007-09-14 23:02:12 -04:00
|
|
|
function delete()
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-04-27 23:22:37 +00:00
|
|
|
/* Is the current user allowed to delete this distribution? We allow
|
|
|
|
|
everyone to delete a queued, empty distribution, because it should be
|
|
|
|
|
deleted along with the last testData associated with it */
|
|
|
|
|
if(!($this->canEdit() || (!sizeof($this->aTestingIds) &&
|
2007-12-10 22:35:45 +01:00
|
|
|
$this->sState != 'accepted')))
|
2007-07-31 03:31:07 +00:00
|
|
|
return false;
|
2007-03-13 16:59:35 +00:00
|
|
|
|
2007-08-24 03:49:33 +00:00
|
|
|
// if the distribution has test results only enable an admin to delete
|
|
|
|
|
// the distribution
|
|
|
|
|
if(sizeof($this->aTestingIds) && !$_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2007-09-08 22:38:20 +00:00
|
|
|
$bSuccess = TRUE;
|
|
|
|
|
|
|
|
|
|
foreach($this->objectGetChildren() as $oChild)
|
2007-03-13 16:59:35 +00:00
|
|
|
{
|
2007-09-08 22:38:20 +00:00
|
|
|
if(!$oChild->delete())
|
|
|
|
|
$bSuccess = FALSE;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
2007-03-13 16:59:35 +00:00
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
// now delete the Distribution
|
|
|
|
|
$sQuery = "DELETE FROM distributions
|
2006-06-27 19:16:27 +00:00
|
|
|
WHERE distributionId = '?'
|
2005-10-17 03:59:24 +00:00
|
|
|
LIMIT 1";
|
2006-06-27 19:16:27 +00:00
|
|
|
if(!($hResult = query_parameters($sQuery, $this->iDistributionId)))
|
2007-09-08 22:38:20 +00:00
|
|
|
$bSuccess = FALSE;
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2007-09-08 22:38:20 +00:00
|
|
|
return $bSuccess;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move Distribution out of the queue.
|
|
|
|
|
function unQueue()
|
|
|
|
|
{
|
2007-04-27 23:22:37 +00:00
|
|
|
/* Check permissions */
|
|
|
|
|
if($this->mustBeQueued())
|
|
|
|
|
return FALSE;
|
2005-10-17 03:59:24 +00:00
|
|
|
|
|
|
|
|
// If we are not in the queue, we can't move the Distribution out of the queue.
|
2007-12-10 22:35:45 +01:00
|
|
|
if($this->sState != 'queued')
|
2005-10-17 03:59:24 +00:00
|
|
|
return false;
|
|
|
|
|
|
2007-12-10 22:35:45 +01:00
|
|
|
if(query_parameters("UPDATE distributions SET state = '?' WHERE distributionId = '?'",
|
|
|
|
|
'accepted', $this->iDistributionId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-12-10 22:35:45 +01:00
|
|
|
$this->sState = 'accepted';
|
2006-12-31 19:39:41 +00:00
|
|
|
// we send an e-mail to interested people
|
2007-06-16 17:02:25 +00:00
|
|
|
$this->mailSubmitter("add");
|
2005-10-17 03:59:24 +00:00
|
|
|
$this->SendNotificationMail();
|
2006-06-27 19:16:27 +00:00
|
|
|
return true;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
addmsg("Error while unqueueing Distribution", "red");
|
|
|
|
|
return false;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Reject($bSilent=false)
|
|
|
|
|
{
|
|
|
|
|
// is the current user allowed to reject this Distribution?
|
|
|
|
|
if(!$_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
{
|
2006-06-27 19:16:27 +00:00
|
|
|
return false;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we are not in the queue, we can't move the Distribution out of the queue.
|
2007-12-10 22:35:45 +01:00
|
|
|
if($this->sState != 'queued')
|
2005-10-17 03:59:24 +00:00
|
|
|
return false;
|
|
|
|
|
|
2007-03-13 16:59:35 +00:00
|
|
|
return $this->delete();
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-08 22:38:20 +00:00
|
|
|
function getTestResults()
|
|
|
|
|
{
|
|
|
|
|
$aTests = array();
|
|
|
|
|
$sQuery = "SELECT * FROM testResults WHERE distributionId = '?'";
|
|
|
|
|
$hResult = query_parameters($sQuery, $this->iDistributionId);
|
|
|
|
|
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
2007-09-24 22:25:49 -04:00
|
|
|
$aTests[] = new testData(null, $oRow);
|
2007-09-08 22:38:20 +00:00
|
|
|
|
|
|
|
|
return $aTests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectGetChildren()
|
|
|
|
|
{
|
|
|
|
|
$aChildren = array();
|
|
|
|
|
|
|
|
|
|
foreach($this->getTestResults() as $oTest)
|
|
|
|
|
{
|
|
|
|
|
$aChildren += $oTest->objectGetChildren();
|
|
|
|
|
$aChildren[] = $oTest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $aChildren;
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
function ReQueue()
|
|
|
|
|
{
|
|
|
|
|
// is the current user allowed to requeue this data
|
|
|
|
|
if(!$_SESSION['current']->hasPriv("admin") &&
|
|
|
|
|
!($_SESSION['current']->iUserId == $this->iSubmitterId))
|
|
|
|
|
{
|
2006-06-27 19:16:27 +00:00
|
|
|
return false;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-12 20:17:27 +01:00
|
|
|
if(query_parameters("UPDATE testResults SET state = '?' WHERE testingId = '?'",
|
|
|
|
|
'queued', $this->iTestingId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-12-10 22:35:45 +01:00
|
|
|
if(query_parameters("UPDATE distribution SET state = '?' WHERE distributionId = '?'",
|
|
|
|
|
'queued', $this->iDistributionId))
|
2006-06-27 19:16:27 +00:00
|
|
|
{
|
2007-12-10 22:35:45 +01:00
|
|
|
$this->sState = 'queued';
|
2006-12-31 19:39:41 +00:00
|
|
|
// we send an e-mail to interested people
|
2006-06-27 19:16:27 +00:00
|
|
|
$this->SendNotificationMail();
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2006-12-31 19:39:41 +00:00
|
|
|
// the test data has been resubmitted
|
2006-06-27 19:16:27 +00:00
|
|
|
addmsg("The Distribution has been resubmitted", "green");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
2006-06-27 19:16:27 +00:00
|
|
|
|
|
|
|
|
/* something has failed if we fell through to this point without */
|
|
|
|
|
/* returning */
|
|
|
|
|
addmsg("Error requeueing Distribution", "red");
|
|
|
|
|
return false;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-09-14 23:02:12 -04:00
|
|
|
function objectGetSubmitterId()
|
|
|
|
|
{
|
|
|
|
|
return $this->iSubmitterId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction)
|
|
|
|
|
{
|
|
|
|
|
return new mailOptions();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectGetMail($sAction, $bMailSubmitter, $bParentAction)
|
|
|
|
|
{
|
|
|
|
|
$oSubmitter = new user($this->iSubmitterId);
|
|
|
|
|
|
|
|
|
|
if($bMailSubmitter)
|
|
|
|
|
{
|
|
|
|
|
switch($sAction)
|
|
|
|
|
{
|
|
|
|
|
case "delete":
|
|
|
|
|
$sSubject = "Submitted distribution deleted";
|
|
|
|
|
$sMsg = "The distribution you submitted (".$this->sName.") has been ".
|
|
|
|
|
"deleted.\n";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$aMailTo = null;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
switch($sAction)
|
|
|
|
|
{
|
|
|
|
|
case "delete":
|
|
|
|
|
$sSubject = "Distribution ".$this->sName." deleted";
|
|
|
|
|
$sMsg = "";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$aMailTo = User::get_notify_email_address_list(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array($sSubject, $sMsg, $aMailTo);
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
function mailSubmitter($sAction="add")
|
|
|
|
|
{
|
2007-01-04 02:35:01 +00:00
|
|
|
global $aClean;
|
2006-06-17 06:10:10 +00:00
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
if($this->iSubmitterId)
|
|
|
|
|
{
|
|
|
|
|
$oSubmitter = new User($this->iSubmitterId);
|
|
|
|
|
switch($sAction)
|
|
|
|
|
{
|
|
|
|
|
case "add":
|
|
|
|
|
{
|
|
|
|
|
$sSubject = "Submitted Distribution accepted";
|
2007-06-16 17:02:25 +00:00
|
|
|
$sMsg = "The Distribution you submitted (".$this->sName.") has been accepted.\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "delete":
|
|
|
|
|
{
|
|
|
|
|
$sSubject = "Submitted Distribution deleted";
|
|
|
|
|
$sMsg = "The Distribution you submitted (".$this->sName.") has been deleted.";
|
|
|
|
|
$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-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$sMsg .= "We appreciate your help in making the Application Database better for all users.";
|
2007-09-08 22:38:20 +00:00
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
mail_appdb($oSubmitter->sEmail, $sSubject ,$sMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function SendNotificationMail($sAction="add",$sMsg=null)
|
|
|
|
|
{
|
2007-01-04 02:35:01 +00:00
|
|
|
global $aClean;
|
2006-06-17 06:10:10 +00:00
|
|
|
|
2005-10-17 03:59:24 +00:00
|
|
|
switch($sAction)
|
|
|
|
|
{
|
|
|
|
|
case "add":
|
2007-12-10 22:35:45 +01:00
|
|
|
if($this->sState == 'accepted')
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-03-13 21:03:08 +00:00
|
|
|
$sSubject = "Distribution ".$this->sName." added by ".
|
|
|
|
|
$_SESSION['current']->sRealname;
|
2007-03-17 21:00:41 +00:00
|
|
|
$sMsg = $this->objectMakeUrl()."\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
if($this->iSubmitterId)
|
|
|
|
|
{
|
|
|
|
|
$oSubmitter = new User($this->iSubmitterId);
|
|
|
|
|
$sMsg .= "This Distribution has been submitted by ".$oSubmitter->sRealname.".";
|
|
|
|
|
$sMsg .= "\n";
|
|
|
|
|
$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-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
addmsg("The Distribution was successfully added into the database.", "green");
|
2006-12-31 19:39:41 +00:00
|
|
|
} else // test data queued.
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
$sSubject = "Distribution ".$this->sName." submitted by ".$_SESSION['current']->sRealname;
|
2006-12-31 19:39:41 +00:00
|
|
|
$sMsg .= "This test data has been queued.";
|
2005-10-17 03:59:24 +00:00
|
|
|
$sMsg .= "\n";
|
|
|
|
|
addmsg("The Distribution you submitted will be added to the database after being reviewed.", "green");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "edit":
|
|
|
|
|
$sSubject = "Distribution ".$this->sName." has been modified by ".$_SESSION['current']->sRealname;
|
2007-03-13 21:03:08 +00:00
|
|
|
$sMsg = $this->objectMakeUrl()."\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
addmsg("Distribution modified.", "green");
|
|
|
|
|
break;
|
|
|
|
|
case "delete":
|
|
|
|
|
$sSubject = "Distribution ".$this->sName." has been deleted by ".$_SESSION['current']->sRealname;
|
|
|
|
|
|
2006-07-13 18:54:10 +00:00
|
|
|
// if sReplyText is set we should report the reason the data was deleted
|
|
|
|
|
if($aClean['sReplyText'])
|
2005-10-17 03:59:24 +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-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addmsg("Distribution deleted.", "green");
|
|
|
|
|
break;
|
|
|
|
|
case "reject":
|
2007-03-13 21:03:08 +00:00
|
|
|
$sSubject = "Distribution '".$this->sName." has been rejected by ".
|
|
|
|
|
$_SESSION['current']->sRealname;
|
|
|
|
|
$sMsg = $this->objectMakeUrl()."\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2006-07-13 18:54:10 +00:00
|
|
|
// if sReplyText is set we should report the reason the data was rejected
|
|
|
|
|
if($aClean['sReplyText'])
|
2005-10-17 03:59:24 +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-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addmsg("Distribution rejected.", "green");
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-06-29 15:54:29 +00:00
|
|
|
$sEmail = User::get_notify_email_address_list(null, null);
|
2005-10-17 03:59:24 +00:00
|
|
|
if($sEmail)
|
|
|
|
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-17 03:18:49 +00:00
|
|
|
function outputEditor()
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
|
|
|
|
|
2007-04-21 18:09:13 +00:00
|
|
|
$this->sName = str_replace('"', '"', $this->sName);
|
2005-10-17 03:59:24 +00:00
|
|
|
// Name
|
2007-04-17 23:19:48 +00:00
|
|
|
echo html_tr(array(
|
2007-05-02 01:08:22 +00:00
|
|
|
array("<b>Distribution Name:</b>", 'align=right class="color0"'),
|
2007-04-17 23:19:48 +00:00
|
|
|
array('<input type=text name="sDistribution" value="'.$this->sName.
|
2007-05-02 01:08:22 +00:00
|
|
|
'" size="60" />', 'class="color0"')
|
2007-04-17 23:19:48 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
|
|
// URL
|
|
|
|
|
echo html_tr(array(
|
2007-05-02 01:08:22 +00:00
|
|
|
array("<b>Distribution URL:</b>", 'align=right class="color0"'),
|
2007-04-17 23:19:48 +00:00
|
|
|
array('<input type=text name="sUrl" value="'.$this->sUrl.
|
2007-05-02 01:08:22 +00:00
|
|
|
'" size="60" />', 'class="color0"')
|
2007-04-17 23:19:48 +00:00
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "</table>\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
|
2007-04-16 23:10:08 +00:00
|
|
|
if($this->iDistributionId)
|
|
|
|
|
{
|
|
|
|
|
echo '<input type="hidden" name="iDistributionId" '.
|
|
|
|
|
'value="'.$this->iDistributionId.'">',"\n";
|
|
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2007-01-17 03:18:49 +00:00
|
|
|
/* retrieves values from $_REQUEST 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-17 03:59:24 +00:00
|
|
|
{
|
2007-10-23 21:49:06 +02:00
|
|
|
if($aClean['iDistributionId'])
|
|
|
|
|
$this->iDistributionId = $aValues['iDistributionId'];
|
|
|
|
|
|
2007-04-16 23:10:08 +00:00
|
|
|
$this->sName = $aValues['sDistribution'];
|
2006-07-08 22:06:28 +00:00
|
|
|
$this->sUrl = $aValues['sUrl'];
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-11 17:02:35 +00:00
|
|
|
/* Get the total number of Distributions in the database */
|
2007-03-24 18:30:16 +00:00
|
|
|
function objectGetEntriesCount($bQueued, $bRejected)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-03-24 18:30:16 +00:00
|
|
|
/* Not implemented */
|
|
|
|
|
if($bRejected)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2007-06-13 03:13:06 +00:00
|
|
|
$hResult = query_parameters("SELECT count(distributionId) as num_dists FROM
|
2007-12-10 22:35:45 +01:00
|
|
|
distributions WHERE state='?'",
|
|
|
|
|
$bQueued ? 'queued' : 'accepted');
|
2007-03-13 16:59:35 +00:00
|
|
|
|
2006-07-11 17:02:35 +00:00
|
|
|
if($hResult)
|
|
|
|
|
{
|
2007-08-03 23:27:25 +00:00
|
|
|
$oRow = query_fetch_object($hResult);
|
2006-07-11 17:02:35 +00:00
|
|
|
return $oRow->num_dists;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-11 17:02:35 +00:00
|
|
|
/* Make a dropdown list of distributions */
|
|
|
|
|
function make_distribution_list($varname, $cvalue)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2007-04-19 23:48:23 +00:00
|
|
|
$sQuery = "SELECT name, distributionId FROM distributions
|
2007-12-10 22:35:45 +01:00
|
|
|
WHERE state = 'accepted'
|
2007-04-19 23:48:23 +00:00
|
|
|
ORDER BY name";
|
2006-07-11 17:02:35 +00:00
|
|
|
$hResult = query_parameters($sQuery);
|
|
|
|
|
if(!$hResult) return;
|
|
|
|
|
|
|
|
|
|
echo "<select name='$varname'>\n";
|
|
|
|
|
echo "<option value=\"\">Choose ...</option>\n";
|
2007-08-03 23:27:25 +00:00
|
|
|
while(list($name, $value) = query_fetch_row($hResult))
|
2006-07-11 17:02:35 +00:00
|
|
|
{
|
|
|
|
|
if($value == $cvalue)
|
|
|
|
|
echo "<option value=$value selected>$name\n";
|
|
|
|
|
else
|
|
|
|
|
echo "<option value=$value>$name\n";
|
|
|
|
|
}
|
|
|
|
|
echo "</select>\n";
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
2007-01-27 00:30:00 +00:00
|
|
|
|
2007-03-17 21:04:43 +00:00
|
|
|
function objectGetHeader()
|
2007-01-27 00:30:00 +00:00
|
|
|
{
|
2007-11-26 23:43:27 +01:00
|
|
|
$oTableRow = new TableRowSortable();
|
2007-01-27 00:30:00 +00:00
|
|
|
|
2007-11-26 23:43:27 +01:00
|
|
|
$oTableRow->AddSortableTextCell("Distribution name", "name");
|
2007-07-31 01:51:40 +00:00
|
|
|
|
|
|
|
|
$oTableRow->AddTextCell("Distribution url");
|
|
|
|
|
|
|
|
|
|
$oTableCell = new TableCell("Linked Tests");
|
|
|
|
|
$oTableCell->SetAlign("right");
|
|
|
|
|
$oTableRow->AddCell($oTableCell);
|
|
|
|
|
|
|
|
|
|
return $oTableRow;
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-11-26 23:43:27 +01:00
|
|
|
public static function objectGetSortableFields()
|
|
|
|
|
{
|
|
|
|
|
return array('name');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "name", $bAscending = TRUE)
|
2007-01-27 00:30:00 +00:00
|
|
|
{
|
2007-03-24 18:30:16 +00:00
|
|
|
/* Not implemented */
|
|
|
|
|
if($bRejected)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2007-02-01 02:06:38 +00:00
|
|
|
/* Only users with edit privileges are allowed to view queued
|
|
|
|
|
items, so return NULL in that case */
|
|
|
|
|
if($bQueued && !distribution::canEdit())
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2007-11-26 23:43:27 +01:00
|
|
|
$sOrder = $bAscending ? "ASC" : "DESC";
|
|
|
|
|
|
2007-03-13 18:29:28 +00:00
|
|
|
/* If row limit is 0 we want to fetch all rows */
|
2007-02-01 02:06:38 +00:00
|
|
|
if(!$iRows)
|
2007-03-24 18:30:16 +00:00
|
|
|
$iRows = distribution::objectGetEntriesCount($bQueued, $bRejected);
|
2007-02-01 02:06:38 +00:00
|
|
|
|
|
|
|
|
$sQuery = "SELECT * FROM distributions
|
2007-12-10 22:35:45 +01:00
|
|
|
WHERE state = '?' ORDER BY $sOrderBy $sOrder LIMIT ?,?";
|
2007-02-01 02:06:38 +00:00
|
|
|
|
2007-12-10 22:35:45 +01:00
|
|
|
return query_parameters($sQuery, $bQueued ? 'queued' : 'accepted',
|
2007-02-01 02:06:38 +00:00
|
|
|
$iStart, $iRows);
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-06-14 00:50:35 +00:00
|
|
|
function objectGetTableRow()
|
2007-01-27 00:30:00 +00:00
|
|
|
{
|
2007-07-23 19:56:43 +00:00
|
|
|
$oTableRow = new TableRow();
|
|
|
|
|
|
|
|
|
|
$oTableRow->AddTextCell($this->objectMakeLink());
|
|
|
|
|
|
|
|
|
|
$oTableCell = new TableCell("$this->sUrl");
|
|
|
|
|
$oTableCell->SetCellLink($this->sUrl);
|
|
|
|
|
$oTableRow->AddCell($oTableCell);
|
|
|
|
|
|
|
|
|
|
$oTableCell = new TableCell(sizeof($this->aTestingIds));
|
|
|
|
|
$oTableCell->SetAlign("right");
|
|
|
|
|
$oTableRow->AddCell($oTableCell);
|
2007-01-27 00:30:00 +00:00
|
|
|
|
2007-07-02 00:35:17 +00:00
|
|
|
// enable the 'delete' action if this distribution has no testing results
|
|
|
|
|
$bDeleteLink = sizeof($this->aTestingIds) ? FALSE : TRUE;
|
2007-01-27 00:30:00 +00:00
|
|
|
|
2007-07-23 19:56:43 +00:00
|
|
|
$oOMTableRow = new OMTableRow($oTableRow);
|
2007-09-18 21:22:43 -04:00
|
|
|
$oOMTableRow->SetHasDeleteLink($bDeleteLink);
|
2007-07-23 19:56:43 +00:00
|
|
|
return $oOMTableRow;
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-12-12 19:13:16 +01:00
|
|
|
public function objectGetState()
|
|
|
|
|
{
|
|
|
|
|
return $this->sState;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-27 00:30:00 +00:00
|
|
|
// Whether the user has permission to edit distributions
|
|
|
|
|
function canEdit()
|
|
|
|
|
{
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2007-04-27 23:22:37 +00:00
|
|
|
/* Maintainers are allowed to process queued test results and therefore also
|
|
|
|
|
queued distributions */
|
2007-12-10 22:35:45 +01:00
|
|
|
if(is_object($this) && $this->sState != 'accepted' &&
|
2007-04-27 23:22:37 +00:00
|
|
|
maintainer::isUserMaintainer($_SESSION['current']))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2007-01-27 00:30:00 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-01-31 02:18:18 +00:00
|
|
|
|
2007-04-21 17:50:44 +00:00
|
|
|
function mustBeQueued()
|
|
|
|
|
{
|
2007-04-27 23:22:37 +00:00
|
|
|
if($_SESSION['current']->hasPriv("admin") ||
|
|
|
|
|
maintainer::isUserMaintainer($_SESSION['current']))
|
2007-04-21 17:50:44 +00:00
|
|
|
return FALSE;
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-13 16:59:35 +00:00
|
|
|
function objectHideDelete()
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-31 02:18:18 +00:00
|
|
|
function display()
|
|
|
|
|
{
|
|
|
|
|
echo "Distribution Name:";
|
|
|
|
|
|
|
|
|
|
if($this->sUrl)
|
|
|
|
|
echo "<a href='".$this->sUrl."'>";
|
|
|
|
|
|
|
|
|
|
echo $this->sName;
|
|
|
|
|
|
|
|
|
|
if ($this->sUrl)
|
|
|
|
|
{
|
|
|
|
|
echo " (".$this->sUrl.")";
|
|
|
|
|
echo "</a> <br />\n";
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
echo "<br />\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($this->aTestingIds)
|
|
|
|
|
{
|
2007-11-09 23:28:01 +01:00
|
|
|
echo '<p><span class="title">Test Results for '.$this->sName.'</span><br />',"\n";
|
2007-01-31 02:18:18 +00:00
|
|
|
echo '<table width="100%" border="1">',"\n";
|
|
|
|
|
echo '<thead class="historyHeader">',"\n";
|
|
|
|
|
echo '<tr>',"\n";
|
|
|
|
|
echo '<td>Application Version</td>',"\n";
|
|
|
|
|
echo '<td>Submitter</td>',"\n";
|
|
|
|
|
echo '<td>Date Submitted</td>',"\n";
|
|
|
|
|
echo '<td>Wine version</td>',"\n";
|
|
|
|
|
echo '<td>Installs?</td>',"\n";
|
|
|
|
|
echo '<td>Runs?</td>',"\n";
|
|
|
|
|
echo '<td>Rating</td>',"\n";
|
|
|
|
|
echo '</tr></thead>',"\n";
|
|
|
|
|
foreach($this->aTestingIds as $iTestingId)
|
|
|
|
|
{
|
|
|
|
|
$oTest = new testData($iTestingId);
|
|
|
|
|
$oVersion = new Version($oTest->iVersionId);
|
|
|
|
|
$oApp = new Application($oVersion->iAppId);
|
|
|
|
|
$oSubmitter = new User($oTest->iSubmitterId);
|
|
|
|
|
$bgcolor = $oTest->sTestedRating;
|
|
|
|
|
|
|
|
|
|
/* make sure the user can view the versions we list in the table */
|
|
|
|
|
/* otherwise skip over displaying the entries in this table */
|
|
|
|
|
if(!$_SESSION[current]->canViewApplication($oApp))
|
|
|
|
|
continue;
|
|
|
|
|
if(!$_SESSION[current]->canViewVersion($oVersion))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
echo '<tr class='.$bgcolor.'>',"\n";
|
2007-04-03 02:08:44 +00:00
|
|
|
echo '<td><a href="'.$oVersion->objectMakeUrl().'&iTestingId='.$oTest->iTestingId.'">',"\n";
|
|
|
|
|
echo version::fullName($oVersion->iVersionId).'</a></td>',"\n";
|
2007-01-31 02:18:18 +00:00
|
|
|
echo '<td>',"\n";
|
|
|
|
|
if($_SESSION['current']->isLoggedIn())
|
|
|
|
|
{
|
|
|
|
|
echo $oSubmitter->sEmail ? "<a href=\"mailto:".$oSubmitter->sEmail."\">":"";
|
|
|
|
|
echo $oSubmitter->sRealname;
|
|
|
|
|
echo $oSubmitter->sEmail ? "</a>":"";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
echo $oSubmitter->sRealname;
|
|
|
|
|
echo '</td>',"\n";
|
2007-07-31 23:48:22 +00:00
|
|
|
echo '<td>'.date("M d Y", mysqldatetime_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
|
2007-01-31 02:18:18 +00:00
|
|
|
echo '<td>'.$oTest->sTestedRelease.' </td>',"\n";
|
|
|
|
|
echo '<td>'.$oTest->sInstalls.' </td>',"\n";
|
|
|
|
|
echo '<td>'.$oTest->sRuns.' </td>',"\n";
|
|
|
|
|
echo '<td>'.$oTest->sTestedRating.' </td>',"\n";
|
|
|
|
|
if ($_SESSION['current']->hasAppVersionModifyPermission($oVersion))
|
|
|
|
|
{
|
2007-03-25 03:56:20 +00:00
|
|
|
echo '<td><a href="'.$oTest->objectMakeUrl().'">',"\n";
|
2007-01-31 02:18:18 +00:00
|
|
|
echo 'Edit</a></td>',"\n";
|
|
|
|
|
}
|
|
|
|
|
echo '</tr>',"\n";
|
|
|
|
|
}
|
|
|
|
|
echo '</table>',"\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-03-13 21:03:08 +00:00
|
|
|
|
|
|
|
|
/* Make a URL for viewing the specified distribution */
|
|
|
|
|
function objectMakeUrl()
|
|
|
|
|
{
|
|
|
|
|
$oObject = new objectManager("distribution", "View Distribution");
|
|
|
|
|
return $oObject->makeUrl("view", $this->iDistributionId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make an HTML link for viewing the specified distirbution */
|
|
|
|
|
function objectMakeLink()
|
|
|
|
|
{
|
|
|
|
|
return "<a href=\"".$this->objectMakeUrl()."\">$this->sName</a>";
|
|
|
|
|
}
|
2007-04-27 23:43:43 +00:00
|
|
|
|
|
|
|
|
function objectMoveChildren($iNewId)
|
|
|
|
|
{
|
|
|
|
|
/* Keep track of how many children we modified */
|
|
|
|
|
$iCount = 0;
|
|
|
|
|
|
|
|
|
|
foreach($this->aTestingIds as $iTestId)
|
|
|
|
|
{
|
|
|
|
|
$oTest = new testData($iTestId);
|
|
|
|
|
$oTest->iDistributionId = $iNewId;
|
|
|
|
|
if($oTest->update(TRUE))
|
|
|
|
|
$iCount++;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $iCount;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-25 16:01:03 +00:00
|
|
|
function objectGetItemsPerPage($bQueued = false)
|
|
|
|
|
{
|
|
|
|
|
$aItemsPerPage = array(25, 50, 100, 200);
|
|
|
|
|
$iDefaultPerPage = 25;
|
|
|
|
|
return array($aItemsPerPage, $iDefaultPerPage);
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-27 23:43:43 +00:00
|
|
|
function objectGetid()
|
|
|
|
|
{
|
|
|
|
|
return $this->iDistributionId;
|
|
|
|
|
}
|
2007-04-29 23:00:01 +00:00
|
|
|
|
|
|
|
|
function allowAnonymousSubmissions()
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-09-08 22:42:34 +00:00
|
|
|
|
|
|
|
|
function objectShowAddEntry()
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|