Fixing bug #404: context lost when doing certain actions. What was fixed:

- Run Query
- Display Data Model Schema
- Drill-down in charts (OQL & SQL)
- Paginated lists (actually a regression)

What remains:
- Global search...
- Drill-down in Flash "impacts / depends on"

SVN:trunk[1377]
This commit is contained in:
Denis Flaven
2011-07-27 16:39:17 +00:00
parent 0cc0c820a5
commit 82c57972c6
8 changed files with 106 additions and 56 deletions

View File

@@ -718,6 +718,12 @@ EOF
case 'open_flash_chart':
static $iChartCounter = 0;
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
if (!empty($sContext))
{
$sContext = '&'.$sContext;
}
$sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
$sTitle = isset($aExtraParams['chart_title']) ? $aExtraParams['chart_title'] : '';
$sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
@@ -748,6 +754,7 @@ EOF
$aData = array();
$aLabels = array();
$idx = 0;
$aURLs = array();
foreach($aGroupBy as $sValue => $iValue)
{
$oDrillDownFilter = clone $this->m_oFilter;
@@ -758,7 +765,7 @@ EOF
$sURLList = '';
foreach($aURLs as $index => $sURL)
{
$sURLList .= "\taURLs[$index] = '".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&format=html&filter=".addslashes($sURL)."';\n";
$sURLList .= "\taURLs[$index] = '".utils::GetAbsoluteUrlAppRoot()."pages/UI.php?operation=search&format=html{$sContext}&filter=".addslashes($sURL)."';\n";
}
$oPage->add_script(
<<<EOF

View File

@@ -53,6 +53,7 @@ class iTopWebPage extends NiceWebPage
$sAbsURLAppRoot = addslashes(utils::GetAbsoluteUrlAppRoot()); // Pass it to Javascript scripts
$oAppContext = new ApplicationContext();
$sExtraParams = $oAppContext->GetForLink();
$sAppContext = addslashes($sExtraParams);
$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_linked_stylesheet("../css/jquery.treeview.css");
@@ -361,18 +362,18 @@ EOF
{
if (id > 0)
{
window.location.href = GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=details&class='+sClass+'&id='+id;
window.location.href = AddAppContext(GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=details&class='+sClass+'&id='+id);
}
else
{
window.location.href = sDefaultUrl;
window.location.href = sDefaultUrl; // Already contains the context...
}
}
function BackToList(sClass)
{
window.location.href = GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=search_oql&oql_class='+sClass+'&oql_clause=WHERE id=0';
window.location.href = AddAppContext(GetAbsoluteUrlAppRoot()+'pages/UI.php?operation=search_oql&oql_class='+sClass+'&oql_clause=WHERE id=0');
}
function ShowDebug()
@@ -388,6 +389,19 @@ EOF
return '$sAbsURLAppRoot';
}
function AddAppContext(sURL)
{
var sContext = '$sAppContext';
if (sContext.length > 0)
{
if (sURL.indexOf('?') == -1)
{
return sURL+'?'+sContext;
}
}
return sURL+'&'+sContext;
}
var oUserPreferences = $sUserPrefs;
// For disabling the CKEditor at init time when the corresponding textarea is disabled !
@@ -592,7 +606,6 @@ EOF
// Render the revision number
if (ITOP_REVISION == '$WCREV$')
{

View File

@@ -56,6 +56,8 @@ class PortalWebPage extends NiceWebPage
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
$sAbsURLAppRoot = addslashes(utils::GetAbsoluteUrlAppRoot()); // Pass it to Javascript scripts
$oAppContext = new ApplicationContext();
$sAppContext = addslashes($oAppContext->GetForLink());
if ($sAlternateStyleSheet != '')
{
$this->add_linked_stylesheet("../portal/$sAlternateStyleSheet/portal.css");
@@ -157,6 +159,20 @@ EOF
return '$sAbsURLAppRoot';
}
function AddAppContext(sURL)
{
var sContext = '$sAppContext';
if (sContext.length > 0)
{
if (sURL.indexOf('?') == -1)
{
return sURL+'?'+sContext;
}
}
return sURL+'&'+sContext;
}
function GoBack(sFormId)
{
var form = $('#'+sFormId);

View File

@@ -214,6 +214,11 @@ class SqlBlock
default:
case 'table':
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
if (!empty($sContext))
{
$sContext = '&'.$sContext;
}
$aDisplayConfig = array();
foreach($this->m_aColumns as $sName => $aColumnData)
{
@@ -236,7 +241,7 @@ class SqlBlock
{
$sFilter = str_replace(':'.$sColName, "'".addslashes( $aRow[$sColName] )."'", $sFilter);
}
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&oql_clause='.urlencode($sFilter).'&format=html?'.$oAppContext->GetForLink();
$sURL = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?operation=search_oql&search_form=0&oql_class='.$sClass.'&oql_clause='.urlencode($sFilter).'&format=html'.$sContext;
$aDisplayRow[$sName] = '<a href="'.$sURL.'">'.$aRow[$sName]."</a>";
}
else