/** * Displays the specified 'step' of the wizard * @param WizardStep $oStep The 'step' to display */ protected function DisplayStep(WizardStep $oStep) { $oPage = new SetupPage($oStep->GetTitle()); if ($oStep->RequiresWritableConfig()) { $sConfigFile = utils::GetConfigFilePath(); if (file_exists($sConfigFile)) { // The configuration file already exists if (!is_writable($sConfigFile)) { $oP = new SetupPage('Installation Cannot Continue'); $oP->add("<h2>Fatal error</h2>\n"); $oP->error("<b>Error:</b> the configuration file '" . $sConfigFile . "' already exists and cannot be overwritten."); $oP->p("The wizard cannot modify the configuration file for you. If you want to upgrade " . ITOP_APPLICATION . ", make sure that the file '<b>" . realpath($sConfigFile) . "</b>' can be modified by the web server."); $oP->output(); return; } } } $oPage->add_linked_script('../setup/setup.js'); $oPage->add_script("function CanMoveForward()\n{\n" . $oStep->JSCanMoveForward() . "\n}\n"); $oPage->add_script("function CanMoveBackward()\n{\n" . $oStep->JSCanMoveBackward() . "\n}\n"); $oPage->add('<form id="wiz_form" method="post">'); $oStep->Display($oPage); // Add the back / next buttons and the hidden form // to store the parameters $oPage->add('<input type="hidden" id="_class" name="_class" value="' . get_class($oStep) . '"/>'); $oPage->add('<input type="hidden" id="_state" name="_state" value="' . $oStep->GetState() . '"/>'); foreach ($this->aParameters as $sCode => $value) { $oPage->add('<input type="hidden" name="_params[' . $sCode . ']" value="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"/>'); } $oPage->add('<input type="hidden" name="_steps" value="' . htmlentities(json_encode($this->aSteps), ENT_QUOTES, 'UTF-8') . '"/>'); $oPage->add('<table style="width:100%;"><tr>'); if (count($this->aSteps) > 0 && $oStep->CanMoveBackward()) { $oPage->add('<td style="text-align: left"><button id="btn_back" type="submit" name="operation" value="back"> << Back </button></td>'); } if ($oStep->CanMoveForward()) { $oPage->add('<td style="text-align:right;"><button id="btn_next" class="default" type="submit" name="operation" value="next">' . htmlentities($oStep->GetNextButtonLabel(), ENT_QUOTES, 'UTF-8') . '</button></td>'); } $oPage->add('</tr></table>'); $oPage->add("</form>"); $oPage->add('<div id="async_action" style="display:none;overflow:auto;max-height:100px;color:#F00;font-size:small;"></div>'); // The div may become visible in case of error // Hack to have the "Next >>" button, be the default button, since the first submit button in the form is the default one $oPage->add_ready_script(<<<EOF \$('form').each(function () { \tvar thisform = \$(this); \t\tthisform.prepend(thisform.find('button.default').clone().removeAttr('id').removeAttr('disabled').css({ \t\tposition: 'absolute', \t\tleft: '-999px', \t\ttop: '-999px', \t\theight: 0, \t\twidth: 0 \t})); }); \$('#btn_back').click(function() { \$('#wiz_form').data('back', true); }); \$('#wiz_form').submit(function() { \tif (\$(this).data('back')) \t{ \t\treturn CanMoveBackward(); \t} \telse \t{ \t\treturn CanMoveForward(); \t} }); \$('#wiz_form').data('back', false); WizardUpdateButtons(); EOF ); $oPage->output(); }
/** * Display the form for the second step of the configuration wizard * which consists in sending an email, which maybe a problem under Windows */ function DisplayStep2(SetupPage $oP, $sFrom, $sTo) { //$sNextOperation = 'step3'; $oP->add("<h1>iTop configuration wizard</h1>\n"); $oP->add("<h2>Step 2: send an email</h2>\n"); $oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n"); $oP->add("<form method=\"post\">\n"); $oEmail = new Email(); $oEmail->SetRecipientTO($sTo); $oEmail->SetRecipientFrom($sFrom); $oEmail->SetSubject("Test iTop"); $oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>"); $iRes = $oEmail->Send($aIssues, true); switch ($iRes) { case EMAIL_SEND_OK: $sTransport = MetaModel::GetConfig()->Get('email_transport'); if ($sTransport == 'LogFile') { $oP->ok("The email has been logged into the file " . APPROOT . "/log/mail.log."); } else { $oP->ok("The email has been sent, check your inbox for the incoming mail..."); } $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n"); break; case EMAIL_SEND_PENDING: $oP->ok("Email queued"); $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n"); break; case EMAIL_SEND_ERROR: foreach ($aIssues as $sError) { $oP->error($sError); } $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n"); break; } }
$oLog->Set('callstack', $e->getTrace()); $oLog->Set('data', $e->getContextData()); $oLog->DBInsertNoReload(); } catch (Exception $e) { IssueLog::Error("Failed to log issue into the DB"); } } IssueLog::Error($e->getMessage()); } // For debugging only //throw $e; } catch (Exception $e) { require_once APPROOT . '/setup/setuppage.class.inc.php'; $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError')); $oP->add("<h1>" . Dict::S('UI:FatalErrorMessage') . "</h1>\n"); $oP->error(Dict::Format('UI:Error_Details', $e->getMessage())); //$oP->p($e->getTraceAsString()); $oP->output(); if (MetaModel::IsLogEnabledIssue()) { if (MetaModel::IsValidClass('EventIssue')) { try { $oLog = new EventIssue(); $oLog->Set('message', $e->getMessage()); $oLog->Set('userinfo', ''); $oLog->Set('issue', 'PHP Exception'); $oLog->Set('impact', 'Page could not be displayed'); $oLog->Set('callstack', $e->getTrace()); $oLog->Set('data', array()); $oLog->DBInsertNoReload(); } catch (Exception $e) { IssueLog::Error("Failed to log issue into the DB");
/** * Display the form for the second step of the configuration wizard * which consists in sending an email, which maybe a problem under Windows */ function DisplayStep2(SetupPage $oP, $sFrom, $sTo) { //$sNextOperation = 'step3'; $oP->add("<h1>iTop configuration wizard</h1>\n"); $oP->add("<h2>Step 2: send an email</h2>\n"); $oP->add("<p>Sending an email to '{$sTo}'... (From: '{$sFrom}')</p>\n"); $oP->add("<form method=\"post\">\n"); $oEmail = new Email(); $oEmail->SetRecipientTO($sTo); $oEmail->SetRecipientFrom($sFrom); $oEmail->SetSubject("Test iTop"); $oEmail->SetBody("<p>Hello,</p><p>The email function is now working fine.</p><p>You may now be able to use the notification function.</p><p>iTop</p>"); $iRes = $oEmail->Send($aIssues, true); switch ($iRes) { case EMAIL_SEND_OK: $oP->ok("The email has been sent, you may now check that the email will arrive..."); break; case EMAIL_SEND_PENDING: $oP->ok("Email queued"); $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n"); break; case EMAIL_SEND_ERROR: foreach ($aIssues as $sError) { $oP->error($sError); } $oP->add("<button onClick=\"window.history.back();\"><< Back</button>\n"); break; } }