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;
|
|
|
|
|
var $sQueued;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
// we are working on an existing distribution.
|
|
|
|
|
if(is_numeric($iDistributionId))
|
|
|
|
|
{
|
|
|
|
|
// We fetch the data related to this distribution.
|
2007-02-01 02:06:38 +00:00
|
|
|
if(!$oRow)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM distributions
|
2006-06-27 19:16:27 +00:00
|
|
|
WHERE distributionId = '?'";
|
|
|
|
|
if($hResult = query_parameters($sQuery, $iDistributionId))
|
2005-10-17 03:59:24 +00:00
|
|
|
$oRow = mysql_fetch_object($hResult);
|
2007-02-01 02:06:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($oRow)
|
|
|
|
|
{
|
|
|
|
|
$this->iDistributionId = $iDistributionId;
|
|
|
|
|
$this->sName = $oRow->name;
|
|
|
|
|
$this->sUrl = $oRow->url;
|
|
|
|
|
$this->sSubmitTime = $oRow->submitTime;
|
|
|
|
|
$this->iSubmitterId = $oRow->submitterId;
|
|
|
|
|
$this->sQueued = $oRow->queued;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* We fetch Test Result Ids.
|
|
|
|
|
*/
|
2006-01-14 03:30:35 +00:00
|
|
|
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
{
|
|
|
|
|
$sQuery = "SELECT testingId
|
|
|
|
|
FROM testResults
|
2006-07-09 06:08:00 +00:00
|
|
|
WHERE distributionId = '?'
|
|
|
|
|
ORDER BY testedRating;" ;
|
2006-01-14 03:30:35 +00:00
|
|
|
} 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
|
|
|
|
|
WHERE testResults.queued = 'false' AND
|
|
|
|
|
testResults.versionId = appVersion.versionId AND
|
|
|
|
|
appFamily.appId = appVersion.appId AND
|
|
|
|
|
appFamily.queued = 'false' AND
|
|
|
|
|
appVersion.queued = 'false' AND
|
2006-07-09 06:08:00 +00:00
|
|
|
distributionId = '?'
|
|
|
|
|
ORDER BY testedRating;";
|
2006-01-14 03:30:35 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-27 19:16:27 +00:00
|
|
|
if($hResult = query_parameters($sQuery, $iDistributionId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
while($oRow = mysql_fetch_object($hResult))
|
|
|
|
|
{
|
|
|
|
|
$this->aTestingIds[] = $oRow->testingId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Creates a new distribution.
|
|
|
|
|
function create()
|
|
|
|
|
{
|
|
|
|
|
//Let's not create a duplicate
|
|
|
|
|
$sQuery = "SELECT *
|
|
|
|
|
FROM distributions
|
2006-06-27 19:16:27 +00:00
|
|
|
WHERE name LIKE '?'";
|
|
|
|
|
$hDuplicate = query_parameters($sQuery, $this->sName);
|
2005-10-17 03:59:24 +00:00
|
|
|
if(!mysql_num_rows($hDuplicate) == 0)
|
|
|
|
|
{
|
|
|
|
|
addmsg("There was an existing Distribution called ".$this->sName.".", "red");
|
|
|
|
|
$oRow = mysql_fetch_object($hDuplicate);
|
|
|
|
|
$this->iDistributionId = $oRow->distributionId;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Security, if we are not an administrator the Distributions must be queued.
|
|
|
|
|
if(!$_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
$this->sQueued = 'true';
|
|
|
|
|
else
|
|
|
|
|
$this->sQueued = 'false';
|
|
|
|
|
|
2006-06-24 04:20:32 +00:00
|
|
|
$hResult = query_parameters("INSERT INTO distributions (name, url, submitterId, queued) ".
|
|
|
|
|
"VALUES ('?', '?', '?', '?')",
|
|
|
|
|
$this->sName, $this->sUrl, $_SESSION['current']->iUserId,
|
|
|
|
|
$this->sQueued);
|
|
|
|
|
if($hResult)
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
$this->iDistributionId = mysql_insert_id();
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete Distributution.
|
|
|
|
|
function delete($bSilent=false)
|
|
|
|
|
{
|
|
|
|
|
// is the current user allowed to delete this Distribution?
|
|
|
|
|
if(!$_SESSION['current']->hasPriv("admin") &&
|
|
|
|
|
!($_SESSION['current']->iUserId == $this->iSubmitterId))
|
|
|
|
|
return;
|
2007-03-13 16:59:35 +00:00
|
|
|
|
|
|
|
|
/* Check for associated test results */
|
|
|
|
|
if(sizeof($this->aTestingIds))
|
|
|
|
|
{
|
|
|
|
|
addmsg("This distribution still has associated test results", "red");
|
|
|
|
|
return 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)))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
addmsg("Error removing the Distribution!", "red");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!$bSilent)
|
|
|
|
|
$this->SendNotificationMail("delete");
|
|
|
|
|
|
|
|
|
|
$this->mailSubmitter("delete");
|
2007-01-30 00:43:33 +00:00
|
|
|
|
|
|
|
|
return true;
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Move Distribution out of the queue.
|
|
|
|
|
function unQueue()
|
|
|
|
|
{
|
|
|
|
|
// is the current user allowed to move 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.
|
|
|
|
|
if(!$this->sQueued == 'true')
|
|
|
|
|
return false;
|
|
|
|
|
|
2007-03-13 16:59:35 +00:00
|
|
|
if(query_parameters("UPDATE distributions SET queued = '?' WHERE distributionId = '?'",
|
2006-06-27 19:16:27 +00:00
|
|
|
"false", $this->iDistributionId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
|
|
|
|
$this->sQueued = 'false';
|
2006-12-31 19:39:41 +00:00
|
|
|
// we send an e-mail to interested people
|
2005-10-17 03:59:24 +00:00
|
|
|
$this->mailSubmitter("unQueue");
|
|
|
|
|
$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.
|
|
|
|
|
if(!$this->sQueued == 'true')
|
|
|
|
|
return false;
|
|
|
|
|
|
2007-03-13 16:59:35 +00:00
|
|
|
return $this->delete();
|
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
|
|
|
}
|
|
|
|
|
|
2006-06-27 19:16:27 +00:00
|
|
|
if(query_parameters("UPDATE testResults SET queued = '?' WHERE testingId = '?'",
|
|
|
|
|
"true", $this->iTestingId))
|
2005-10-17 03:59:24 +00:00
|
|
|
{
|
2006-06-27 19:16:27 +00:00
|
|
|
if(query_parameters("UPDATE distribution SET queued = '?' WHERE distributionId = '?'",
|
|
|
|
|
"true", $this->iDistributionId))
|
|
|
|
|
{
|
|
|
|
|
$this->sQueued = 'true';
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
|
$sMsg = "The Distribution you submitted (".$this->sName.") has been accepted.";
|
|
|
|
|
}
|
|
|
|
|
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.";
|
|
|
|
|
|
|
|
|
|
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":
|
|
|
|
|
if($this->sQueued == "false")
|
|
|
|
|
{
|
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";
|
|
|
|
|
|
|
|
|
|
// Name
|
|
|
|
|
echo '<tr valign=top><td class="color1" width="20%"><b>Distribution Name</b></td>',"\n";
|
|
|
|
|
echo '<td class="color0"><input type=text name="sName" value="'.$this->sName.'" size="50"></td></tr>',"\n";
|
|
|
|
|
// Url
|
|
|
|
|
echo '<tr valign=top><td class="color1"><b>Distribution Url</b></td>',"\n";
|
|
|
|
|
echo '<td class="color0"><input type=text name="sUrl" value="'.$this->sUrl.'" size="50"></td></tr>',"\n";
|
|
|
|
|
|
|
|
|
|
echo '<input type="hidden" name="iDistributionId" value="'.$this->iDistributionId.'">',"\n";
|
|
|
|
|
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2006-07-08 22:06:28 +00:00
|
|
|
$this->iDistributionId = $aValues['iDistributionId'];
|
|
|
|
|
$this->sName = $aValues['sName'];
|
|
|
|
|
$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-03-13 16:59:35 +00:00
|
|
|
$hResult = query_parameters("SELECT count(distributionId) as num_dists FROM
|
|
|
|
|
distributions WHERE queued='?'",
|
|
|
|
|
$bQueued ? "true" : "false");
|
|
|
|
|
|
2006-07-11 17:02:35 +00:00
|
|
|
if($hResult)
|
|
|
|
|
{
|
|
|
|
|
$oRow = mysql_fetch_object($hResult);
|
|
|
|
|
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
|
|
|
{
|
2006-07-11 17:02:35 +00:00
|
|
|
$sQuery = "SELECT name, distributionId FROM distributions ORDER BY name";
|
|
|
|
|
$hResult = query_parameters($sQuery);
|
|
|
|
|
if(!$hResult) return;
|
|
|
|
|
|
|
|
|
|
echo "<select name='$varname'>\n";
|
|
|
|
|
echo "<option value=\"\">Choose ...</option>\n";
|
|
|
|
|
while(list($name, $value) = mysql_fetch_row($hResult))
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
$aCells = array(
|
|
|
|
|
"Distribution name",
|
|
|
|
|
"Distribution url",
|
|
|
|
|
array("Linked Tests", "align=\"right\""));
|
|
|
|
|
|
2007-03-17 21:04:43 +00:00
|
|
|
return $aCells;
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-24 18:30:16 +00:00
|
|
|
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
|
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-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
|
|
|
|
|
WHERE queued = '?' ORDER BY name LIMIT ?,?";
|
|
|
|
|
|
|
|
|
|
return query_parameters($sQuery, $bQueued ? "true" : "false",
|
|
|
|
|
$iStart, $iRows);
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-02-01 02:06:38 +00:00
|
|
|
function objectGetInstanceFromRow($oRow)
|
2007-01-27 00:30:00 +00:00
|
|
|
{
|
2007-02-01 02:06:38 +00:00
|
|
|
return new distribution($oRow->distributionId, $oRow);
|
2007-01-27 00:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-13 21:08:39 +00:00
|
|
|
/* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */
|
|
|
|
|
function objectOutputTableRow($oManager, $sClass, $sEditLinkLabel)
|
2007-01-27 00:30:00 +00:00
|
|
|
{
|
|
|
|
|
$aCells = array(
|
2007-02-03 19:03:42 +00:00
|
|
|
"<a href=\"".$oManager->makeUrl("view", $this->iDistributionId,
|
|
|
|
|
"View distribution")."\">$this->sName.</a>",
|
2007-01-27 00:30:00 +00:00
|
|
|
"<a href=\"$this->sUrl\">$this->sUrl</a>",
|
|
|
|
|
array(sizeof($this->aTestingIds), "align=\"right\""));
|
|
|
|
|
|
|
|
|
|
if($this->canEdit())
|
|
|
|
|
{
|
2007-01-30 00:46:05 +00:00
|
|
|
if(!sizeof($this->aTestingIds))
|
2007-03-13 21:08:39 +00:00
|
|
|
$shDeleteLink = " [<a href='".$oManager->makeUrl("delete",
|
2007-02-03 19:03:42 +00:00
|
|
|
$this->iDistributionId)."'>delete</a>]";
|
2007-03-13 21:08:39 +00:00
|
|
|
|
|
|
|
|
$aCells[] = array(
|
|
|
|
|
"[<a href='".$oManager->makeUrl("edit",
|
|
|
|
|
$this->iDistributionId)."'>$sEditLinkLabel</a>]$shDeleteLink",
|
2007-01-27 00:30:00 +00:00
|
|
|
"align=\"center\"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo html_tr($aCells, $sClass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Whether the user has permission to edit distributions
|
|
|
|
|
function canEdit()
|
|
|
|
|
{
|
|
|
|
|
if($_SESSION['current']->hasPriv("admin"))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2007-01-31 02:18:18 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
echo '<p><span class="title">Testing Results for '.$this->sName.'</span><br />',"\n";
|
|
|
|
|
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";
|
|
|
|
|
echo '<td><a href="'.BASE.'appview.php?iVersionId='.$oTest->iVersionId.'&iTestingId='.$oTest->iTestingId.'">',"\n";
|
|
|
|
|
echo $oApp->sName.' '.$oVersion->sName.'</a></td>',"\n";
|
|
|
|
|
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";
|
|
|
|
|
echo '<td>'.date("M d Y", mysqltimestamp_to_unixtimestamp($oTest->sSubmitTime)).'</td>',"\n";
|
|
|
|
|
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>";
|
|
|
|
|
}
|
2005-10-17 03:59:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|