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 // the user submitted his comment
if(!empty($aClean['sBody'])) if(!empty($aClean['sBody']))
{ {
// create a new comment
$oComment = 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); $oVersion = new version($oComment->iVersionId);
util_redirect_and_exit($oVersion->objectMakeUrl()); util_redirect_and_exit($oVersion->objectMakeUrl());
// let's show the comment form // 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'])) if(($aClean['sSub'] == 'Submit a new bug link.' ) && ($aClean['iBuglinkId']))
{ {
$oBuglink = new Bug(); $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()); util_redirect_and_exit($oVersion->objectMakeUrl());
} }
if($aClean['sSub'] == 'StartMonitoring') if($aClean['sSub'] == 'StartMonitoring')
{ {
$oMonitor = new Monitor(); $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()); util_redirect_and_exit($oVersion->objectMakeUrl());
} }
if($aClean['sSub'] == 'StopMonitoring') if($aClean['sSub'] == 'StopMonitoring')

View File

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

View File

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

View File

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