Commit 2e15a411 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Feature #4813 / Exception during form load: show 'form edit link' if editor is logged in.

parent 2ed2346a
......@@ -553,6 +553,7 @@ abstract class AbstractBuildForm {
// Preparation for Log, Debug
$this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($fe), STORE_SYSTEM);
$this->store->setVar(SYSTEM_FORM_ELEMENT_ID, $fe[FE_ID], STORE_SYSTEM);
// Fill STORE_LDAP
$fe = $this->prepareFillStoreFireLdap($fe);
......
......@@ -508,6 +508,7 @@ const SYSTEM_SQL_COUNT = 'sqlCount'; // Type: SANITIZE_DIGIT / Int.Number of ro
const SYSTEM_SQL_PARAM_ARRAY = 'sqlParamArray'; // Type: SANITIZE_ALL / Parameter of prepared SQL Statement. Useful for error reporting.
const SYSTEM_FORM = CLIENT_FORM; // '<formName> / <formId>'
const SYSTEM_FORM_ELEMENT = 'formElement'; // '<formElementName> / <formElementeId>'
const SYSTEM_FORM_ELEMENT_ID = 'formElementId'; // '<formElementName> / <formElementeId>'
const SYSTEM_FORM_ELEMENT_COLUMN = 'formElementColumn'; // '<columnname of current processed formElement>'
const SYSTEM_FORM_ELEMENT_MESSAGE = 'formElementMessage'; // '<columnname of current processed formElement>'
const SYSTEM_REPORT_COLUMN_INDEX = 'reportColumnIndex'; // Keyname of SQL-column processed at the moment.
......@@ -522,7 +523,7 @@ const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#';
const SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME = 'parameterLanguageFieldName';
const CSS_REQUIRED = 'required-field';
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen gloable Vars benutzt.
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen globale Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
//const SYSTEM_FORM_ELEMENT_DEF = 'formElementDefinition'; // Type: SANITIZE_ALL / AssocArray. Formelement which are processed at the moment. Useful for error reporting.
//const SYSTEM_FORM_ELEMENT_FIELD = 'formElementField'; // Type: SANITIZE_ALNUMX / String. Fieldname of processed Formelement. Useful for error reporting.
......
......@@ -8,16 +8,19 @@
namespace qfq;
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/UserFormException.php');
require_once(__DIR__ . '/../Constants.php');
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/../store/T3Info.php');
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/../report/Link.php');
require_once(__DIR__ . '/../database/Database.php');
require_once(__DIR__ . '/UserFormException.php');
class AbstractException extends \Exception {
public $messageArray = array();
public $store;
public $store = null;
protected $file = '';
protected $line = '';
......@@ -27,6 +30,7 @@ class AbstractException extends \Exception {
*/
public function formatException() {
$t3Vars = array();
$htmlForm = '';
$debug = '';
try {
......@@ -64,7 +68,7 @@ class AbstractException extends \Exception {
// Form
if (isset($this->messageArray['Form']) && $this->messageArray['Form'] != '') {
$html .= "Form: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form'])) . "<br>";
$htmlForm = "Form: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray['Form'])) . "<br>";
}
if (isset($this->messageArray['Form Element']) && $this->messageArray['Form Element'] != '') {
......@@ -84,13 +88,17 @@ class AbstractException extends \Exception {
$html .= "Column value: " . Support::wrapTag("<strong>", htmlspecialchars($this->messageArray[SYSTEM_REPORT_COLUMN_VALUE])) . "<br>";
}
$html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html);
$html = Support::wrapTag("<div class='warning'>", $html);
if ($store !== null && Support::findInSet(SYSTEM_SHOW_DEBUG_INFO_YES, $store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM))) {
$storeSystem = $store->getStore(STORE_SYSTEM);
$this->messageArray['current sip'] = $store->getStore(STORE_SIP);
// In case there is a 'form' name given in SIP, we probably have a problem in a form and a direct link to edit the broken form is helpful.
if (!empty($storeSystem[SYSTEM_FORM])) {
$renderedUrl = $this->buildFormLink($storeSystem);
$htmlForm = "Form: " . $renderedUrl . "<br>";
}
// Layout
$debug = '<tr bgcolor="#dddddd"><td colspan="2">Exception</td></tr>';
foreach ($this->messageArray as $key => $value) {
......@@ -103,10 +111,48 @@ class AbstractException extends \Exception {
$debug .= "<tr>" . "<td>$key</td>" . "<td>" . htmlspecialchars($value) . "</td>" . "</tr>";
}
}
$debug = "<table border=1>" . $debug . "</table>";
}
$html = "<h2>Error</h2>" . Support::wrapTag('<p>', $html . $htmlForm);
$html = Support::wrapTag("<div class='warning'>", $html);
return $html . $debug;
}
/**
* Build a FormEditor link to the broken form.
*/
private function buildFormLink($storeSystem) {
$linkForm = '';
$linkFormElement = '';
try {
$db = new Database();
$sql = "SELECT id FROM Form WHERE name='" . $storeSystem[SYSTEM_FORM] . "'";
$r = $db->sql($sql, ROW_EXPECT_0_1);
if (!is_numeric($r[F_ID])) {
return '';
}
$sip = new Sip();
$link = new Link($sip);
// Link to 'Form'
$linkForm = $link->renderLink(TOKEN_SIP . '|' . TOKEN_PAGE . ':' . $storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM . '&' .
CLIENT_RECORD_ID . '=' . $r[F_ID] . '|' . TOKEN_TEXT . ':' . $storeSystem[SYSTEM_FORM]);
// Link to 'FormElement'
if (!empty($storeSystem[SYSTEM_FORM_ELEMENT_ID])) {
$linkFormElement = ' / ' . $link->renderLink(TOKEN_SIP . '|' . TOKEN_PAGE . ':' . $storeSystem[SYSTEM_EDIT_FORM_PAGE] . '&' . CLIENT_FORM . '=' . FORM_NAME_FORM_ELEMENT . '&' .
CLIENT_RECORD_ID . '=' . $storeSystem[SYSTEM_FORM_ELEMENT_ID] . '|' . TOKEN_TEXT . ':' . 'FormElement: ' . $storeSystem[SYSTEM_FORM_ELEMENT_ID]);
}
} catch (\exception $e) {
}
return $linkForm . $linkFormElement;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment