Implemented Feature #1015238: Allow reports not to paginate
authormr-russ <mr-russ>
Mon, 16 Apr 2007 11:02:35 +0000 (11:02 +0000)
committermr-russ <mr-russ>
Mon, 16 Apr 2007 11:02:35 +0000 (11:02 +0000)
Each report allows you to select whether to paginate or not.  If you chose not to paginate, you can run UPDATE and INSERT queries.

HISTORY
classes/Reports.php
reports.php
sql.php
sql/reports-pgsql.sql

diff --git a/HISTORY b/HISTORY
index 87a504d85c2af25c4b39b52ec5a0bc0ec4e8e860..693d7ada2e54496d6d936e316b97dea4ec3e31c0 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -5,6 +5,7 @@ Version 4.2
 -----------
 
 Features
+* Pagination selection available fore reports
 * You can configure reports db, schema and table names
 
 Bugs
index da5a81e71b8d1d0c847763f4730bc68865141cef..3ad5181a1f782a3e00ed292734b8214bb7d8cc8e 100644 (file)
@@ -4,7 +4,7 @@
         * the functions provided by the database driver exclusively, and hence
         * will work with any database without modification.
         *
-        * $Id: Reports.php,v 1.17 2007/04/14 08:00:03 mr-russ Exp $
+        * $Id: Reports.php,v 1.18 2007/04/16 11:02:35 mr-russ Exp $
         */
 
        class Reports {
@@ -57,7 +57,7 @@
                        else $filter = $ops = array();
 
                        $sql = $this->driver->getSelectSQL($this->reports_table,
-                               array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'),
+                               array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql', 'paginate'),
                                $filter, $ops, array('db_name' => 'asc', 'report_name' => 'asc'));
 
                        return $this->driver->selectSet($sql);
@@ -70,7 +70,7 @@
                 */
                function getReport($report_id) {                        
                        $sql = $this->driver->getSelectSQL($this->reports_table,
-                               array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'),
+                               array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql', 'paginate'),
                                array('report_id' => $report_id), array('report_id' => '='), array());
 
                        return $this->driver->selectSet($sql);
                 * @param $db_name The name of the database
                 * @param $descr The comment on the report
                 * @param $report_sql The SQL for the report
+                * @param $paginate The report should be paginated
                 * @return 0 success
                 */
-               function createReport($report_name, $db_name, $descr, $report_sql) {
+               function createReport($report_name, $db_name, $descr, $report_sql, $paginate) {
                        global $misc;
                        $server_info = $misc->getServerInfo();
                        $temp = array(
                                'report_name' => $report_name,
                                'db_name' => $db_name,
                                'created_by' => $server_info['username'],
-                               'report_sql' => $report_sql
+                               'report_sql' => $report_sql,
+                               'paginate' => $paginate ? 'true' : 'false',
                        );
                        if ($descr != '') $temp['descr'] = $descr;
 
                 * @param $db_name The name of the database
                 * @param $descr The comment on the report
                 * @param $report_sql The SQL for the report
+                * @param $paginate The report should be paginated
                 * @return 0 success
                 */
-               function alterReport($report_id, $report_name, $db_name, $descr, $report_sql) {
+               function alterReport($report_id, $report_name, $db_name, $descr, $report_sql, $paginate) {
                        global $misc;
                        $server_info = $misc->getServerInfo();
                        $temp = array(
                                'db_name' => $db_name,
                                'created_by' => $server_info['username'],
                                'report_sql' => $report_sql,
+                               'paginate' => $paginate ? 'true' : 'false',
                                'descr' => $descr
                        );
 
index 9cf5b542effa50a59f41143e64344363983727ee..c0a4045e6895b0f88db1d2c9cc21487ab069360d 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List reports in a database
         *
-        * $Id: reports.php,v 1.24 2007/01/26 17:55:42 soranzo Exp $
+        * $Id: reports.php,v 1.25 2007/04/16 11:02:36 mr-russ Exp $
         */
 
        // Include application functions
@@ -26,6 +26,9 @@
                        $_POST['db_name'] = $report->fields['db_name'];
                        $_POST['descr'] = $report->fields['descr'];
                        $_POST['report_sql'] = $report->fields['report_sql'];
+                       if ($report->fields['paginate'] == 't') {
+                               $_POST['paginate'] = TRUE;
+                       }
                }
 
                // Get a list of available databases
@@ -59,6 +62,7 @@
                echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
                        htmlspecialchars($_POST['report_sql']), "</textarea></td></tr>\n";
                echo "</table>\n";
+               echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_POST['paginate']) ? ' checked="checked"' : ''), " />&nbsp;{$lang['strpaginate']}</label>\n";
                echo "<p><input type=\"hidden\" name=\"action\" value=\"save_edit\" />\n";
                echo "<input type=\"submit\" value=\"{$lang['strsave']}\" />\n";
                echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
@@ -82,7 +86,7 @@
                elseif ($_POST['report_sql'] == '') doEdit($lang['strreportneedsdef']);
                else {
                        $status = $reportsdb->alterReport($_POST['report_id'], $_POST['report_name'], $_POST['db_name'],
-                                                               $_POST['descr'], $_POST['report_sql']);
+                                                               $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
                        if ($status == 0)
                                doDefault($lang['strreportcreated']);
                        else
                echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
                        htmlspecialchars($_REQUEST['report_sql']), "</textarea></td></tr>\n";
                echo "</table>\n";
+               echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " />&nbsp;{$lang['strpaginate']}</label>\n";
                echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n";
                echo "<input type=\"submit\" value=\"{$lang['strsave']}\" />\n";
                echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
                elseif ($_POST['report_sql'] == '') doCreate($lang['strreportneedsdef']);
                else {
                        $status = $reportsdb->createReport($_POST['report_name'], $_POST['db_name'],
-                                                               $_POST['descr'], $_POST['report_sql']);
+                                                               $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
                        if ($status == 0)
                                doDefault($lang['strreportcreated']);
                        else
                $misc->printMsg($msg);
                
                $reports = $reportsdb->getReports();
-               
+
                $columns = array(
                        'report' => array(
                                'title' => $lang['strreport'],
                        ),
                        'run' => array(
                                'title' => $lang['strrun'],
-                               'url'   => "display.php?subject=report&amp;{$misc->href}&amp;return_url={$return_url}&amp;return_desc=".urlencode($lang['strback'])."&amp;",
-                               'vars'  => array('report' => 'report_name', 'database' => 'db_name', 'query' => 'report_sql'),
+                               'url'   => "sql.php?subject=report&amp;{$misc->href}&amp;return_url={$return_url}&amp;return_desc=".urlencode($lang['strback'])."&amp;",
+                               'vars'  => array('report' => 'report_name', 'database' => 'db_name', 'query' => 'report_sql', 'paginate' => 'paginate'),
                        ),
                        'edit' => array(
                                'title' => $lang['stredit'],
diff --git a/sql.php b/sql.php
index 03bd8c3c6f428c02ab6c509114256ad1aca48cd3..d1f5c2f3b4648c36432f4c09528d5ea3da3428fd 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.33 2007/01/10 01:31:18 soranzo Exp $
+        * $Id: sql.php,v 1.34 2007/04/16 11:02:36 mr-russ Exp $
         */
 
        // Prevent timeouts on large exports (non-safe mode only)
                $_REQUEST['query'] = $_POST['query'];
        }
        
+       // Pagination maybe set by a get link that has it as FALSE,
+       // if that's the case, unset the variable.
+
+       if (isset($_REQUEST['paginate']) && $_REQUEST['paginate'] == 'f') {
+               unset($_REQUEST['paginate']);
+               unset($_POST['paginate']);
+               unset($_GET['paginate']);
+       }
        // Check to see if pagination has been specified. In that case, send to display
        // script for pagination
-       if (isset($_POST['paginate']) && !isset($_POST['explain']) && !isset($_POST['explain_analyze'])) {
+       if (isset($_REQUEST['paginate']) && !isset($_REQUEST['explain']) && !isset($_REQUEST['explain_analyze'])) {
                include('./display.php');
                exit;
        }
        else {
                // Set fetch mode to NUM so that duplicate field names are properly returned
                $data->conn->setFetchMode(ADODB_FETCH_NUM);
-               $rs = $data->conn->Execute($_POST['query']);
+               $rs = $data->conn->Execute($_REQUEST['query']);
 
                // $rs will only be an object if there is no error
                if (is_object($rs)) {
        echo "<p>{$lang['strsqlexecuted']}</p>\n";
 
        echo "<p><a class=\"navlink\" href=\"database.php?database=", urlencode($_REQUEST['database']),
-               "&amp;server=", urlencode($_REQUEST['server']), "&amp;action=sql&amp;query=", urlencode($_POST['query']), "\">{$lang['streditsql']}</a>";
+               "&amp;server=", urlencode($_REQUEST['server']), "&amp;action=sql&amp;query=", urlencode($_REQUEST['query']), "\">{$lang['streditsql']}</a>";
        if ($conf['show_reports'] && isset($rs) && is_object($rs) && $rs->recordCount() > 0) {
                echo " | <a class=\"navlink\" href=\"reports.php?{$misc->href}&amp;action=create&amp;report_sql=",
-                       urlencode($_POST['query']), "\">{$lang['strcreatereport']}</a>";
+                       urlencode($_REQUEST['query']), "\">{$lang['strcreatereport']}</a>";
        }
        echo "</p>\n";
        
index 0c4c6c5d81e88cbbfe2d23b282bb832b7138823c..1272a76230a34f87f11541bd2bc8022b6d534d1b 100644 (file)
@@ -2,7 +2,7 @@
 -- 
 -- To run, type: psql template1 < reports-pgsql.sql
 --
--- $Id: reports-pgsql.sql,v 1.3 2003/10/23 08:32:20 chriskl Exp $
+-- $Id: reports-pgsql.sql,v 1.4 2007/04/16 11:02:36 mr-russ Exp $
 
 CREATE DATABASE phppgadmin;
 
@@ -16,6 +16,7 @@ CREATE TABLE ppa_reports (
        created_by varchar(255) NOT NULL,
        descr text,
        report_sql text NOT NULL,
+       paginate boolean NOT NULL,
        PRIMARY KEY (report_id)
 );