From dca5a408cb1f9f4e38b2701db0bc38fb4fc7f8e8 Mon Sep 17 00:00:00 2001 From: Tony Lambregts Date: Mon, 13 Dec 2004 03:50:11 +0000 Subject: [PATCH] Integrate APPDB with Bugzilla to use the versions table from Bugzilla. --- README | 59 ++++++++++++++++++++++----- include/config.php.sample | 10 +++++ include/util.php | 62 ++++++++++++++++++++++++++++ preferences.php | 77 +++++++++++++++++++---------------- tables/bugzilla_tables.sql | 62 ++++++++++++++++++++++++++++ tables/create_bugzilla_tables | 4 ++ 6 files changed, 228 insertions(+), 46 deletions(-) create mode 100644 tables/bugzilla_tables.sql create mode 100644 tables/create_bugzilla_tables diff --git a/README b/README index c762840..6165fd5 100644 --- a/README +++ b/README @@ -1,32 +1,71 @@ WineHQ Application Database ------------------------------------------------------------------------- +#------------------------------------------------------------------------# Authors: Jeremy Newman Charles Leop Contributors: - Paul van Schayck + Paul van Schayck Chris Morgan - + Tony Lambregts + Jonathan Ernst To install locally for testing/hacking: ------------------------------------------------------------------------- +#------------------------------------------------------------------------# -- Symlink from /var/www to the appdb directory +# Symlink from /var/www to the appdb directory -- Copy include/config.php.sample to include/config.php +# Copy include/config.php.sample to include/config.php -- Edit include/config.php as you see fit, the default name of the database +# Edit include/config.php as you see fit, the default name of the database used in the table creation step below is "apidb", you'll have to modify these files if you change this in config.php -- cd tables, run ./create_tables to create the database tables +# cd tables, run ./create_tables to create the database tables -- Try to open up localhost/appdb, if you get a directory listing +# Try to open up localhost/appdb, if you get a directory listing Edit your /etc/apache/httpd.conf "DirectoryIndex" to include index.php so apache will open index.php after not finding index.html/index.htm etc -- Check your /etc/php/php.ini to ensure that +# Check your /etc/php/php.ini to ensure that 'register_globals = On' (variables won't get passed) 'magic_quotes_gpc = Off' (you would end up with \ everywhere) 'session.bug_compat_42' = On' (Problem with auto-globals and session variables) + +#------------------------------------------------------------------------# +You can create ether set up a real bugzilla database or a fake one + +# cd tables, run ./create_bugzilla_tables to create the fake bugzilla tables +#------------------------------------------------------------------------# +# or installing a real bugzilla database (hope this helps) + +# download buzilla (password for cvs is cvs) + +cd /var/www/html +export CVSROOT=:pserver:cvs@cvs.winehq.org:/home/wine +cvs login +cvs -z 0 checkout bugzilla + +# change directory to bugzilla and change the group ownership to apache. + +cd bugzilla +chgrp -R apache . +chmod -R g+rX . + + +# change to su and run ./checksetup.pl and fix up what it finds wrong. +# this may take several runs + +su +./checksetup.pl + +# in the /etc/httpd/conf/hppt.conf file find "AddHandler cgi-script .cgi" and add the following. + + +Options ExecCGI +AllowOverride Limit +Order allow,deny +Allow from all + + +# edit local config as nessary to allow access. diff --git a/include/config.php.sample b/include/config.php.sample index 4b00f97..e47e3d9 100644 --- a/include/config.php.sample +++ b/include/config.php.sample @@ -26,4 +26,14 @@ $userdb_dbpass = "lemonade"; $userdb_dbhost = "localhost"; $userdb_db = "apidb"; +/* + * Bugzilla database info + */ +$bugzilla_dbuser = "root"; +$bugzilla_dbpass = ""; +$bugzilla_dbhost = "localhost"; +$bugzilla_db = "bugs"; +/* $bugzilla_db_port = 3306; is this needed? I dont think so.*/ +$bugzilla_product_id = 1; + ?> diff --git a/include/util.php b/include/util.php index cab8716..566eef3 100644 --- a/include/util.php +++ b/include/util.php @@ -171,6 +171,68 @@ function get_xml_tag ($file, $mode = null) } } +/* bugzilla functions */ + +function openbugzilladb() +{ + global $bugzilla_dbuser, $bugzilla_dbpass, $bugzilla_dbhost, $bugzilla_db, $bugzilla_product_id; + global $dbcon, $dbref; + + $dbref++; + + if($dbcon) + return $dbcon; + + $dbcon = mysql_connect($bugzilla_dbhost, $bugzilla_dbuser, $bugzilla_dbpass); + if(!$dbcon) + { + echo "An error occurred: ".mysql_error()."

\n"; + exit; + } + mysql_select_db($bugzilla_db); + return $dbcon; +} + +function closebugzilladb() +{ + global $dbcon, $dbref; + + if(--$dbref) + return; + + mysql_close($adbcon); +} + +function make_bugzilla_version_list($varname, $cvalue) +{ + global $bugzilla_db, $bugzilla_product_id; + + $table = $bugzilla_db.".versions"; + $where = "WHERE product_id=".$bugzilla_product_id; + $query = "SELECT value FROM $table $where ORDER BY value"; + + openbugzilladb(); + + $result = mysql_query($query); + + if(!$result) + { + closebugzilladb(); + return; // Oops + } + echo "\n"; + closebugzilladb(); +} + /* get the number of applications in the appQueue table */ function getQueuedAppCount() { diff --git a/preferences.php b/preferences.php index 8e534c9..8c6b63b 100644 --- a/preferences.php +++ b/preferences.php @@ -15,41 +15,46 @@ function build_prefs_list() $result = mysql_query("SELECT * FROM prefs_list ORDER BY id"); while($r = mysql_fetch_object($result)) - { - //skip admin options - //TODO: add a field to prefs_list to flag the user level for the pref - if(!havepriv("admin")) - { - if($r->name == "query:mode") - continue; - if($r->name == "sidebar") - continue; - if($r->name == "window:query") - continue; - if($r->name == "query:hide_header") - continue; - if($r->name == "query:hide_sidebar") - continue; - if($r->name == "debug") - continue; - } - - $input = html_select("pref_$r->name", explode('|', $r->value_list), - $_SESSION['current']->getpref($r->name, $r->def_value)); - echo html_tr(array("  $r->description", $input)); - } + { + //skip admin options + //TODO: add a field to prefs_list to flag the user level for the pref + if(!havepriv("admin")) + { + if($r->name == "query:mode") + continue; + if($r->name == "sidebar") + continue; + if($r->name == "window:query") + continue; + if($r->name == "query:hide_header") + continue; + if($r->name == "query:hide_sidebar") + continue; + if($r->name == "debug") + continue; + } + + $input = html_select("pref_$r->name", explode('|', $r->value_list), + $_SESSION['current']->getpref($r->name, $r->def_value)); + echo html_tr(array("  $r->description", $input)); + } } function show_user_fields() { - - $user = new User(); - - $ext_username = $_SESSION['current']->username; - $ext_realname = $user->lookup_realname($_SESSION['current']->userid); - $ext_email = $user->lookup_email($_SESSION['current']->userid); - - include(BASE."include/"."form_edit.php"); + + $user = new User(); + + $ext_username = $_SESSION['current']->username; + $ext_realname = $user->lookup_realname($_SESSION['current']->userid); + $ext_email = $user->lookup_email($_SESSION['current']->userid); + + include(BASE."include/"."form_edit.php"); + $version = "unspecified"; + echo "  wine version "; + make_bugzilla_version_list("version", $version); + echo ""; + } if($HTTP_POST_VARS) @@ -60,11 +65,11 @@ if($HTTP_POST_VARS) $user = new User(); while(list($key, $value) = each($HTTP_POST_VARS)) - { - if(!ereg("^pref_(.+)$", $key, $arr)) - continue; - $_SESSION['current']->setpref($arr[1], $value); - } + { + if(!ereg("^pref_(.+)$", $key, $arr)) + continue; + $_SESSION['current']->setpref($arr[1], $value); + } if ($ext_password == $ext_password2) { diff --git a/tables/bugzilla_tables.sql b/tables/bugzilla_tables.sql new file mode 100644 index 0000000..a10ccbf --- /dev/null +++ b/tables/bugzilla_tables.sql @@ -0,0 +1,62 @@ +create database if not exists bugs; + +use bugs; + +drop table if exists versions; + + +/* + * versions information + */ +create table versions ( + value tinytext, + product_id smallint not null +); + +INSERT INTO versions VALUES ('unspecified', 1 ); +INSERT INTO versions VALUES ('20010112', 1 ); +INSERT INTO versions VALUES ('20010216', 1 ); +INSERT INTO versions VALUES ('20010305', 1 ); +INSERT INTO versions VALUES ('20010326', 1 ); +INSERT INTO versions VALUES ('20010418', 1 ); +INSERT INTO versions VALUES ('20010510', 1 ); +INSERT INTO versions VALUES ('20010629', 1 ); +INSERT INTO versions VALUES ('20010824', 1 ); +INSERT INTO versions VALUES ('20011004', 1 ); +INSERT INTO versions VALUES ('20011108', 1 ); +INSERT INTO versions VALUES ('20020228', 1 ); +INSERT INTO versions VALUES ('20020310', 1 ); +INSERT INTO versions VALUES ('20020411', 1 ); +INSERT INTO versions VALUES ('20020509', 1 ); +INSERT INTO versions VALUES ('20020605', 1 ); +INSERT INTO versions VALUES ('20020710', 1 ); +INSERT INTO versions VALUES ('20020804', 1 ); +INSERT INTO versions VALUES ('20020904', 1 ); +INSERT INTO versions VALUES ('20021007', 1 ); +INSERT INTO versions VALUES ('20021031', 1 ); +INSERT INTO versions VALUES ('20021125', 1 ); +INSERT INTO versions VALUES ('20021219', 1 ); +INSERT INTO versions VALUES ('20030115', 1 ); +INSERT INTO versions VALUES ('20030219', 1 ); +INSERT INTO versions VALUES ('20030318', 1 ); +INSERT INTO versions VALUES ('20030408', 1 ); +INSERT INTO versions VALUES ('20030508', 1 ); +INSERT INTO versions VALUES ('20030618', 1 ); +INSERT INTO versions VALUES ('20030709', 1 ); +INSERT INTO versions VALUES ('20030813', 1 ); +INSERT INTO versions VALUES ('20030911', 1 ); +INSERT INTO versions VALUES ('20031016', 1 ); +INSERT INTO versions VALUES ('20031118', 1 ); +INSERT INTO versions VALUES ('20031212', 1 ); +INSERT INTO versions VALUES ('20040121', 1 ); +INSERT INTO versions VALUES ('20040213', 1 ); +INSERT INTO versions VALUES ('20040309', 1 ); +INSERT INTO versions VALUES ('20040408', 1 ); +INSERT INTO versions VALUES ('20040505', 1 ); +INSERT INTO versions VALUES ('20040615', 1 ); +INSERT INTO versions VALUES ('20040716', 1 ); +INSERT INTO versions VALUES ('20040813', 1 ); +INSERT INTO versions VALUES ('20040914', 1 ); +INSERT INTO versions VALUES ('20041019', 1 ); +INSERT INTO versions VALUES ('20041201', 1 ); +INSERT INTO versions VALUES ('CVS', 1 ); diff --git a/tables/create_bugzilla_tables b/tables/create_bugzilla_tables new file mode 100644 index 0000000..62fd5eb --- /dev/null +++ b/tables/create_bugzilla_tables @@ -0,0 +1,4 @@ +#! /bin/sh + +echo Creating fake Bugzilla tables +mysql -u root < bugzilla_tables.sql