From: Sebastien D. <sde...@us...> - 2005-01-12 15:49:14
|
Update of /cvsroot/tslogparser/web/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23666/admin Added Files: index.php modules.inc.php upgrade.php Log Message: Include the tool on the website --- NEW FILE: modules.inc.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ /* This file defines the base module class which will be used. A module consists in four functions closely related to a testsuite model ("type"). These functions are: int TS_parse(ref parent, string TS_name, string TS_description, string TS_path); int TS_delete(ref parent, int TS_id); int RUN_parse(ref parent, string RUN_name, string RUN_description, int TS_id, string CONTENT); int RUN_delete(ref parent, int RUN_id); An additionnal function is added for informational purpose (no functionnal need) string module_info(void) TS_parse will check for the directory TS_path and analyse its content. In case a correct testsuite structure is found, the testsuite is parsed and put into the database with name and description as provided. The return value is $true if success and $false otherwise. TS_delete will search the database for a testsuite TS_id, then delete it. In case the testsuite contains runs, TS_delete will fail. In case TS_id is not of the correct type, TS_delete will fail. Otherwise, the testsuite is deleted from the database. The return value is $true if success and $false otherwise. RUN_parse will add a new run in the database. It starts with checking that TS_id exists and is of the correct testsuite type. Then it analyzes CONTENT and if a correct run format is found, the results are added into the database with RUN_name and RUN_description information. The return value is $true if success and $false otherwise. RUN_delete will delete RUN_id run from database. It starts with checking that RUN_id belongs to a testsuite of the correct type. Then it removes it from the database. The return value is $true if success and $false otherwise. All 4 previous functions have a 'parent' pointer to the testsuite class. This is used for error reporting directly into the parent's 'last_error' property. module_info will return an HTML-formated text (enclosed in <p> and </p> tags) describing the module and the testsuite it supports. All information related to the module (version, known bugs, ...) are suitable for this function (think of it as the only documentation for the module). */ /* This particular file mechanism is as follow: -> Include each .php file from the modules subdirectory. Each inclusion returns its module name, which is added into the base catalog. -> The function list_modules returns the catalog. -> The function select_module selects one of the modules as the working module. (provider of the modules functions as described earlier). It returns true on success, false if the requested module is not available. -> The function selected_module returns the currently selected module. -> The function deselect_module changes the selection back to none. -> The TS_parse, TS_delete, RUN_parse, RUN_delete and module_info functions are wrappers to the selected module functions, or return an error when no module is selected. */ class testsuite { var $modules_catalog; var $selected_module; var $last_error=""; var $debug=0; /* Class constructor: initializes the modules catalog */ function testsuite() { $this->modules_catalog=array(); $this->selected_module=""; /* Enumerate the modules files and include them */ foreach (glob("modules/*.mod.php") as $filename) { $tmp = require($filename); if (is_string($tmp) && class_exists($tmp)) { $this->modules_catalog[]=$tmp; } else { die("File $filename has an incorrect format\n"); } } } /* Functions for manipulating the selected module */ function list_modules() { return $this->modules_catalog; } function selected_module() { return $this->selected_module; } function select_module($newmod) { if (in_array($newmod, $this->modules_catalog)) { /* Set the module for this execution */ $this->selected_module=$newmod; return true; } return false; } function deselect_module() { $this->selected_module=""; } /* Wrapper functions to the selected module */ function module_info($what="", $module="") { if (!$module) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } $module=$this->selected_module; } if (!is_callable(array($module,'module_info'))) { die("Module ".$module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($module, 'module_info'), array($what)); } function TS_parse($TS_name, $TS_description, $path) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'TS_parse'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($this->selected_module, 'TS_parse'), array(&$this, $TS_name, $TS_description, $path)); } function TS_delete($TS_ID) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'TS_delete'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($this->selected_module, 'TS_delete'), array(&$this, $TS_ID)); } function RUN_parse($RUN_name, $RUN_description, $TS_id, &$CONTENT) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'RUN_parse'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($this->selected_module, 'RUN_parse'), array(&$this, $RUN_name, $RUN_description, $TS_id, $CONTENT)); } function RUN_delete($RUN_id) { /* Check the environment is correct */ if ($this->selected_module == "") { die("No selected module"); } if (!is_callable(array($this->selected_module,'RUN_delete'))) { die("Module ".$this->selected_module." is malformed.\n"); } /* Call actually the module method */ return call_user_func_array( array($this->selected_module, 'RUN_delete'), array(&$this, $RUN_id)); } } ?> --- NEW FILE: upgrade.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ /* This file will set up or upgrade the database schema. */ $root="../"; $_PAGE["title"]="TSLP Database Installation / Upgrade"; /* Output header page */ require($root."header.inc.php"); /* We'll need functions defined in other files */ require($root."database.inc.php"); /* The following files define several usefull functions */ require($root."db/remove_db_data.inc.php"); require($root."db/initial_db_schema.inc.php"); echo "<pre>\n"; /* Connect the database server */ echo "Checking database connexion...: "; $db_link = @mysql_connect($db_server,$db_user,$db_pw); if (!$db_link) { echo "<font color='red'>Fail</font>\n"; echo "<i>MySQL error</i>: <b>".mysql_error()."</b>"; echo "</pre>\n"; echo "<p>Please check your db_inc.php file parameters.</p>\n"; require($root."footer.inc.php"); die(); } else { echo "<font color='green'>Ok</font>\n"; } /* Select the database */ echo "Selecting database............: "; $tmp = @mysql_select_db($db); if (!$tmp) { echo "<font color='red'>Fail</font>\n"; echo "<i>MySQL error</i>: <b>".mysql_error()."</b>"; echo "</pre>\n"; echo "<p>Please check your db_inc.php file parameters.</p>\n"; die(); mysql_close($db_link); require($root."footer.inc.php"); die(); } else { echo "<font color='green'>Ok</font>\n"; } /* Check if the configuration table exists */ $config=array(); echo "Checking current version......: "; $tmp = @mysql_query("SELECT * FROM opts_config"); if ($tmp) { while ($row = mysql_fetch_assoc($tmp)) $config[$row["cfg_key"]]=$row["cfg_val"]; } if (!isset($config["version"])) { if (isset($_GET["reset"])) { echo "<font color='orange'>Building...</font>\n"; echo " Deleting old database content...\n"; echo " ".remove_db_data()."\n"; echo " Creating new content...\n"; echo " ".initial_db_schema()."\n"; $tmp = @mysql_query("SELECT * FROM opts_config"); while ($row = mysql_fetch_assoc($tmp)) $config[$row["cfg_key"]]=$row["cfg_val"]; } else { echo "<font color='red'>Not found</font>\n"; echo "</pre>\n"; echo "<p>You have either an old or an incomplete installation.\n"; echo "The system is unable to upgrade/repair the database.</p>\n"; echo "<p><b>Do you want to install a fresh database? \n"; echo "(ALL EXISTING DATA WILL BE ERASED!)</p>\n"; echo "<form method='GET'>\n"; echo " <p><input type='submit' name='reset' value='Install/Reset'></p>\n"; echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } echo "<b>".$config["version"]."</b>\n"; require_once($root."db/update_db.inc.php"); echo "Checking required version.....: <b>".LATEST_VERSION."</b>\n"; if ( $config["version"] < LATEST_VERSION) { echo " Updating...\n"; update_db($config["version"]); echo " <font color='green'><b>Done!</b> You may start using the new version safely.</font>\n"; } else { echo "Your database is already up-to-date.\n"; } echo "</pre>\n"; db_fini(); require($root."footer.inc.php"); die(); --- NEW FILE: index.php --- <?php /* * Copyright (c) 2005, Bull S.A.. All rights reserved. * Created by: Sebastien Decugis * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write the Free Software Foundation, Inc., 59 * Temple Place - Suite 330, Boston MA 02111-1307, USA. */ /* This file allows an admin to list the current releases and runs, to delete some entries or to add new ones. We create an array with: ---------------------------------------------------------------------------------- | modules | TS releases | TS description | RUNs | RUN Descriptions | ---------------------------------------------------------------------------------- | opts | 1.5.0 | This is the... | Fedora Core 3 | Run on IA32 ... | | <info> | <delete*> | <edit> | <delete> | <edit> | | | | |----------------------------------| | | | | Solaris 10 | Run on ... | | | | | <delete> | <edit> | | | | |----------------------------------| | | | | <add new> | | | |-------------------------------------------------------------------| | | <add new> | | | | |--------------------------------------------------------------------------------| | ltp | 200412 | This is... | <add new> | | | <info> | <delete> | <edit> | | | | |-------------------------------------------------------------------| | | <add new> | | | | |--------------------------------------------------------------------------------| | nfsv4 | <add new> | | | | | <info> | | | | | |--------------------------------------------------------------------------------| */ $root="../"; $_PAGE["title"]="TSLP Administration Interface"; /* Output header page */ require($root."header.inc.php"); /* We'll need functions defined in other files */ require($root."database.inc.php"); require($root."functions.inc.php"); /* We'll need the database connexion */ db_init(); /* Initialize the plugins modules */ require($root."admin/modules.inc.php"); $tslp = new testsuite(); /* Query the modules list first */ $modules=$tslp->list_modules(); if (isset($_POST["action"])) { $_GET["action"]=$_POST["action"]; if (isset($_POST["add_run"])) $_GET["add_run"] = $_POST["add_run"]; if (isset($_POST["module"])) $_GET["module"] = $_POST["module"]; if (isset($_POST["tsid"])) $_GET["tsid"] = $_POST["tsid"]; if (isset($_POST["run_name"])) $_GET["run_name"] = $_POST["run_name"]; if (isset($_POST["run_descr"])) $_GET["run_descr"] = $_POST["run_descr"]; } /* Parse the GET parameters if any */ if (isset($_GET["action"])) { if (0) { echo "<hr><pre>\n"; print_r($_GET); echo "</pre><hr>\n"; } if (isset($_GET["info_mod"])) $_GET["module"]=$_GET["info_mod"]; /* Check module coherency */ if (isset($_GET["add_ts"]) || isset($_GET["delete_ts"]) || isset($_GET["add_run"]) || isset($_GET["delete_run"]) || isset($_GET["info_mod"])) { if (!isset($_GET["module"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } if (!in_array($_GET["module"], $modules)) { echo "<b>Module <i>".$_GET["module"]."</i> unavailable.</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } $tslp->select_module($_GET["module"]) or die("Invalid plugin"); } /***************************** *** Module information *** *****************************/ if (isset($_GET["info_mod"])) { echo "<table border=\"1\">\n"; echo " <tr>\n"; echo " <td align=\"center\">\n"; echo " <b>Module Informations</b>\n"; echo " </td>\n"; echo " </tr>\n"; echo " <tr>\n"; echo " <td>\n"; echo $tslp->module_info(); echo " </td>\n"; echo " </tr>\n"; echo "</table>\n"; echo "<p><a href=\"index.php\">Go back</a> to administration.</p>\n"; } /***************************** *** Add new test suite *** *****************************/ if (isset($_GET["add_ts"])) { /* Check Step 3 parameters and eventually fall back to step 2 */ if (!isset($_GET["ts_name"])) $_GET["ts_name"]=""; if (!isset($_GET["ts_descr"])) $_GET["ts_descr"]=""; if (!isset($_GET["ts_root"])) $_GET["ts_root"]=""; if (($_GET["action"] == 2) && ( !trim($_GET["ts_name"]) || !trim($_GET["ts_root"]))) { echo "<p>Please fill all <b>(*) fields.</b></p>\n"; $_GET["action"] = 1; } if ($_GET["action"] == 2) { /* Here we're in step 2 in process: ready to proceed */ echo "<pre>\n"; $tmp = $tslp->TS_parse($_GET["ts_name"], $_GET["ts_descr"], $_GET["ts_root"]); echo "</pre>\n"; if (!$tmp) { $_GET["action"] = 1; echo "<p><b>Error:</b> <i>".$tslp->last_error."</i>.</p>\n"; } } if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"add_ts\" value=\"add\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"".$_GET["module"]."\">\n"; ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Add a new release in database.</h3> </td> </tr> <tr> <td>Selected module:</td> <td><b><?php echo $_GET["module"]; ?></b></td> </tr> <tr> <td>New release name(*):</td> <td><input type="text" name="ts_name" maxlength="30" size="80" value=<?php echo "\"".$_GET["ts_name"]."\""; ?>></td> </tr> <tr> <td>New release description:</td> <td><textarea name="ts_descr" rows="3" cols="79"><?php echo $_GET["ts_descr"]; ?></textarea></td> </tr> <tr> <td>Path to new release(*):</td> <td><input type="text" name="ts_root" size="80" value=<?php echo "\"".$_GET["ts_root"]."\""; ?>></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="send" value="Send"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } /* Here we're in step 2 in process: ready to proceed */ $tslp->select_module($_GET["module"]) or die("Invalid plugin"); $tmp = $tslp->TS_parse($_GET["ts_name"], $_GET["ts_descr"], $_GET["ts_root"]); } /***************************** *** Edit test suite *** *****************************/ if (isset($_GET["edit_ts"])) { if (!isset($_GET["tsid"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } if ($_GET["action"] == 2) { $sql= " UPDATE opts_versions " ." SET ver_comment=".stringToDB($_GET["ts_descr"]) ." WHERE ver_id=".$_GET["tsid"] ." AND ver_module=".stringToDB($_GET["module"]); $tmp = db_execute_insert($sql); if (!$tmp) { $_GET["action"] = 1; echo "<p><b>An error occured,</b> release NOT changed.</p>\n"; } } /* Ask new description */ if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"edit_ts\" value=\"del\">\n"; echo " <input type=\"hidden\" name=\"tsid\" value=\"".$_GET["tsid"]."\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"".$_GET["module"]."\">\n"; $sql= " SELECT ver_name, ver_comment " ." FROM opts_versions" ." WHERE ver_id=".$_GET["tsid"] ." AND ver_module=".stringToDB($_GET["module"]); $release = db_execute_select($sql); if (!$release) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Edit a release description.</h3> </td> </tr> <tr> <td>Release name:</td> <td><?php echo stringFromDB($release[0]["ver_name"]); ?></td> </tr> <tr> <td>Release description:</td> <td><textarea name="ts_descr" rows="3" cols="79"><?php echo $release[0]["ver_comment"]; ?></textarea></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="Change" value="confirm"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } /***************************** *** Delete test suite *** *****************************/ if (isset($_GET["delete_ts"])) { if (!isset($_GET["tsid"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } /* We already confirmed the deletion */ if ($_GET["action"] == 2) { echo "<pre>\n"; $tmp = $tslp->TS_delete($_GET["tsid"]); echo "</pre>\n"; if (!$tmp) { $_GET["action"] = 1; echo "<p><b>Error:</b> <i>".$tslp->last_error."</i>.</p>\n"; } } /* Require confirmation */ if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"delete_ts\" value=\"del\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"".$_GET["module"]."\">\n"; echo " <input type=\"hidden\" name=\"tsid\" value=\"".$_GET["tsid"]."\">\n"; $sql= " SELECT ver_name, ver_comment " ." FROM opts_versions" ." WHERE ver_id=".$_GET["tsid"] ." AND ver_module=".stringToDB($_GET["module"]); $release = db_execute_select($sql); if (!$release) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Delete a release from database.</h3> </td> </tr> <tr> <td>Release name:</td> <td><?php echo stringFromDB($release[0]["ver_name"]); ?></td> </tr> <tr> <td>Release description:</td> <td><pre><?php echo stringFromDB($release[0]["ver_comment"]); ?></pre></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="Delete" value="confirm"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } /***************************** *** Add run *** *****************************/ if (isset($_GET["add_run"])) { if (!isset($_GET["tsid"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } /* Check Step 3 parameters and eventually fall back to step 2 */ if (!isset($_GET["run_name"])) $_GET["run_name"]=""; if (!isset($_GET["run_descr"])) $_GET["run_descr"]=""; if ($_GET["action"] == 2) { if (!isset($_FILES['logfile'])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } $log = file_get_contents($_FILES['logfile']['tmp_name']); if (!$log) { $_GET["action"] = 1; echo "<p>Unable to read the file ".$_FILES['logfile']['name']."</p>\n"; } if ((!trim($_GET["run_name"]) || !trim($_GET["run_descr"]) || !$log)) { echo "<p>Please fill all <b>(*) fields.</b></p>\n"; $_GET["action"] = 1; } } if ($_GET["action"] == 2) { /* Here we're in step 2 in process: ready to proceed */ echo "<pre>\n"; $tmp = $tslp->RUN_parse($_GET["run_name"], $_GET["run_descr"], $_GET["tsid"], $log); echo "</pre>\n"; if (!$tmp) { $_GET["action"] = 1; echo "<p><b>Error:</b> <i>".$tslp->last_error."</i>.</p>\n"; } } if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form enctype=\"multipart/form-data\" method=\"POST\">\n"; echo " <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1048576\">"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"add_run\" value=\"add\">\n"; echo " <input type=\"hidden\" name=\"tsid\" value=\"".$_GET["tsid"]."\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"".$_GET["module"]."\">\n"; $sql= " SELECT ver_name " ." FROM opts_versions" ." WHERE ver_id=".$_GET["tsid"] ." AND ver_module=".stringToDB($_GET["module"]); $release = db_execute_select($sql); if (!$release) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Add a new run logfile in database.</h3> </td> </tr> <tr> <td>Selected module:</td> <td><b><?php echo $_GET["module"]; ?></b></td> </tr> <tr> <td>Selected testsuite release:</td> <td><b><?php echo $release[0]["ver_name"]; ?></b></td> </tr> <tr> <td>New run name(*):</td> <td><input type="text" name="run_name" maxlength="30" size="80" value=<?php echo "\"".$_GET["run_name"]."\""; ?>></td> </tr> <tr> <td>New release description:</td> <td><textarea name="run_descr" rows="3" cols="79"><?php echo $_GET["run_descr"]; ?></textarea></td> </tr> <tr> <td>Log file (*):</td> <td>Upload this file: <input name="logfile" type="file"></td> </tr> <tr> <td colspan="2" align=center><input type="submit" name="send" value="Send"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } /***************************** *** Edit run *** *****************************/ if (isset($_GET["edit_run"])) { if (!isset($_GET["runid"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } if ($_GET["action"] == 2) { $sql= " UPDATE opts_run " ." SET run_comments=".stringToDB($_GET["run_descr"]) ." WHERE run_id=".$_GET["runid"]; $tmp = db_execute_insert($sql); if (!$tmp) { $_GET["action"] = 1; echo "<p><b>An error occured,</b> run NOT changed.</p>\n"; } } /* Ask new description */ if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"edit_run\" value=\"edit\">\n"; echo " <input type=\"hidden\" name=\"runid\" value=\"".$_GET["runid"]."\">\n"; $sql= " SELECT run_name, run_comments " ." FROM opts_run" ." WHERE run_id=".$_GET["runid"]; $run = db_execute_select($sql); if (!$run) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Edit a run logfile description.</h3> </td> </tr> <tr> <td>Run name:</td> <td><?php echo stringFromDB($run[0]["run_name"]); ?></td> </tr> <tr> <td>Run description:</td> <td><textarea name="run_descr" rows="3" cols="79"><?php echo $run[0]["run_comments"]; ?></textarea></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="Change" value="confirm"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } /***************************** *** Delete run *** *****************************/ if (isset($_GET["delete_run"])) { if (!isset($_GET["runid"])) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } /* We already confirmed the deletion */ if ($_GET["action"] == 2) { echo "<pre>\n"; $tmp = $tslp->RUN_delete($_GET["runid"]); echo "</pre>\n"; if (!$tmp) { $_GET["action"] = 1; echo "<p><b>Error:</b> <i>".$tslp->last_error."</i>.</p>\n"; } } /* Require confirmation */ if ($_GET["action"] < 2) { /* Output the new testsuite form */ echo "<form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"2\">\n"; echo " <input type=\"hidden\" name=\"delete_run\" value=\"del\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"".$_GET["module"]."\">\n"; echo " <input type=\"hidden\" name=\"runid\" value=\"".$_GET["runid"]."\">\n"; $sql= " SELECT run_name, run_comments " ." FROM opts_run" ." WHERE run_id=".$_GET["runid"]; $run = db_execute_select($sql); if (!$run) { echo "<b>Invalid parameters</b>\n"; db_fini(); require($root."footer.inc.php"); die(); } ?> <table border="1" align="center" width="80%"> <tr> <td colspan="2" align="center"> <h3>Delete a run from database.</h3> </td> </tr> <tr> <td>Run name:</td> <td><?php echo stringFromDB($run[0]["run_name"]); ?></td> </tr> <tr> <td>Release description:</td> <td><?php echo stringFromDB($run[0]["run_comments"]); ?></td> </tr> <tr> <td colspan=2 align=center><input type="submit" name="Delete" value="confirm"></td> </tr> </table> <p><a href="index.php">Go back</a> to administration index.</p> <?php echo "</form>\n"; db_fini(); require($root."footer.inc.php"); die(); } } } /* We are building the global array */ /* list the releases and runs from the database */ $sql= " SELECT ver_name, ver_comment, ver_id, ver_module " ." FROM opts_versions" ." ORDER BY ver_id DESC"; $release_table = db_execute_select($sql); $sql= " SELECT DISTINCT run_id, run_name, run_comments" ." FROM opts_run" ." ORDER BY run_id"; $allrun_table = db_execute_select($sql); $orphaned=array(); foreach ($allrun_table as $myrow) $orphaned[$myrow["run_id"]]=$myrow["run_name"]; $sql= " SELECT DISTINCT run_name, run_id, run_comments, ver_name, ver_module " ." FROM opts_run, opts_run_results, opts_version_descriptions, opts_versions " ." WHERE run_id=res_run" ." AND res_testcase=descr_id" ." AND descr_version=ver_id" ." ORDER BY ver_name"; $run_table = db_execute_select($sql); /* Sort all this information into an array */ $DATA=array(); foreach ($modules as $module) $DATA[$module]=array( "module"=>strip_tags($tslp->module_info("title", $module)), "TS"=>array(), "count"=>1); /* We count the "add new TS line here" */ foreach ($release_table as $release) { if (!isset($DATA[$release["ver_module"]]["TS"])) /* This release' module is not available */ $DATA[$release["ver_module"]]=array("TS"=>array(), "count"=>0); $DATA[$release["ver_module"]]["TS"][$release["ver_name"]]= array("id"=>$release["ver_id"], "comment"=>$release["ver_comment"], "RUNS"=>array(), "count"=>1); /* count the "add new run" here */ $DATA[$release["ver_module"]]["count"] += 1; } foreach ($run_table as $run) { unset($orphaned[$run["run_id"]]); if (!isset($DATA[$run["ver_module"]])) /* This run's module is not available -- really abnormal */ $DATA[$run["ver_module"]]=array("TS"=>array(),"count"=>0); if (!isset($DATA[$run["ver_module"]]["TS"][$run["ver_name"]])) /* This run belongs to no testsuite */ $DATA[$run["ver_module"]]["TS"][$run["ver_name"]]=array("RUNS"=>array(),"count"=>0); $DATA[$run["ver_module"]]["TS"][$run["ver_name"]]["RUNS"][$run["run_id"]]= array( "run_name"=>$run["run_name"], "run_comments"=>$run["run_comments"]); $DATA[$release["ver_module"]]["count"] += 1; $DATA[$release["ver_module"]]["TS"][$run["ver_name"]]["count"] += 1; } //echo "<hr><pre>\n"; //print_r($DATA); //echo "</pre><hr>\n"; if ($orphaned) { echo "<p>The database contains <b>".count($orphaned)."</b> orphaned runs.</p>\n"; } /* We're ready to build the array */ ?> <table border="1" valign="top"> <tr> <td title="TestSuite Module" align="center"><b>Module</b></td> <td title="TestSuite Release Name" align="center"><b>TS Release</b></td> <td title="TestSuite Decription" align="center"><b>TS Description</b></td> <td title="Execution Log Name" align="center"><b>RUN</b></td> <td title="Execution Log Description" align="center"><b>RUN Description</b></td> </tr> <?php /* Output the array content */ foreach ($DATA as $module => $mod_data) { $plugged=isset($mod_data["module"]); $tags=0; echo " <tr>\n"; echo " <td"; if ($mod_data["count"]) echo " rowspan=\"".$mod_data["count"]."\""; if ($plugged) echo " title=\"".$mod_data["module"]."\""; echo " align=\"center\" valign=\"top\">\n"; echo "<p>".$module."</p>\n"; if ($plugged) { echo "<p>\n"; echo " <form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"1\">\n"; echo " <input type=\"hidden\" name=\"info_mod\" value=\"$module\">\n"; echo " <input type=\"Submit\" name=\"about\" value=\"About\">\n"; echo " </form>\n"; echo "</p>"; } else echo "<p>Unsupported module</p>\n"; echo " </td>\n"; if ($plugged) { echo " <td align=\"center\" colspan=\"2\">\n"; echo " <form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"1\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"$module\">\n"; echo " <input type=\"submit\" name=\"add_ts\" value=\"Add New Testsuite Version\">\n"; echo " </form>\n"; echo " </td>\n"; echo " <td colspan=\"2\"> </td>\n"; echo " </tr>\n"; } foreach ($mod_data["TS"] as $ts_name => $ts_data) { if ($plugged || ($tags > 0)) echo " <tr>\n"; $known=isset($ts_data["id"]); if ($plugged && $known) { echo " <form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"1\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"$module\">\n"; echo " <input type=\"hidden\" name=\"tsid\" value=\"".$ts_data["id"]."\">\n"; } echo " <td"; if ($ts_data["count"]) echo " rowspan=\"".$ts_data["count"]."\""; echo " align=\"center\" valign=\"top\">\n"; echo "<p><code>".$ts_name."</code></p>\n"; if (!$known) echo " <p><i>Unknown TS</i></p>\n"; else { echo " <p><input type=\"Submit\" name=\"delete_ts\" value=\"Delete\""; if ((!$plugged) || ($ts_data["count"] > 1)) echo " disabled"; echo "></p>\n"; } echo " </td>\n"; echo " <td"; if ($ts_data["count"]) echo " rowspan=\"".$ts_data["count"]."\""; echo " valign=\"top\" align=\"center\">\n"; echo "<p><font size='-1'>".$ts_data["comment"]."</font></p>\n"; if ($known) { echo " <p><input type=\"Submit\" name=\"edit_ts\" value=\"Edit\""; if (!$plugged) echo " disabled"; echo "></p>\n"; } echo "</td>\n"; /* Add new run if we are in a known TS */ if ($known) { echo " <td align=\"center\" colspan=\"2\">"; echo " <input type=\"submit\" name=\"add_run\" value=\"Add New Logfile\"></td>\n"; echo " </tr>\n"; } echo "</form>\n"; foreach ($ts_data["RUNS"] as $run_id => $run_data) { if ($known || ($tags > 1)) echo " <tr>\n"; echo " <form method=\"GET\">\n"; echo " <input type=\"hidden\" name=\"action\" value=\"1\">\n"; echo " <input type=\"hidden\" name=\"runid\" value=\"".$run_id."\">\n"; echo " <input type=\"hidden\" name=\"module\" value=\"$module\">\n"; echo " <td valign=\"top\" align=\"center\">\n"; echo " <p><code>".$run_data["run_name"]."</code></p>\n"; echo " <p><input type=\"submit\" name=\"delete_run\" value=\"Delete\"></p>\n"; echo " </td>\n"; echo " <td valign=\"top\" align=\"center\">\n"; echo " <p><font size='-1'>".$run_data["run_comments"]."</font></p>\n"; echo " <p><input type=\"submit\" name=\"edit_run\" value=\"Edit\"></p>\n"; echo " </td>\n"; echo " </form>\n"; echo " </tr>\n"; $tags = 2; } $tags = 1; } } echo "</table>\n"; /* End of file */ db_fini(); require($root."footer.inc.php"); ?> |