From 7f49c5055ea7b8cf4ac08e74db1c2ab946a5851c Mon Sep 17 00:00:00 2001 From: Tony Lambregts Date: Wed, 13 Jul 2005 01:14:53 +0000 Subject: [PATCH] Modify the version object to include an array of bugs and use that array when deleting a version --- include/version.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/version.php b/include/version.php index 2aa552f..6af44a4 100644 --- a/include/version.php +++ b/include/version.php @@ -7,6 +7,7 @@ require_once(BASE."include/note.php"); require_once(BASE."include/comment.php"); require_once(BASE."include/url.php"); require_once(BASE."include/screenshot.php"); +require_once(BASE."include/bugs.php"); /** * Version class for handling versions. @@ -25,6 +26,7 @@ class Version { var $aCommentsIds; // an array that contains the commentId of every comment linked to this version var $aScreenshotsIds; // an array that contains the screenshotId of every screenshot linked to this version var $aUrlsIds; // an array that contains the screenshotId of every url linked to this version + var $aBuglinkIds; // an array that contains the buglinkId of every bug linked to this version /** * constructor, fetches the data. @@ -111,6 +113,22 @@ class Version { $this->aUrlsIds[] = $oRow->id; } } + + /* + * We fetch Bug linkIds. + */ + $this->aBuglinkIds = array(); + $sQuery = "SELECT * + FROM buglinks + WHERE versionId = ".$iVersionId." + ORDER BY bug_id"; + if($hResult = query_appdb($sQuery)) + { + while($oRow = mysql_fetch_object($hResult)) + { + $this->aBuglinkIds[] = $oRow->linkId; + } + } } } @@ -251,6 +269,11 @@ class Version { $oUrl = new Url($iUrlId); $oUrl->delete($bSilent); } + foreach($this->$aBuglinkIds as $iBug_id) + { + $oBug = new bug($iBug_id); + $oBug->delete($bSilent); + } // remove any maintainers for this version so we don't orphan them $sQuery = "DELETE from appMaintainers WHERE versionId='".$this->iVersionId."';";