Module: appdb Branch: master Commit: 7aa0f3e59cd8c0678e40700db8ba64107cb72517 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=7aa0f3e59cd8c0678e40700db...
Author: Alexander Nicolaysen Sørnes <alexander@linux-xqqm.(none)> Date: Tue Oct 27 21:45:33 2009 +0100
appBundle: Don't allow apps to be added more than once to a given bundle
---
admin/editBundle.php | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/admin/editBundle.php b/admin/editBundle.php index 8243d5c..adb0ec1 100644 --- a/admin/editBundle.php +++ b/admin/editBundle.php @@ -31,12 +31,21 @@ if($aClean['sCmd']) } if($aClean['sCmd'] == "add") { - $hResult = query_parameters("INSERT INTO appBundle (bundleId, appId) VALUES". - "('?', '?')", - $aClean['iBundleId'], - $aClean['iAppId']); - if($hResult) - addmsg("App $appId added to Bundle".$aClean['iBundleId'], "green"); + $oApp = new application($aClean['iAppId']); + /* Check that the app hasn't already been added */ + $hResult = query_parameters("SELECT * FROM appBundle WHERE bundleId = '?' AND appId = '?'", $aClean['iBundleId'], $aClean['iAppId']); + if($hResult && mysql_num_rows($hResult) == 0) + { + $hResult = query_parameters("INSERT INTO appBundle (bundleId, appId) VALUES". + "('?', '?')", + $aClean['iBundleId'], + $aClean['iAppId']); + if($hResult) + addmsg("App $appId added to Bundle".$aClean['iBundleId'], "green"); + } else + { + addmsg("{$oApp->sName} is already in the bundle", 'red'); + } } }