From bab429ee90ac1c75e841e02a7b314ff126b30f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Sat, 26 May 2007 01:37:25 +0000 Subject: [PATCH] Return true when creating duplicate distributions --- include/distribution.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/include/distribution.php b/include/distribution.php index 0ae8c72..49a274c 100644 --- a/include/distribution.php +++ b/include/distribution.php @@ -82,14 +82,21 @@ class distribution { //Let's not create a duplicate $sQuery = "SELECT * FROM distributions - WHERE name LIKE '?'"; - $hDuplicate = query_parameters($sQuery, $this->sName); - if(!mysql_num_rows($hDuplicate) == 0) + WHERE name = '?'"; + $hResult = query_parameters($sQuery, $this->sName); + + if($hResult && $oRow = mysql_fetch_object($hResult)) { - addmsg("There was an existing Distribution called ".$this->sName.".", "red"); - $oRow = mysql_fetch_object($hDuplicate); - $this->iDistributionId = $oRow->distributionId; - return false; + if(mysql_num_rows($hResult)) + { + 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; + } } $hResult = query_parameters("INSERT INTO distributions (name, url, submitterId, queued) ".