registerFunction("getZoning");
$xajax->registerFunction("checkIOBStatus");
session_start();
$user = $_SESSION['user'];
$in_xAjax = false;
$xAjax_objResponse;
$NoInactivityTimer = true; // Set so the xajax calls don't look at the inactivity timer.
include('common_admin_inc.htm');
include('IOB_inc.htm');
// The php function that is called from JavaScript tough xAjax when the user selects a Blade.
function getZoning($aBladeID)
{
global $in_xAjax;
global $xAjax_objResponse;
$user = $_SESSION['user'];
$xAjax_objResponse = new xajaxResponse();
$in_xAjax = true;
// This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets.
// Whihc causes an xajax XML error if the user is redirected to the login page durring the xajax call setup.
// If we are logged out this function will reload the page which will take the user back to the login page.
CheckLoggedOut();
// Get the HostPortFailover data first.
error_log("Calling get_host_port_failover($user, $aBladeID);");
$hpfData = get_host_port_failover($user, $aBladeID);
error_log("hpfData = ". print_r($hpfData, true) );
if( $hpfData->enabled == 1 )
{
error_log("HostPortFaileOver IS enabled");
// Get rid of the Apply button and pop the caution with the link to HPF.
$theText = '
' .
'You must disable Host Port Failover for this blade before you can configure channel zoning. ' .
'Please Click here to cofigure Host Port Failover.
';
$xAjax_objResponse->assign('hpfWarn', 'innerHTML', $theText );
$xAjax_objResponse->assign('ApplyDiv', 'style.visibility', 'hidden' );
}
error_log("Calling get_blade_zoning($user, $aBladeID);");
$theData = get_blade_zoning($user, $aBladeID);
error_log("theData = ". print_r($theData, true) );
// Load up the zones for the first target
$target = 1;
foreach( $theData as $zones )
{
// Data returned is in a 0-5 array
for($i = 2; $i<6; $i++)
{
error_log("Channel ". ($i+1) ." = ".$zones[$i]);
$id = $target."chan".($i+1);
$xAjax_objResponse->assign($id, "checked", $zones[$i]==1?true:false );
}
$target++;
}
// First load the original values so we know if there was a change.
// $xAjax_objResponse->assign("primPortIdOrig", "value", $theData->port_id );
// $xAjax_objResponse->assign("featureEnabledOrig", "value", $theData->enabled );
// $xAjax_objResponse->script('alert(xajax.$("primPortIdOrig").value);');
// $xAjax_objResponse->script('alert(xajax.$("featureEnabledOrig").value);');
// Some Debug examples
//$xAjax_objResponse->script('alert(xajax.$("testlevel[1]").value);');
//$xAjax_objResponse->script('alert(xajax.viewSource());');
$in_xAjax = false;
return $xAjax_objResponse;
}
// Function to check the status off all blades if any are not ready or powered down a timer is set to rerun the function.
function checkIOBStatus()
{
global $in_xAjax;
global $xAjax_objResponse;
global $IOB_bladeStatus;
$user = $_SESSION['user'];
$xAjax_objResponse = new xajaxResponse();
$in_xAjax = true;
// This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets.
// Which causes an xajax XML error if the user is redirected to the login page durring the xajax call setup.
// If we are logged out this function will reload the page which will take the user back to the login page.
CheckLoggedOut();
error_log("Reloading Blade Status");
//$xAjax_objResponse->script('alert(xajax.$("testlevel[1]").value);');
$iobs = get_blades($user);
//error_log("In XAjaX - iobs = ". print_r($iobs,true) );
//error_log("==========================================================================");
$doItAgain = false;
foreach($iobs as $iob)
{
if( $iob->status == 6 )
$xAjax_objResponse->assign("IOBStat_".$iob->id, "innerHTML", $IOB_bladeStatus[$iob->status]);
else
$xAjax_objResponse->assign("IOBStat_".$iob->id, "innerHTML", "".$IOB_bladeStatus[$iob->status]."");
$xAjax_objResponse->assign("IOBStat", "innerHTML", "Note: One or more blades are not ready. The page will auto re-load when all the blades are ready.");
if( $iob->status != 6 )
{
// This blade is NOT ready so set a timer to try this again.
$doItAgain = true;
}
}
if( $doItAgain )
$xAjax_objResponse->script('setTimeout("xajax_checkIOBStatus()",20000);');
else
$xAjax_objResponse->script('setTimeout("location.reload(true)",10);');
$in_xAjax = false;
return $xAjax_objResponse;
}
$xajax->processRequest();
/*******************************************************************************************/
// Handle the progress screen if opened and get the NEW data
if ($_SERVER[REQUEST_METHOD] == "POST")
{
$operationInProgress = true;
$status = new ReturnStatus();
error_log("_POST = ". print_r($_POST, true) );
// Build the Array from the post data to send to the php extension.
$string = "";
$data = array(array(0,0,0,0,0,0),array(0,0,0,0,0,0));
for($target=0; $target<2; $target++)
{
for($chan=3; $chan<=6; $chan++)
{
$id = $target+1 ."chan". $chan ;
if(isset($_POST[$id]))
{
error_log("Setting $id to 1");
$data[$target][$chan-1] = 1;
$string .= "1";
}
else
$string .= "0";
}
}
error_log("string = ". $string );
error_log("NEW data = ". print_r($data, true) );
error_log("set_blade_zoning( $user, ".$_POST['bladId'].", $data );");
set_blade_zoning( $user, $_POST['bladeId'], $string );
print $status->out();
return;
}
/*#############################################################
# Only Channels 1 and 2 can be tagets. All chanhels can be
# Initiators. But NO targets Make No Since. So pop up a
# message when there are no targets.
#############################################################*/
$channels = array('', 'T', 'T', 'I', 'I', 'I', 'I', 'I'); // No 0 !?!
?>
printJavascript();
?>
Blade Channel Zoning