Author: cfinck
Date: Sun Jun 21 02:21:24 2009
New Revision: 439

URL: http://svn.reactos.org/svn/reactos?rev=439&view=rev
Log:
- Encapsulate the SQL stuff done on the Compare page into a class 
WineTest_ResultReader.
  This can now be used to export the result data in other formats as well.
- Add a CSV and XML (including a DTD) export for the result data
- Fix minor stuff on the Detail page

Added:
    branches/danny-web/www/www.reactos.org/testman/export.php   (with props)
    branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php   (with 
props)
    branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php   (with 
props)
    branches/danny-web/www/www.reactos.org/testman/lib/   (with props)
    
branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php
   (with props)
    branches/danny-web/www/www.reactos.org/testman/res/   (with props)
    branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd   (with 
props)
Modified:
    branches/danny-web/www/www.reactos.org/testman/compare.php
    branches/danny-web/www/www.reactos.org/testman/css/compare.css
    branches/danny-web/www/www.reactos.org/testman/detail.php
    branches/danny-web/www/www.reactos.org/testman/lang/de.inc.php
    branches/danny-web/www/www.reactos.org/testman/lang/en.inc.php
    branches/danny-web/www/www.reactos.org/testman/lang/pl.inc.php
    branches/danny-web/www/www.reactos.org/testman/utils.inc.php

Modified: branches/danny-web/www/www.reactos.org/testman/compare.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/compare.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/compare.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/compare.php [iso-8859-1] Sun 
Jun 21 02:21:24 2009
@@ -9,7 +9,6 @@
 */
 
        require_once("config.inc.php");
-       require_once("connect.db.php");
        require_once("utils.inc.php");
        require_once("languages.inc.php");
        require_once(SHARED_PATH . "subsys_layout.php");
@@ -71,29 +70,29 @@
 <h2><?php echo $testman_langres["compare_title"]; ?></h2>
 
 <?php
-       if(!isset($_GET["ids"]))
+       if(!array_key_exists("ids", $_GET))
                die("Necessary information not specified");
        
-       $id_array = explode(",", $_GET["ids"]);
-       
-       if(!$id_array)
-               die("<i>ids</i> parameter is no array");
-       
-       // Verify that the array only contains numeric values to prevent SQL 
injections
-       for($i = 0; $i < count($id_array); $i++)
-               if(!is_numeric($id_array[$i]))
-                       die("<i>ids</i> parameter is not entirely numeric!");
-       
-       if(count($id_array) > MAX_COMPARE_RESULTS)
-               die(sprintf($testman_langres["maxselection"], 
MAX_COMPARE_RESULTS));
-       
-       if(count($id_array) > 1)
-       {
-               echo '<div>';
-               printf('<input type="checkbox" id="showchanged" 
onclick="ShowChangedCheckbox_OnClick(this)" /> <label 
for="showchanged">%s</label>', $testman_langres["showchanged"]);
-               echo '</div><br />';
-       }
+       $reader = new WineTest_ResultReader();
+       $result = $reader->setTestIDList($_GET["ids"]);
+       
+       // A string return value indicates an error.
+       if(is_string($result))
+               die($result);
 ?>
+
+<div>
+       <?php
+               // Activate the option to only show the changed results between 
several test runs if more than one Test ID was passed.
+               if($reader->getTestIDCount() > 1)
+                       printf('<input type="checkbox" id="showchanged" 
onclick="ShowChangedCheckbox_OnClick(this)" /> <label 
for="showchanged">%s</label><br />', $testman_langres["showchanged"]);
+               
+               echo $testman_langres["export_as"];
+       ?>:
+       
+       <button onclick="window.open('export.php?f=csv&amp;ids=<?php echo 
$_GET["ids"]; ?>')">CSV</button>
+       <button onclick="window.open('export.php?f=xml&amp;ids=<?php echo 
$_GET["ids"]; ?>')">XML</button>
+</div><br />
 
 <div id="legend">
        <div id="intro"><?php echo $testman_langres["legend"]; ?>:</div>
@@ -113,43 +112,18 @@
 </div>
 
 <?php
-       // Establish a DB connection
-       try
-       {
-               $dbh = new PDO("mysql:host=" . DB_HOST, DB_USER, DB_PASS);
-       }
-       catch(PDOException $e)
-       {
-               // Give no exact error message here, so no server internals are 
exposed
-               die("Could not establish the DB connection");
-       }
-       
-       // Get all Suite IDs linked to our Test IDs
-       $stmt = $dbh->query(
-               "SELECT s.id " .
-               "FROM " . DB_TESTMAN . ".winetest_suites s " .
-               "JOIN " . DB_TESTMAN . ".winetest_results e ON e.suite_id = 
s.id " .
-               "WHERE e.test_id IN (" . $_GET["ids"] . ")"
-       ) or die("Query failed #1");
-       $suite_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
-       $suite_idlist = implode(",", $suite_ids);
-       
        // Add the table and fill in the table head part
        echo '<table id="comparetable" class="datatable" cellspacing="0" 
cellpadding="0">';
        echo '<thead><tr class="head">';
        printf('<th class="TestSuite">%s</th>', $testman_langres["testsuite"]);
        
-       $stmt = $dbh->prepare(
-               "SELECT UNIX_TIMESTAMP(r.timestamp) timestamp, a.name, 
r.revision, r.platform " .
-               "FROM " . DB_TESTMAN . ".winetest_runs r " .
-               "JOIN " . DB_ROSCMS . ".roscms_accounts a ON r.user_id = a.id " 
.
-               "WHERE r.id = :id"
-       );
-       
-       for($i = 0; $i < count($id_array); $i++)
-       {
-               $stmt->bindParam(":id", $id_array[$i]);
-               $stmt->execute() or die("Query failed #2");
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               $stmt = $reader->getTestRunInfoStatement($i);
+               
+               if(is_string($stmt))
+                       die($stmt);
+               
                $row = $stmt->fetch(PDO::FETCH_ASSOC);
                
                echo '<th onmousedown="ResultHead_OnMouseDown(this)">';
@@ -164,13 +138,15 @@
        echo   '<tr class="even">';
        printf('<td id="totals" onmouseover="Cell_OnMouseOver(this)" 
onmouseout="Cell_OnMouseOut(this)">%s</td>', $testman_langres["totals"]);
        
-       $stmt = $dbh->prepare("SELECT r.count, r.failures FROM " . DB_TESTMAN . 
".winetest_runs r WHERE r.id = :id");
        $prev_row = null;
        
-       for($i = 0; $i < count($id_array); $i++)
-       {
-               $stmt->bindParam(":id", $id_array[$i]);
-               $stmt->execute() or die("Query failed #3");
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               $stmt = $reader->getTestRunInfoStatement($i);
+               
+               if(is_string($stmt))
+                       die($stmt);
+               
                $row = $stmt->fetch(PDO::FETCH_ASSOC);
                
                echo '<td onmouseover="Cell_OnMouseOver(this)" 
onmouseout="Cell_OnMouseOut(this)">';
@@ -188,32 +164,23 @@
        // Get the test results for each column
        $result_stmt = array();
        
-       for($i = 0; $i < count($id_array); $i++)
-       {
-               $result_stmt[$i] = $dbh->prepare(
-                       "SELECT e.id, e.status, e.count, e.failures, e.skipped 
" .
-                       "FROM " . DB_TESTMAN . ".winetest_suites s " .
-                       "LEFT JOIN " . DB_TESTMAN . ".winetest_results e ON 
e.suite_id = s.id AND e.test_id = :testid " .
-                       "WHERE s.id IN (" . $suite_idlist . ")" .
-                       "ORDER BY s.module, s.test"
-               );
-               $result_stmt[$i]->bindParam(":testid", $id_array[$i]);
-               $result_stmt[$i]->execute() or die("Query failed #4 for 
statement $i");
-       }
-       
-       // Get all test suites for which we have at least one result in our ID 
list
-       $stmt = $dbh->query(
-               "SELECT DISTINCT s.id, s.module, s.test " .
-               "FROM " . DB_TESTMAN . ".winetest_suites s " .
-               "JOIN " . DB_TESTMAN . ".winetest_results e ON e.suite_id = 
s.id " .
-               "WHERE test_id IN (" . $_GET["ids"] . ") " .
-               "ORDER BY s.module ASC, s.test ASC"
-       ) or die("Query failed #5");
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               $result_stmt[$i] = $reader->getListResultInfoStatement($i);
+               
+               if(is_string($result_stmt[$i]))
+                       die($result_stmt[$i]);
+       }
+       
+       $suites_stmt = $reader->getListTestSuiteInfoStatement();
+       
+       if(is_string($suites_stmt))
+               die($suites_stmt);
        
        $oddeven = true;
        $unchanged = array();
        
-       while($suites_row = $stmt->fetch(PDO::FETCH_ASSOC))
+       while($suites_row = $suites_stmt->fetch(PDO::FETCH_ASSOC))
        {
                printf('<tr id="suite_%s" class="%s">', $suites_row["id"], 
($oddeven ? "odd" : "even"));
                printf('<td onmouseover="Cell_OnMouseOver(this)" 
onmouseout="Cell_OnMouseOut(this)">%s:%s</td>', $suites_row["module"], 
$suites_row["test"]);
@@ -224,7 +191,7 @@
                $temp_failedtests = -1;
                $temp_skippedtests = -1;
                
-               for($i = 0; $i < count($result_stmt); $i++)
+               for($i = 0; $i < $reader->getTestIDCount(); $i++)
                {
                        $row = $result_stmt[$i]->fetch(PDO::FETCH_ASSOC);
                        

Modified: branches/danny-web/www/www.reactos.org/testman/css/compare.css
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/css/compare.css?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/css/compare.css [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/css/compare.css [iso-8859-1] 
Sun Jun 21 02:21:24 2009
@@ -4,6 +4,10 @@
   PURPOSE:    Stylesheet for the Compare Page
   COPYRIGHT:  Copyright 2008-2009 Colin Finck <[email protected]>
 */
+
+button {
+       font-weight: bold;
+}
 
 #legend {
        border: solid 1px black;

Modified: branches/danny-web/www/www.reactos.org/testman/detail.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/detail.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/detail.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/detail.php [iso-8859-1] Sun 
Jun 21 02:21:24 2009
@@ -36,7 +36,7 @@
 <h2><?php echo $testman_langres["detail_title"]; ?></h2>
 
 <?php
-       if(!isset($_GET["id"]))
+       if(!array_key_exists("id", $_GET))
                die("Necessary information not specified");
        
        // Establish a DB connection
@@ -123,7 +123,7 @@
        </tr>
        <tr class="even" onmouseover="Row_OnMouseOver(this)" 
onmouseout="Row_OnMouseOut(this)">
                <td class="info"><?php echo $testman_langres["comment"]; 
?>:</td>
-               <td><?php echo GetPlatformString($row["comment"]); ?></td>
+               <td><?php echo $row["comment"]; ?></td>
        </tr>
 </table>
 

Added: branches/danny-web/www/www.reactos.org/testman/export.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/export.php?rev=439&view=auto
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/export.php (added)
+++ branches/danny-web/www/www.reactos.org/testman/export.php [iso-8859-1] Sun 
Jun 21 02:21:24 2009
@@ -1,0 +1,26 @@
+<?php
+/*
+  PROJECT:    ReactOS Web Test Manager
+  LICENSE:    GNU GPLv2 or any later version as published by the Free Software 
Foundation
+  PURPOSE:    Exporting the results as a XML file
+  COPYRIGHT:  Copyright 2009 Colin Finck <[email protected]>
+*/
+
+       require_once("utils.inc.php");
+       
+       if(!array_key_exists("f", $_GET) || !array_key_exists("ids", $_GET))
+               die("Necessary information not specified");
+       
+       $reader = new WineTest_ResultReader();
+       $result = $reader->setTestIDList($_GET["ids"]);
+       
+       // A string return value indicates an error.
+       if(is_string($result))
+               die($result);
+
+       switch($_GET["f"])
+       {
+               case "csv": require_once("export_csv.inc.php"); break;
+               case "xml": require_once("export_xml.inc.php"); break;
+       }
+?>

Propchange: branches/danny-web/www/www.reactos.org/testman/export.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php?rev=439&view=auto
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php (added)
+++ branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php 
[iso-8859-1] Sun Jun 21 02:21:24 2009
@@ -1,0 +1,74 @@
+<?php
+/*
+  PROJECT:    ReactOS Web Test Manager
+  LICENSE:    GNU GPLv2 or any later version as published by the Free Software 
Foundation
+  PURPOSE:    Exporting the results as a CSV file
+  COPYRIGHT:  Copyright 2009 Colin Finck <[email protected]>
+*/
+
+       header("Content-Type: text/csv");
+       header("Content-Disposition: filename=Results.csv");
+
+
+       // First row: Revisions
+       echo ";;";
+       
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               $stmt = $reader->getTestRunInfoStatement($i);
+               
+               if(is_string($stmt))
+                       die($stmt);
+               
+               $row = $stmt->fetch(PDO::FETCH_ASSOC);
+               
+               // Add a blank cell and four times the revision (so that we can 
later add the headers)
+               echo $row["revision"] . ";" . $row["revision"] . ";" . 
$row["revision"] . ";" . $row["revision"] . ";;";
+       }
+       
+       echo "\n";
+
+       
+       // Second row: Status, Total Tests, Failures, Skipped headers
+       echo ";;";
+       
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+               echo "Status;Total Tests;Failures;Skipped;;";
+
+       echo "\n";
+
+
+       // Next rows: Module and Test on the left, results for each column
+       // Get the test results for each column
+       $result_stmt = array();
+       
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               $result_stmt[$i] = $reader->getListResultInfoStatement($i);
+               
+               if(is_string($result_stmt[$i]))
+                       die($result_stmt[$i]);
+       }
+       
+       $suites_stmt = $reader->getListTestSuiteInfoStatement();
+
+       if(is_string($suites_stmt))
+               die($suites_stmt);
+       
+       while($suites_row = $suites_stmt->fetch(PDO::FETCH_ASSOC))
+       {
+               echo $suites_row["module"] . ";" . $suites_row["test"] . ";";
+               
+               for($i = 0; $i < $reader->getTestIDCount(); $i++)
+               {
+                       $row = $result_stmt[$i]->fetch(PDO::FETCH_ASSOC);
+                       
+                       echo strtoupper($row["status"]) . ";";
+                       echo $row["count"] . ";";
+                       echo $row["failures"] . ";";
+                       echo $row["skipped"] . ";;";
+               }
+               
+               echo "\n";
+       }
+?>

Propchange: branches/danny-web/www/www.reactos.org/testman/export_csv.inc.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php?rev=439&view=auto
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php (added)
+++ branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php 
[iso-8859-1] Sun Jun 21 02:21:24 2009
@@ -1,0 +1,49 @@
+<?php
+/*
+  PROJECT:    ReactOS Web Test Manager
+  LICENSE:    GNU GPLv2 or any later version as published by the Free Software 
Foundation
+  PURPOSE:    Exporting the results as a XML file
+  COPYRIGHT:  Copyright 2009 Colin Finck <[email protected]>
+*/
+
+       header("Content-Type: text/xml");
+       header("Content-Disposition: filename=Results.xml");
+       
+       echo '<?xml version="1.0" encoding="us-ascii" ?>';
+       echo '<!DOCTYPE testinfo SYSTEM "http://' . $_SERVER["SERVER_NAME"] . 
dirname($_SERVER["SCRIPT_NAME"]) . '/res/testinfo.dtd">';
+       echo '<testinfo>';
+       
+       for($i = 0; $i < $reader->getTestIDCount(); $i++)
+       {
+               // Add an element for each revision
+               $stmt = $reader->getTestRunInfoStatement($i);
+               
+               if(is_string($stmt))
+                       die($stmt);
+               
+               $row = $stmt->fetch(PDO::FETCH_ASSOC);
+               echo '<revision id="' . $row["revision"] . '" timestamp="' . 
$row["timestamp"] . '" user="' . $row["name"] . '" platform="' . 
$row["platform"] . '">';
+               
+               // Now get the all test results for this revision
+               $stmt = $reader->getSingleResultInfoStatement($i);
+               
+               if(is_string($stmt))
+                       die($stmt);
+               
+               while($row = $stmt->fetch(PDO::FETCH_ASSOC))
+               {
+                       echo '<test ';
+                       echo 'id="' . $row["id"] . '" ';
+                       echo 'module="' . $row["module"] . '" ';
+                       echo 'test="' . $row["test"] . '" ';
+                       echo 'status="' . $row["status"] . '" ';
+                       echo 'count="' . $row["count"] . '" ';
+                       echo 'failures="' . $row["failures"] . '" ';
+                       echo 'skipped="' . $row["skipped"] . '" />';
+               }
+               
+               echo '</revision>';
+       }
+       
+       echo '</testinfo>';
+?>

Propchange: branches/danny-web/www/www.reactos.org/testman/export_xml.inc.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/danny-web/www/www.reactos.org/testman/lang/de.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/lang/de.inc.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/lang/de.inc.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/lang/de.inc.php [iso-8859-1] 
Sun Jun 21 02:21:24 2009
@@ -38,6 +38,7 @@
                // Compare page
                "compare_title" => "Ergebnisse vergleichen",
                "showchanged" => "Nur geänderte Ergebnisse anzeigen",
+               "export_as" => "Exportieren als",
                
                "legend" => "Legende",
                "totaltests" => "Ausgeführte Tests",

Modified: branches/danny-web/www/www.reactos.org/testman/lang/en.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/lang/en.inc.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/lang/en.inc.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/lang/en.inc.php [iso-8859-1] 
Sun Jun 21 02:21:24 2009
@@ -38,6 +38,7 @@
                // Compare page
                "compare_title" => "Comparing Results",
                "showchanged" => "Show only changed results",
+               "export_as" => "Export as",
                
                "legend" => "Legend",
                "totaltests" => "Total Tests",

Modified: branches/danny-web/www/www.reactos.org/testman/lang/pl.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/lang/pl.inc.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/lang/pl.inc.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/lang/pl.inc.php [iso-8859-1] 
Sun Jun 21 02:21:24 2009
@@ -39,6 +39,7 @@
                // Compare page
                "compare_title" => "Porównywanie wyników",
                "showchanged" => "Pokaż tylko zmienione wyniki",
+               "export_as" => "Eksportuj jako",
                
                "legend" => "Legenda",
                "totaltests" => "Wszystkie testy",

Propchange: branches/danny-web/www/www.reactos.org/testman/lib/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sun Jun 21 02:21:24 2009
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)

Propchange: branches/danny-web/www/www.reactos.org/testman/lib/
------------------------------------------------------------------------------
    bugtraq:message = See issue #%BUGID% for more details.

Propchange: branches/danny-web/www/www.reactos.org/testman/lib/
------------------------------------------------------------------------------
    bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%

Added: 
branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php?rev=439&view=auto
==============================================================================
--- 
branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php
 (added)
+++ 
branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php
 [iso-8859-1] Sun Jun 21 02:21:24 2009
@@ -1,0 +1,217 @@
+<?php
+/*
+  PROJECT:    ReactOS Web Test Manager
+  LICENSE:    GNU GPLv2 or any later version as published by the Free Software 
Foundation
+  PURPOSE:    Class for reading WineTest results
+  COPYRIGHT:  Copyright 2009 Colin Finck <[email protected]>
+*/
+
+       require_once("config.inc.php");
+       require_once("connect.db.php");
+       
+       class WineTest_ResultReader
+       {
+               private $dbh;
+               private $suite_id_list;
+               private $test_id_array = array();
+               private $test_id_list = null;
+               
+               /**
+                * Constructs a WineTest_ResultReader object and establishes 
the DB connection.
+                */
+               public function __construct()
+               {
+                       // Establish a DB connection
+                       try
+                       {
+                               $this->dbh = new PDO("mysql:host=" . DB_HOST, 
DB_USER, DB_PASS);
+                       }
+                       catch(PDOException $e)
+                       {
+                               // Give no exact error message here, so no 
server internals are exposed
+                               die("Could not establish the DB connection");
+                       }
+               }
+               
+               /**
+                * Validate and set the passed ID list and do some basic tasks.
+                *
+                * @param string $new_test_id_list
+                * A comma-separated list of Test IDs to compare.
+                *
+                * @return
+                * Boolean true on success, otherwise a string containing an 
error message.
+                */
+               public function setTestIDList($new_test_id_list)
+               {
+                       $new_test_id_array = explode(",", $new_test_id_list);
+                       
+                       // Verify that a suitable value was passed
+                       if(!$new_test_id_array)
+                               return "new_test_id_list cannot be converted 
into an array";
+                       
+                       // Verify that the array only contains numeric values 
and store them as integers to prevent SQL injections
+                       for($i = 0; $i < count($new_test_id_array); $i++)
+                       {
+                               if(!is_numeric($new_test_id_array[$i]))
+                                       return "new_test_id_list is not 
entirely numeric!";
+                               
+                               $new_test_id_array[$i] = 
(int)$new_test_id_array[$i];
+                       }
+                       
+                       // Verify that the user did not select more results 
than he's allowed to
+                       if(count($new_test_id_array) > MAX_COMPARE_RESULTS)
+                               return "You may only select up to " . 
MAX_COMPARE_RESULTS . " results for comparison!";
+                       
+                       // We're safe to use these IDs now.
+                       $this->test_id_array = $new_test_id_array;
+                       $this->test_id_list = $new_test_id_list;
+                       
+                       // Get all Suite IDs linked to our Test IDs
+                       $stmt = $this->dbh->query(
+                               "SELECT s.id " .
+                               "FROM " . DB_TESTMAN . ".winetest_suites s " .
+                               "JOIN " . DB_TESTMAN . ".winetest_results e ON 
e.suite_id = s.id " .
+                               "WHERE e.test_id IN (" . $this->test_id_list . 
")"
+                       );
+                       
+                       if(!$stmt)
+                               return __FILE__ . ":" . __LINE__ . ", " . 
__METHOD__ . " - Query failed";
+                       
+                       $suite_id_array = $stmt->fetchAll(PDO::FETCH_COLUMN);
+                       $this->suite_id_list = implode(",", $suite_id_array);
+                       
+                       return true;
+               }
+               
+               /**
+                * Retrieves the number of Test IDs of the stored 
$test_id_array.
+                *
+                * @return
+                * An int value containing the number of IDs.
+                */
+               public function getTestIDCount()
+               {
+                       return count($this->test_id_array);
+               }
+               
+               /**
+                * Retrieves a PDOStatement for getting general information 
about a Test Run.
+                *
+                * @param int $i
+                * The index of the Test ID to get the information from.
+                *
+                * @return
+                * On success, the method returns a PDOStatement, from which 
you can fetch the information.
+                * In case of failure, the method returns a string containing 
an error message.
+                */
+               public function getTestRunInfoStatement($i)
+               {
+                       if($i >= count($this->test_id_array))
+                               return "Index $i is out of range!";
+                       
+                       $stmt = $this->dbh->query(
+                               "SELECT UNIX_TIMESTAMP(r.timestamp) timestamp, 
a.name, r.revision, r.platform, r.count, r.failures " .
+                               "FROM " . DB_TESTMAN . ".winetest_runs r " .
+                               "JOIN " . DB_ROSCMS . ".roscms_accounts a ON 
r.user_id = a.id " .
+                               "WHERE r.id = " . $this->test_id_array[$i] . " 
" .
+                               "LIMIT 1"
+                       );
+                       
+                       if(!$stmt)
+                               return __FILE__ . ":" . __LINE__ . ", " . 
__METHOD__ . " - Query failed for $i";
+                       
+                       return $stmt;
+               }
+               
+               /**
+                * Retrieves a PDOStatement for getting test result information.
+                * Compared to getListResultInfoStatement, this method will 
only output full rows and the output will also contain information about the 
test suite.
+                *
+                * @param int $i
+                * The index of the Test ID to get the information from.
+                *
+                * @return
+                * On success, the method returns a PDOStatement, from which 
you can fetch the information.
+                * In case of failure, the method returns a string containing 
an error message.
+                */
+               public function getSingleResultInfoStatement($i)
+               {
+                       if($i >= count($this->test_id_array))
+                               return "Index $i is out of range!";
+                       
+                       $stmt = $this->dbh->query(
+                               "SELECT e.id, e.status, e.count, e.failures, 
e.skipped, s.module, s.test " .
+                               "FROM " . DB_TESTMAN . ".winetest_results e " .
+                               "JOIN " . DB_TESTMAN . ".winetest_suites s ON 
e.suite_id = s.id " .
+                               "WHERE e.test_id = " . $this->test_id_array[$i] 
. " " .
+                               "ORDER BY s.module, s.test"
+                       );
+                       
+                       if(!$stmt)
+                               return __FILE__ . ":" . __LINE__ . ", " . 
__METHOD__ . " - Query failed for $i";
+                       
+                       return $stmt;
+               }
+               
+               /**
+                * Retrieves a PDOStatement for getting information about the 
Test Suites used by at least one result in our ID list.
+                *
+                * @return
+                * On success, the method returns a PDOStatement, from which 
you can fetch the information.
+                * In case of failure, the method returns a string containing 
an error message.
+                */
+               public function getListTestSuiteInfoStatement()
+               {
+                       if(!$this->test_id_list)
+                               return "test_id_list was not initialized, call 
setTestIDList first!";
+                       
+                       // Get all test suites for which we have at least one 
result in our ID list
+                       $stmt = $this->dbh->query(
+                               "SELECT DISTINCT s.id, s.module, s.test " .
+                               "FROM " . DB_TESTMAN . ".winetest_suites s " .
+                               "JOIN " . DB_TESTMAN . ".winetest_results e ON 
e.suite_id = s.id " .
+                               "WHERE test_id IN (" . $this->test_id_list . ") 
" .
+                               "ORDER BY s.module ASC, s.test ASC"
+                       );
+                       
+                       if(!$stmt)
+                               return __FILE__ . ":" . __LINE__ . ", " . 
__METHOD__ . " - Query failed";
+                       
+                       return $stmt;
+               }
+               
+               /**
+                * Retrieves a PDOStatement for getting test result information.
+                * Compared to getSingleResultInfoStatement, this method will 
output a row for each suite, for which we have at least one result in our ID 
list.
+                *
+                * @param int $i
+                * The index of the Test ID to get the information from.
+                *
+                * @return
+                * On success, the method returns a PDOStatement, from which 
you can fetch the information.
+                * In case of failure, the method returns a string containing 
an error message.
+                */
+               public function getListResultInfoStatement($i)
+               {
+                       if(!$this->suite_id_list)
+                               return "suite_id_list was not initialized, call 
setTestIDList first!";
+                       
+                       if($i >= count($this->test_id_array))
+                               return "Index $i is out of range!";
+                       
+                       $stmt = $this->dbh->query(
+                               "SELECT e.id, e.status, e.count, e.failures, 
e.skipped " .
+                               "FROM " . DB_TESTMAN . ".winetest_suites s " .
+                               "LEFT JOIN " . DB_TESTMAN . ".winetest_results 
e ON e.suite_id = s.id AND e.test_id = " . $this->test_id_array[$i] . " " .
+                               "WHERE s.id IN (" . $this->suite_id_list . ")" .
+                               "ORDER BY s.module, s.test"
+                       );
+                       
+                       if(!$stmt)
+                               return __FILE__ . ":" . __LINE__ . ", " . 
__METHOD__ . " - Query failed for $i";
+                       
+                       return $stmt;
+               }
+       }
+?>

Propchange: 
branches/danny-web/www/www.reactos.org/testman/lib/WineTest_ResultReader.class.php
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: branches/danny-web/www/www.reactos.org/testman/res/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Sun Jun 21 02:21:24 2009
@@ -1,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)

Propchange: branches/danny-web/www/www.reactos.org/testman/res/
------------------------------------------------------------------------------
    bugtraq:message = See issue #%BUGID% for more details.

Propchange: branches/danny-web/www/www.reactos.org/testman/res/
------------------------------------------------------------------------------
    bugtraq:url = http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%

Added: branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd?rev=439&view=auto
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd (added)
+++ branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd 
[iso-8859-1] Sun Jun 21 02:21:24 2009
@@ -1,0 +1,44 @@
+<!--
+  PROJECT:    ReactOS Web Test Manager
+  LICENSE:    GNU GPLv2 or any later version as published by the Free Software 
Foundation
+  PURPOSE:    DTD for the XML export data
+  COPYRIGHT:  Copyright 2009 Colin Finck <[email protected]>
+-->
+
+<!--=============================== Entities ===============================-->
+
+<!ENTITY % TestID "CDATA">
+    <!-- Test ID in the database -->
+
+<!ENTITY % Timestamp "CDATA">
+    <!-- Unix timestamp -->
+
+<!ENTITY % ResultID "CDATA">
+    <!-- Result ID in the database -->
+
+<!ENTITY % Number "CDATA">
+    <!-- one or more digits -->
+
+
+<!--=============================== Elements ===============================-->
+
+<!ELEMENT testinfo (revision*)>
+
+<!ELEMENT revision (test*)>
+<!ATTLIST revision
+  id         %TestID     #REQUIRED
+  timestamp  %Timestamp  #REQUIRED
+  user       CDATA       #REQUIRED
+  platform   CDATA       #REQUIRED
+>
+
+<!ELEMENT test EMPTY>
+<!ATTLIST test
+  id         %ResultID   #REQUIRED
+  module     CDATA       #REQUIRED
+  test       CDATA       #REQUIRED
+  status     CDATA       #REQUIRED
+  count      %Number     #REQUIRED
+  failures   %Number     #REQUIRED
+  skipped    %Number     #REQUIRED
+>

Propchange: branches/danny-web/www/www.reactos.org/testman/res/testinfo.dtd
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/danny-web/www/www.reactos.org/testman/utils.inc.php
URL: 
http://svn.reactos.org/svn/reactos/branches/danny-web/www/www.reactos.org/testman/utils.inc.php?rev=439&r1=438&r2=439&view=diff
==============================================================================
--- branches/danny-web/www/www.reactos.org/testman/utils.inc.php [iso-8859-1] 
(original)
+++ branches/danny-web/www/www.reactos.org/testman/utils.inc.php [iso-8859-1] 
Sun Jun 21 02:21:24 2009
@@ -5,7 +5,13 @@
   PURPOSE:    Utility functions shared among several PHP files
   COPYRIGHT:  Copyright 2008-2009 Colin Finck <[email protected]>
 */
-               
+
+       // All classes are autoloaded through this magic function
+       function __autoload($class)
+       {
+               require_once("lib/$class.class.php");
+       }
+       
        function GetPlatformString($platform)
        {
                // First get the main operating system

Reply via email to