From 29db88de2ab47e008b72fbe3e0b5e4f1058fb116 Mon Sep 17 00:00:00 2001 From: chriskl Date: Mon, 15 Dec 2003 08:30:54 +0000 Subject: [PATCH] change awk path in convert.awk. make reports feature detect that reports db doesn't exist and complain nicely --- BUGS | 2 +- HISTORY | 1 + classes/Reports.php | 21 ++++++---- classes/database/Postgres.php | 4 +- lang/convert.awk | 2 +- lang/english.php | 3 +- lang/recoded/english.php | 3 +- reports.php | 72 ++++++++++++++++++----------------- 8 files changed, 60 insertions(+), 48 deletions(-) diff --git a/BUGS b/BUGS index dcb416a5..0b95d270 100644 --- a/BUGS +++ b/BUGS @@ -3,7 +3,6 @@ Internal Bugs List This file is used to track current working tasks - just ignore it! -better detection for when reports database hasn't been installed. fix getIndexes() and getConstraints() for < 7.3 to know about index type (eg. constraints can only be btree indexes) re-enable help system @@ -19,3 +18,4 @@ investigate phpPgInfo Need to fix: * Variables and processes views for < 7.3 +* Viewing database properties is broken... diff --git a/HISTORY b/HISTORY index 5b38724b..4e99d52f 100644 --- a/HISTORY +++ b/HISTORY @@ -12,6 +12,7 @@ Features Bugs * Object browser fixed for databases with no schemas +* Properly detect that reports database is missing Translations * Spanish from Martin Marques diff --git a/classes/Reports.php b/classes/Reports.php index e462a709..a2424c4f 100644 --- a/classes/Reports.php +++ b/classes/Reports.php @@ -4,22 +4,27 @@ * the functions provided by the database driver exclusively, and hence * will work with any database without modification. * - * $Id: Reports.php,v 1.9 2003/12/10 16:03:30 chriskl Exp $ + * $Id: Reports.php,v 1.10 2003/12/15 08:30:54 chriskl Exp $ */ class Reports { // A database driver var $driver; + var $reports_db = 'phppgadmin'; /* Constructor */ - function Reports() { - global $misc; - - // Create a new database access object. - // @@ IF THE phppgadmin DATABASE DOES NOT EXIST THEN - // @@ LOGIN FAILURE OCCURS - $this->driver = &$misc->getDatabaseAccessor('phppgadmin'); + function Reports(&$status) { + global $misc, $data; + + // Check to see if the reports database exists + $rs = $data->getDatabase($this->reports_db); + if ($rs->recordCount() != 1) $status = -1; + else { + // Create a new database access object. + $this->driver = &$misc->getDatabaseAccessor($this->reports_db); + $status = 0; + } } /** diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 62f479a6..b1006925 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.166 2003/12/13 09:28:46 chriskl Exp $ + * $Id: Postgres.php,v 1.167 2003/12/15 08:30:54 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -226,7 +226,7 @@ class Postgres extends BaseDB { function &getDatabase($database) { $this->clean($database); $sql = "SELECT * FROM pg_database WHERE datname='{$database}'"; - return $this->selectRow($sql); + return $this->selectSet($sql); } /** diff --git a/lang/convert.awk b/lang/convert.awk index dc684d4a..1db11f21 100755 --- a/lang/convert.awk +++ b/lang/convert.awk @@ -1,4 +1,4 @@ -#!/bin/awk -f +#!/usr/bin/awk -f # # Script contains all needed conversions of recoded text # diff --git a/lang/english.php b/lang/english.php index 40f70899..8d463e43 100755 --- a/lang/english.php +++ b/lang/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.121 2003/12/13 09:28:46 chriskl Exp $ + * $Id: english.php,v 1.122 2003/12/15 08:30:54 chriskl Exp $ */ // Language and character set @@ -128,6 +128,7 @@ $lang['strnodata'] = 'No rows found.'; $lang['strnoobjects'] = 'No objects found.'; $lang['strrownotunique'] = 'No unique identifier for this row.'; + $lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.'; // Tables $lang['strtable'] = 'Table'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 8afc1b27..689eedbb 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -4,7 +4,7 @@ * English language file for phpPgAdmin. Use this as a basis * for new translations. * - * $Id: english.php,v 1.73 2003/12/13 09:28:46 chriskl Exp $ + * $Id: english.php,v 1.74 2003/12/15 08:30:54 chriskl Exp $ */ // Language and character set @@ -128,6 +128,7 @@ $lang['strnodata'] = 'No rows found.'; $lang['strnoobjects'] = 'No objects found.'; $lang['strrownotunique'] = 'No unique identifier for this row.'; + $lang['strnoreportsdb'] = 'You have not created the reports database. Read the INSTALL file for directions.'; // Tables $lang['strtable'] = 'Table'; diff --git a/reports.php b/reports.php index 320b0e64..f559ee04 100644 --- a/reports.php +++ b/reports.php @@ -3,7 +3,7 @@ /** * List reports in a database * - * $Id: reports.php,v 1.14 2003/09/09 06:23:12 chriskl Exp $ + * $Id: reports.php,v 1.15 2003/12/15 08:30:54 chriskl Exp $ */ // Include application functions @@ -12,10 +12,6 @@ $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; $PHP_SELF = $_SERVER['PHP_SELF']; - // Create a database accessor for the reports database - include_once('classes/Reports.php'); - $reportsdb = new Reports(); - /** * Displays a screen where they can edit a report */ @@ -272,35 +268,43 @@ $misc->printHeader($lang['strreports']); $misc->printBody(); - switch ($action) { - case 'save_edit': - if (isset($_POST['cancel'])) doDefault(); - else doSaveEdit(); - break; - case 'edit': - doEdit(); - break; - case 'properties': - doProperties(); - break; - case 'save_create': - if (isset($_POST['cancel'])) doDefault(); - else doSaveCreate(); - break; - case 'create': - doCreate(); - break; - case 'drop': - if (isset($_POST['drop'])) doDrop(false); - else doDefault(); - break; - case 'confirm_drop': - doDrop(true); - break; - default: - doDefault(); - break; - } + // Create a database accessor for the reports database + include_once('classes/Reports.php'); + $reportsdb = new Reports($status); + if ($status != 0) { + echo "

{$lang['strnoreportsdb']}

\n"; + } + else { + switch ($action) { + case 'save_edit': + if (isset($_POST['cancel'])) doDefault(); + else doSaveEdit(); + break; + case 'edit': + doEdit(); + break; + case 'properties': + doProperties(); + break; + case 'save_create': + if (isset($_POST['cancel'])) doDefault(); + else doSaveCreate(); + break; + case 'create': + doCreate(); + break; + case 'drop': + if (isset($_POST['drop'])) doDrop(false); + else doDefault(); + break; + case 'confirm_drop': + doDrop(true); + break; + default: + doDefault(); + break; + } + } $misc->printFooter(); -- 2.39.5