Authors: Jonathan Ernst <Jonathan@ernstfamily.ch>, Paul van Schayck <polleke@gmail.com>, Tony Lambregts <tony_lambregts@telusplanet.net>

New preferences fix
This commit is contained in:
WineHQ
2005-01-14 05:28:58 +00:00
parent 2a153fec68
commit 6b806b79e1
2 changed files with 10 additions and 22 deletions

View File

@@ -1,43 +1,31 @@
<?php <?php
$hAppdbLink = null;
$hBugzillaLink = null;
function query_appdb($sQuery,$sComment="") function query_appdb($sQuery,$sComment="")
{ {
global $hAppdbLink; global $hAppdbLink;
if(!$hAppdbLink) if(!is_resource($hAppdbLink))
{ {
$hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS); $hAppdbLink = mysql_connect(APPS_DBHOST, APPS_DBUSER, APPS_DBPASS);
mysql_select_db(APPS_DB);
} }
mysql_select_db(APPS_DB, $hAppdbLink);
$hResult = mysql_query($sQuery, $hAppdbLink); $hResult = mysql_query($sQuery, $hAppdbLink);
if(!$hResult) query_error($sQuery, $sComment); if(!$hResult) query_error($sQuery, $sComment);
return $hResult; return $hResult;
} }
function query_userdb($sQuery,$sComment="")
{
global $huserdbLink;
if(!$huserdbLink)
{
$huserdbLink = mysql_connect(USERS_DBHOST, USERS_DBUSER, USERS_DBPASS);
mysql_select_db(USERS_DB);
}
$hResult = mysql_query($sQuery, $huserdbLink);
if(!$hResult) query_error($sQuery, $sComment);
return $hResult;
}
function query_bugzilladb($sQuery,$sComment="") function query_bugzilladb($sQuery,$sComment="")
{ {
global $hBugzillaLink; global $hBugzillaLink;
if(!$hBugzillaLink) if(!is_resource($hBugzillaLink))
{ {
$hBugzillaLink = mysql_connect(BUGZILLA_DBHOST, BUGZILLA_DBUSER, BUGZILLA_DBPASS); $hBugzillaLink = mysql_connect(BUGZILLA_DBHOST, BUGZILLA_DBUSER, BUGZILLA_DBPASS);
mysql_select_db(BUGZILLA_DB);
} }
mysql_select_db(BUGZILLA_DB, $hBugzillaLink);
$hResult = mysql_query($sQuery, $hBugzillaLink); $hResult = mysql_query($sQuery, $hBugzillaLink);
if(!$hResult) query_error($sQuery, $sComment); if(!$hResult) query_error($sQuery, $sComment);
return $hResult; return $hResult;
@@ -47,7 +35,7 @@ function query_bugzilladb($sQuery,$sComment="")
function query_error($sQuery, $sComment="") function query_error($sQuery, $sComment="")
{ {
$sStatusMessage = "<p><b>Database Error!</b><br />"; $sStatusMessage = "<p><b>Database Error!</b><br />";
$sStatusMessage .= "Query: ".$sQuery; $sStatusMessage .= "Query: ".$sQuery."<br />";
$sStatusMessage .= $sComment ? $sComment."<br />" : ""; $sStatusMessage .= $sComment ? $sComment."<br />" : "";
$sStatusMessage .= mysql_error()."</p>\n"; $sStatusMessage .= mysql_error()."</p>\n";
addmsg($sStatusMessage, "red"); addmsg($sStatusMessage, "red");

View File

@@ -17,8 +17,8 @@ if(!loggedin())
function build_prefs_list() function build_prefs_list()
{ {
$result = query_userdb("SELECT * FROM prefs_list ORDER BY id"); $result = query_appdb("SELECT * FROM prefs_list ORDER BY id");
while($r = mysql_fetch_object($result)) while($result && $r = mysql_fetch_object($result))
{ {
//skip admin options //skip admin options
//TODO: add a field to prefs_list to flag the user level for the pref //TODO: add a field to prefs_list to flag the user level for the pref