AnsweredAssumed Answered

Is it possible to terminate an installation from module loader based on user input?

Question asked by Ramblin Ramblin on Feb 22, 2014
Latest reply on Mar 31, 2014 by Jerry Clark
Does anyone know a way to conditionally terminate an installation being done via module loader by displaying to the admin doing the install a question and, depending on the answer, completely terminate the installation, or continue with the installation?

I have tried putting the followong code into the pre_install.php script and the code suicceeds in displaying the question, with the two answer cuttons, but the script does not wait for an answer; it just continues on with the installation as if there was no form to be completed.  If the admin does click on one of the buttons, an error message "No Mode of Operation" is displayed.

The code does work fine as a stand-alone code.

I do know that a php page does complete the page on the first pass so I assume it is just finishing the first pass and going on to the rest of the script that initially included the pre_install.php page.  So, how do I do what I want to do?

The code I have (just test code to see if I can terminate the installation - which I cannot using this code :
 <?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');

if ( ! ( isset($_POST['terminate']) || isset($_POST['continue']) ) )
{
// Debugging point - check if made it to this condition
  echo "Neither of the Post variables terminate or contine is set.<br />";

// Fetch the URL of this page, including any $_GET variables present
$pageURL = 'http';
if ( isset($_SERVER["HTTPS"]) )
{
  $pageURL .= "s";
}
$pageURL .= "://";
if ( $_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443")
{
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else
{
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}

// Debugging point - output values fetched from $_SERVER array
echo "The SERVER_NAME for this page is ".$_SERVER["SERVER_NAME"]." <br />";
echo "The SERVER_PORT for this page is ".$_SERVER["SERVER_PORT"]." <br />";
echo "The URI for this page is ".$_SERVER["REQUEST_URI"]." <br />";
echo "The url for this page is $pageURL <br />";

// Ask the user if they want to proceed based on the warnings given
echo "<h3>If you proceed with this installation, your Accounts detailview will be customized<br />";
echo " and previous customizations will be lost.</h3>";
echo "<h2>Given the warnings you have received, select one of the following options<br />";
echo "by clicking on the button below that describes what you want to do.</h2>";
echo "<form name='proceed_check' action=$pageURL method='post' >";
echo " <input type='submit' name='terminate' value='Terminate the installation of this package.'>    ";
echo " <input type='submit' name='continue' value='Continue with the installation of this package.'><br>";
echo "</form>";

}
else
{

  // Debugging point - check if made it to this condition
if ( isset($_POST['terminate']) )
{
  die( "This installation has been terminated at the user&#39;s request.<br />" );
}
else
{
  echo "This installation will continue with the user&#39;s approval.<br />";
}
 

}

// Debugging point - see if the die() command worked
// Note that anything past here will be accessed on the original page call
echo "Made it past the terminate check.<br />";

?>

So, does anyone know how I can terminate an installation being done via module loader by displaying to
the admin doing the install a question and, depending on the answer,
completely terminate the installation, or continue with the
installation?

Outcomes