View Issue Details

IDProjectCategoryView StatusLast Update
544RackTablesdefaultpublic2012-06-25 19:59
Reporteruser287Assigned Toandriyanov  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionwon't fix 
Product Version0.19.11 
Summary544: Quiet modes support
DescriptionWhen "quiet" parameter is "0" or missing, then all is displayed as before.

For "quiet=1", all interface stuff is omitted: logo, search bar, path info and tabs. This mode should be useful for embedding RT forms into another webapps like billing, etc.

For "quiet=2", only errors/warnings/notices are displayed, and all remaining contents is omitted. This mode is useful for API calls from external apps.

For example:
https://srv1/racktables/index.php?module=redirect&page=ipaddress&tab=properties&op=editAddress&ip=10.20.30.40&name=vipclient&quiet=2
TagsNo tags attached.
Attached Files
racktables-quiet.diff (2,760 bytes)   
Index: branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php
===================================================================
--- branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php	(revision 4983)
+++ branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php	(working copy)
@@ -470,6 +470,8 @@
 	if ($nexttab === NULL)
 		$nexttab = $tabno;
 	$url = "index.php?page=${nextpage}&tab=${nexttab}";
+	if (array_key_exists ('quiet', $_REQUEST))
+		$url .= '&quiet=' . $_REQUEST['quiet'];
 	if (isset ($page[$nextpage]['bypass']))
 		$url .= '&' . $page[$nextpage]['bypass'] . '=' . $_REQUEST[$page[$nextpage]['bypass']];
 
Index: branches/maintenance-0.19.x/wwwroot/inc/interface.php
===================================================================
--- branches/maintenance-0.19.x/wwwroot/inc/interface.php	(revision 4983)
+++ branches/maintenance-0.19.x/wwwroot/inc/interface.php	(working copy)
@@ -73,14 +73,18 @@
 
 function renderInterfaceHTML ($pageno, $tabno, $payload)
 {
+	$quiet = array_key_exists ('quiet', $_REQUEST) ? $_REQUEST['quiet'] : 0;
+	$title = ($quiet === 0) ? getTitle ($pageno) : "RackTables:$pageno:$tabno";
+
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head><title><?php echo getTitle ($pageno); ?></title>
+<head><title><?php echo $title; ?></title>
 <?php printPageHeaders(); ?>
 </head>
 <body>
 <table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%" class="maintable">
- <tr class="mainheader"><td>
+<?php if ($quiet == 0) {
+?><tr class="mainheader"><td>
    <table width="100%" cellspacing="0" cellpadding="2" border="0">
    <tr>
     <td valign=top><a href="http://racktables.org/"><?php printImageHREF ('logo'); ?></a></td>
@@ -94,9 +98,12 @@
   </table>
  </td></tr>
  <tr><td><?php showTabs ($pageno, $tabno); ?></td></tr>
- <tr><td><?php showMessageOrError(); ?></td></tr>
+<?php } // if ($quiet == 0)
+?><tr><td><?php showMessageOrError(); ?></td></tr>
+<?php if ($quiet < 2) { ?>
  <tr><td><?php echo $payload; ?></td></tr>
-</table>
+<?php } // if ($quiet < 2)
+?></table>
 </body>
 </html>
 <?php
@@ -6553,8 +6560,9 @@
 function printOpFormIntro ($opname, $extra = array(), $upload = FALSE)
 {
 	global $pageno, $tabno, $page;
+	$quiet_arg = array_key_exists ('quiet', $_REQUEST) ? '&quiet=' . $_REQUEST['quiet'] : '';
 
-	echo "<form method=post id=${opname} name=${opname} action='?module=redirect&page=${pageno}&tab=${tabno}&op=${opname}'";
+	echo "<form method=post id=${opname} name=${opname} action='?module=redirect&page=${pageno}&tab=${tabno}&op=${opname}${quiet_arg}'";
 	if ($upload)
 		echo " enctype='multipart/form-data'";
 	echo ">";
racktables-quiet.diff (2,760 bytes)   
racktables-quiet-0.19.12.diff (2,804 bytes)   
Index: branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php
===================================================================
--- branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php	(revision 5010)
+++ branches/maintenance-0.19.x/wwwroot/inc/ophandlers.php	(working copy)
@@ -475,6 +475,8 @@
 	if ($nexttab === NULL)
 		$nexttab = $tabno;
 	$url = "index.php?page=${nextpage}&tab=${nexttab}";
+	if (array_key_exists ('quiet', $_REQUEST))
+		$url .= '&quiet=' . $_REQUEST['quiet'];
 	if (isset ($page[$nextpage]['bypass']))
 		$url .= '&' . $page[$nextpage]['bypass'] . '=' . $_REQUEST[$page[$nextpage]['bypass']];
 
Index: branches/maintenance-0.19.x/wwwroot/inc/interface.php
===================================================================
--- branches/maintenance-0.19.x/wwwroot/inc/interface.php	(revision 5010)
+++ branches/maintenance-0.19.x/wwwroot/inc/interface.php	(working copy)
@@ -78,14 +78,18 @@
 
 function renderInterfaceHTML ($pageno, $tabno, $payload)
 {
+	$quiet = array_key_exists ('quiet', $_REQUEST) ? $_REQUEST['quiet'] : 0;
+	$title = ($quiet === 0) ? getTitle ($pageno) : "RackTables:$pageno:$tabno";
+
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head><title><?php echo getTitle ($pageno); ?></title>
+<head><title><?php echo $title; ?></title>
 <?php printPageHeaders(); ?>
 </head>
 <body>
 <table border=0 cellpadding=0 cellspacing=0 width="100%" height="100%" class="maintable">
- <tr class="mainheader"><td>
+<?php if ($quiet == 0) {
+?> <tr class="mainheader"><td>
    <table width="100%" cellspacing="0" cellpadding="2" border="0">
    <tr>
     <td valign=top><a href="http://racktables.org/"><?php printImageHREF ('logo'); ?></a></td>
@@ -99,9 +103,12 @@
   </table>
  </td></tr>
  <tr><td><?php showTabs ($pageno, $tabno); ?></td></tr>
- <tr><td><?php showMessageOrError(); ?></td></tr>
- <tr><td><?php echo $payload; ?></td></tr>
-</table>
+<?php } // if ($quiet == 0)
+?><tr><td><?php showMessageOrError(); ?></td></tr>
+<?php if ($quiet < 2) {
+?><tr><td><?php echo $payload; ?></td></tr>
+<?php } // if ($quiet < 2)
+?></table>
 </body>
 </html>
 <?php
@@ -6556,8 +6563,9 @@
 function printOpFormIntro ($opname, $extra = array(), $upload = FALSE)
 {
 	global $pageno, $tabno, $page;
+	$quiet_arg = array_key_exists ('quiet', $_REQUEST) ? '&quiet=' . $_REQUEST['quiet'] : '';
 
-	echo "<form method=post id=${opname} name=${opname} action='?module=redirect&page=${pageno}&tab=${tabno}&op=${opname}'";
+	echo "<form method=post id=${opname} name=${opname} action='?module=redirect&page=${pageno}&tab=${tabno}&op=${opname}${quiet_arg}'";
 	if ($upload)
 		echo " enctype='multipart/form-data'";
 	echo ">";
racktables-quiet-0.19.12.diff (2,804 bytes)   

Activities

user287

2012-03-20 01:36

  ~0000636

racktables-quiet.diff is for 0.19.11.
racktables-quiet-0.19.12.diff is for the latest SVN snapshot.
andriyanov

andriyanov

2012-03-20 04:32

reporter   ~0000637

I do not like your patch. You do not need to pass 'quiet' HTTP param every time user visits another RT page. Instead, you can distinguish quiet and normal mode by URL part before index.php.

You can make a 'quiet' subdir with this index.php in it:
<?php
$quiet = 1;
require '../index.php';
?>

Also you could duplicate some other code in index.php thus you won't need to patch RT files at all.

This feature will not find its way into upstream.

user287

2012-03-20 06:52

  ~0000638

> You can make a 'quiet' subdir with this index.php in it:
> ...
> $quiet = 1;
> require '../index.php';

At now, there are two quiet modes, "1" (skip navigation stuff) and "2" (skip navigation stuff + query forms). Should I create "quiet1/index.php", "quiet2/index.php", and so on?

Injecting "quiet" to GET/POST params in ophandlers.php:buildWideRedirectURL() and interface.php:printOpFormIntro() adds 4 lines. This change seems more compact than multiple index.php overloads.

Secondly, how to overload original renderInterfaceHTML by quiet version? The only way is to duplicate index.php completely, and then to replace renderInterfaceHTML call by duplicated+stripped renderInterfaceHTML body. That's hard to support because modified version must be eventually (re-)synchronized with upstream updates.

Please don't close this issue. May be a compromise is possible.
I agree that my patch is not ideal, but the common idea is right:
RT should be prepared for ready to embedded GUI/API use out-of-a-box.
andriyanov

andriyanov

2012-03-20 18:43

reporter   ~0000639

A compromise is possible, but before I want to make clear something I don't understand.

1. Do you need to do anything else but calling ophandlers in quiet mode = 1? Specifically, following web links? Note that your 'quiet' HTTP parameter will not appear in those links and will be lost as soon as user clicks any link.

2. Is there any other purpose of quiet=2 mode but automating DB modifications through http queries? If no, it is much siplier to call php-cli scripts like

<?php
$script_mode = TRUE;
include '/wwwroot/inc/init.php'
updateAddress ('127.0.0.1', 'loopback', 'yes');
?>

Now you see why I'm against your patch: it does not seem to work properly in =1 mode and tries to automate things in wrong way in =2 mode.
andriyanov

andriyanov

2012-06-25 19:59

reporter   ~0000688

The feature is objectionable, no feedback received.

Issue History

Date Modified Username Field Change
2012-03-19 22:08 user287 New Issue
2012-03-19 22:08 user287 File Added: racktables-quiet.diff
2012-03-20 01:34 user287 File Added: racktables-quiet-0.19.12.diff
2012-03-20 01:36 user287 Note Added: 0000636
2012-03-20 04:32 andriyanov Note Added: 0000637
2012-03-20 06:52 user287 Note Added: 0000638
2012-03-20 18:28 andriyanov Status new => assigned
2012-03-20 18:28 andriyanov Assigned To => andriyanov
2012-03-20 18:43 andriyanov Note Added: 0000639
2012-06-25 19:59 andriyanov Note Added: 0000688
2012-06-25 19:59 andriyanov Status assigned => closed
2012-06-25 19:59 andriyanov Resolution open => won't fix