Objects should set class variables and call create() instead of passing the parameters into the

create() function.
This commit is contained in:
Chris Morgan
2007-04-21 02:30:22 +00:00
committed by WineHQ
parent 96bfe05734
commit cf9cba4093
5 changed files with 47 additions and 21 deletions

View File

@@ -27,8 +27,14 @@ if(!$_SESSION['current']->isLoggedIn())
// the user submitted his comment
if(!empty($aClean['sBody']))
{
// create a new comment
$oComment = new Comment();
$oComment->create($aClean['sSubject'], $aClean['sBody'], $aClean['iThread'], $aClean['iVersionId']);
$oComment->sSubject = $aClean['sSubject'];
$oComment->sBody = $aClean['sBody'];
$oComment->iParentId = $aClean['iThread'];
$oComment->iVersionId = $aClean['iVersionId'];
$oComment->create();
$oVersion = new version($oComment->iVersionId);
util_redirect_and_exit($oVersion->objectMakeUrl());
// let's show the comment form

View File

@@ -105,13 +105,18 @@ if ($aClean['sSub'])
if(($aClean['sSub'] == 'Submit a new bug link.' ) && ($aClean['iBuglinkId']))
{
$oBuglink = new Bug();
$oBuglink->create($aClean['iVersionId'],$aClean['iBuglinkId']);
$oBuglink->iVersionId = $aClean['iVersionId'];
$oBuglink->iBug_id = $aClean['iBuglinkId'];
$oBuglink->create();
util_redirect_and_exit($oVersion->objectMakeUrl());
}
if($aClean['sSub'] == 'StartMonitoring')
{
$oMonitor = new Monitor();
$oMonitor->create($_SESSION['current']->iUserId,$aClean['iAppId'],$aClean['iVersionId']);
$oMonitor->iuserId = $_SESSION['current']->iUserId;
$oMonitor->iAppId = $aClean['iAppId'];
$oMonitor->iVersionId = $aClean['iVersionId'];
$oMonitor->create();
util_redirect_and_exit($oVersion->objectMakeUrl());
}
if($aClean['sSub'] == 'StopMonitoring')

View File

@@ -11,11 +11,15 @@ require_once(BASE."include/application.php");
*/
class Bug {
var $iLinkId;
// parameters necessary to create a new Bug with Bug::create()
var $iVersionId;
var $iBug_id;
// values retrieved from bugzilla
var $sShort_desc;
var $sBug_status;
var $sResolution;
var $iVersionId;
var $iAppId;
var $sSubmitTime;
var $iSubmitterId;
@@ -65,11 +69,13 @@ class Bug {
/**
* Creates a new Bug.
*/
function create($iVersionId = null, $iBug_id = null)
function create()
{
$oVersion = new Version($iVersionId);
$oVersion = new Version($this->iVersionId);
// Security, if we are not an administrator or a maintainer, the Bug must be queued.
if(!($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($oVersion->iVersionId) || $_SESSION['current']->isSuperMaintainer($oVersion->iAppId)))
if(!($_SESSION['current']->hasPriv("admin") ||
$_SESSION['current']->isMaintainer($oVersion->iVersionId) ||
$_SESSION['current']->isSuperMaintainer($oVersion->iAppId)))
{
$this->bQueued = true;
} else
@@ -78,9 +84,9 @@ class Bug {
}
/* lets check for a valid bug id */
if(!is_numeric($iBug_id))
if(!is_numeric($this->iBug_id))
{
addmsg($iBug_id." is not a valid bug number.", "red");
addmsg($this->iBug_id." is not a valid bug number.", "red");
return false;
}
@@ -88,7 +94,7 @@ class Bug {
$sQuery = "SELECT *
FROM bugs
WHERE bug_id = ".$iBug_id;
WHERE bug_id = ".$this->iBug_id;
if(mysql_num_rows(query_bugzilladb($sQuery, "checking bugzilla")) == 0)
{
addmsg("There is no bug in Bugzilla with that bug number.", "red");
@@ -100,11 +106,11 @@ class Bug {
$sQuery = "SELECT *
FROM buglinks
WHERE versionId = '?'";
if($hResult = query_parameters($sQuery, $iVersionId))
if($hResult = query_parameters($sQuery, $this->iVersionId))
{
while($oRow = mysql_fetch_object($hResult))
{
if($oRow->bug_id == $iBug_id)
if($oRow->bug_id == $this->iBug_id)
{
addmsg("The Bug link has already been submitted.", "red");
return false;
@@ -116,7 +122,8 @@ class Bug {
$hResult = query_parameters("INSERT INTO buglinks (versionId, bug_id, queued, submitterId) ".
"VALUES('?', '?', '?', '?')",
$iVersionId, $iBug_id, $this->bQueued?"true":"false",
$this->iVersionId, $this->iBug_id,
$this->bQueued ? "true":"false",
$_SESSION['current']->iUserId);
if($hResult)
{
@@ -129,7 +136,7 @@ class Bug {
WHERE buglinks.versionId = appVersion.versionId
AND buglinks.versionId = '?'
AND buglinks.bug_id = '?'";
if($hResult = query_parameters($sQuery, $iVersionId, $iBug_id))
if($hResult = query_parameters($sQuery, $this->iVersionId, $this->iBug_id))
{
$oRow = mysql_fetch_object($hResult);
$this->bug($oRow->linkId);
@@ -138,7 +145,7 @@ class Bug {
$this->SendNotificationMail();
return true;
}else
} else
{
addmsg("Error while creating a new Bug link.", "red");
return false;

View File

@@ -9,11 +9,15 @@ require_once(BASE."include/user.php");
*/
class Comment {
var $iCommentId;
// variables necessary for creating a comment
var $iParentId;
var $iAppId;
var $iVersionId;
var $sSubject;
var $sBody;
var $iVersionId;
var $iAppId;
var $sDateCreated;
var $sHostname;
var $oOwner;
@@ -55,7 +59,8 @@ class Comment {
{
$hResult = query_parameters("INSERT INTO appComments (parentId, versionId, subject, ".
"body, userId, time, hostname) VALUES ('?', '?', '?', '?', '?', ?, '?')",
$iParentId, $iVersionId, $sSubject, $sBody, $_SESSION['current']->iUserId,
$iParentId, $iVersionId, $sSubject, $sBody,
$_SESSION['current']->iUserId,
"NOW()", get_remote());
if($hResult)

View File

@@ -9,6 +9,8 @@
*/
class Monitor {
var $iMonitorId;
// variables necessary for creating a monitor
var $iAppId;
var $iVersionId;
var $iUserId;
@@ -58,17 +60,18 @@ class Monitor {
* Informs interested people about the creation.
* Returns true on success, false on failure
*/
function create($iUserId, $iAppId=0, $iVersionId=0)
function create()
{
/* Check for duplicate entries */
$oMonitor = new monitor();
$oMonitor->find($iUserId, $iVersionId);
$oMonitor->find($this->iUserId, $this->iVersionId);
if($oMonitor->iVersionId)
return FALSE;
// create the new monitor entry
$hResult = query_parameters("INSERT INTO appMonitors (versionId, appId, userId) ".
"VALUES ('?', '?', '?')",
$iVersionId, $iAppId, $iUserId);
$this->iVersionId, $this->iAppId, $this->iUserId);
if($hResult)
{