some cleanup in reports part
authorioguix <ioguix>
Wed, 9 Jan 2008 00:19:10 +0000 (00:19 +0000)
committerioguix <ioguix>
Wed, 9 Jan 2008 00:19:10 +0000 (00:19 +0000)
classes/Misc.php
display.php
reports.php
sql.php

index 6bd9462c6694a6b8cd8e533fd60e9158e3b1112a..6cfa9602968ac25398d1c0ced5e75d928eb4dee2 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.166 2007/12/11 14:17:17 ioguix Exp $
+        * $Id: Misc.php,v 1.167 2008/01/09 00:19:10 ioguix Exp $
         */
 
        class Misc {
                                        );
 
                                case 'server':
+                               case 'report':
                                        $server_info = $this->getServerInfo();
                                        $hide_users = !$data->isSuperUser($server_info['username']);
                                        $tmp = array (
                                                        'urlvars' => array('subject' => 'server'),
                                                        'hide' => !$conf['show_reports'],
                                                        'icon' => 'Reports',
-                                               )
+                                               ),
                                        ));
                                        return $tmp;
                                        break;
                        }
                        if ($subject == 'server') $done = true;
 
+                       if (isset($_REQUEST['report']) && !$done) {
+                               $vars .= 'report='.urlencode($_REQUEST['report']).'&';
+                               $trail['report'] = array(
+                                       'title' => $lang['strreport'],
+                                       'text'  => $_REQUEST['report'],
+                                       'url'   => "reports.php?subject=report&{$vars}",
+                                       'icon'  => 'Report'
+                               );
+                       }
+
                        if (isset($_REQUEST['database']) && !$done) {
                                $vars .= 'database='.urlencode($_REQUEST['database']).'&';
                                $trail['database'] = array(
                                        'icon'  => 'Roles'
                                );
                        }
-                       if ($subject == 'database' || $subject == 'role') $done = true;
+                       if ($subject == 'database' || $subject == 'role' || $subject == 'report') $done = true;
 
                        if (isset($_REQUEST['schema']) && !$done) {
                                $vars .= 'schema='.urlencode($_REQUEST['schema']).'&';
index 004324be880bca6d79bdda65a146359ccc791cfe..21422190397eded5be66450039f91e11ae628a5d 100644 (file)
@@ -9,7 +9,7 @@
         * @param $return_desc The return link name
         * @param $page The current page
         *
-        * $Id: display.php,v 1.65 2007/11/29 23:23:56 ioguix Exp $
+        * $Id: display.php,v 1.66 2008/01/09 00:19:10 ioguix Exp $
         */
 
        // Prevent timeouts on large exports (non-safe mode only)
                                urlencode($_REQUEST['page']), "\">{$lang['strexpand']}</a></li>\n";
 
                // Create report
-               if (isset($_REQUEST['query']) && $conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0)
+               if (isset($_REQUEST['query']) && ($subject !== 'report') && $conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0)
                        echo "\t<li><a href=\"reports.php?{$misc->href}&amp;action=create&amp;report_sql=",
                                urlencode($_REQUEST['query']), "\">{$lang['strcreatereport']}</a></li>\n";
 
index 6c20189bc519a438b998bc3b667a33d358b08c62..fb8f0f526dfded5df8331225d773f41c1ff55def 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List reports in a database
         *
-        * $Id: reports.php,v 1.33 2007/09/13 13:41:01 ioguix Exp $
+        * $Id: reports.php,v 1.34 2008/01/09 00:19:10 ioguix Exp $
         */
 
        // Include application functions
                global $lang;
 
                if (!isset($_REQUEST['report_name'])) $_REQUEST['report_name'] = '';
-               if (!isset($_REQUEST['db_name'])) $_REQUEST['db_name'] = (isset($_REQUEST['database']) ? $_REQUEST['database'] : '');
+               if (!isset($_REQUEST['db_name'])) $_REQUEST['db_name'] = '';
                if (!isset($_REQUEST['descr'])) $_REQUEST['descr'] = '';
                if (!isset($_REQUEST['report_sql'])) $_REQUEST['report_sql'] = '';
 
+               if (isset($_REQUEST['database'])) {
+                       $_REQUEST['db_name'] = $_REQUEST['database'];
+                       unset($_REQUEST['database']);
+                       $misc->setForm();
+               }
+               
                $databases = $data->getDatabases();
 
                $misc->printTrail('server');
diff --git a/sql.php b/sql.php
index 33b8b40e366de41ad1fb0d26411e468ad673aec9..3b9f0984227d351d75887fbaeb68c90be3d4fee3 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -6,7 +6,7 @@
         * how many SQL statements have been strung together with semi-colons
         * @param $query The SQL query string to execute
         *
-        * $Id: sql.php,v 1.41 2007/12/07 21:58:40 ioguix Exp $
+        * $Id: sql.php,v 1.42 2008/01/09 00:19:10 ioguix Exp $
         */
 
        // Prevent timeouts on large exports (non-safe mode only)
@@ -88,6 +88,7 @@
                exit;
        }
        
+       $subject = isset($_REQUEST['subject'])? $_REQUEST['subject'] : '';
        $misc->printHeader($lang['strqueryresults']);
        $misc->printBody();
        $misc->printTrail('database');
        }
        
        echo "<p>{$lang['strsqlexecuted']}</p>\n";
+                       
+       echo "<ul class=\"navlink\">\n";
+       
+       // Return
+       if (isset($_REQUEST['return_url']) && isset($_REQUEST['return_desc']))
+               echo "\t<li><a href=\"{$_REQUEST['return_url']}\">{$_REQUEST['return_desc']}</a></li>\n";
 
-       echo "<ul class=\"navlink\">\n\t<li><a href=\"database.php?database=", urlencode($_REQUEST['database']),
+       // Edit         
+       echo "\t<li><a href=\"database.php?database=", urlencode($_REQUEST['database']),
                "&amp;server=", urlencode($_REQUEST['server']), "&amp;action=sql&amp;query=", urlencode($_REQUEST['query']), "\">{$lang['streditsql']}</a></li>\n";
-       if ($conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0)
+                               
+       // Create report
+       if (($subject !== 'report') && $conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0)
                echo "\t<li><a href=\"reports.php?{$misc->href}&amp;action=create&amp;report_sql=",
                        urlencode($_REQUEST['query']), "\">{$lang['strcreatereport']}</a></li>\n";
+       
+       // Create view and download
+       if (isset($_REQUEST['query']) && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
+               // Report views don't set a schema, so we need to disable create view in that case
+               if (isset($_REQUEST['schema'])) 
+                       echo "\t<li><a href=\"views.php?action=create&amp;formDefinition=",
+                               urlencode($_REQUEST['query']), "&amp;{$misc->href}\">{$lang['strcreateview']}</a></li>\n";
+               echo "\t<li><a href=\"dataexport.php?query=", urlencode($_REQUEST['query']);
+               if (isset($_REQUEST['search_path']))
+                       echo "&amp;search_path=", urlencode($_REQUEST['search_path']);
+               echo "&amp;{$misc->href}\">{$lang['strdownload']}</a></li>\n";
+       }
+
        echo "</ul>\n";
        
        $misc->printFooter();